Remove legacy GrContext factories function and supporting code/types.

Change-Id: I437a4a0a58bf70ea1b8b0659b099a2af2bfa64fe
Reviewed-on: https://skia-review.googlesource.com/116197
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index c097a4d..99bea4f 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -58,18 +58,22 @@
 
 #ifndef SK_BUILD_FOR_WIN
     #include <unistd.h>
+
 #endif
 
 #if SK_SUPPORT_GPU
-    #include "gl/GrGLDefines.h"
     #include "GrCaps.h"
-    #include "GrContextPriv.h"
     #include "GrContextFactory.h"
-    #include "gl/GrGLUtil.h"
+    #include "GrContextPriv.h"
     #include "SkGr.h"
+    #include "gl/GrGLDefines.h"
+    #include "gl/GrGLGpu.h"
+    #include "gl/GrGLUtil.h"
+
     using sk_gpu_test::ContextInfo;
     using sk_gpu_test::GrContextFactory;
     using sk_gpu_test::TestContext;
+
     GrContextOptions grContextOpts;
 #endif
 
@@ -217,8 +221,9 @@
     void fillOptions(ResultsWriter* log) override {
         const GrGLubyte* version;
         if (this->contextInfo.backend() == kOpenGL_GrBackend) {
-            const GrGLInterface* gl = reinterpret_cast<const GrGLInterface*>(
-                    this->contextInfo.testContext()->backendContext());
+            const GrGLInterface* gl =
+                    static_cast<GrGLGpu*>(this->contextInfo.grContext()->contextPriv().getGpu())
+                            ->glInterface();
             GR_GL_CALL_RET(gl, version, GetString(GR_GL_VERSION));
             log->configOption("GL_VERSION", (const char*)(version));
 
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 31396d4..eebe679 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -101,8 +101,6 @@
   "$_src/gpu/GrGpuResource.cpp",
   "$_src/gpu/GrGpuResourceRef.cpp",
   "$_src/gpu/GrGpuResourceRef.h",
-  "$_src/gpu/GrGpuFactory.cpp",
-  "$_src/gpu/GrGpuFactory.h",
   "$_src/gpu/GrImageTextureMaker.cpp",
   "$_src/gpu/GrImageTextureMaker.h",
   "$_src/gpu/GrMemoryPool.cpp",
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index eccad04..8200dd4 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -57,9 +57,6 @@
     /**
      * Creates a GrContext for a backend context.
      */
-    static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions& options);
-    static GrContext* Create(GrBackend, GrBackendContext);
-
     static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>, const GrContextOptions&);
     static sk_sp<GrContext> MakeGL(sk_sp<const GrGLInterface>);
     // Deprecated
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index e21bb2c..7eb5848 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -195,14 +195,6 @@
     kMock_GrBackend,
 };
 
