Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: include/gpu/GrContext.h

Issue 618733002: Revert of Make "priv" classes for GrTexure and GrSurface. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrSurface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrContext.h
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index e1af73ccb2497c9cbea64b248aa5b9b6bf5c1c2f..45cd599132d32843a5cc988b53228284d80e13ff 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -1121,7 +1121,24 @@
* 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,
« no previous file with comments | « gyp/gpu.gypi ('k') | include/gpu/GrSurface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698