diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index b420df2bc8..63beb7de22 100755 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -548,8 +548,9 @@ void GrContext::unlockScratchTexture(GrTexture* texture) { if (texture->wasDestroyed()) { if (texture->getCacheEntry()->key().isScratch()) { // This texture was detached from the cache but the cache still had a ref to it but - // not a pointer to it. - texture->unref(); + // not a pointer to it. This will unref the texture and delete its resource cache + // entry. + delete texture->getCacheEntry(); } return; } diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h index 235b11a394..82ffbeabfe 100644 --- a/src/gpu/GrResourceCache.h +++ b/src/gpu/GrResourceCache.h @@ -152,6 +152,7 @@ private: SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrResourceCacheEntry); friend class GrResourceCache; + friend class GrContext; }; ///////////////////////////////////////////////////////////////////////////////