Fix rendering issue with layers intersecting the clip rect.
Change-Id: Icbe35194fa219ef13ce639d33631235f8d7df3d7
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml
index d30a723..5597415 100644
--- a/tests/HwAccelerationTest/AndroidManifest.xml
+++ b/tests/HwAccelerationTest/AndroidManifest.xml
@@ -118,6 +118,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
+
+ <activity
+ android:name="ThinPatchesActivity"
+ android:label="_9patchThin"
+ android:theme="@android:style/Theme.Translucent.NoTitleBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
<activity
android:name="NinePatchesActivity"
diff --git a/tests/HwAccelerationTest/res/drawable/btn_toggle_off.9.png b/tests/HwAccelerationTest/res/drawable/btn_toggle_off.9.png
new file mode 100644
index 0000000..26ee1c2
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable/btn_toggle_off.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/res/drawable/btn_toggle_on.9.png b/tests/HwAccelerationTest/res/drawable/btn_toggle_on.9.png
new file mode 100644
index 0000000..53e95af
--- /dev/null
+++ b/tests/HwAccelerationTest/res/drawable/btn_toggle_on.9.png
Binary files differ
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
index 5b7753e..d9a2893 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/NewLayersActivity.java
@@ -39,6 +39,7 @@
super(c);
mLayerPaint = new Paint();
+ mLayerPaint.setAlpha(127);
mRectPaint = new Paint();
mRectPaint.setAntiAlias(true);
mRectPaint.setTextSize(24.0f);
@@ -47,28 +48,21 @@
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
-
canvas.drawRGB(128, 255, 128);
+
+ canvas.save();
+
canvas.translate(140.0f, 100.0f);
-
- mLayerPaint.setAlpha(127);
- int count = canvas.saveLayer(0.0f, 0.0f, 200.0f, 100.0f, mLayerPaint,
- Canvas.ALL_SAVE_FLAG);
-
- mRectPaint.setColor(0x7fff0000);
- canvas.drawRect(-20.0f, -20.0f, 220.0f, 120.0f, mRectPaint);
-
- mRectPaint.setColor(0xff000000);
- canvas.drawText("This is a very long string to overlap between layers and framebuffer",
- -100.0f, 50.0f, mRectPaint);
-
- canvas.restoreToCount(count);
+ drawStuff(canvas, Canvas.ALL_SAVE_FLAG);
canvas.translate(0.0f, 200.0f);
+ drawStuff(canvas, Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
- mLayerPaint.setAlpha(127);
- count = canvas.saveLayer(0.0f, 0.0f, 200.0f, 100.0f, mLayerPaint,
- Canvas.HAS_ALPHA_LAYER_SAVE_FLAG);
+ canvas.restore();
+ }
+
+ private void drawStuff(Canvas canvas, int saveFlags) {
+ int count = canvas.saveLayer(0.0f, 0.0f, 200.0f, 100.0f, mLayerPaint, saveFlags);
mRectPaint.setColor(0x7fff0000);
canvas.drawRect(-20.0f, -20.0f, 220.0f, 120.0f, mRectPaint);
@@ -76,7 +70,7 @@
mRectPaint.setColor(0xff000000);
canvas.drawText("This is a very long string to overlap between layers and framebuffer",
-100.0f, 50.0f, mRectPaint);
-
+
canvas.restoreToCount(count);
}
}
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java
new file mode 100644
index 0000000..d374c32
--- /dev/null
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ThinPatchesActivity.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.test.hwui;
+
+import android.app.Activity;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.FrameLayout;
+
+@SuppressWarnings({"UnusedDeclaration"})
+public class ThinPatchesActivity extends Activity {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ FrameLayout layout = new FrameLayout(this);
+ PatchView b = new PatchView(this);
+ b.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT));
+ layout.addView(b);
+ layout.setBackgroundColor(0xffffffff);
+
+ setContentView(layout);
+ }
+
+ private class PatchView extends View {
+ private Drawable mPatch;
+
+ public PatchView(Activity activity) {
+ super(activity);
+
+ final Resources resources = activity.getResources();
+ mPatch = resources.getDrawable(R.drawable.btn_toggle_on);
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ final int width = 100;
+ final int height = 60;
+
+ final int left = (getWidth() - width) / 2;
+ final int top = (getHeight() - height) / 2;
+
+ mPatch.setBounds(left, top, left + width, top + height);
+ mPatch.draw(canvas);
+ }
+ }
+}