Make textures register with GrResourceCache2 as scratch.

R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/510053003
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index c325efd..a5732f7 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -20,11 +20,17 @@
     SkASSERT(!this->isInCache(resource));
     fResources.addToHead(resource);
     ++fCount;
+    if (!resource->getScratchKey().isNullScratch()) {
+        fScratchMap.insert(resource->getScratchKey(), resource);
+    }
 }
 
 void GrResourceCache2::removeResource(GrGpuResource* resource) {
     SkASSERT(this->isInCache(resource));
-    fResources.remove(resource);
+    fResources.remove(resource);    
+    if (!resource->getScratchKey().isNullScratch()) {
+        fScratchMap.remove(resource->getScratchKey(), resource);
+    }
     --fCount;
 }
 
@@ -35,6 +41,7 @@
         // abandon should have already removed this from the list.
         SkASSERT(head != fResources.head());
     }
+    SkASSERT(!fScratchMap.count());
     SkASSERT(!fCount);
 }
 
@@ -45,5 +52,6 @@
         // release should have already removed this from the list.
         SkASSERT(head != fResources.head());
     }
+    SkASSERT(!fScratchMap.count());
     SkASSERT(!fCount);
 }