Split GrContextThreadSafeProxy into its own files (take 2)

This just shuffles stuff around.

Change-Id: I90e24a73bf44dd3e88fc121a0528bf94e4fdead4
Reviewed-on: https://skia-review.googlesource.com/c/187786
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index d122a4d..657b7da 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -169,76 +169,6 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
-GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID,
-                                                   GrBackendApi backend,
-                                                   const GrContextOptions& options,
-                                                   sk_sp<GrSkSLFPFactoryCache> cache)
-        : fCaps(std::move(caps))
-        , fContextUniqueID(uniqueID)
-        , fBackend(backend)
-        , fOptions(options)
-        , fFPFactoryCache(std::move(cache)) {}
-
-GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
-
-sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() {
-    return fThreadSafeProxy;
-}
-
-SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
-                                     size_t cacheMaxResourceBytes,
-                                     const SkImageInfo& ii, const GrBackendFormat& backendFormat,
-                                     int sampleCnt, GrSurfaceOrigin origin,
-                                     const SkSurfaceProps& surfaceProps,
-                                     bool isMipMapped, bool willUseGLFBO0) {
-    if (!backendFormat.isValid()) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) {
-        // The willUseGLFBO0 flags can only be used for a GL backend.
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    if (!fCaps->mipMapSupport()) {
-        isMipMapped = false;
-    }
-
-    GrPixelConfig config = fCaps->getConfigFromBackendFormat(backendFormat, ii.colorType());
-    if (config == kUnknown_GrPixelConfig) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    if (!SkSurface_Gpu::Valid(fCaps.get(), config, ii.colorSpace())) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, config);
-    if (!sampleCnt) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    GrFSAAType FSAAType = GrFSAAType::kNone;
-    if (sampleCnt > 1) {
-        FSAAType = fCaps->usesMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA;
-    }
-
-    // This surface characterization factory assumes that the resulting characterization is
-    // textureable.
-    if (!fCaps->isConfigTexturable(config)) {
-        return SkSurfaceCharacterization(); // return an invalid characterization
-    }
-
-    return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this),
-                                     cacheMaxResourceBytes, ii,
-                                     origin, config, FSAAType, sampleCnt,
-                                     SkSurfaceCharacterization::Textureable(true),
-                                     SkSurfaceCharacterization::MipMapped(isMipMapped),
-                                     SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0),
-                                     SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
-                                     surfaceProps);
-}
-
 void GrContext::abandonContext() {
     ASSERT_SINGLE_OWNER
 
@@ -1140,6 +1070,8 @@
     return renderTargetContext;
 }
 
