From b06e5a2f558133b865cb0c3cc0b36e9bd2e594e2 Mon Sep 17 00:00:00 2001 From: robertphillips Date: Tue, 30 Sep 2014 06:58:20 -0700 Subject: Revert of Make "priv" classes for GrTexure and GrSurface. (patchset #9 id:260001 of https://codereview.chromium.org/596053002/) Reason for revert: Breaking the Chrome builds with: lib/libcc.so: error: undefined reference to 'GrAutoScratchTexture::detach()' (http://108.170.220.120:10117/builders/Canary-Chrome-Ubuntu13.10-Ninja-x86_64-DRT/builds/2990/steps/Retry_BuildContentShell_1/logs/stdio) Original issue's description: > Make "priv" classes for GrTexure and GrSurface. R=egdaniel@google.com, joshualitt@google.com, bsalomon@google.com TBR=bsalomon@google.com, egdaniel@google.com, joshualitt@google.com NOTREECHECKS=true NOTRY=true Author: robertphillips@google.com Review URL: https://codereview.chromium.org/618733002 --- include/gpu/GrContext.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include/gpu/GrContext.h') diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index e1af73ccb2..45cd599132 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -1121,7 +1121,24 @@ public: * Note that the caller is assumed to accept and manage the ref to the * returned texture. */ - GrTexture* detach(); + GrTexture* detach() { + if (NULL == fTexture) { + return NULL; + } + GrTexture* texture = fTexture; + fTexture = NULL; + + // This GrAutoScratchTexture has a ref from lockAndRefScratchTexture, which we give up now. + // The cache also has a ref which we are lending to the caller of detach(). When the caller + // lets go of the ref and the ref count goes to 0 internal_dispose will see this flag is + // set and re-ref the texture, thereby restoring the cache's ref. + SkASSERT(!texture->unique()); + texture->impl()->setFlag((GrTextureFlags) GrTextureImpl::kReturnToCache_FlagBit); + texture->unref(); + SkASSERT(texture->getCacheEntry()); + + return texture; + } GrTexture* set(GrContext* context, const GrTextureDesc& desc, -- cgit v1.2.3