From 04d46eb69fb4f4c4c332c36c6ae845da3b2ae848 Mon Sep 17 00:00:00 2001 From: Chris Craik Date: Thu, 7 Apr 2016 13:51:07 -0700 Subject: Support replace op in new pipeline bug:26562461 Change-Id: Ie48d2da30f5e9d9abe88a5cd973dfb26e38abf63 --- libs/hwui/Snapshot.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'libs/hwui/Snapshot.cpp') diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp index d7842801fdd8..2c9c9d90f686 100644 --- a/libs/hwui/Snapshot.cpp +++ b/libs/hwui/Snapshot.cpp @@ -242,6 +242,33 @@ void Snapshot::setProjectionPathMask(LinearAllocator& allocator, const SkPath* p #endif } +static Snapshot* getClipRoot(Snapshot* target) { + while (target->previous && target->previous->previous) { + target = target->previous; + } + return target; +} + +const ClipBase* Snapshot::serializeIntersectedClip(LinearAllocator& allocator, + const ClipBase* recordedClip, const Matrix4& recordedClipTransform) { + auto target = this; + if (CC_UNLIKELY(recordedClip && recordedClip->intersectWithRoot)) { + // Clip must be intersected with root, instead of current clip. + target = getClipRoot(this); + } + + return target->mClipArea->serializeIntersectedClip(allocator, + recordedClip, recordedClipTransform); +} + +void Snapshot::applyClip(const ClipBase* recordedClip, const Matrix4& transform) { + if (CC_UNLIKELY(recordedClip && recordedClip->intersectWithRoot)) { + // current clip is being replaced, but must intersect with clip root + *mClipArea = *(getClipRoot(this)->mClipArea); + } + mClipArea->applyClip(recordedClip, transform); +} + /////////////////////////////////////////////////////////////////////////////// // Queries /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3-59-g8ed1b