diff options
author | Romain Guy <romainguy@google.com> | 2013-08-01 15:29:25 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-08-01 15:35:24 -0700 |
commit | b7b93e00893f5c690a96bd3e0e10583bc5721f83 (patch) | |
tree | 89c975e81ab527630ab4c10478b80bca12593d24 | |
parent | 5d3dff1d66f99fbd5bef9178e62d789119c02ad1 (diff) | |
download | frameworks_base-b7b93e00893f5c690a96bd3e0e10583bc5721f83.zip frameworks_base-b7b93e00893f5c690a96bd3e0e10583bc5721f83.tar.gz frameworks_base-b7b93e00893f5c690a96bd3e0e10583bc5721f83.tar.bz2 |
Fix region clipping bugs
See external bug #58344
Change-Id: Iecd6c41fc8076cd76add2335d3442a6dd8878f12
-rw-r--r-- | libs/hwui/DisplayListOp.h | 1 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 14 | ||||
-rw-r--r-- | libs/hwui/Stencil.cpp | 1 | ||||
-rw-r--r-- | tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java | 6 |
4 files changed, 12 insertions, 10 deletions
diff --git a/libs/hwui/DisplayListOp.h b/libs/hwui/DisplayListOp.h index 5ac2511..be0800f 100644 --- a/libs/hwui/DisplayListOp.h +++ b/libs/hwui/DisplayListOp.h @@ -594,7 +594,6 @@ public: private: SkRegion* mRegion; - SkRegion::Op mOp; }; class ResetShaderOp : public StateOp { diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index be0cd2a..36be9a7 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -1668,7 +1668,7 @@ bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom, SkPath path; path.addRect(left, top, right, bottom); - return clipPath(&path, op); + return OpenGLRenderer::clipPath(&path, op); } bool OpenGLRenderer::clipPath(SkPath* path, SkRegion::Op op) { @@ -1679,11 +1679,15 @@ bool OpenGLRenderer::clipPath(SkPath* path, SkRegion::Op op) { path->transform(transform, &transformed); SkRegion clip; - if (!mSnapshot->clipRegion->isEmpty()) { - clip.setRegion(*mSnapshot->clipRegion); + if (!mSnapshot->previous->clipRegion->isEmpty()) { + clip.setRegion(*mSnapshot->previous->clipRegion); } else { - Rect* bounds = mSnapshot->clipRect; - clip.setRect(bounds->left, bounds->top, bounds->right, bounds->bottom); + if (mSnapshot->previous == mFirstSnapshot) { + clip.setRect(0, 0, mWidth, mHeight); + } else { + Rect* bounds = mSnapshot->previous->clipRect; + clip.setRect(bounds->left, bounds->top, bounds->right, bounds->bottom); + } } SkRegion region; diff --git a/libs/hwui/Stencil.cpp b/libs/hwui/Stencil.cpp index ba2e6f2..2764523 100644 --- a/libs/hwui/Stencil.cpp +++ b/libs/hwui/Stencil.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "Debug.h" #include "Extensions.h" #include "Properties.h" #include "Stencil.h" diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java index 066e35c..fe4d602 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ClipRegion2Activity.java @@ -48,7 +48,7 @@ public class ClipRegion2Activity extends Activity { } public static class RegionView extends FrameLayout { - private final Region mRegion = new Region(); + private Region mRegion = new Region(); private float mClipPosition = 0.0f; public RegionView(Context c) { @@ -69,9 +69,7 @@ public class ClipRegion2Activity extends Activity { canvas.save(); - mRegion.setEmpty(); - mRegion.op(0, 0, getWidth(), getHeight(), - Region.Op.REPLACE); + mRegion.set(0, 0, getWidth(), getHeight()); mRegion.op(getWidth() / 4, getHeight() / 4, 3 * getWidth() / 4, 3 * getHeight() / 4, Region.Op.DIFFERENCE); |