summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2015-07-16 22:23:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-16 22:23:34 +0000
commit7b0fa466b59002342d14030aafb7e2f9473ca14d (patch)
tree5b4cd0a2750d61718de3d51baad2595ebc672c45 /libs
parent9236af43d8418459b939049d4e7a092d2b58bff8 (diff)
parent0f724601d78d8f36a297333227d9c460e10b3203 (diff)
downloadframeworks_base-7b0fa466b59002342d14030aafb7e2f9473ca14d.zip
frameworks_base-7b0fa466b59002342d14030aafb7e2f9473ca14d.tar.gz
frameworks_base-7b0fa466b59002342d14030aafb7e2f9473ca14d.tar.bz2
am 0f724601: Merge "Fix clip area behavior for REPLACE op" into mnc-dev
* commit '0f724601d78d8f36a297333227d9c460e10b3203': Fix clip area behavior for REPLACE op
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/ClipArea.cpp9
-rw-r--r--libs/hwui/ClipArea.h2
-rw-r--r--libs/hwui/unit_tests/ClipAreaTests.cpp11
3 files changed, 18 insertions, 4 deletions
diff --git a/libs/hwui/ClipArea.cpp b/libs/hwui/ClipArea.cpp
index eb520b4..b1a6844 100644
--- a/libs/hwui/ClipArea.cpp
+++ b/libs/hwui/ClipArea.cpp
@@ -263,10 +263,11 @@ void ClipArea::enterRectangleMode() {
bool ClipArea::rectangleModeClipRectWithTransform(const Rect& r,
const mat4* transform, SkRegion::Op op) {
- // TODO: we should be able to handle kReplace_Op efficiently without
- // going through RegionMode and later falling back into RectangleMode.
-
- if (op != SkRegion::kIntersect_Op) {
+ if (op == SkRegion::kReplace_Op && transform->rectToRect()) {
+ mClipRect = r;
+ transform->mapRect(mClipRect);
+ return true;
+ } else if (op != SkRegion::kIntersect_Op) {
enterRegionMode();
return regionModeClipRectWithTransform(r, transform, op);
}
diff --git a/libs/hwui/ClipArea.h b/libs/hwui/ClipArea.h
index e284af0..51ef27b 100644
--- a/libs/hwui/ClipArea.h
+++ b/libs/hwui/ClipArea.h
@@ -153,6 +153,8 @@ private:
}
void regionFromPath(const SkPath& path, SkRegion& pathAsRegion) {
+ // TODO: this should not mask every path to the viewport - this makes it impossible to use
+ // paths to clip to larger areas (which is valid e.g. with SkRegion::kReplace_Op)
pathAsRegion.setPath(path, createViewportRegion());
}
diff --git a/libs/hwui/unit_tests/ClipAreaTests.cpp b/libs/hwui/unit_tests/ClipAreaTests.cpp
index 166d5b6..0c5e5e7 100644
--- a/libs/hwui/unit_tests/ClipAreaTests.cpp
+++ b/libs/hwui/unit_tests/ClipAreaTests.cpp
@@ -112,5 +112,16 @@ TEST(ClipArea, paths) {
regionBounds.set(skRect);
EXPECT_EQ(expected, regionBounds);
}
+
+TEST(ClipArea, replaceNegative) {
+ ClipArea area(createClipArea());
+ area.setClip(0, 0, 100, 100);
+
+ Matrix4 transform;
+ transform.loadIdentity();
+ Rect expected(-50, -50, 50, 50);
+ area.clipRectWithTransform(expected, &transform, SkRegion::kReplace_Op);
+ EXPECT_EQ(expected, area.getClipRect());
+}
}
}