aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/gpu/GrContext.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-08 08:40:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-08 08:40:09 -0700
commitbcf0a52d4f4221b158e68a06ba0c4cc4db011060 (patch)
tree6ad69163908f2fa15a6f857b16c1df7c12216ed1 /include/gpu/GrContext.h
parentb82b9d577e9d811d88de89594bbd6e697892616c (diff)
GrResourceCache2 manages scratch texture.
Diffstat (limited to 'include/gpu/GrContext.h')
-rw-r--r--include/gpu/GrContext.h57
1 files changed, 20 insertions, 37 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 4500936b82..6d89d4668a 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;
}