Merge "Canvas.getClipBounds() was broken and unreliable with OpenGL ES 2.0"

This commit is contained in:
Romain Guy
2011-10-04 19:22:41 -07:00
committed by Android (Google) Code Review

View File

@@ -70,13 +70,6 @@ public:
clipRect = s->clipRect; clipRect = s->clipRect;
} }
if ((s->flags & Snapshot::kFlagClipSet) &&
!(s->flags & Snapshot::kFlagDirtyLocalClip)) {
mLocalClip.set(s->mLocalClip);
} else {
flags |= Snapshot::kFlagDirtyLocalClip;
}
if (s->flags & Snapshot::kFlagFboTarget) { if (s->flags & Snapshot::kFlagFboTarget) {
flags |= Snapshot::kFlagFboTarget; flags |= Snapshot::kFlagFboTarget;
region = s->region; region = s->region;
@@ -105,19 +98,15 @@ public:
* flag kFlagIsLayer is also set. * flag kFlagIsLayer is also set.
*/ */
kFlagIsFboLayer = 0x4, kFlagIsFboLayer = 0x4,
/**
* Indicates that the local clip should be recomputed.
*/
kFlagDirtyLocalClip = 0x8,
/** /**
* Indicates that this snapshot has changed the ortho matrix. * Indicates that this snapshot has changed the ortho matrix.
*/ */
kFlagDirtyOrtho = 0x10, kFlagDirtyOrtho = 0x8,
/** /**
* Indicates that this snapshot or an ancestor snapshot is * Indicates that this snapshot or an ancestor snapshot is
* an FBO layer. * an FBO layer.
*/ */
kFlagFboTarget = 0x20 kFlagFboTarget = 0x10
}; };
/** /**
@@ -169,7 +158,7 @@ public:
} }
if (clipped) { if (clipped) {
flags |= Snapshot::kFlagClipSet | Snapshot::kFlagDirtyLocalClip; flags |= Snapshot::kFlagClipSet;
} }
return clipped; return clipped;
@@ -180,19 +169,16 @@ public:
*/ */
void setClip(float left, float top, float right, float bottom) { void setClip(float left, float top, float right, float bottom) {
clipRect->set(left, top, right, bottom); clipRect->set(left, top, right, bottom);
flags |= Snapshot::kFlagClipSet | Snapshot::kFlagDirtyLocalClip; flags |= Snapshot::kFlagClipSet;
} }
const Rect& getLocalClip() { const Rect& getLocalClip() {
if (flags & Snapshot::kFlagDirtyLocalClip) { mat4 inverse;
mat4 inverse; inverse.loadInverse(*transform);
inverse.loadInverse(*transform);
mLocalClip.set(*clipRect); mLocalClip.set(*clipRect);
inverse.mapRect(mLocalClip); inverse.mapRect(mLocalClip);
flags &= ~Snapshot::kFlagDirtyLocalClip;
}
return mLocalClip; return mLocalClip;
} }
@@ -204,7 +190,7 @@ public:
void resetClip(float left, float top, float right, float bottom) { void resetClip(float left, float top, float right, float bottom) {
clipRect = &mClipRectRoot; clipRect = &mClipRectRoot;
clipRect->set(left, top, right, bottom); clipRect->set(left, top, right, bottom);
flags |= Snapshot::kFlagClipSet | Snapshot::kFlagDirtyLocalClip; flags |= Snapshot::kFlagClipSet;
} }
bool isIgnored() const { bool isIgnored() const {