| Index: src/gpu/GrDrawState.h
|
| diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
|
| index 3043fd76d52afb6169cb08381ee8f9cb88f84fc1..71c44d4867916bc6366fb288e1a1e4eed3242819 100644
|
| --- a/src/gpu/GrDrawState.h
|
| +++ b/src/gpu/GrDrawState.h
|
| @@ -346,6 +346,36 @@ public:
|
| int fCoverageEffectCnt;
|
| };
|
|
|
| + /**
|
| + * AutoRestoreStencil
|
| + *
|
| + * This simple struct saves and restores the stencil settings
|
| + */
|
| + class AutoRestoreStencil : public ::SkNoncopyable {
|
| + public:
|
| + AutoRestoreStencil() : fDrawState(NULL) {}
|
| +
|
| + 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;
|
| + };
|
| +
|
| /// @}
|
|
|
| ///////////////////////////////////////////////////////////////////////////
|
|
|