Rename GrResourceCache2->GrResourceCache
authorbsalomon <bsalomon@google.com>
Wed, 11 Feb 2015 18:49:59 +0000 (10:49 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 11 Feb 2015 18:49:59 +0000 (10:49 -0800)
TBR=robertphillips@google.com

Review URL: https://codereview.chromium.org/921453002

12 files changed:
bench/GrResourceCacheBench.cpp
gyp/gpu.gypi
include/gpu/GrContext.h
include/gpu/GrGpuResource.h
src/gpu/GrClipMaskManager.h
src/gpu/GrContext.cpp
src/gpu/GrGpu.cpp
src/gpu/GrGpuResource.cpp
src/gpu/GrResourceCache.cpp [moved from src/gpu/GrResourceCache2.cpp with 91% similarity]
src/gpu/GrResourceCache.h [moved from src/gpu/GrResourceCache2.h with 96% similarity]
src/gpu/GrTest.cpp
tests/ResourceCacheTest.cpp

index 7469217..39007c3 100644 (file)
@@ -13,7 +13,7 @@
 #include "GrGpuResource.h"
 #include "GrContext.h"
 #include "GrGpu.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "SkCanvas.h"
 
 enum {
@@ -69,17 +69,17 @@ protected:
         // Set the cache budget to be very large so no purging occurs.
         context->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
 
-        GrResourceCache2* cache2 = context->getResourceCache2();
+        GrResourceCache* cache = context->getResourceCache();
 
         // Make sure the cache is empty.
-        cache2->purgeAllUnlocked();
-        SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
+        cache->purgeAllUnlocked();
+        SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes());
 
         GrGpu* gpu = context->getGpu();
 
         for (int i = 0; i < loops; ++i) {
             populate_cache(gpu, CACHE_SIZE_COUNT);
-            SkASSERT(CACHE_SIZE_COUNT == cache2->getResourceCount());
+            SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount());
         }
     }
 
@@ -106,11 +106,11 @@ protected:
         // Set the cache budget to be very large so no purging occurs.
         fContext->setResourceCacheLimits(CACHE_SIZE_COUNT, 1 << 30);
 
-        GrResourceCache2* cache2 = fContext->getResourceCache2();
+        GrResourceCache* cache = fContext->getResourceCache();
 
         // Make sure the cache is empty.
-        cache2->purgeAllUnlocked();
-        SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
+        cache->purgeAllUnlocked();
+        SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes());
 
         GrGpu* gpu = fContext->getGpu();
 
@@ -121,13 +121,13 @@ protected:
         if (!fContext) {
             return;
         }
-        GrResourceCache2* cache2 = fContext->getResourceCache2();
-        SkASSERT(CACHE_SIZE_COUNT == cache2->getResourceCount());
+        GrResourceCache* cache = fContext->getResourceCache();
+        SkASSERT(CACHE_SIZE_COUNT == cache->getResourceCount());
         for (int i = 0; i < loops; ++i) {
             for (int k = 0; k < CACHE_SIZE_COUNT; ++k) {
                 GrContentKey key;
                 BenchResource::ComputeKey(k, &key);
-                SkAutoTUnref<GrGpuResource> resource(cache2->findAndRefContentResource(key));
+                SkAutoTUnref<GrGpuResource> resource(cache->findAndRefContentResource(key));
                 SkASSERT(resource);
             }
         }
index 2036b89..5cc743f 100644 (file)
       '<(skia_src_path)/gpu/GrRenderTarget.cpp',
       '<(skia_src_path)/gpu/GrReducedClip.cpp',
       '<(skia_src_path)/gpu/GrReducedClip.h',
-      '<(skia_src_path)/gpu/GrResourceCache2.cpp',
-      '<(skia_src_path)/gpu/GrResourceCache2.h',
+      '<(skia_src_path)/gpu/GrResourceCache.cpp',
+      '<(skia_src_path)/gpu/GrResourceCache.h',
       '<(skia_src_path)/gpu/GrStencil.cpp',
       '<(skia_src_path)/gpu/GrStencil.h',
       '<(skia_src_path)/gpu/GrStencilAndCoverPathRenderer.cpp',
index 4a9701f..48510d6 100644 (file)
@@ -33,7 +33,7 @@ class GrPath;
 class GrPathRenderer;
 class GrPipelineBuilder;
 class GrResourceEntry;
-class GrResourceCache2;
+class GrResourceCache;
 class GrTestTarget;
 class GrTextContext;
 class GrTextureParams;
@@ -755,7 +755,7 @@ public:
     GrDrawTarget* getTextTarget();
     const GrIndexBuffer* getQuadIndexBuffer() const;
     GrAARectRenderer* getAARectRenderer() { return fAARectRenderer; }
-    GrResourceCache2* getResourceCache2() { return fResourceCache2; }
+    GrResourceCache* getResourceCache() { return fResourceCache; }
 
     // Called by tests that draw directly to the context via GrDrawTarget
     void getTestTarget(GrTestTarget*);
@@ -792,7 +792,7 @@ private:
     SkAutoTUnref<GrRenderTarget>    fRenderTarget;
     const GrClipData*               fClip;  // TODO: make this ref counted
 
-    GrResourceCache2*               fResourceCache2;
+    GrResourceCache*                fResourceCache;
     GrFontCache*                    fFontCache;
     SkAutoTDelete<GrLayerCache>     fLayerCache;
 
index dcb4a47..8e983d8 100644 (file)
@@ -16,7 +16,7 @@
 
 class GrContext;
 class GrGpu;
-class GrResourceCache2;
+class GrResourceCache;
 
 /**
  * Base class for GrGpuResource. Handles the various types of refs we need. Separated out as a base
@@ -113,13 +113,13 @@ private:
 
     // This class is used to manage conversion of refs to pending reads/writes.
     friend class GrGpuResourceRef;
-    friend class GrResourceCache2; // to check IO ref counts.
+    friend class GrResourceCache; // to check IO ref counts.
 
     template <typename, GrIOType> friend class GrPendingIOResource;
 };
 
 /**
- * Base class for objects that can be kept in the GrResourceCache2.
+ * Base class for objects that can be kept in the GrResourceCache.
  */
 class SK_API GrGpuResource : public GrIORef<GrGpuResource> {
 public:
@@ -276,7 +276,7 @@ private:
 
     static uint32_t CreateUniqueID();
 
-    // We're in an internal doubly linked list owned by GrResourceCache2
+    // We're in an internal doubly linked list owned by GrResourceCache
     SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrGpuResource);
 
 
index ed3d431..bc164da 100644 (file)
@@ -57,7 +57,7 @@ public:
 
     /**
      * Purge resources to free up memory. TODO: This class shouldn't hold any long lived refs
-     * which will allow ResourceCache2 to automatically purge anything this class has created.
+     * which will allow Resourcecache to automatically purge anything this class has created.
      */
     void purgeResources();
 
