summaryrefslogtreecommitdiffstats
path: root/tests/HwAccelerationTest
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2010-12-21 06:20:28 -0800
committerXavier Ducrohet <xav@android.com>2010-12-22 10:30:53 -0800
commitd38e776a3cc8cb53945cbebafbe6f6c2e3501fa5 (patch)
tree91f1359ed446aeafc20c8322073612a77c1652d5 /tests/HwAccelerationTest
parent70119929549b6d241244c51952ed1f4a313a5ff7 (diff)
downloadframeworks_base-d38e776a3cc8cb53945cbebafbe6f6c2e3501fa5.zip
frameworks_base-d38e776a3cc8cb53945cbebafbe6f6c2e3501fa5.tar.gz
frameworks_base-d38e776a3cc8cb53945cbebafbe6f6c2e3501fa5.tar.bz2
LayoutLib: support for layers.
Layers require that drawing methods potentially draw in more than one bitmaps. To handle this this patch offers the following: - move all drawing methods to use Drawable - Drawables are now handled by GcSnapshot since its the one handling the layers - moved Canvas_Delegate.createCustomGraphics to GcSnapshot which does not expose the Graphics2D objects anymore so its draw() methods are the only way to draw. - handles creating layers in GcSnapshot.save() and blitting them in restore() Other changes: - Clean up the create/save API in GcSnapshot - Fixed drawing bitmaps with alpha and other composite modes. Change-Id: I1e230087493d044a10de71f4b6d29083e3f3bf64
Diffstat (limited to 'tests/HwAccelerationTest')
-rw-r--r--tests/HwAccelerationTest/res/layout/_layers.xml6
-rw-r--r--tests/HwAccelerationTest/res/layout/_newlayers.xml6
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/LayersActivity.java24
-rw-r--r--tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java6
4 files changed, 27 insertions, 15 deletions
diff --git a/tests/HwAccelerationTest/res/layout/_layers.xml b/tests/HwAccelerationTest/res/layout/_layers.xml
new file mode 100644
index 0000000..c2b186d
--- /dev/null
+++ b/tests/HwAccelerationTest/res/layout/_layers.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.android.test.hwui.LayersActivity.LayersView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+</com.android.test.hwui.LayersActivity.LayersView>
diff --git a/tests/HwAccelerationTest/res/layout/_newlayers.xml b/tests/HwAccelerationTest/res/layout/_newlayers.xml
new file mode 100644
index 0000000..062a2e1
--- /dev/null
+++ b/tests/HwAccelerationTest/res/layout/_newlayers.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<com.android.test.hwui.NewLayersActivity.LayersView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+</com.android.test.hwui.NewLayersActivity.LayersView>
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/LayersActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/LayersActivity.java
index b705117..9d5cd28 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/LayersActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/LayersActivity.java
@@ -33,11 +33,11 @@ public class LayersActivity extends Activity {
setContentView(new LayersView(this));
}
- static class LayersView extends View {
+ public static class LayersView extends View {
private Paint mLayerPaint;
private final Paint mRectPaint;
- LayersView(Context c) {
+ public LayersView(Context c) {
super(c);
mLayerPaint = new Paint();
@@ -47,11 +47,11 @@ public class LayersActivity extends Activity {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
-
+
canvas.translate(140.0f, 100.0f);
//canvas.drawRGB(255, 255, 255);
-
+
int count = canvas.saveLayer(0.0f, 0.0f, 200.0f, 100.0f, mLayerPaint,
Canvas.ALL_SAVE_FLAG);
@@ -59,9 +59,9 @@ public class LayersActivity extends Activity {
canvas.drawRect(0.0f, 0.0f, 200.0f, 100.0f, mRectPaint);
canvas.restoreToCount(count);
-
+
canvas.translate(0.0f, 125.0f);
-
+
count = canvas.saveLayer(0.0f, 0.0f, 200.0f, 100.0f, mLayerPaint,
Canvas.ALL_SAVE_FLAG);
@@ -75,8 +75,8 @@ public class LayersActivity extends Activity {
mRectPaint.setColor(0xff0000ff);
mRectPaint.setAlpha(255);
- canvas.drawRect(0.0f, 0.0f, 100.0f, 50.0f, mRectPaint);
-
+ canvas.drawRect(0.0f, 0.0f, 100.0f, 50.0f, mRectPaint);
+
mLayerPaint.setAlpha(127);
mLayerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));
count = canvas.saveLayer(50.0f, 25.0f, 150.0f, 75.0f, mLayerPaint,
@@ -86,13 +86,13 @@ public class LayersActivity extends Activity {
canvas.drawRect(50.0f, 25.0f, 150.0f, 75.0f, mRectPaint);
canvas.restoreToCount(count);
-
+
canvas.translate(0.0f, 125.0f);
mRectPaint.setColor(0xff0000ff);
mRectPaint.setAlpha(255);
- canvas.drawRect(0.0f, 0.0f, 100.0f, 50.0f, mRectPaint);
-
+ canvas.drawRect(0.0f, 0.0f, 100.0f, 50.0f, mRectPaint);
+
mLayerPaint.setColor(0xffff0000);
mLayerPaint.setAlpha(127);
mLayerPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
@@ -103,7 +103,7 @@ public class LayersActivity extends Activity {
canvas.drawRect(50.0f, 25.0f, 150.0f, 75.0f, mRectPaint);
canvas.restoreToCount(count);
-
+
mLayerPaint = new Paint();
}
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
index d9a2893..2509d367 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
@@ -31,11 +31,11 @@ public class NewLayersActivity extends Activity {
setContentView(new LayersView(this));
}
- static class LayersView extends View {
+ public static class LayersView extends View {
private Paint mLayerPaint;
private final Paint mRectPaint;
- LayersView(Context c) {
+ public LayersView(Context c) {
super(c);
mLayerPaint = new Paint();
@@ -57,7 +57,7 @@ public class NewLayersActivity extends Activity {
canvas.translate(0.0f, 200.0f);
drawStuff(canvas, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
-
+
canvas.restore();
}