Move GrProxyProvider down to GrRecordingContext

Bug: skia:10286
Change-Id: I474cb0e4cbde3b576604e80891912104990b786c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/372118
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Adlai Holler <adlai@google.com>
diff --git a/include/gpu/GrRecordingContext.h b/include/gpu/GrRecordingContext.h
index 003111e..360ee14 100644
--- a/include/gpu/GrRecordingContext.h
+++ b/include/gpu/GrRecordingContext.h
@@ -19,6 +19,7 @@
 class GrMemoryPool;
 class GrProgramDesc;
 class GrProgramInfo;
+class GrProxyProvider;
 class GrRecordingContextPriv;
 class GrSurfaceContext;
 class GrSurfaceProxy;
@@ -144,6 +145,9 @@
     // match that of the DDL.
     OwnedArenas&& detachArenas();
 
+    GrProxyProvider* proxyProvider() { return fProxyProvider.get(); }
+    const GrProxyProvider* proxyProvider() const { return fProxyProvider.get(); }
+
     struct ProgramData {
         ProgramData(std::unique_ptr<const GrProgramDesc>, const GrProgramInfo*);
         ProgramData(ProgramData&&);                     // for SkTArray
@@ -234,6 +238,7 @@
     OwnedArenas                       fArenas;
 
     std::unique_ptr<GrDrawingManager> fDrawingManager;
+    std::unique_ptr<GrProxyProvider>  fProxyProvider;
 
 #if GR_TEST_UTILS
     int fSuppressWarningMessages = 0;
diff --git a/include/private/GrImageContext.h b/include/private/GrImageContext.h
index b87ebf7..f2abf9c 100644
--- a/include/private/GrImageContext.h
+++ b/include/private/GrImageContext.h
@@ -12,8 +12,8 @@
 #include "include/private/GrSingleOwner.h"
 
 class GrImageContextPriv;
-class GrProxyProvider;
 
+// CONTEXT TODO: Remove this once SkImage_Gpu is migrated to holding just a ThreadSafeProxy.
 class GrImageContext : public GrContext_Base {
 public:
     ~GrImageContext() override;
@@ -30,17 +30,12 @@
     SK_API virtual void abandonContext();
     SK_API virtual bool abandoned();
 
-    GrProxyProvider* proxyProvider() { return fProxyProvider.get(); }
-    const GrProxyProvider* proxyProvider() const { return fProxyProvider.get(); }
-
     /** This is only useful for debug purposes */
     GrSingleOwner* singleOwner() const { return &fSingleOwner; }
 
     GrImageContext* asImageContext() override { return this; }
 
 private:
-    std::unique_ptr<GrProxyProvider> fProxyProvider;
-
     // In debug builds we guard against improper thread handling
     // This guard is passed to the GrDrawingManager and, from there to all the
     // GrSurfaceDrawContexts.  It is also passed to the GrResourceProvider and SkGpuDevice.
diff --git a/src/gpu/GrDirectContextPriv.h b/src/gpu/GrDirectContextPriv.h
index 0c4dc15..6299549 100644
--- a/src/gpu/GrDirectContextPriv.h
+++ b/src/gpu/GrDirectContextPriv.h
@@ -43,7 +43,7 @@
     GrImageContext* asImageContext() { return fContext->asImageContext(); }
     GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
 
-    // from GrImageContext
+    // from GrRecordingContext
     GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
     const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
 
diff --git a/src/gpu/GrImageContext.cpp b/src/gpu/GrImageContext.cpp
index d2ceed8..c5c1abf 100644
--- a/src/gpu/GrImageContext.cpp
+++ b/src/gpu/GrImageContext.cpp
@@ -18,7 +18,6 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 GrImageContext::GrImageContext(sk_sp<GrContextThreadSafeProxy> proxy)
             : INHERITED(std::move(proxy)) {
-    fProxyProvider = std::make_unique<GrProxyProvider>(this);
 }
 
 GrImageContext::~GrImageContext() {}
diff --git a/src/gpu/GrImageContextPriv.h b/src/gpu/GrImageContextPriv.h
index b2a902b..f681003 100644
--- a/src/gpu/GrImageContextPriv.h
+++ b/src/gpu/GrImageContextPriv.h
@@ -28,10 +28,6 @@
     GrImageContext* asImageContext() { return fContext->asImageContext(); }
     GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
 
-    // from GrImageContext
-    GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
-    const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
-
     bool abandoned() const { return fContext->abandoned(); }
 
     /** This is only useful for debug purposes */
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index bd21b49..09e0dac 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -39,6 +39,7 @@
 GrRecordingContext::GrRecordingContext(sk_sp<GrContextThreadSafeProxy> proxy)
         : INHERITED(std::move(proxy))
         , fAuditTrail(new GrAuditTrail()) {
+    fProxyProvider = std::make_unique<GrProxyProvider>(this);
 }
 
 GrRecordingContext::~GrRecordingContext() = default;
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index f7fc8a9..5da75f7 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -31,7 +31,7 @@
     GrImageContext* asImageContext() { return fContext->asImageContext(); }
     GrRecordingContext* asRecordingContext() { return fContext->asRecordingContext(); }
 
-    // from GrImageContext
+    // from GrRecordingContext
     GrProxyProvider* proxyProvider() { return fContext->proxyProvider(); }
     const GrProxyProvider* proxyProvider() const { return fContext->proxyProvider(); }
 
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1558471..da7df04 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -423,7 +423,6 @@
     }
     GrSwizzle swizzle = context->priv().caps()->getReadSwizzle(backendFormat, grColorType);
     GrSurfaceProxyView view(std::move(proxy), origin, swizzle);
-    // CONTEXT TODO: rm this usage of the 'backdoor' to create an image
     return sk_make_sp<SkImage_Gpu>(sk_ref_sp(context), kNeedNewImageUniqueID,
                                    std::move(view), colorType, alphaType, std::move(colorSpace));
 }