index 7a910c5..6c6ec50 100755 (executable)
@@ -23,7 +23,7 @@
 #include "GrOvalRenderer.h"
 #include "GrPathRenderer.h"
 #include "GrPathUtils.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "GrSoftwarePathRenderer.h"
 #include "GrStencilAndCoverTextContext.h"
 #include "GrStrokeInfo.h"
@@ -88,7 +88,7 @@ GrContext::GrContext(const Options& opts) : fOptions(opts) {
     fClip = NULL;
     fPathRendererChain = NULL;
     fSoftwarePathRenderer = NULL;
-    fResourceCache2 = NULL;
+    fResourceCache = NULL;
     fFontCache = NULL;
     fDrawBuffer = NULL;
     fDrawBufferVBAllocPool = NULL;
@@ -111,8 +111,8 @@ bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
 }
 
 void GrContext::initCommon() {
-    fResourceCache2 = SkNEW(GrResourceCache2);
-    fResourceCache2->setOverBudgetCallback(OverBudgetCB, this);
+    fResourceCache = SkNEW(GrResourceCache);
+    fResourceCache->setOverBudgetCallback(OverBudgetCB, this);
 
     fFontCache = SkNEW_ARGS(GrFontCache, (fGpu));
 
@@ -137,7 +137,7 @@ GrContext::~GrContext() {
         (*fCleanUpData[i].fFunc)(this, fCleanUpData[i].fInfo);
     }
 
-    SkDELETE(fResourceCache2);
+    SkDELETE(fResourceCache);
     SkDELETE(fFontCache);
     SkDELETE(fDrawBuffer);
     SkDELETE(fDrawBufferVBAllocPool);
@@ -154,7 +154,7 @@ GrContext::~GrContext() {
 void GrContext::abandonContext() {
     // abandon first to so destructors
     // don't try to free the resources in the API.
-    fResourceCache2->abandonAll();
+    fResourceCache->abandonAll();
 
     fGpu->contextAbandoned();
 
@@ -202,10 +202,10 @@ void GrContext::freeGpuResources() {
 
 void GrContext::getResourceCacheUsage(int* resourceCount, size_t* resourceBytes) const {
     if (resourceCount) {
-        *resourceCount = fResourceCache2->getBudgetedResourceCount();
+        *resourceCount = fResourceCache->getBudgetedResourceCount();
     }
     if (resourceBytes) {
-        *resourceBytes = fResourceCache2->getBudgetedResourceBytes();
+        *resourceBytes = fResourceCache->getBudgetedResourceBytes();
     }
 }
 
@@ -299,13 +299,13 @@ GrTexture* GrContext::internalRefScratchTexture(const GrSurfaceDesc& inDesc, uin
             GrTexturePriv::ComputeScratchKey(*desc, &key);
             uint32_t scratchFlags = 0;
             if (kNoPendingIO_ScratchTextureFlag & flags) {
-                scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag;
+                scratchFlags = GrResourceCache::kRequireNoPendingIO_ScratchFlag;
             } else  if (!(desc->fFlags & kRenderTarget_GrSurfaceFlag)) {
                 // If it is not a render target then it will most likely be populated by
                 // writePixels() which will trigger a flush if the texture has pending IO.
-                scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
+                scratchFlags = GrResourceCache::kPreferNoPendingIO_ScratchFlag;
             }
-            GrGpuResource* resource = fResourceCache2->findAndRefScratchResource(key, scratchFlags);
+            GrGpuResource* resource = fResourceCache->findAndRefScratchResource(key, scratchFlags);
             if (resource) {
                 GrSurface* surface = static_cast<GrSurface*>(resource);
                 GrRenderTarget* rt = surface->asRenderTarget();
@@ -1569,15 +1569,15 @@ const GrFragmentProcessor* GrContext::createUPMToPMEffect(GrTexture* texture,
 
 void GrContext::getResourceCacheLimits(int* maxTextures, size_t* maxTextureBytes) const {
     if (maxTextures) {
-        *maxTextures = fResourceCache2->getMaxResourceCount();
+        *maxTextures = fResourceCache->getMaxResourceCount();
     }
     if (maxTextureBytes) {
-        *maxTextureBytes = fResourceCache2->getMaxResourceBytes();
+        *maxTextureBytes = fResourceCache->getMaxResourceBytes();
     }
 }
 
 void GrContext::setResourceCacheLimits(int maxTextures, size_t maxTextureBytes) {
-    fResourceCache2->setLimits(maxTextures, maxTextureBytes);
+    fResourceCache->setLimits(maxTextures, maxTextureBytes);
 }
 
 bool GrContext::addResourceToCache(const GrContentKey& key, GrGpuResource* resource) {
@@ -1589,11 +1589,11 @@ bool GrContext::addResourceToCache(const GrContentKey& key, GrGpuResource* resou
 }
 
 bool GrContext::isResourceInCache(const GrContentKey& key) const {
-    return fResourceCache2->hasContentKey(key);
+    return fResourceCache->hasContentKey(key);
 }
 
 GrGpuResource* GrContext::findAndRefCachedResource(const GrContentKey& key) {
-    return fResourceCache2->findAndRefContentResource(key);
+    return fResourceCache->findAndRefContentResource(key);
 }
 
 //////////////////////////////////////////////////////////////////////////////
index 67637e7..d23d452 100644 (file)
@@ -13,7 +13,7 @@
 #include "GrContext.h"
 #include "GrDrawTargetCaps.h"
 #include "GrIndexBuffer.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "GrStencilBuffer.h"
 #include "GrVertexBuffer.h"
 
@@ -88,7 +88,7 @@ bool GrGpu::attachStencilBufferToRenderTarget(GrRenderTarget* rt, bool budgeted)
     GrScratchKey sbKey;
     GrStencilBuffer::ComputeKey(rt->width(), rt->height(), rt->numSamples(), &sbKey);
     SkAutoTUnref<GrStencilBuffer> sb(static_cast<GrStencilBuffer*>(
-        this->getContext()->getResourceCache2()->findAndRefScratchResource(sbKey)));
+        this->getContext()->getResourceCache()->findAndRefScratchResource(sbKey)));
     if (sb) {
         rt->setStencilBuffer(sb);
         bool attached = this->attachStencilBufferToRenderTarget(sb, rt);
index 7fb5559..7f65af2 100644 (file)
@@ -7,14 +7,14 @@
  */
 
 #include "GrGpuResource.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "GrGpu.h"
 
-static inline GrResourceCache2* get_resource_cache2(GrGpu* gpu) {
+static inline GrResourceCache* get_resource_cache(GrGpu* gpu) {
     SkASSERT(gpu);
     SkASSERT(gpu->getContext());
-    SkASSERT(gpu->getContext()->getResourceCache2());
-    return gpu->getContext()->getResourceCache2();
+    SkASSERT(gpu->getContext()->getResourceCache());
+    return gpu->getContext()->getResourceCache();
 }
 
 GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle)
@@ -25,7 +25,7 @@ GrGpuResource::GrGpuResource(GrGpu* gpu, LifeCycle lifeCycle)
 }
 
 void GrGpuResource::registerWithCache() {
-    get_resource_cache2(fGpu)->resourceAccess().insertResource(this);
+    get_resource_cache(fGpu)->resourceAccess().insertResource(this);
 }
 
 GrGpuResource::~GrGpuResource() {
@@ -36,7 +36,7 @@ GrGpuResource::~GrGpuResource() {
 void GrGpuResource::release() { 
     SkASSERT(fGpu);
     this->onRelease();
-    get_resource_cache2(fGpu)->resourceAccess().removeResource(this);
+    get_resource_cache(fGpu)->resourceAccess().removeResource(this);
     fGpu = NULL;
     fGpuMemorySize = 0;
 }
@@ -44,7 +44,7 @@ void GrGpuResource::release() {
 void GrGpuResource::abandon() {
     SkASSERT(fGpu);
     this->onAbandon();
-    get_resource_cache2(fGpu)->resourceAccess().removeResource(this);
+    get_resource_cache(fGpu)->resourceAccess().removeResource(this);
     fGpu = NULL;
     fGpuMemorySize = 0;
 }
@@ -79,12 +79,12 @@ void GrGpuResource::didChangeGpuMemorySize() const {
     size_t oldSize = fGpuMemorySize;
     SkASSERT(kInvalidGpuMemorySize != oldSize);
     fGpuMemorySize = kInvalidGpuMemorySize;
-    get_resource_cache2(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize);
+    get_resource_cache(fGpu)->resourceAccess().didChangeGpuMemorySize(this, oldSize);
 }
 
 void GrGpuResource::removeContentKey() {
     SkASSERT(fContentKey.isValid());
-    get_resource_cache2(fGpu)->resourceAccess().willRemoveContentKey(this);
+    get_resource_cache(fGpu)->resourceAccess().willRemoveContentKey(this);
     fContentKey.reset();
 }
 
@@ -104,7 +104,7 @@ bool GrGpuResource::setContentKey(const GrContentKey& key) {
 
     fContentKey = key;
 
-    if (!get_resource_cache2(fGpu)->resourceAccess().didSetContentKey(this)) {
+    if (!get_resource_cache(fGpu)->resourceAccess().didSetContentKey(this)) {
         fContentKey.reset();
         return false;
     }
@@ -117,7 +117,7 @@ void GrGpuResource::notifyIsPurgeable() const {
         SkDELETE(this);
     } else {
         GrGpuResource* mutableThis = const_cast<GrGpuResource*>(this);
-        get_resource_cache2(fGpu)->resourceAccess().notifyPurgeable(mutableThis);
+        get_resource_cache(fGpu)->resourceAccess().notifyPurgeable(mutableThis);
     }
 }
 
@@ -133,7 +133,7 @@ void GrGpuResource::setScratchKey(const GrScratchKey& scratchKey) {
 
 void GrGpuResource::removeScratchKey() {
     if (!this->wasDestroyed() && fScratchKey.isValid()) {
-        get_resource_cache2(fGpu)->resourceAccess().willRemoveScratchKey(this);
+        get_resource_cache(fGpu)->resourceAccess().willRemoveScratchKey(this);
         fScratchKey.reset();
     }
 }
@@ -141,14 +141,14 @@ void GrGpuResource::removeScratchKey() {
 void GrGpuResource::makeBudgeted() {
     if (GrGpuResource::kUncached_LifeCycle == fLifeCycle) {
         fLifeCycle = kCached_LifeCycle;
-        get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this);
+        get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
     }
 }
 
 void GrGpuResource::makeUnbudgeted() {
     if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fContentKey.isValid()) {
         fLifeCycle = kUncached_LifeCycle;
-        get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this);
+        get_resource_cache(fGpu)->resourceAccess().didChangeBudgetStatus(this);
     }
 }
 
similarity index 91%
rename from src/gpu/GrResourceCache2.cpp
rename to src/gpu/GrResourceCache.cpp
index c165659..2b842a8 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "GrGpuResource.h"  
 
 #include "SkChecksum.h"
@@ -45,12 +45,12 @@ uint32_t GrResourceKeyHash(const uint32_t* data, size_t size) {
 
 //////////////////////////////////////////////////////////////////////////////
 
-class GrResourceCache2::AutoValidate : ::SkNoncopyable {
+class GrResourceCache::AutoValidate : ::SkNoncopyable {
 public:
-    AutoValidate(GrResourceCache2* cache) : fCache(cache) { cache->validate(); }
+    AutoValidate(GrResourceCache* cache) : fCache(cache) { cache->validate(); }
     ~AutoValidate() { fCache->validate(); }
 private:
-    GrResourceCache2* fCache;
+    GrResourceCache* fCache;
 };
 
  //////////////////////////////////////////////////////////////////////////////
@@ -58,7 +58,7 @@ private:
 static const int kDefaultMaxCount = 2 * (1 << 10);
 static const size_t kDefaultMaxSize = 96 * (1 << 20);
 
-GrResourceCache2::GrResourceCache2()
+GrResourceCache::GrResourceCache()
     : fMaxCount(kDefaultMaxCount)
     , fMaxBytes(kDefaultMaxSize)
 #if GR_CACHE_STATS
@@ -77,17 +77,17 @@ GrResourceCache2::GrResourceCache2()
     , fOverBudgetData(NULL) {
 }
 
-GrResourceCache2::~GrResourceCache2() {
+GrResourceCache::~GrResourceCache() {
     this->releaseAll();
 }
 
-void GrResourceCache2::setLimits(int count, size_t bytes) {
+void GrResourceCache::setLimits(int count, size_t bytes) {
     fMaxCount = count;
     fMaxBytes = bytes;
     this->purgeAsNeeded();
 }
 
-void GrResourceCache2::insertResource(GrGpuResource* resource) {
+void GrResourceCache::insertResource(GrGpuResource* resource) {
     SkASSERT(resource);
     SkASSERT(!resource->wasDestroyed());
     SkASSERT(!this->isInCache(resource));
@@ -117,7 +117,7 @@ void GrResourceCache2::insertResource(GrGpuResource* resource) {
     this->purgeAsNeeded();
 }
 
-void GrResourceCache2::removeResource(GrGpuResource* resource) {
+void GrResourceCache::removeResource(GrGpuResource* resource) {
     SkASSERT(this->isInCache(resource));
 
     size_t size = resource->gpuMemorySize();
@@ -138,7 +138,7 @@ void GrResourceCache2::removeResource(GrGpuResource* resource) {
     this->validate();
 }
 
-void GrResourceCache2::abandonAll() {
+void GrResourceCache::abandonAll() {
     AutoValidate av(this);
 
     SkASSERT(!fPurging);
@@ -156,7 +156,7 @@ void GrResourceCache2::abandonAll() {
     SkASSERT(!fBudgetedBytes);
 }
 
-void GrResourceCache2::releaseAll() {
+void GrResourceCache::releaseAll() {
     AutoValidate av(this);
 
     SkASSERT(!fPurging);
@@ -173,7 +173,7 @@ void GrResourceCache2::releaseAll() {
     SkASSERT(!fBudgetedBytes);
 }
 
-class GrResourceCache2::AvailableForScratchUse {
+class GrResourceCache::AvailableForScratchUse {
 public:
     AvailableForScratchUse(bool rejectPendingIO) : fRejectPendingIO(rejectPendingIO) { }
 
@@ -188,7 +188,7 @@ private:
     bool fRejectPendingIO;
 };
 
-GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrScratchKey& scratchKey,
+GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& scratchKey,
                                                            uint32_t flags) {
     SkASSERT(!fPurging);
     SkASSERT(scratchKey.isValid());
@@ -216,19 +216,19 @@ GrGpuResource* GrResourceCache2::findAndRefScratchResource(const GrScratchKey& s
     return resource;
 }
 
-void GrResourceCache2::willRemoveScratchKey(const GrGpuResource* resource) {
+void GrResourceCache::willRemoveScratchKey(const GrGpuResource* resource) {
     SkASSERT(resource->cacheAccess().getScratchKey().isValid());
     fScratchMap.remove(resource->cacheAccess().getScratchKey(), resource);
 }
 
-void GrResourceCache2::willRemoveContentKey(const GrGpuResource* resource) {
+void GrResourceCache::willRemoveContentKey(const GrGpuResource* resource) {
     // Someone has a ref to this resource in order to invalidate it. When the ref count reaches
     // zero we will get a notifyPurgable() and figure out what to do with it.
     SkASSERT(resource->getContentKey().isValid());
     fContentHash.remove(resource->getContentKey());
 }
 
-bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) {
+bool GrResourceCache::didSetContentKey(GrGpuResource* resource) {
     SkASSERT(!fPurging);
     SkASSERT(resource);
     SkASSERT(this->isInCache(resource));
@@ -244,7 +244,7 @@ bool GrResourceCache2::didSetContentKey(GrGpuResource* resource) {
     return true;
 }
 
-void GrResourceCache2::makeResourceMRU(GrGpuResource* resource) {
+void GrResourceCache::makeResourceMRU(GrGpuResource* resource) {
     SkASSERT(!fPurging);
     SkASSERT(resource);
     SkASSERT(this->isInCache(resource));
@@ -252,7 +252,7 @@ void GrResourceCache2::makeResourceMRU(GrGpuResource* resource) {
     fResources.addToHead(resource);
 }
 
-void GrResourceCache2::notifyPurgeable(GrGpuResource* resource) {
+void GrResourceCache::notifyPurgeable(GrGpuResource* resource) {
     SkASSERT(resource);
     SkASSERT(this->isInCache(resource));
     SkASSERT(resource->isPurgeable());
@@ -303,7 +303,7 @@ void GrResourceCache2::notifyPurgeable(GrGpuResource* resource) {
     this->validate();
 }
 
-void GrResourceCache2::didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) {
+void GrResourceCache::didChangeGpuMemorySize(const GrGpuResource* resource, size_t oldSize) {
     // SkASSERT(!fPurging); GrPathRange increases size during flush. :(
     SkASSERT(resource);
     SkASSERT(this->isInCache(resource));
@@ -325,7 +325,7 @@ void GrResourceCache2::didChangeGpuMemorySize(const GrGpuResource* resource, siz
     this->validate();
 }
 
-void GrResourceCache2::didChangeBudgetStatus(GrGpuResource* resource) {
+void GrResourceCache::didChangeBudgetStatus(GrGpuResource* resource) {
     SkASSERT(!fPurging);
     SkASSERT(resource);
     SkASSERT(this->isInCache(resource));
@@ -348,7 +348,7 @@ void GrResourceCache2::didChangeBudgetStatus(GrGpuResource* resource) {
     this->validate();
 }
 
-void GrResourceCache2::internalPurgeAsNeeded() {
+void GrResourceCache::internalPurgeAsNeeded() {
     SkASSERT(!fPurging);
     SkASSERT(!fNewlyPurgeableResourceWhilePurging);
     SkASSERT(fBudgetedCount > fMaxCount || fBudgetedBytes > fMaxBytes);
@@ -385,7 +385,7 @@ void GrResourceCache2::internalPurgeAsNeeded() {
     this->validate();
 }
 
-void GrResourceCache2::purgeAllUnlocked() {
+void GrResourceCache::purgeAllUnlocked() {
     SkASSERT(!fPurging);
     SkASSERT(!fNewlyPurgeableResourceWhilePurging);
 
@@ -413,7 +413,7 @@ void GrResourceCache2::purgeAllUnlocked() {
     this->validate();
 }
 
-void GrResourceCache2::processInvalidContentKeys(
+void GrResourceCache::processInvalidContentKeys(
     const SkTArray<GrContentKeyInvalidatedMessage>& msgs) {
     for (int i = 0; i < msgs.count(); ++i) {
         GrGpuResource* resource = this->findAndRefContentResource(msgs[i].key());
@@ -425,7 +425,7 @@ void GrResourceCache2::processInvalidContentKeys(
 }
 
 #ifdef SK_DEBUG
-void GrResourceCache2::validate() const {
+void GrResourceCache::validate() const {
     // Reduce the frequency of validations for large resource counts.
     static SkRandom gRandom;
     int mask = (SkNextPow2(fCount + 1) >> 5) - 1;
similarity index 96%
rename from src/gpu/GrResourceCache2.h
rename to src/gpu/GrResourceCache.h
index e844f11..522641b 100644 (file)
@@ -6,8 +6,8 @@
  * found in the LICENSE file.
  */
 
-#ifndef GrResourceCache2_DEFINED
-#define GrResourceCache2_DEFINED
+#ifndef GrResourceCache_DEFINED
+#define GrResourceCache_DEFINED
 
 #include "GrGpuResource.h"
 #include "GrGpuResourceCacheAccess.h"
@@ -36,10 +36,10 @@ class SkString;
  * If a resource has neither key type then it will be deleted as soon as the last reference to it
  * is dropped. If a key has both keys the content key takes precedence.
  */
-class GrResourceCache2 {
+class GrResourceCache {
 public:
-    GrResourceCache2();
-    ~GrResourceCache2();
+    GrResourceCache();
+    ~GrResourceCache();
 
     /** Used to access functionality needed by GrGpuResource for lifetime management. */
     class ResourceAccess;
@@ -254,9 +254,9 @@ private:
 
 };
 
-class GrResourceCache2::ResourceAccess {
+class GrResourceCache::ResourceAccess {
 private:
-    ResourceAccess(GrResourceCache2* cache) : fCache(cache) { }
+    ResourceAccess(GrResourceCache* cache) : fCache(cache) { }
     ResourceAccess(const ResourceAccess& that) : fCache(that.fCache) { }
     ResourceAccess& operator=(const ResourceAccess&); // unimpl
 
@@ -315,13 +315,13 @@ private:
     const ResourceAccess* operator&() const;
     ResourceAccess* operator&();
 
-    GrResourceCache2* fCache;
+    GrResourceCache* fCache;
 
     friend class GrGpuResource; // To access all the proxy inline methods.
-    friend class GrResourceCache2; // To create this type.
+    friend class GrResourceCache; // To create this type.
 };
 
-inline GrResourceCache2::ResourceAccess GrResourceCache2::resourceAccess() {
+inline GrResourceCache::ResourceAccess GrResourceCache::resourceAccess() {
     return ResourceAccess(this);
 }
 
index 2f32eb5..14259e6 100644 (file)
@@ -9,7 +9,7 @@
 #include "GrTest.h"
 
 #include "GrInOrderDrawBuffer.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "SkString.h"
 
 void GrTestTarget::init(GrContext* ctx, GrDrawTarget* target) {
@@ -38,12 +38,12 @@ void GrContext::setMaxTextureSizeOverride(int maxTextureSizeOverride) {
 }
 
 void GrContext::purgeAllUnlockedResources() {
-    fResourceCache2->purgeAllUnlocked();
+    fResourceCache->purgeAllUnlocked();
 }
 
 void GrContext::dumpCacheStats(SkString* out) const {
 #if GR_CACHE_STATS
-    fResourceCache2->dumpStats(out);
+    fResourceCache->dumpStats(out);
 #endif
 }
 
@@ -75,7 +75,7 @@ void GrGpu::Stats::dump(SkString* out) {
 #endif
 
 #if GR_CACHE_STATS
-void GrResourceCache2::dumpStats(SkString* out) const {
+void GrResourceCache::dumpStats(SkString* out) const {
     this->validate();
 
     int locked = 0;
index 7a3355f..856bd72 100644 (file)
@@ -10,7 +10,7 @@
 #include "GrContext.h"
 #include "GrContextFactory.h"
 #include "GrGpu.h"
-#include "GrResourceCache2.h"
+#include "GrResourceCache.h"
 #include "SkCanvas.h"
 #include "SkGr.h"
 #include "SkMessageBus.h"
@@ -160,12 +160,12 @@ public:
         fContext.reset(GrContext::CreateMockContext());
         SkASSERT(fContext);
         fContext->setResourceCacheLimits(maxCnt, maxBytes);
-        GrResourceCache2* cache2 = fContext->getResourceCache2();
-        cache2->purgeAllUnlocked();
-        SkASSERT(0 == cache2->getResourceCount() && 0 == cache2->getResourceBytes());
+        GrResourceCache* cache = fContext->getResourceCache();
+        cache->purgeAllUnlocked();
+        SkASSERT(0 == cache->getResourceCount() && 0 == cache->getResourceBytes());
     }
 
-    GrResourceCache2* cache() { return fContext->getResourceCache2(); }
+    GrResourceCache* cache() { return fContext->getResourceCache(); }
 
     GrContext* context() { return fContext; }
 
@@ -176,7 +176,7 @@ private:
 static void test_no_key(skiatest::Reporter* reporter) {
     Mock mock(10, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     // Create a bunch of resources with no keys
     TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
@@ -189,37 +189,37 @@ static void test_no_key(skiatest::Reporter* reporter) {
     d->setSize(14);
 
     REPORTER_ASSERT(reporter, 4 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() + c->gpuMemorySize() +
-                              d->gpuMemorySize() == cache2->getResourceBytes());
+                              d->gpuMemorySize() == cache->getResourceBytes());
 
     // Should be safe to purge without deleting the resources since we still have refs.
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, 4 == TestResource::NumAlive());
 
     // Since the resources have neither content nor scratch keys, delete immediately upon unref.
 
     a->unref();
     REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, b->gpuMemorySize() + c->gpuMemorySize() + d->gpuMemorySize() ==
-                              cache2->getResourceBytes());
+                              cache->getResourceBytes());
 
     c->unref();
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, b->gpuMemorySize() + d->gpuMemorySize() ==
-                              cache2->getResourceBytes());
+                              cache->getResourceBytes());
 
     d->unref();
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, b->gpuMemorySize() == cache2->getResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, b->gpuMemorySize() == cache->getResourceBytes());
 
     b->unref();
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
 }
 
 // Each integer passed as a template param creates a new domain.
@@ -232,7 +232,7 @@ template <int> static void make_content_key(GrContentKey* key, int data) {
 static void test_budgeting(skiatest::Reporter* reporter) {
     Mock mock(10, 300);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     GrContentKey contentKey;
     make_content_key<0>(&contentKey, 0);
@@ -255,69 +255,69 @@ static void test_budgeting(skiatest::Reporter* reporter) {
     GrContentKey contentKey2;
     make_content_key<0>(&contentKey2, 1);
     REPORTER_ASSERT(reporter, !wrapped->cacheAccess().setContentKey(contentKey2));
-    REPORTER_ASSERT(reporter, NULL == cache2->findAndRefContentResource(contentKey2));
+    REPORTER_ASSERT(reporter, NULL == cache->findAndRefContentResource(contentKey2));
 
     // Make sure sizes are as we expect
-    REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
                               wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
-                              cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
+                              cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() ==
-                              cache2->getBudgetedResourceBytes());
+                              cache->getBudgetedResourceBytes());
 
     // Our refs mean that the resources are non purgeable.
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 4 == cache2->getResourceCount());
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 4 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
                               wrapped->gpuMemorySize() + unbudgeted->gpuMemorySize() ==
-                              cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
+                              cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() ==
-                              cache2->getBudgetedResourceBytes());
+                              cache->getBudgetedResourceBytes());
 
     // Unreffing the wrapped resource should free it right away.
     wrapped->unref();
-    REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + content->gpuMemorySize() +
-                              unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
+                              unbudgeted->gpuMemorySize() == cache->getResourceBytes());
 
     // Now try freeing the budgeted resources first
     wrapped = SkNEW_ARGS(TestResource, (context->getGpu(), GrGpuResource::kWrapped_LifeCycle));
     scratch->setSize(12);
     content->unref();
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, scratch->gpuMemorySize() + wrapped->gpuMemorySize() +
-                              unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, scratch->gpuMemorySize() == cache2->getBudgetedResourceBytes());
+                              unbudgeted->gpuMemorySize() == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, scratch->gpuMemorySize() == cache->getBudgetedResourceBytes());
 
     scratch->unref();
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() + wrapped->gpuMemorySize() ==
-                              cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+                              cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
 
     wrapped->unref();
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, unbudgeted->gpuMemorySize() == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
 
     unbudgeted->unref();
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
 }
 
 static void test_unbudgeted(skiatest::Reporter* reporter) {
     Mock mock(10, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     GrContentKey contentKey;
     make_content_key<0>(&contentKey, 0);
@@ -331,58 +331,58 @@ static void test_unbudgeted(skiatest::Reporter* reporter) {
     scratch = TestResource::CreateScratch(context->getGpu(), TestResource::kB_SimulatedProperty);
     scratch->setSize(10);
     scratch->unref();
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 10 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 10 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 10 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 10 == cache->getBudgetedResourceBytes());
 
     content = SkNEW_ARGS(TestResource, (context->getGpu()));
     content->setSize(11);
     REPORTER_ASSERT(reporter, content->cacheAccess().setContentKey(contentKey));
     content->unref();
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
 
-    size_t large = 2 * cache2->getResourceBytes();
+    size_t large = 2 * cache->getResourceBytes();
     unbudgeted = SkNEW_ARGS(TestResource,
                             (context->getGpu(), large, GrGpuResource::kUncached_LifeCycle));
-    REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 21 + large == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 21 + large == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
 
     unbudgeted->unref();
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
 
     wrapped = SkNEW_ARGS(TestResource,
                          (context->getGpu(), large, GrGpuResource::kWrapped_LifeCycle));
-    REPORTER_ASSERT(reporter, 3 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 21 + large == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 3 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 21 + large == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
 
     wrapped->unref();
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 2 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 21 == cache2->getBudgetedResourceBytes());
-
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 2 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 21 == cache->getBudgetedResourceBytes());
+
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
 }
 
 static void test_unbudgeted_to_scratch(skiatest::Reporter* reporter) {
     Mock mock(10, 300);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     TestResource* resource =
         TestResource::CreateScratch(context->getGpu(), TestResource::kA_SimulatedProperty, false);
@@ -395,19 +395,19 @@ static void test_unbudgeted_to_scratch(skiatest::Reporter* reporter) {
         REPORTER_ASSERT(reporter, resource->cacheAccess().getScratchKey() == key);
         REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
         REPORTER_ASSERT(reporter, !resource->cacheAccess().isBudgeted());
-        REPORTER_ASSERT(reporter, NULL == cache2->findAndRefScratchResource(key));
-        REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-        REPORTER_ASSERT(reporter, size == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-        REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+        REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(key));
+        REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+        REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+        REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
 
         // Once it is unrefed, it should become available as scratch.
         resource->unref();
-        REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-        REPORTER_ASSERT(reporter, size == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount());
-        REPORTER_ASSERT(reporter, size == cache2->getBudgetedResourceBytes());
-        resource = static_cast<TestResource*>(cache2->findAndRefScratchResource(key));
+        REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+        REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
+        REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes());
+        resource = static_cast<TestResource*>(cache->findAndRefScratchResource(key));
         REPORTER_ASSERT(reporter, resource);
         REPORTER_ASSERT(reporter, resource->cacheAccess().getScratchKey() == key);
         REPORTER_ASSERT(reporter, resource->cacheAccess().isScratch());
@@ -420,20 +420,20 @@ static void test_unbudgeted_to_scratch(skiatest::Reporter* reporter) {
         } else {
             // After the second time around, try removing the scratch key
             resource->cacheAccess().removeScratchKey();
-            REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-            REPORTER_ASSERT(reporter, size == cache2->getResourceBytes());
-            REPORTER_ASSERT(reporter, 1 == cache2->getBudgetedResourceCount());
-            REPORTER_ASSERT(reporter, size == cache2->getBudgetedResourceBytes());
+            REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+            REPORTER_ASSERT(reporter, size == cache->getResourceBytes());
+            REPORTER_ASSERT(reporter, 1 == cache->getBudgetedResourceCount());
+            REPORTER_ASSERT(reporter, size == cache->getBudgetedResourceBytes());
             REPORTER_ASSERT(reporter, !resource->cacheAccess().getScratchKey().isValid());
             REPORTER_ASSERT(reporter, !resource->cacheAccess().isScratch());
             REPORTER_ASSERT(reporter, resource->cacheAccess().isBudgeted());
 
             // now when it is unrefed it should die since it has no key.
             resource->unref();
-            REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-            REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
-            REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceCount());
-            REPORTER_ASSERT(reporter, 0 == cache2->getBudgetedResourceBytes());
+            REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+            REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
+            REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceCount());
+            REPORTER_ASSERT(reporter, 0 == cache->getBudgetedResourceBytes());
         }
     }
 }
@@ -441,7 +441,7 @@ static void test_unbudgeted_to_scratch(skiatest::Reporter* reporter) {
 static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
     Mock mock(5, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     // Create two resources that have the same scratch key.
     TestResource* a = TestResource::CreateScratch(context->getGpu(),
@@ -453,40 +453,40 @@ static void test_duplicate_scratch_key(skiatest::Reporter* reporter) {
     GrScratchKey scratchKey1;
     TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey1);
     // Check for negative case consistency. (leaks upon test failure.)
-    REPORTER_ASSERT(reporter, NULL == cache2->findAndRefScratchResource(scratchKey1));
+    REPORTER_ASSERT(reporter, NULL == cache->findAndRefScratchResource(scratchKey1));
 
     GrScratchKey scratchKey;
     TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
 
-    // Scratch resources are registered with GrResourceCache2 just by existing. There are 2.
+    // Scratch resources are registered with GrResourceCache just by existing. There are 2.
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() ==
-                              cache2->getResourceBytes());
+                              cache->getResourceBytes());
 
     // Our refs mean that the resources are non purgeable.
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
 
     // Unref but don't purge
     a->unref();
     b->unref();
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->countScratchEntriesForKey(scratchKey));)
 
     // Purge again. This time resources should be purgeable.
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
 }
 
 static void test_remove_scratch_key(skiatest::Reporter* reporter) {
     Mock mock(5, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     // Create two resources that have the same scratch key.
     TestResource* a = TestResource::CreateScratch(context->getGpu(),
@@ -501,52 +501,52 @@ static void test_remove_scratch_key(skiatest::Reporter* reporter) {
     // Ensure that scratch key lookup is correct for negative case.
     TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
     // (following leaks upon test failure).
-    REPORTER_ASSERT(reporter, cache2->findAndRefScratchResource(scratchKey) == NULL);
+    REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey) == NULL);
 
-    // Scratch resources are registered with GrResourceCache2 just by existing. There are 2.
+    // Scratch resources are registered with GrResourceCache just by existing. There are 2.
     TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 2 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
 
     // Find the first resource and remove its scratch key
     GrGpuResource* find;
-    find = cache2->findAndRefScratchResource(scratchKey);
+    find = cache->findAndRefScratchResource(scratchKey);
     find->cacheAccess().removeScratchKey();
     // It's still alive, but not cached by scratch key anymore
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
 
     // The cache should immediately delete it when it's unrefed since it isn't accessible.
     find->unref();
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 1 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
 
     // Repeat for the second resource.
-    find = cache2->findAndRefScratchResource(scratchKey);
+    find = cache->findAndRefScratchResource(scratchKey);
     find->cacheAccess().removeScratchKey();
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
 
     // Should be able to call this multiple times with no problem.
     find->cacheAccess().removeScratchKey();
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
 
     find->unref();
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
-    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache2->countScratchEntriesForKey(scratchKey));)
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
+    SkDEBUGCODE(REPORTER_ASSERT(reporter, 0 == cache->countScratchEntriesForKey(scratchKey));)
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
 }
 
 static void test_scratch_key_consistency(skiatest::Reporter* reporter) {
     Mock mock(5, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     // Create two resources that have the same scratch key.
     TestResource* a = TestResource::CreateScratch(context->getGpu(),
@@ -581,20 +581,20 @@ static void test_scratch_key_consistency(skiatest::Reporter* reporter) {
     // Ensure that scratch key lookup is correct for negative case.
     TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
     // (following leaks upon test failure).
-    REPORTER_ASSERT(reporter, cache2->findAndRefScratchResource(scratchKey) == NULL);
+    REPORTER_ASSERT(reporter, cache->findAndRefScratchResource(scratchKey) == NULL);
 
     // Find the first resource with a scratch key and a copy of a scratch key.
     TestResource::ComputeScratchKey(TestResource::kB_SimulatedProperty, &scratchKey);
-    GrGpuResource* find = cache2->findAndRefScratchResource(scratchKey);
+    GrGpuResource* find = cache->findAndRefScratchResource(scratchKey);
     REPORTER_ASSERT(reporter, find != NULL);
     find->unref();
 
     scratchKey2 = scratchKey;
-    find = cache2->findAndRefScratchResource(scratchKey2);
+    find = cache->findAndRefScratchResource(scratchKey2);
     REPORTER_ASSERT(reporter, find != NULL);
     REPORTER_ASSERT(reporter, find == a || find == b);
 
-    GrGpuResource* find2 = cache2->findAndRefScratchResource(scratchKey2);
+    GrGpuResource* find2 = cache->findAndRefScratchResource(scratchKey2);
     REPORTER_ASSERT(reporter, find2 != NULL);
     REPORTER_ASSERT(reporter, find2 == a || find2 == b);
     REPORTER_ASSERT(reporter, find2 != find);
@@ -605,7 +605,7 @@ static void test_scratch_key_consistency(skiatest::Reporter* reporter) {
 static void test_duplicate_content_key(skiatest::Reporter* reporter) {
     Mock mock(5, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     GrContentKey key;
     make_content_key<0>(&key, 0);
@@ -621,38 +621,38 @@ static void test_duplicate_content_key(skiatest::Reporter* reporter) {
     REPORTER_ASSERT(reporter, !b->cacheAccess().setContentKey(key));
 
     // Still have two resources because b is still reffed.
-    REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+    REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
     REPORTER_ASSERT(reporter, a->gpuMemorySize() + b->gpuMemorySize() ==
-                              cache2->getResourceBytes());
+                              cache->getResourceBytes());
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
 
     b->unref();
     // Now b should be gone.
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache->getResourceBytes());
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
 
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache->getResourceBytes());
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
 
     // Drop the ref on a but it isn't immediately purged as it still has a valid scratch key.
     a->unref();
-    REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache2->getResourceBytes());
+    REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, a->gpuMemorySize() == cache->getResourceBytes());
     REPORTER_ASSERT(reporter, 1 == TestResource::NumAlive());
 
-    cache2->purgeAllUnlocked();
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
+    cache->purgeAllUnlocked();
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
 }
 
 static void test_purge_invalidated(skiatest::Reporter* reporter) {
     Mock mock(5, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     GrContentKey key1, key2, key3;
     make_content_key<0>(&key1, 1);
@@ -671,9 +671,9 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
     // hold b until *after* the message is sent.
     c->unref();
 
-    REPORTER_ASSERT(reporter, cache2->hasContentKey(key1));
-    REPORTER_ASSERT(reporter, cache2->hasContentKey(key2));
-    REPORTER_ASSERT(reporter, cache2->hasContentKey(key3));
+    REPORTER_ASSERT(reporter, cache->hasContentKey(key1));
+    REPORTER_ASSERT(reporter, cache->hasContentKey(key2));
+    REPORTER_ASSERT(reporter, cache->hasContentKey(key3));
     REPORTER_ASSERT(reporter, 3 == TestResource::NumAlive());
 
     typedef GrContentKeyInvalidatedMessage Msg;
@@ -682,19 +682,19 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
     // Invalidate two of the three, they should be purged and no longer accessible via their keys.
     Bus::Post(Msg(key1));
     Bus::Post(Msg(key2));
-    cache2->purgeAsNeeded();
+    cache->purgeAsNeeded();
     // a should be deleted now, but we still have a ref on b.
-    REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
-    REPORTER_ASSERT(reporter, !cache2->hasContentKey(key2));
+    REPORTER_ASSERT(reporter, !cache->hasContentKey(key1));
+    REPORTER_ASSERT(reporter, !cache->hasContentKey(key2));
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, cache2->hasContentKey(key3));
+    REPORTER_ASSERT(reporter, cache->hasContentKey(key3));
 
     // Invalidate the third.
     Bus::Post(Msg(key3));
-    cache2->purgeAsNeeded();
+    cache->purgeAsNeeded();
     // we still have a ref on b, c should be recycled as scratch.
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, !cache2->hasContentKey(key3));
+    REPORTER_ASSERT(reporter, !cache->hasContentKey(key3));
 
     // make b purgeable. It should be immediately deleted since it has no key.
     b->unref();
@@ -703,16 +703,16 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
     // Make sure we actually get to c via it's scratch key, before we say goodbye.
     GrScratchKey scratchKey;
     TestResource::ComputeScratchKey(TestResource::kA_SimulatedProperty, &scratchKey);
-    GrGpuResource* scratch = cache2->findAndRefScratchResource(scratchKey);
+    GrGpuResource* scratch = cache->findAndRefScratchResource(scratchKey);
     REPORTER_ASSERT(reporter, scratch == c);
     SkSafeUnref(scratch);
 
     // Get rid of c.
-    cache2->purgeAllUnlocked();
-    scratch = cache2->findAndRefScratchResource(scratchKey);
+    cache->purgeAllUnlocked();
+    scratch = cache->findAndRefScratchResource(scratchKey);
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceCount());
-    REPORTER_ASSERT(reporter, 0 == cache2->getResourceBytes());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceCount());
+    REPORTER_ASSERT(reporter, 0 == cache->getResourceBytes());
     REPORTER_ASSERT(reporter, !scratch);
     SkSafeUnref(scratch);
 }
@@ -720,7 +720,7 @@ static void test_purge_invalidated(skiatest::Reporter* reporter) {
 static void test_cache_chained_purge(skiatest::Reporter* reporter) {
     Mock mock(3, 30000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     GrContentKey key1, key2;
     make_content_key<0>(&key1, 1);
@@ -743,14 +743,14 @@ static void test_cache_chained_purge(skiatest::Reporter* reporter) {
 
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
 
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
 
     // Break the cycle
     a->setUnrefWhenDestroyed(NULL);
     REPORTER_ASSERT(reporter, 2 == TestResource::NumAlive());
 
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, 0 == TestResource::NumAlive());
 }
 
@@ -763,7 +763,7 @@ static void test_resource_size_changed(skiatest::Reporter* reporter) {
     {
         Mock mock(3, 30000);
         GrContext* context = mock.context();
-        GrResourceCache2* cache2 = mock.cache();
+        GrResourceCache* cache = mock.cache();
 
         TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
         a->cacheAccess().setContentKey(key1);
@@ -773,24 +773,24 @@ static void test_resource_size_changed(skiatest::Reporter* reporter) {
         b->cacheAccess().setContentKey(key2);
         b->unref();
 
-        REPORTER_ASSERT(reporter, 200 == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+        REPORTER_ASSERT(reporter, 200 == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
         {
-            SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache2->findAndRefContentResource(key2)));
+            SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache->findAndRefContentResource(key2)));
             find2->setSize(200);
-            SkAutoTUnref<TestResource> find1(static_cast<TestResource*>(cache2->findAndRefContentResource(key1)));
+            SkAutoTUnref<TestResource> find1(static_cast<TestResource*>(cache->findAndRefContentResource(key1)));
             find1->setSize(50);
         }
 
-        REPORTER_ASSERT(reporter, 250 == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+        REPORTER_ASSERT(reporter, 250 == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
     }
 
     // Test increasing a resources size beyond the cache budget.
     {
         Mock mock(2, 300);
         GrContext* context = mock.context();
-        GrResourceCache2* cache2 = mock.cache();
+        GrResourceCache* cache = mock.cache();
 
         TestResource* a = SkNEW_ARGS(TestResource, (context->getGpu()));
         a->setSize(100);
@@ -802,17 +802,17 @@ static void test_resource_size_changed(skiatest::Reporter* reporter) {
         b->cacheAccess().setContentKey(key2);
         b->unref();
 
-        REPORTER_ASSERT(reporter, 200 == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 2 == cache2->getResourceCount());
+        REPORTER_ASSERT(reporter, 200 == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 2 == cache->getResourceCount());
 
         {
-            SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache2->findAndRefContentResource(key2)));
+            SkAutoTUnref<TestResource> find2(static_cast<TestResource*>(cache->findAndRefContentResource(key2)));
             find2->setSize(201);
         }
-        REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
+        REPORTER_ASSERT(reporter, !cache->hasContentKey(key1));
 
-        REPORTER_ASSERT(reporter, 201 == cache2->getResourceBytes());
-        REPORTER_ASSERT(reporter, 1 == cache2->getResourceCount());
+        REPORTER_ASSERT(reporter, 201 == cache->getResourceBytes());
+        REPORTER_ASSERT(reporter, 1 == cache->getResourceCount());
     }
 }
 
@@ -824,7 +824,7 @@ static void test_large_resource_count(skiatest::Reporter* reporter) {
 
     Mock mock(2 * kResourceCnt, 2 * kResourceCnt + 1000);
     GrContext* context = mock.context();
-    GrResourceCache2* cache2 = mock.cache();
+    GrResourceCache* cache = mock.cache();
 
     for (int i = 0; i < kResourceCnt; ++i) {
         GrContentKey key1, key2;
@@ -845,33 +845,33 @@ static void test_large_resource_count(skiatest::Reporter* reporter) {
     }
 
     REPORTER_ASSERT(reporter, TestResource::NumAlive() == 2 * kResourceCnt);
-    REPORTER_ASSERT(reporter, cache2->getBudgetedResourceBytes() == 2 * kResourceCnt);
-    REPORTER_ASSERT(reporter, cache2->getBudgetedResourceCount() == 2 * kResourceCnt);
-    REPORTER_ASSERT(reporter, cache2->getResourceBytes() == 2 * kResourceCnt);
-    REPORTER_ASSERT(reporter, cache2->getResourceCount() == 2 * kResourceCnt);
+    REPORTER_ASSERT(reporter, cache->getBudgetedResourceBytes() == 2 * kResourceCnt);
+    REPORTER_ASSERT(reporter, cache->getBudgetedResourceCount() == 2 * kResourceCnt);
+    REPORTER_ASSERT(reporter, cache->getResourceBytes() == 2 * kResourceCnt);
+    REPORTER_ASSERT(reporter, cache->getResourceCount() == 2 * kResourceCnt);
     for (int i = 0; i < kResourceCnt; ++i) {
         GrContentKey key1, key2;
         make_content_key<1>(&key1, i);
         make_content_key<2>(&key2, i);
 
-        REPORTER_ASSERT(reporter, cache2->hasContentKey(key1));
-        REPORTER_ASSERT(reporter, cache2->hasContentKey(key2));
+        REPORTER_ASSERT(reporter, cache->hasContentKey(key1));
+        REPORTER_ASSERT(reporter, cache->hasContentKey(key2));
     }
 
-    cache2->purgeAllUnlocked();
+    cache->purgeAllUnlocked();
     REPORTER_ASSERT(reporter, TestResource::NumAlive() == 0);
-    REPORTER_ASSERT(reporter, cache2->getBudgetedResourceBytes() == 0);
-    REPORTER_ASSERT(reporter, cache2->getBudgetedResourceCount() == 0);
-    REPORTER_ASSERT(reporter, cache2->getResourceBytes() == 0);
-    REPORTER_ASSERT(reporter, cache2->getResourceCount() == 0);
+    REPORTER_ASSERT(reporter, cache->getBudgetedResourceBytes() == 0);
+    REPORTER_ASSERT(reporter, cache->getBudgetedResourceCount() == 0);
+    REPORTER_ASSERT(reporter, cache->getResourceBytes() == 0);
+    REPORTER_ASSERT(reporter, cache->getResourceCount() == 0);
 
     for (int i = 0; i < kResourceCnt; ++i) {
         GrContentKey key1, key2;
         make_content_key<1>(&key1, i);
         make_content_key<2>(&key2, i);
 
-        REPORTER_ASSERT(reporter, !cache2->hasContentKey(key1));
-        REPORTER_ASSERT(reporter, !cache2->hasContentKey(key2));
+        REPORTER_ASSERT(reporter, !cache->hasContentKey(key1));
+        REPORTER_ASSERT(reporter, !cache->hasContentKey(key2));
     }
 }