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

Unified Diff: include/gpu/GrContext.h

Issue 608883003: GrResourceCache2 manages scratch texture. (Closed) Base URL: https://skia.googlesource.com/skia.git@surfimpl
Patch Set: remove todo Created 6 years, 2 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 4500936b82076d19210207409338f627854e9d77..6d89d4668a967780961947d9d557444b34dd721f 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -290,15 +290,13 @@ public:
* tiling non-power-of-two textures on APIs that don't support this (e.g.
* unextended GLES2). Tiling a NPOT texture created by lockScratchTexture on
* such an API will create gaps in the tiling pattern. This includes clamp
- * mode. (This may be addressed in a future update.)
- */
- 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.
+ * mode. (This may be addressed in a future update.)7
+ *
+ * internalFlag is a temporary workaround until changes in the internal
+ * architecture are complete. Use the default value.
*/
- void unlockScratchTexture(GrTexture* texture);
+ GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch match,
+ bool internalFlag = false);
/**
* Creates a texture that is outside the cache. Does not count against
@@ -951,6 +949,7 @@ public:
GrDrawTarget* getTextTarget();
const GrIndexBuffer* getQuadIndexBuffer() const;
GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; }
+ GrResourceCache* getResourceCache() { return fResourceCache; }
GrResourceCache2* getResourceCache2() { return fResourceCache2; }
// Called by tests that draw directly to the context via GrDrawTarget
@@ -1075,15 +1074,7 @@ private:
size_t rowBytes,
bool filter);
- // 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);
+ GrTexture* createNewScratchTexture(const GrTextureDesc& desc);
/**
* These functions create premul <-> unpremul effects if it is possible to generate a pair
@@ -1103,8 +1094,7 @@ private:
};
/**
- * Gets and locks a scratch texture from a descriptor using either exact or approximate criteria.
- * Unlocks texture in the destructor.
+ * This is deprecated. Don't use it.
*/
class SK_API GrAutoScratchTexture : public ::SkNoncopyable {
public:
@@ -1115,10 +1105,11 @@ public:
GrAutoScratchTexture(GrContext* context,
const GrTextureDesc& desc,
- GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch)
+ GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch,
+ bool internalFlag = false)
: fContext(NULL)
, fTexture(NULL) {
- this->set(context, desc, match);
+ this->set(context, desc, match, internalFlag);
}
~GrAutoScratchTexture() {
@@ -1127,34 +1118,26 @@ public:
void reset() {
if (fContext && fTexture) {
- fContext->unlockScratchTexture(fTexture);
fTexture->unref();
fTexture = NULL;
}
}
- /*
- * 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* detach() {
+ GrTexture* texture = fTexture;
+ fTexture = NULL;
+ return texture;
+ }
GrTexture* set(GrContext* context,
const GrTextureDesc& desc,
- GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch) {
+ GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch,
+ bool internalFlag = 0) {
this->reset();
fContext = context;
if (fContext) {
- fTexture = fContext->lockAndRefScratchTexture(desc, match);
+ fTexture = fContext->lockAndRefScratchTexture(desc, match, internalFlag);
if (NULL == fTexture) {
fContext = NULL;
}
« 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