From ccb39504096db647dafdb254cae59ae172969b8e Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Mon, 1 Oct 2012 18:25:13 +0000 Subject: Speculative render target ref/unref fixes https://codereview.appspot.com/6592051/ git-svn-id: http://skia.googlecode.com/svn/trunk@5754 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/gpu/GrContext.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include/gpu/GrContext.h') diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 3c38fad9e2..16eab6668e 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -640,21 +640,24 @@ public: /////////////////////////////////////////////////////////////////////////// // Helpers - class AutoRenderTarget : ::GrNoncopyable { + class AutoRenderTarget : public ::GrNoncopyable { public: AutoRenderTarget(GrContext* context, GrRenderTarget* target) { fPrevTarget = context->getRenderTarget(); + GrSafeRef(fPrevTarget); context->setRenderTarget(target); fContext = context; } AutoRenderTarget(GrContext* context) { fPrevTarget = context->getRenderTarget(); + GrSafeRef(fPrevTarget); fContext = context; } ~AutoRenderTarget() { - if (fContext) { + if (NULL != fContext) { fContext->setRenderTarget(fPrevTarget); } + GrSafeUnref(fPrevTarget); } private: GrContext* fContext; @@ -728,12 +731,13 @@ public: kWideOpen_InitialClip, }; - AutoClip(GrContext* context, InitialClip initialState) { + AutoClip(GrContext* context, InitialClip initialState) + : fContext(context) { GrAssert(kWideOpen_InitialClip == initialState); - fOldClip = context->getClip(); fNewClipData.fClipStack = &fNewClipStack; + + fOldClip = context->getClip(); context->setClip(&fNewClipData); - fContext = context; } AutoClip(GrContext* context, const GrRect& newClipRect) -- cgit v1.2.3