diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-01 18:25:13 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-01 18:25:13 +0000 |
commit | ccb39504096db647dafdb254cae59ae172969b8e (patch) | |
tree | 376bd2f514586a2edd45f7515d5aa94ed3dc73c6 /include/gpu/GrContext.h | |
parent | 7ec0015ec307151418bad8426cb5434823a38dfd (diff) |
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
Diffstat (limited to 'include/gpu/GrContext.h')
-rw-r--r-- | include/gpu/GrContext.h | 14 |
1 files changed, 9 insertions, 5 deletions
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) |