diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkClipStack.h | 21 | ||||
-rw-r--r-- | src/core/SkClipStackDevice.h | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/core/SkClipStack.h b/src/core/SkClipStack.h index e889208f47..9360f4de33 100644 --- a/src/core/SkClipStack.h +++ b/src/core/SkClipStack.h @@ -341,6 +341,27 @@ public: void save(); void restore(); + class AutoRestore { + public: + AutoRestore(SkClipStack* cs, bool doSave) + : fCS(cs), fSaveCount(cs->getSaveCount()) + { + if (doSave) { + fCS->save(); + } + } + ~AutoRestore() { + SkASSERT(fCS->getSaveCount() >= fSaveCount); // no underflow + while (fCS->getSaveCount() > fSaveCount) { + fCS->restore(); + } + } + + private: + SkClipStack* fCS; + const int fSaveCount; + }; + /** * getBounds places the current finite bound in its first parameter. In its * second, it indicates which kind of bound is being returned. If diff --git a/src/core/SkClipStackDevice.h b/src/core/SkClipStackDevice.h index 1dd321d820..916aaf8455 100644 --- a/src/core/SkClipStackDevice.h +++ b/src/core/SkClipStackDevice.h @@ -18,7 +18,7 @@ public: , fClipStack(fStorage, sizeof(fStorage)) {} - const SkClipStack& cs() const { return fClipStack; } + SkClipStack& cs() { return fClipStack; } SkIRect devClipBounds() const; |