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

Unified Diff: include/gpu/GrContext.h

Issue 611383003: Revert of GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
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 | « gm/yuvtorgbeffect.cpp ('k') | include/gpu/GrGpuResource.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 d2f3729f15190a93c708ee0055636dbc303d05c9..e1af73ccb2497c9cbea64b248aa5b9b6bf5c1c2f 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -295,6 +295,12 @@
GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch match);
/**
+ * When done with an entry, call unlockScratchTexture(entry) on it, which returns
+ * it to the cache, where it may be purged. This does not unref the texture.
+ */
+ void unlockScratchTexture(GrTexture* texture);
+
+ /**
* Creates a texture that is outside the cache. Does not count against
* cache's budget.
*/
@@ -1045,7 +1051,15 @@
size_t rowBytes,
bool filter);
- bool createNewScratchTexture(const GrTextureDesc& desc);
+ // Needed so GrTexture's returnToCache helper function can call
+ // addExistingTextureToCache
+ friend class GrTexture;
+ friend class GrStencilAndCoverPathRenderer;
+ friend class GrStencilAndCoverTextContext;
+
+ // Add an existing texture to the texture cache. This is intended solely
+ // for use with textures released from an GrAutoScratchTexture.
+ void addExistingTextureToCache(GrTexture* texture);
/**
* These functions create premul <-> unpremul effects if it is possible to generate a pair
@@ -1065,7 +1079,8 @@
};
/**
- * This is deprecated. Don't use it.
+ * Gets and locks a scratch texture from a descriptor using either exact or approximate criteria.
+ * Unlocks texture in the destructor.
*/
class GrAutoScratchTexture : public ::SkNoncopyable {
public:
@@ -1088,16 +1103,25 @@
void reset() {
if (fContext && fTexture) {
+ fContext->unlockScratchTexture(fTexture);
fTexture->unref();
fTexture = NULL;
}
}
- GrTexture* detach() {
- GrTexture* texture = fTexture;
- fTexture = NULL;
- return texture;
- }
+ /*
+ * When detaching a texture we do not unlock it in the texture cache but
+ * we do set the returnToCache flag. In this way the texture remains
+ * "locked" in the texture cache until it is freed and recycled in
+ * GrTexture::internal_dispose. In reality, the texture has been removed
+ * from the cache (because this is in AutoScratchTexture) and by not
+ * calling unlockScratchTexture we simply don't re-add it. It will be
+ * reattached in GrTexture::internal_dispose.
+ *
+ * Note that the caller is assumed to accept and manage the ref to the
+ * returned texture.
+ */
+ GrTexture* detach();
GrTexture* set(GrContext* context,
const GrTextureDesc& desc,
« no previous file with comments | « gm/yuvtorgbeffect.cpp ('k') | include/gpu/GrGpuResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698