Track the number of resources that would become purgeable after flush
in GrResourceCache.

Bug: skia:8927
Change-Id: Ia00ba0ea541a22e29e9a8208044e1fabd5296782
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/205484
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index c831471..f33755d 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -105,7 +105,11 @@
     GrTextureProxy* proxy = fUniquelyKeyedProxies.find(key);
     sk_sp<GrTextureProxy> result;
     if (proxy) {
-        proxy->firstRefAccess().ref();
+        GrResourceCache* cache = nullptr;
+        if (auto directContext = fImageContext->priv().asDirectContext()) {
+            cache = directContext->priv().getResourceCache();
+        }
+        proxy->firstRefAccess().ref(cache);
         result.reset(proxy);
         SkASSERT(result->origin() == origin);
     }