diff options
| author | 2016-06-29 16:22:27 -0700 | |
|---|---|---|
| committer | 2016-06-29 16:22:28 -0700 | |
| commit | 82457c51176855b9be0b441010870093a6feb414 (patch) | |
| tree | d00581f5984e6fd6cd150b53bb4af90d0d5df69f /libs/hwui/ClipArea.cpp | |
| parent | 6401217532e5357549988182b90bea28a86691e2 (diff) | |
Handle post-record-time clipPath scaling
bug:29547149
Change-Id: I268210b240d2d8e08638114715f9622840fc02f7
Diffstat (limited to 'libs/hwui/ClipArea.cpp')
| -rw-r--r-- | libs/hwui/ClipArea.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libs/hwui/ClipArea.cpp b/libs/hwui/ClipArea.cpp index fe6823925083..39b8d3de9c75 100644 --- a/libs/hwui/ClipArea.cpp +++ b/libs/hwui/ClipArea.cpp @@ -464,10 +464,7 @@ const ClipBase* ClipArea::serializeIntersectedClip(LinearAllocator& allocator, } case ClipMode::Region: other = getRegion(recordedClip); - - // TODO: handle non-translate transforms properly! - other.translate(recordedClipTransform.getTranslateX(), - recordedClipTransform.getTranslateY()); + applyTransformToRegion(recordedClipTransform, &other); } ClipRegion* regionClip = allocator.create<ClipRegion>(); @@ -527,11 +524,29 @@ void ClipArea::applyClip(const ClipBase* clip, const Matrix4& transform) { } } else { SkRegion region(getRegion(clip)); - // TODO: handle non-translate transforms properly! - region.translate(transform.getTranslateX(), transform.getTranslateY()); + applyTransformToRegion(transform, ®ion); clipRegion(region, SkRegion::kIntersect_Op); } } +void ClipArea::applyTransformToRegion(const Matrix4& transform, SkRegion* region) { + if (transform.isSimple() && !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(); + other.op(rect.left, rect.top, rect.right, rect.bottom, SkRegion::kUnion_Op); + it.next(); + } + region->swap(other); + } else { + // TODO: handle non-translate transforms properly! + region->translate(transform.getTranslateX(), transform.getTranslateY()); + } +} + } /* namespace uirenderer */ } /* namespace android */ |