-/**
- * Backend-specific 3D context handle
- *      OpenGL: const GrGLInterface*. If null will use the result of GrGLMakeNativeInterface().
- *      Vulkan: GrVkBackendContext*.
- *      Mock: const GrMockOptions* or null for default constructed GrMockContextOptions.
- */
-typedef intptr_t GrBackendContext;
-
 ///////////////////////////////////////////////////////////////////////////////
 
 /**
diff --git a/src/gpu/GrDirectContext.cpp b/src/gpu/GrDirectContext.cpp
index 7302c90..204d676 100644
--- a/src/gpu/GrDirectContext.cpp
+++ b/src/gpu/GrDirectContext.cpp
@@ -95,29 +95,6 @@
     typedef GrContext INHERITED;
 };
 
-GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
-    GrContextOptions defaultOptions;
-    return Create(backend, backendContext, defaultOptions);
-}
-
-GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
-                             const GrContextOptions& options) {
-
-    sk_sp<GrContext> context(new GrDirectContext(backend));
-
-    context->fGpu = GrGpu::Make(backend, backendContext, options, context.get());
-    if (!context->fGpu) {
-        return nullptr;
-    }
-
-    context->fCaps = context->fGpu->refCaps();
-    if (!context->init(options)) {
-        return nullptr;
-    }
-
-    return context.release();
-}
-
 sk_sp<GrContext> GrContext::MakeGL(sk_sp<const GrGLInterface> interface) {
     GrContextOptions defaultOptions;
     return MakeGL(std::move(interface), defaultOptions);
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 78b6fd4..87d93ac 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -44,15 +44,6 @@
 
 class GrGpu : public SkRefCnt {
 public:
-    /**
-     * Create an instance of GrGpu that matches the specified backend. If the requested backend is
-     * not supported (at compile-time or run-time) this returns nullptr. The context will not be
-     * fully constructed and should not be used by GrGpu until after this function returns.
-     */
-    static sk_sp<GrGpu> Make(GrBackend, GrBackendContext, const GrContextOptions&, GrContext*);
-
-    ////////////////////////////////////////////////////////////////////////////
-
     GrGpu(GrContext* context);
     ~GrGpu() override;
 
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
deleted file mode 100644
index eb3c292..0000000
--- a/src/gpu/GrGpuFactory.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#include "GrGpuFactory.h"
-#include "gl/GrGLGpu.h"
-#include "mock/GrMockGpu.h"
-#ifdef SK_VULKAN
-#include "vk/GrVkGpu.h"
-#endif
-
-sk_sp<GrGpu> GrGpu::Make(GrBackend backend,
-                         GrBackendContext backendContext,
-                         const GrContextOptions& options,
-                         GrContext* context) {
-    switch (backend) {
-        case kOpenGL_GrBackend:
-            return GrGLGpu::Make(backendContext, options, context);
-#ifdef SK_VULKAN
-        case kVulkan_GrBackend:
-            return GrVkGpu::Make(backendContext, options, context);
-#endif
-        case kMock_GrBackend:
-            return GrMockGpu::Make(backendContext, options, context);
-        default:
-            return nullptr;
-    }
-}
diff --git a/src/gpu/GrGpuFactory.h b/src/gpu/GrGpuFactory.h
deleted file mode 100644
index aecc2c1..0000000
--- a/src/gpu/GrGpuFactory.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright 2015 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef GrGpuFactory_DEFINED
-#define GrGpuFactory_DEFINED
-
-#include "GrTypes.h"
-
-class GrGpu;
-class GrContext;
-struct GrContextOptions;
-
-typedef GrGpu* (*CreateGpuProc)(GrBackendContext, const GrContextOptions& options, GrContext*);
-
-class GrGpuFactoryRegistrar {
-public:
-    GrGpuFactoryRegistrar(int i, CreateGpuProc proc);
-};
-
-#endif
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index c6e2d25..08bca6d 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -175,12 +175,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-sk_sp<GrGpu> GrGLGpu::Make(GrBackendContext backendContext, const GrContextOptions& options,
-                           GrContext* context) {
-    const auto* interface = reinterpret_cast<const GrGLInterface*>(backendContext);
-    return Make(sk_ref_sp(interface), options, context);
-}
-
 sk_sp<GrGpu> GrGLGpu::Make(sk_sp<const GrGLInterface> interface, const GrContextOptions& options,
                            GrContext* context) {
     if (!interface) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 9a03d97..4858963 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -34,7 +34,6 @@
 
 class GrGLGpu final : public GrGpu, private GrMesh::SendToGpuImpl {
 public:
-    static sk_sp<GrGpu> Make(GrBackendContext backendContext, const GrContextOptions&, GrContext*);
     static sk_sp<GrGpu> Make(sk_sp<const GrGLInterface>, const GrContextOptions&, GrContext*);
     ~GrGLGpu() override;
 
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index 4b786ab..a677d63 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -38,11 +38,6 @@
     return sk_atomic_inc(&gID);
 }
 
-sk_sp<GrGpu> GrMockGpu::Make(GrBackendContext backendContext,
-                             const GrContextOptions& contextOptions, GrContext* context) {
-    return Make(reinterpret_cast<const GrMockOptions*>(backendContext), contextOptions, context);
-}
-
 sk_sp<GrGpu> GrMockGpu::Make(const GrMockOptions* mockOptions,
                              const GrContextOptions& contextOptions, GrContext* context) {
     static const GrMockOptions kDefaultOptions = GrMockOptions();
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 5065350..73e6a4b 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -20,7 +20,6 @@
 
 class GrMockGpu : public GrGpu {
 public:
-    static sk_sp<GrGpu> Make(GrBackendContext, const GrContextOptions&, GrContext*);
     static sk_sp<GrGpu> Make(const GrMockOptions*, const GrContextOptions&, GrContext*);
 
     ~GrMockGpu() override {}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index b59d85e..af95058 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -73,12 +73,6 @@
 }
 #endif
 
-sk_sp<GrGpu> GrVkGpu::Make(GrBackendContext backendContext, const GrContextOptions& options,
-                           GrContext* context) {
-    const auto* backend = reinterpret_cast<const GrVkBackendContext*>(backendContext);
-    return Make(sk_ref_sp(backend), options, context);
-}
-
 sk_sp<GrGpu> GrVkGpu::Make(sk_sp<const GrVkBackendContext> backendContext,
                            const GrContextOptions& options, GrContext* context) {
     if (!backendContext) {
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 20df339..7bdfbea 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -9,7 +9,6 @@
 #define GrVkGpu_DEFINED
 
 #include "GrGpu.h"
-#include "GrGpuFactory.h"
 #include "vk/GrVkBackendContext.h"
 #include "GrVkCaps.h"
 #include "GrVkCopyManager.h"
@@ -38,7 +37,6 @@
 
 class GrVkGpu : public GrGpu {
 public:
-    static sk_sp<GrGpu> Make(GrBackendContext backendContext, const GrContextOptions&, GrContext*);
     static sk_sp<GrGpu> Make(sk_sp<const GrVkBackendContext>, const GrContextOptions&, GrContext*);
 
     ~GrVkGpu() override;
diff --git a/tools/gpu/TestContext.h b/tools/gpu/TestContext.h
index 5b512db..2949cc7 100644
--- a/tools/gpu/TestContext.h
+++ b/tools/gpu/TestContext.h
@@ -59,7 +59,6 @@
     SkScopeExit SK_WARN_UNUSED_RESULT makeCurrentAndAutoRestore() const;
 
     virtual GrBackend backend() = 0;
-    virtual GrBackendContext backendContext() = 0;
 
     virtual sk_sp<GrContext> makeGrContext(const GrContextOptions&);
 
diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h
index cea630a..f5a0593 100644
--- a/tools/gpu/gl/GLTestContext.h
+++ b/tools/gpu/gl/GLTestContext.h
@@ -21,9 +21,6 @@
     ~GLTestContext() override;
 
     virtual GrBackend backend() override { return kOpenGL_GrBackend; }
-    virtual GrBackendContext backendContext() override {
-        return reinterpret_cast<GrBackendContext>(fGL.get());
-    }
 
     bool isValid() const { return SkToBool(this->gl()); }
 
diff --git a/tools/gpu/mock/MockTestContext.cpp b/tools/gpu/mock/MockTestContext.cpp
index 5cc5529..6075bc8 100644
--- a/tools/gpu/mock/MockTestContext.cpp
+++ b/tools/gpu/mock/MockTestContext.cpp
@@ -20,9 +20,7 @@
     ~MockTestContext() override {}
 
     virtual GrBackend backend() override { return kMock_GrBackend; }
-    virtual GrBackendContext backendContext() override {
-        return reinterpret_cast<GrBackendContext>(nullptr);
-    }
+
     void testAbandon() override {}
     void submit() override {}
     void finish() override {}
diff --git a/tools/gpu/mtl/MtlTestContext.mm b/tools/gpu/mtl/MtlTestContext.mm
index 38755b2..cdc0f8f 100644
--- a/tools/gpu/mtl/MtlTestContext.mm
+++ b/tools/gpu/mtl/MtlTestContext.mm
@@ -122,8 +122,6 @@
 
     GrBackend backend() override { return kMetal_GrBackend; }
 
-    GrBackendContext backendContext() override { return 0; }
-
     void testAbandon() override {}
 
     // There is really nothing to here since we don't own any unqueued command buffers here.
diff --git a/tools/gpu/vk/VkTestContext.h b/tools/gpu/vk/VkTestContext.h
index 5090f55..9fd4170 100644
--- a/tools/gpu/vk/VkTestContext.h
+++ b/tools/gpu/vk/VkTestContext.h
@@ -18,9 +18,6 @@
 class VkTestContext : public TestContext {
 public:
     virtual GrBackend backend() override { return kVulkan_GrBackend; }
-    virtual GrBackendContext backendContext() override {
-        return reinterpret_cast<GrBackendContext>(fVk.get());
-    }
 
     sk_sp<const GrVkBackendContext> getVkBackendContext() {
         return fVk;
diff --git a/tools/sk_app/GLWindowContext.h b/tools/sk_app/GLWindowContext.h
index 44810c9..68fd1eb 100644
--- a/tools/sk_app/GLWindowContext.h
+++ b/tools/sk_app/GLWindowContext.h
@@ -31,10 +31,6 @@
 
     void setDisplayParams(const DisplayParams& params) override;
 
-    GrBackendContext getBackendContext() override {
-        return (GrBackendContext) fBackendContext.get();
-    }
-
 protected:
     GLWindowContext(const DisplayParams&);
     // This should be called by subclass constructor. It is also called when window/display
diff --git a/tools/sk_app/RasterWindowContext.h b/tools/sk_app/RasterWindowContext.h
index 75bde03..db8600a 100644
--- a/tools/sk_app/RasterWindowContext.h
+++ b/tools/sk_app/RasterWindowContext.h
@@ -16,9 +16,6 @@
 public:
     RasterWindowContext(const DisplayParams& params) : WindowContext(params) {}
 
-    // Explicitly convert nullptr to GrBackendContext is needed for compiling
-    GrBackendContext getBackendContext() override { return (GrBackendContext) nullptr; }
-
 protected:
     bool isGpuContext() override { return false; }
 };
diff --git a/tools/sk_app/VulkanWindowContext.h b/tools/sk_app/VulkanWindowContext.h
index df6ef33..1fca9dc 100644
--- a/tools/sk_app/VulkanWindowContext.h
+++ b/tools/sk_app/VulkanWindowContext.h
@@ -38,10 +38,6 @@
         this->initializeContext();
     }
 
-    GrBackendContext getBackendContext() override {
-        return (GrBackendContext) fBackendContext.get();
-    }
-
     /** Platform specific function that creates a VkSurfaceKHR for a window */
     using CreateVkSurfaceFn = std::function<VkSurfaceKHR(VkInstance)>;
     /** Platform specific function that determines whether presentation will succeed. */
diff --git a/tools/sk_app/WindowContext.h b/tools/sk_app/WindowContext.h
index 71c21ac..9a12f2c 100644
--- a/tools/sk_app/WindowContext.h
+++ b/tools/sk_app/WindowContext.h
@@ -45,7 +45,6 @@
         fSurfaceProps = props;
     }
 
-    virtual GrBackendContext getBackendContext() = 0;
     GrContext* getGrContext() const { return fContext.get(); }
 
     int width() const { return fWidth; }