summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Snapshot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/Snapshot.cpp')
-rw-r--r--libs/hwui/Snapshot.cpp44
1 files changed, 16 insertions, 28 deletions
diff --git a/libs/hwui/Snapshot.cpp b/libs/hwui/Snapshot.cpp
index d947299..22c7dde 100644
--- a/libs/hwui/Snapshot.cpp
+++ b/libs/hwui/Snapshot.cpp
@@ -31,7 +31,7 @@ Snapshot::Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0),
transform = &mTransformRoot;
clipRect = &mClipRectRoot;
region = NULL;
- clipRegion = NULL;
+ clipRegion = &mClipRegionRoot;
}
/**
@@ -39,12 +39,10 @@ Snapshot::Snapshot(): flags(0), previous(NULL), layer(NULL), fbo(0),
* the previous snapshot.
*/
Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
- flags(0), previous(s), layer(NULL), fbo(s->fbo),
+ flags(0), previous(s), layer(s->layer), fbo(s->fbo),
invisible(s->invisible), empty(false),
viewport(s->viewport), height(s->height), alpha(s->alpha) {
- clipRegion = NULL;
-
if (saveFlags & SkCanvas::kMatrix_SaveFlag) {
mTransformRoot.load(*s->transform);
transform = &mTransformRoot;
@@ -55,17 +53,13 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
if (saveFlags & SkCanvas::kClip_SaveFlag) {
mClipRectRoot.set(*s->clipRect);
clipRect = &mClipRectRoot;
-#if STENCIL_BUFFER_SIZE
- if (s->clipRegion) {
+ if (!s->clipRegion->isEmpty()) {
mClipRegionRoot.op(*s->clipRegion, SkRegion::kUnion_Op);
- clipRegion = &mClipRegionRoot;
}
-#endif
+ clipRegion = &mClipRegionRoot;
} else {
clipRect = s->clipRect;
-#if STENCIL_BUFFER_SIZE
clipRegion = s->clipRegion;
-#endif
}
if (s->flags & Snapshot::kFlagFboTarget) {
@@ -81,41 +75,38 @@ Snapshot::Snapshot(const sp<Snapshot>& s, int saveFlags):
///////////////////////////////////////////////////////////////////////////////
void Snapshot::ensureClipRegion() {
-#if STENCIL_BUFFER_SIZE
- if (!clipRegion) {
- clipRegion = &mClipRegionRoot;
+ if (clipRegion->isEmpty()) {
clipRegion->setRect(clipRect->left, clipRect->top, clipRect->right, clipRect->bottom);
}
-#endif
}
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);
if (clipRegion->isRect()) {
clipRegion->setEmpty();
- clipRegion = NULL;
}
} else {
clipRect->setEmpty();
- clipRegion = NULL;
}
-#endif
}
bool Snapshot::clipRegionOp(float left, float top, float right, float bottom, SkRegion::Op op) {
-#if STENCIL_BUFFER_SIZE
SkIRect tmp;
tmp.set(left, top, right, bottom);
clipRegion->op(tmp, op);
copyClipRectFromRegion();
return true;
-#else
- return false;
-#endif
+}
+
+bool Snapshot::clipRegionTransformed(const SkRegion& region, SkRegion::Op op) {
+ ensureClipRegion();
+ clipRegion->op(region, op);
+ copyClipRectFromRegion();
+ flags |= Snapshot::kFlagClipSet;
+ return true;
}
bool Snapshot::clip(float left, float top, float right, float bottom, SkRegion::Op op) {
@@ -129,7 +120,7 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) {
switch (op) {
case SkRegion::kIntersect_Op: {
- if (CC_UNLIKELY(clipRegion)) {
+ if (CC_UNLIKELY(!clipRegion->isEmpty())) {
ensureClipRegion();
clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kIntersect_Op);
} else {
@@ -142,7 +133,7 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) {
break;
}
case SkRegion::kUnion_Op: {
- if (CC_UNLIKELY(clipRegion)) {
+ if (CC_UNLIKELY(!clipRegion->isEmpty())) {
ensureClipRegion();
clipped = clipRegionOp(r.left, r.top, r.right, r.bottom, SkRegion::kUnion_Op);
} else {
@@ -171,12 +162,9 @@ bool Snapshot::clipTransformed(const Rect& r, SkRegion::Op op) {
void Snapshot::setClip(float left, float top, float right, float bottom) {
clipRect->set(left, top, right, bottom);
-#if STENCIL_BUFFER_SIZE
- if (clipRegion) {
+ if (!clipRegion->isEmpty()) {
clipRegion->setEmpty();
- clipRegion = NULL;
}
-#endif
flags |= Snapshot::kFlagClipSet;
}