Allow unbudgeted resources to be recycled by the cache as scratch.

Review URL: https://codereview.chromium.org/870743002
diff --git a/src/gpu/GrGpuResource.cpp b/src/gpu/GrGpuResource.cpp
index 3e9964f..15d5888 100644
--- a/src/gpu/GrGpuResource.cpp
+++ b/src/gpu/GrGpuResource.cpp
@@ -86,8 +86,8 @@
     // Currently this can only be called once and can't be called when the resource is scratch.
     SkASSERT(this->internalHasRef());
 
-    // Wrapped resources can never have a key.
-    if (this->isWrapped()) {
+    // Wrapped and uncached resources can never have a content key.
+    if (!this->cacheAccess().isBudgeted()) {
         return false;
     }
 
@@ -138,6 +138,13 @@
     }
 }
 
+void GrGpuResource::makeUnbudgeted() {
+    if (GrGpuResource::kCached_LifeCycle == fLifeCycle && !fContentKey.isValid()) {
+        fLifeCycle = kUncached_LifeCycle;
+        get_resource_cache2(fGpu)->resourceAccess().didChangeBudgetStatus(this);
+    }
+}
+
 uint32_t GrGpuResource::CreateUniqueID() {
     static int32_t gUniqueID = SK_InvalidUniqueID;
     uint32_t id;