Index: src/gpu/GrDrawState.h |
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h |
index 3043fd76d52afb6169cb08381ee8f9cb88f84fc1..23009e45f9c1e93610781692a9d815d293c72fe0 100644 |
--- a/src/gpu/GrDrawState.h |
+++ b/src/gpu/GrDrawState.h |
@@ -346,6 +346,38 @@ public: |
int fCoverageEffectCnt; |
}; |
+ /** |
+ * AutoRestoreStencil |
+ * |
+ * This simple struct saves and restores the stencil settings |
+ */ |
+ class AutoRestoreStencil : public ::SkNoncopyable { |
+ public: |
+ AutoRestoreStencil() |
+ : fDrawState(NULL) {} |
bsalomon
2014/10/24 21:04:38
can put the two cons each on one line if you want
|
+ |
+ AutoRestoreStencil(GrDrawState* ds) |
+ : fDrawState(NULL) { this->set(ds); } |
+ |
+ ~AutoRestoreStencil() { this->set(NULL); } |
+ |
+ void set(GrDrawState* ds) { |
+ if (fDrawState) { |
+ fDrawState->setStencil(fStencilSettings); |
+ } |
+ fDrawState = ds; |
+ if (ds) { |
+ fStencilSettings = ds->getStencil(); |
+ } |
+ } |
+ |
+ bool isSet() const { return SkToBool(fDrawState); } |
+ |
+ private: |
+ GrDrawState* fDrawState; |
+ GrStencilSettings fStencilSettings; |
+ }; |
+ |
/// @} |
/////////////////////////////////////////////////////////////////////////// |