Chromium Code Reviews| Index: include/gpu/GrContext.h |
| diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h |
| index 4500936b82076d19210207409338f627854e9d77..aa127a58e248d29cd878225ac03d97b9366a00ed 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 |
|
bsalomon
2014/10/07 04:07:55
will remove the stray 7 and fix up sentence in sub
|
| + * |
| + * internalFlags is a temporary workaround until changes in the internal |
| + * architectural changes are complete. Use the default value. |
| */ |
| - void unlockScratchTexture(GrTexture* texture); |
| + GrTexture* lockAndRefScratchTexture(const GrTextureDesc&, ScratchTexMatch match, |
| + uint32_t internalFlags = 0); |
| /** |
| * Creates a texture that is outside the cache. Does not count against |
| @@ -1075,15 +1073,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); |
| + bool createNewScratchTexture(const GrTextureDesc& desc); |
| /** |
| * These functions create premul <-> unpremul effects if it is possible to generate a pair |
| @@ -1103,8 +1093,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 +1104,11 @@ public: |
| GrAutoScratchTexture(GrContext* context, |
| const GrTextureDesc& desc, |
| - GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch) |
| + GrContext::ScratchTexMatch match = GrContext::kApprox_ScratchTexMatch, |
| + uint32_t internalFlags = 0) |
| : fContext(NULL) |
| , fTexture(NULL) { |
| - this->set(context, desc, match); |
| + this->set(context, desc, match, internalFlags); |
| } |
| ~GrAutoScratchTexture() { |
| @@ -1127,34 +1117,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, |
| + uint32_t internalFlags = 0) { |
| this->reset(); |
| fContext = context; |
| if (fContext) { |
| - fTexture = fContext->lockAndRefScratchTexture(desc, match); |
| + fTexture = fContext->lockAndRefScratchTexture(desc, match, internalFlags); |
| if (NULL == fTexture) { |
| fContext = NULL; |
| } |