Loading libs/hwui/ClipArea.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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(); } Loading libs/hwui/tests/unit/ClipAreaTests.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
libs/hwui/ClipArea.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -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(); } Loading
libs/hwui/tests/unit/ClipAreaTests.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -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