diff options
| author | 2012-08-31 19:52:30 -0700 | |
|---|---|---|
| committer | 2012-08-31 20:04:18 -0700 | |
| commit | a8557d2169e14997637f57bc897640c8882d4a46 (patch) | |
| tree | 7b2266c166f65ef186e913f18110dab6bbd7d9e8 /libs/hwui/Snapshot.cpp | |
| parent | 703bd32647556524fa8cadbe869c8a8d734640ef (diff) | |
Revert "Add more support for transformed clip rects and paths"
this introduced a dead lock in GradientCache's ctor.
This reverts commit dfe082f63e94cde9aee271c94d13de5e7217e036.
Bug: 7096001
Change-Id: I57b8bbab11fb7cb502fa58e3bbf5d19864db874f
Diffstat (limited to 'libs/hwui/Snapshot.cpp')
| -rw-r--r-- | libs/hwui/Snapshot.cpp | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp index 4484676bc3f7..5d5961a14004 100644 --- a/libs/hwui/Snapshot.cpp +++ b/libs/hwui/Snapshot.cpp @@ -57,7 +57,7 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags): clipRect = &mClipRectRoot; #if STENCIL_BUFFER_SIZE if (s->clipRegion) { - mClipRegionRoot.op(*s->clipRegion, SkRegion::kUnion_Op); + mClipRegionRoot.merge(*s->clipRegion); clipRegion = &mClipRegionRoot; } #endif @@ -84,7 +84,8 @@ void Snapshot::ensureClipRegion() { #if STENCIL_BUFFER_SIZE if (!clipRegion) { clipRegion = &mClipRegionRoot; - clipRegion->setRect(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom); + android::Rect tmp(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom); + clipRegion->set(tmp); } #endif } @@ -92,11 +93,11 @@ void Snapshot::ensureClipRegion() { void Snapshot::copyClipRectFromRegion() { #if STENCIL_BUFFER_SIZE if (!clipRegion->isEmpty()) { - const SkIRect& bounds = clipRegion->getBounds(); - clipRect->set(bounds.fLeft, bounds.fTop, bounds.fRight, bounds.fBottom); + android::Rect bounds(clipRegion->bounds()); + clipRect->set(bounds.left, bounds.top, bounds.right, bounds.bottom); if (clipRegion->isRect()) { - clipRegion->setEmpty(); + clipRegion->clear(); clipRegion = NULL; } } else { @@ -106,11 +107,43 @@ void Snapshot::copyClipRectFromRegion() { #endif } -bool Snapshot::clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op) { +bool Snapshot::clipRegionOr(float left, float top, float right, float bottom) { #if STENCIL_BUFFER_SIZE - SkIRect tmp; - tmp.set(left, top, right, bottom); - clipRegion->op(tmp, op); + android::Rect tmp(left, top, right, bottom); + clipRegion->orSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionXor(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->xorSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionAnd(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->andSelf(tmp); + copyClipRectFromRegion(); + return true; +#else + return false; +#endif +} + +bool Snapshot::clipRegionNand(float left, float top, float right, float bottom) { +#if STENCIL_BUFFER_SIZE + android::Rect tmp(left, top, right, bottom); + clipRegion->subtractSelf(tmp); copyClipRectFromRegion(); return true; #else @@ -128,9 +161,14 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) { bool clipped = false; switch (op) { + case SkRegion::kDifference_Op: { + ensureClipRegion(); + clipped = clipRegionNand(r.left, r.top, r.right, r.bottom); + break; + } case SkRegion::kIntersect_Op: { if (CC_UNLIKELY(clipRegion)) { - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kIntersect_Op); + clipped = clipRegionOr(r.left, r.top, r.right, r.bottom); } else { clipped = clipRect->intersect(r); if (!clipped) { @@ -142,22 +180,26 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) { } case SkRegion::kUnion_Op: { if (CC_UNLIKELY(clipRegion)) { - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kUnion_Op); + clipped = clipRegionAnd(r.left, r.top, r.right, r.bottom); } else { clipped = clipRect->unionWith(r); } break; } + case SkRegion::kXOR_Op: { + ensureClipRegion(); + clipped = clipRegionXor(r.left, r.top, r.right, r.bottom); + break; + } + case SkRegion::kReverseDifference_Op: { + // TODO!!!!!!! + break; + } case SkRegion::kReplace_Op: { setClip(r.left, r.top, r.right, r.bottom); clipped = true; break; } - default: { - ensureClipRegion(); - clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, op); - break; - } } if (clipped) { @@ -171,7 +213,7 @@ void Snapshot::setClip(float left, float top, float right, float bottom) { clipRect->set(left, top, right, bottom); #if STENCIL_BUFFER_SIZE if (clipRegion) { - clipRegion->setEmpty(); + clipRegion->clear(); clipRegion = NULL; } #endif |