aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrContext.h
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2014-09-30 06:58:20 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-30 06:58:20 -0700
commitb06e5a2f558133b865cb0c3cc0b36e9bd2e594e2 (patch)
tree52a68d8103a78776d05f5c933b4f715dd7828633 /include/gpu/GrContext.h
parentdbe6074a06efc5fb6883bb5e4f251ed67c8c0ab4 (diff)
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
Diffstat (limited to 'include/gpu/GrContext.h')
-rw-r--r--include/gpu/GrContext.h19
1 files changed, 18 insertions, 1 deletions
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,