Revert of Use presence of a content key as non-scratch indicator (patchset #5 id:80001 of https://codereview.chromium.org/639873002/)

Reason for revert:
breaking nanobench on ubuntu

Original issue's description:
> Use presence of a content key as non-scratch indicator
>
> BUG=skia:2889
>
> Committed: https://skia.googlesource.com/skia/+/9eefe0851eeaa8ded05b4774ebcb38ed201d5dbf

TBR=robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:2889

Review URL: https://codereview.chromium.org/642493003
diff --git a/include/gpu/GrGpuResource.h b/include/gpu/GrGpuResource.h
index b01f0e9..afd9275 100644
--- a/include/gpu/GrGpuResource.h
+++ b/include/gpu/GrGpuResource.h
@@ -71,7 +71,7 @@
     }
 
 protected:
-    GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0) { }
+    GrIORef() : fRefCnt(1), fPendingReads(0), fPendingWrites(0), fIsScratch(kNo_IsScratch) { }
 
     bool internalHasPendingRead() const { return SkToBool(fPendingReads); }
     bool internalHasPendingWrite() const { return SkToBool(fPendingWrites); }
@@ -118,7 +118,16 @@
 
     // This class is used to manage conversion of refs to pending reads/writes.
     friend class GrGpuResourceRef;
-    friend class GrResourceCache2; // to check IO ref counts.
+
+    // This is temporary until GrResourceCache is fully replaced by GrResourceCache2.
+    enum IsScratch {
+        kNo_IsScratch,
+        kYes_IsScratch
+    } fIsScratch;
+
+    friend class GrContext; // to set the above field.
+    friend class GrResourceCache; // to check the above field.
+    friend class GrResourceCache2; // to check the above field.
 
     template <typename, GrIOType> friend class GrPendingIOResource;
 };
@@ -181,12 +190,6 @@
      */
     const GrResourceKey& getScratchKey() const { return fScratchKey; }
 
-    /** 
-     * If this resource is currently cached by its contents then this will return
-     * the content key. Otherwise, NULL is returned.
-     */
-    const GrResourceKey* getContentKey() const;
-
     /**
      * Gets an id that is unique for this GrGpuResource object. It is static in that it does
      * not change when the content of the GrGpuResource object changes. This will never return
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 6ece67f..a722eed 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -6,6 +6,7 @@
  * found in the LICENSE file.
  */
 
+
 #include "GrContext.h"
 
 #include "effects/GrConfigConversionEffect.h"
@@ -443,6 +444,7 @@
         return NULL;
     }
     fResourceCache->addResource(texture->getScratchKey(), texture);
+    texture->fIsScratch = GrGpuResource::kYes_IsScratch;
     return texture;
 }
 
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 5452184..a074d7c 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -101,13 +101,6 @@
     fScratchKey = scratchKey;
 }
 
-const GrResourceKey* GrGpuResource::getContentKey() const {
-    if (fCacheEntry && !fCacheEntry->key().isScratch()) {
-        return &fCacheEntry->key();
-    }
-    return NULL;
-}
-
 uint32_t GrGpuResource::CreateUniqueID() {
     static int32_t gUniqueID = SK_InvalidUniqueID;
     uint32_t id;
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index f50ed7d..c683b5b 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -6,10 +6,13 @@
  * found in the LICENSE file.
  */
 
+
+
 #include "GrResourceCache.h"
 #include "GrGpuResource.h"
 #include "GrTexturePriv.h"
 
+
 DECLARE_SKMESSAGEBUS_MESSAGE(GrResourceInvalidatedMessage);
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -178,7 +181,7 @@
     // scratch texture reuse is turned off.
     SkASSERT(resource->getCacheEntry());
     if (resource->getCacheEntry()->key().getResourceType() == GrTexturePriv::ResourceType() &&
-        resource->getCacheEntry()->key().isScratch() &&
+        resource->fIsScratch &&
         !fCaps->reuseScratchTextures() &&
         !(static_cast<const GrTexture*>(resource)->desc().fFlags &
           kRenderTarget_GrTextureFlagBit)) {
@@ -187,12 +190,12 @@
 }
 
 GrGpuResource* GrResourceCache::find(const GrResourceKey& key) {
-    // GrResourceCache2 is responsible for scratch resources.
-    SkASSERT(!key.isScratch());
-
     GrAutoResourceCacheValidate atcv(this);
 
-    GrResourceCacheEntry* entry = fCache.find(key);
+    GrResourceCacheEntry* entry = NULL;
+
+    entry = fCache.find(key);
+
     if (NULL == entry) {
         return NULL;
     }
@@ -201,6 +204,8 @@
     this->internalDetach(entry);
     this->attachToHead(entry);
 
+    // GrResourceCache2 is responsible for scratch resources.
+    SkASSERT(GrGpuResource::kNo_IsScratch == entry->resource()->fIsScratch);
     return entry->fResource;
 }
 
diff --git a/src/gpu/GrResourceCache2.cpp b/src/gpu/GrResourceCache2.cpp
index 76673cf..85e66a7 100644
--- a/src/gpu/GrResourceCache2.cpp
+++ b/src/gpu/GrResourceCache2.cpp
@@ -67,15 +67,15 @@
             // either by drawing code or for pending io operations.
             // This will be removed when flush no longer creates resources.
             return resource->reffedOnlyByCache() && !resource->internalHasPendingIO() &&
-                   (NULL == resource->getContentKey());
+                   GrGpuResource::kYes_IsScratch == resource->fIsScratch;
         } else {
             // Because duties are currently shared between GrResourceCache and GrResourceCache2, the
             // current interpretation of this rule is that only GrResourceCache has a ref but that
             // it has been marked as a scratch resource.
-            return resource->reffedOnlyByCache() && (NULL == resource->getContentKey());
+            return resource->reffedOnlyByCache() &&
+                GrGpuResource::kYes_IsScratch == resource->fIsScratch;
         }
     }
-
 private:
     bool fFlushing;
 };