From 56c79b10377e358b8092d9c6ab3e1aacf2cd60e5 Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Wed, 11 Jul 2012 20:57:46 +0000 Subject: 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 --- include/gpu/GrContext.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'include') 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; } -- cgit v1.2.3