Simplify promise image lazy instantiation callbacks.

Now that we never re-fulfill a promise image we no longer need to deinstantiate
promise image proxies. They now can use kSingleUse callback semantics.

This was the only usage of the kDeinstantiate lazy callback type so it is
removed. The DeinstantiateProxyTracker is also no longer required and is
removed.

The GrTexture idle callback mechanism now uses GrReleaseProcHelper, which has
been extended to support chaining multiple callbacks together and an abandon()
method that aborts calling the callback in the destructor. It has been renamed
GrRefCntedCallback to reflect its more general usage.

Bug: skia:8800
Change-Id: I857c9eec57fdf706631a266ec8bea682d6657a7c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/196500
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 542e785..4a7935f 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -57,9 +57,10 @@
      * will always be called before the texture is destroyed, even in unusual shutdown scenarios
      * (e.g. GrContext::abandonContext()).
      */
-    using IdleProc = void(void*);
-    virtual void setIdleProc(IdleProc, void* context) = 0;
-    virtual void* idleContext() const = 0;
+    virtual void addIdleProc(sk_sp<GrRefCntedCallback> callback) {
+        callback->addChild(std::move(fIdleCallback));
+        fIdleCallback = std::move(callback);
+    }
 
     /** Access methods that are only to be used within Skia code. */
     inline GrTexturePriv texturePriv();
@@ -70,7 +71,15 @@
 
     virtual bool onStealBackendTexture(GrBackendTexture*, SkImage::BackendTextureReleaseProc*) = 0;
 
+    sk_sp<GrRefCntedCallback> fIdleCallback;
+
+    void willRemoveLastRefOrPendingIO() override {
+        // We're about to be idle in the resource cache. Do our part to trigger the idle callback.
+        fIdleCallback.reset();
+    }
+
 private:
+
     void computeScratchKey(GrScratchKey*) const override;
     size_t onGpuMemorySize() const override;
     void markMipMapsDirty();