Skip to content

Commit 4e54f93

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Add test for layer updates optimizations" into jb-mr1-dev
2 parents 2a81fe6 + 189ff17 commit 4e54f93

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

tests/HwAccelerationTest/AndroidManifest.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
</intent-filter>
4242
</activity>
4343

44+
<activity
45+
android:name="MultiLayersActivity"
46+
android:label="_MultiLayers">
47+
<intent-filter>
48+
<action android:name="android.intent.action.MAIN" />
49+
<category android:name="android.intent.category.LAUNCHER" />
50+
</intent-filter>
51+
</activity>
52+
4453
<activity
4554
android:name="TJunctionActivity"
4655
android:label="_T-Junction">
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.android.test.hwui;
18+
19+
import android.app.Activity;
20+
import android.content.Context;
21+
import android.graphics.Canvas;
22+
import android.graphics.Paint;
23+
import android.os.Bundle;
24+
import android.view.View;
25+
import android.widget.LinearLayout;
26+
27+
@SuppressWarnings("UnusedDeclaration")
28+
public class MultiLayersActivity extends Activity {
29+
@Override
30+
protected void onCreate(Bundle savedInstanceState) {
31+
super.onCreate(savedInstanceState);
32+
33+
LinearLayout grid = new LinearLayout(this);
34+
grid.setOrientation(LinearLayout.VERTICAL);
35+
36+
LinearLayout row1 = new LinearLayout(this);
37+
row1.setOrientation(LinearLayout.HORIZONTAL);
38+
grid.addView(row1, new LinearLayout.LayoutParams(
39+
LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f));
40+
41+
LinearLayout row2 = new LinearLayout(this);
42+
row2.setOrientation(LinearLayout.HORIZONTAL);
43+
grid.addView(row2, new LinearLayout.LayoutParams(
44+
LinearLayout.LayoutParams.MATCH_PARENT, 0, 1.0f));
45+
46+
row1.addView(new LayerView(this, 0xffff0000), new LinearLayout.LayoutParams(
47+
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
48+
row1.addView(new LayerView(this, 0xff00ff00), new LinearLayout.LayoutParams(
49+
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
50+
51+
row2.addView(new LayerView(this, 0xff0000ff), new LinearLayout.LayoutParams(
52+
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
53+
row2.addView(new LayerView(this, 0xffffff00), new LinearLayout.LayoutParams(
54+
0, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
55+
56+
setContentView(grid);
57+
}
58+
59+
private class LayerView extends View {
60+
private final Paint mPaint;
61+
62+
public LayerView(Context context, int color) {
63+
super(context);
64+
mPaint = new Paint();
65+
mPaint.setColor(color);
66+
setLayerType(LAYER_TYPE_HARDWARE, null);
67+
}
68+
69+
@Override
70+
protected void onDraw(Canvas canvas) {
71+
canvas.drawRect(0.0f, 0.0f, getWidth(), getHeight(), mPaint);
72+
invalidate();
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)