Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Unified Diff: src/core/SkMatrixClipStateMgr.cpp

Issue 176413002: Simplify storage of MC State stack (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkMatrixClipStateMgr.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkMatrixClipStateMgr.cpp
===================================================================
--- src/core/SkMatrixClipStateMgr.cpp (revision 13551)
+++ src/core/SkMatrixClipStateMgr.cpp (working copy)
@@ -28,7 +28,6 @@
int regionID,
SkRegion::Op op,
int matrixID) {
- // TODO: add a region dictionary so we don't have to copy the region in here
ClipOp* newClip = fClips.append();
newClip->fClipType = kRegion_ClipType;
newClip->fGeom.fRegionID = regionID;
@@ -166,7 +165,7 @@
fCurMCState->fExpectedDepth++; // 1 for saveLayer
#endif
- fCurMCState->fSaveLayerBaseStateID = fCurOpenStateID;
+ *fStateIDStack.append() = fCurOpenStateID;
fCurMCState->fSavedSkipOffsets = fSkipOffsets;
// TODO: recycle these rather then new & deleting them on every saveLayer/
@@ -205,7 +204,9 @@
fActualDepth--;
#endif
- fCurOpenStateID = fCurMCState->fSaveLayerBaseStateID;
+ SkASSERT(fStateIDStack.count() >= 1);
+ fCurOpenStateID = fStateIDStack[fStateIDStack.count()-1];
+ fStateIDStack.pop();
SkASSERT(0 == fSkipOffsets->count());
SkASSERT(NULL != fCurMCState->fSavedSkipOffsets);
@@ -243,23 +244,8 @@
return gMCStateID;
}
-bool SkMatrixClipStateMgr::isCurrentlyOpen(int32_t stateID) {
- if (fCurMCState->fIsSaveLayer)
- return false;
-
- SkDeque::Iter iter(fMatrixClipStack, SkDeque::Iter::kBack_IterStart);
-
- for (const MatrixClipState* state = (const MatrixClipState*) iter.prev();
- state != NULL;
- state = (const MatrixClipState*) iter.prev()) {
- if (state->fIsSaveLayer) {
- if (state->fSaveLayerBaseStateID == stateID) {
- return true;
- }
- }
- }
-
- return false;
+bool SkMatrixClipStateMgr::isNestingMCState(int stateID) {
+ return fStateIDStack.count() > 0 && fStateIDStack[fStateIDStack.count()-1] == fCurOpenStateID;
}
bool SkMatrixClipStateMgr::call(CallType callType) {
@@ -280,7 +266,7 @@
}
if (kIdentityWideOpenStateID != fCurOpenStateID &&
- !this->isCurrentlyOpen(fCurOpenStateID)) {
+ !this->isNestingMCState(fCurOpenStateID)) {
// Don't write a restore if the open state is one in which a saveLayer
// is nested. The save after the saveLayer's restore will close it.
fPicRecord->recordRestore(); // Close the open block
@@ -397,9 +383,7 @@
#ifdef SK_DEBUG
void SkMatrixClipStateMgr::validate() {
- if (fCurOpenStateID == fCurMCState->fMCStateID &&
- (!fCurMCState->fIsSaveLayer ||
- fCurOpenStateID != fCurMCState->fSaveLayerBaseStateID)) {
+ if (fCurOpenStateID == fCurMCState->fMCStateID && !this->isNestingMCState(fCurOpenStateID)) {
// The current state is the active one so it should have a skip
// offset for each clip
SkDeque::Iter iter(fMatrixClipStack, SkDeque::Iter::kBack_IterStart);
« no previous file with comments | « src/core/SkMatrixClipStateMgr.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698