diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 20:57:46 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 20:57:46 +0000 |
commit | 56c79b10377e358b8092d9c6ab3e1aacf2cd60e5 (patch) | |
tree | 0945f3dd6dd3a43c1d0fc9c5c08257bbc8996cdc /include | |
parent | eb311845c1b412a9a7d851444a70ec24ab60fb2c (diff) |
Added GrContext::AutoClipStack to encapsulate setting\resetting of clip stack
http://codereview.appspot.com/6343097/
git-svn-id: http://skia.googlecode.com/svn/trunk@4558 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrContext.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 8f7378f664..a199beb1f4 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -338,12 +338,6 @@ public: */ void setClip(const GrClip& clip); - /** - * Convenience method for setting the clip to a rect. - * @param rect the rect to set as the new clip. - */ - void setClip(const GrIRect& rect); - /////////////////////////////////////////////////////////////////////////// // Draws @@ -701,6 +695,26 @@ public: GrMatrix fMatrix; }; + class AutoClip : GrNoncopyable { + public: + AutoClip(GrContext* context, const GrRect& newClipRect) + : fContext(context) + , fNewClip(newClipRect) { + fOldClip = fContext->getClip(); + fContext->setClip(fNewClip); + } + + ~AutoClip() { + if (NULL != fContext) { + fContext->setClip(fOldClip); + } + } + private: + GrContext* fContext; + GrClip fOldClip; + GrClip fNewClip; + }; + /////////////////////////////////////////////////////////////////////////// // Functions intended for internal use only. GrGpu* getGpu() { return fGpu; } |