diff options
author | 2016-07-14 14:24:16 -0700 | |
---|---|---|
committer | 2016-07-14 14:37:08 -0700 | |
commit | 0658435096a26067c0183e0a977c9ae0af1cc006 (patch) | |
tree | 4c4cea9509a917bfb2bf2c25d3b3204a951043c2 | |
parent | 55c7c9c2d4fd9cf3295eb7a4602adf87425b1945 (diff) |
Fix rotated clip regions
bug: 26562461
fixes: 30109912
SeekBar clips out the area of the thumb when drawing its track. This
creates a clip region, since a rect has been subtracted.
This changes region transform support in computing final clip to
properly support any rect-to-rect transform (such as 90 degree rotation)
when applying a clip region.
Change-Id: Ib3bbc52637e59e00b3a7e7d5c4c40555e26c578b
-rw-r--r-- | libs/hwui/ClipArea.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/tests/unit/ClipAreaTests.cpp | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/libs/hwui/ClipArea.cpp b/libs/hwui/ClipArea.cpp index 39b8d3de9c75..84451bacbc09 100644 --- a/libs/hwui/ClipArea.cpp +++ b/libs/hwui/ClipArea.cpp @@ -530,14 +530,14 @@ void ClipArea::applyClip(const ClipBase* clip, const Matrix4& transform) { } void ClipArea::applyTransformToRegion(const Matrix4& transform, SkRegion* region) { - if (transform.isSimple() && !transform.isPureTranslate()) { + if (transform.rectToRect() && !transform.isPureTranslate()) { // handle matrices with scale manually by mapping each rect SkRegion other; SkRegion::Iterator it(*region); while (!it.done()) { Rect rect(it.rect()); transform.mapRect(rect); - rect.roundOut(); + rect.snapGeometryToPixelBoundaries(true); other.op(rect.left, rect.top, rect.right, rect.bottom, SkRegion::kUnion_Op); it.next(); } diff --git a/libs/hwui/tests/unit/ClipAreaTests.cpp b/libs/hwui/tests/unit/ClipAreaTests.cpp index afabd359ed45..d4d7919f9eee 100644 --- a/libs/hwui/tests/unit/ClipAreaTests.cpp +++ b/libs/hwui/tests/unit/ClipAreaTests.cpp @@ -334,5 +334,14 @@ TEST(ClipArea, applyTransformToRegion_translateScale) { EXPECT_EQ(SkIRect::MakeLTRB(12, 26, 16, 32), region.getBounds()); } +TEST(ClipArea, applyTransformToRegion_rotate90) { + SkRegion region(SkIRect::MakeLTRB(1, 2, 3, 4)); + Matrix4 transform; + transform.loadRotate(90); + ClipArea::applyTransformToRegion(transform, ®ion); + EXPECT_TRUE(region.isRect()); + EXPECT_EQ(SkIRect::MakeLTRB(-4, 1, -2, 3), region.getBounds()); +} + } // namespace uirenderer } // namespace android |