+sk_sp<GrSkSLFPFactoryCache> GrContextPriv::getFPFactoryCache() { return fContext->fFPFactoryCache; }
+
 std::unique_ptr<GrFragmentProcessor> GrContext::createPMToUPMEffect(
         std::unique_ptr<GrFragmentProcessor> fp) {
     ASSERT_SINGLE_OWNER
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 468a599..24309ec 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -279,9 +279,7 @@
 
     GrContextOptions::PersistentCache* getPersistentCache() { return fContext->fPersistentCache; }
 
-    sk_sp<GrSkSLFPFactoryCache> getFPFactoryCache() {
-        return fContext->fFPFactoryCache;
-    }
+    sk_sp<GrSkSLFPFactoryCache> getFPFactoryCache();
 
     /** This is only useful for debug purposes */
     SkDEBUGCODE(GrSingleOwner* debugSingleOwner() const { return &fContext->fSingleOwner; } )
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
new file mode 100644
index 0000000..cfa4b33
--- /dev/null
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "GrContextThreadSafeProxy.h"
+#include "GrContextThreadSafeProxyPriv.h"
+
+#include "GrCaps.h"
+#include "GrContext.h"
+#include "GrSkSLFPFactoryCache.h"
+#include "SkSurface_Gpu.h"
+#include "SkSurfaceCharacterization.h"
+
+GrContextThreadSafeProxy::GrContextThreadSafeProxy(sk_sp<const GrCaps> caps, uint32_t uniqueID,
+                                                   GrBackendApi backend,
+                                                   const GrContextOptions& options,
+                                                   sk_sp<GrSkSLFPFactoryCache> cache)
+        : fCaps(std::move(caps))
+        , fContextUniqueID(uniqueID)
+        , fBackend(backend)
+        , fOptions(options)
+        , fFPFactoryCache(std::move(cache)) {}
+
+GrContextThreadSafeProxy::~GrContextThreadSafeProxy() = default;
+
+sk_sp<GrContextThreadSafeProxy> GrContext::threadSafeProxy() {
+    return fThreadSafeProxy;
+}
+
+bool GrContextThreadSafeProxy::matches(GrContext* context) const {
+    return context->uniqueID() == fContextUniqueID;
+}
+
+SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
+                                     size_t cacheMaxResourceBytes,
+                                     const SkImageInfo& ii, const GrBackendFormat& backendFormat,
+                                     int sampleCnt, GrSurfaceOrigin origin,
+                                     const SkSurfaceProps& surfaceProps,
+                                     bool isMipMapped, bool willUseGLFBO0) {
+    if (!backendFormat.isValid()) {
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    if (GrBackendApi::kOpenGL != backendFormat.backend() && willUseGLFBO0) {
+        // The willUseGLFBO0 flags can only be used for a GL backend.
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    if (!fCaps->mipMapSupport()) {
+        isMipMapped = false;
+    }
+
+    GrPixelConfig config = fCaps->getConfigFromBackendFormat(backendFormat, ii.colorType());
+    if (config == kUnknown_GrPixelConfig) {
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    if (!SkSurface_Gpu::Valid(fCaps.get(), config, ii.colorSpace())) {
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    sampleCnt = fCaps->getRenderTargetSampleCount(sampleCnt, config);
+    if (!sampleCnt) {
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    GrFSAAType FSAAType = GrFSAAType::kNone;
+    if (sampleCnt > 1) {
+        FSAAType = fCaps->usesMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA;
+    }
+
+    // This surface characterization factory assumes that the resulting characterization is
+    // textureable.
+    if (!fCaps->isConfigTexturable(config)) {
+        return SkSurfaceCharacterization(); // return an invalid characterization
+    }
+
+    return SkSurfaceCharacterization(sk_ref_sp<GrContextThreadSafeProxy>(this),
+                                     cacheMaxResourceBytes, ii,
+                                     origin, config, FSAAType, sampleCnt,
+                                     SkSurfaceCharacterization::Textureable(true),
+                                     SkSurfaceCharacterization::MipMapped(isMipMapped),
+                                     SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0),
+                                     SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
+                                     surfaceProps);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+sk_sp<GrSkSLFPFactoryCache> GrContextThreadSafeProxyPriv::fpFactoryCache() const {
+    return fProxy->fFPFactoryCache;
+}
diff --git a/src/gpu/GrContextThreadSafeProxyPriv.h b/src/gpu/GrContextThreadSafeProxyPriv.h
index 1d251e4..298ad78 100644
--- a/src/gpu/GrContextThreadSafeProxyPriv.h
+++ b/src/gpu/GrContextThreadSafeProxyPriv.h
@@ -8,7 +8,7 @@
 #ifndef GrContextThreadSafeProxyPriv_DEFINED
 #define GrContextThreadSafeProxyPriv_DEFINED
 
-#include "GrContext.h"
+#include "GrContextThreadSafeProxy.h"
 
 /**
  * Class that adds methods to GrContextThreadSafeProxy that are only intended for use internal to
@@ -23,7 +23,7 @@
     sk_sp<const GrCaps> refCaps() const { return fProxy->fCaps; }
     uint32_t contextUniqueID() const { return fProxy->fContextUniqueID; }
     GrBackendApi backend() const { return fProxy->fBackend; }
-    sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const { return fProxy->fFPFactoryCache; }
+    sk_sp<GrSkSLFPFactoryCache> fpFactoryCache() const;
 
 private:
     explicit GrContextThreadSafeProxyPriv(GrContextThreadSafeProxy* proxy) : fProxy(proxy) {}
diff --git a/src/gpu/GrDDLContext.cpp b/src/gpu/GrDDLContext.cpp
index eb5ed29..5461bd9 100644
--- a/src/gpu/GrDDLContext.cpp
+++ b/src/gpu/GrDDLContext.cpp
@@ -9,6 +9,7 @@
 #include "GrCaps.h"
 #include "GrContextPriv.h"
 #include "GrContextThreadSafeProxyPriv.h"
+#include "GrSkSLFPFactoryCache.h"
 
 /**
  * The DDL Context is the one in effect during DDL Recording. It isn't backed by a GrGPU and
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index c46d84e..9e6075c 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -9,6 +9,7 @@
 #include "GrContext.h"
 
 #include "GrContextPriv.h"
+#include "GrContextThreadSafeProxy.h"
 #include "GrGpu.h"
 
 #include "effects/GrSkSLFP.h"
diff --git a/src/image/SkImage_GpuBase.h b/src/image/SkImage_GpuBase.h
index 37d3b22..cd7b906 100644
--- a/src/image/SkImage_GpuBase.h
+++ b/src/image/SkImage_GpuBase.h
@@ -9,12 +9,12 @@
 #define SkImage_GpuBase_DEFINED
 
 #include "GrBackendSurface.h"
+#include "GrContext.h"
 #include "GrTypesPriv.h"
 #include "SkDeferredDisplayListRecorder.h"
 #include "SkImage_Base.h"
 #include "SkYUVAIndex.h"
 
-class GrContext;
 class SkColorSpace;
 
 class SkImage_GpuBase : public SkImage_Base {