diff options
author | Brian Salomon <bsalomon@google.com> | 2018-03-23 16:10:36 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-03-23 21:12:50 +0000 |
commit | 032aaae5be51e92ec9677d6c511241b19a7cb70d (patch) | |
tree | 8fe817c2a16ff23bcb18dfda5a70cec1cc9524de | |
parent | a6a3df7d64dc81082619ab103450fc6d0af7c644 (diff) |
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>
-rw-r--r-- | bench/nanobench.cpp | 15 | ||||
-rw-r--r-- | gn/gpu.gni | 2 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 3 | ||||
-rw-r--r-- | include/gpu/GrTypes.h | 8 | ||||
-rw-r--r-- | src/gpu/GrDirectContext.cpp | 23 | ||||
-rw-r--r-- | src/gpu/GrGpu.h | 9 | ||||
-rw-r--r-- | src/gpu/GrGpuFactory.cpp | 32 | ||||
-rw-r--r-- | src/gpu/GrGpuFactory.h | 24 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 6 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 1 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.cpp | 5 | ||||
-rw-r--r-- | src/gpu/mock/GrMockGpu.h | 1 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 6 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.h | 2 | ||||
-rw-r--r-- | tools/gpu/TestContext.h | 1 | ||||
-rw-r--r-- | tools/gpu/gl/GLTestContext.h | 3 | ||||
-rw-r--r-- | tools/gpu/mock/MockTestContext.cpp | 4 | ||||
-rw-r--r-- | tools/gpu/mtl/MtlTestContext.mm | 2 | ||||
-rw-r--r-- | tools/gpu/vk/VkTestContext.h | 3 | ||||
-rw-r--r-- | tools/sk_app/GLWindowContext.h | 4 | ||||
-rw-r--r-- | tools/sk_app/RasterWindowContext.h | 3 | ||||
-rw-r--r-- | tools/sk_app/VulkanWindowContext.h | 4 | ||||
-rw-r--r-- | tools/sk_app/WindowContext.h | 1 |
23 files changed, 11 insertions, 151 deletions
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp index c097a4d14e..99bea4f60f 100644 --- a/bench/nanobench.cpp +++ b/bench/nanobench.cpp @@ -58,18 +58,22 @@ extern bool gSkForceRasterPipelineBlitter; #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 @@ struct GPUTarget : public Target { 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 31396d4f77..eebe679a0d 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -101,8 +101,6 @@ skia_gpu_sources = [ "$_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 eccad0465a..8200dd4da8 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -57,9 +57,6 @@ public: /** * 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 e21bb2c13a..7eb5848558 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -195,14 +195,6 @@ enum GrBackend { 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 7302c90d5a..204d676686 100644 --- a/src/gpu/GrDirectContext.cpp +++ b/src/gpu/GrDirectContext.cpp @@ -95,29 +95,6 @@ private: 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 78b6fd4654..87d93ac4e4 100644 --- a/src/gpu/GrGpu.h +++ b/src/gpu/GrGpu.h @@ -44,15 +44,6 @@ class SkJSONWriter; 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 eb3c2928b6..0000000000 --- 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 aecc2c1705..0000000000 --- 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 c6e2d2537f..08bca6dcc8 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -175,12 +175,6 @@ bool GrGLGpu::BlendCoeffReferencesConstant(GrBlendCoeff coeff) { /////////////////////////////////////////////////////////////////////////////// -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 9a03d97126..4858963271 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -34,7 +34,6 @@ class GrSwizzle; 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 4b786ab9b2..a677d63bba 100644 --- a/src/gpu/mock/GrMockGpu.cpp +++ b/src/gpu/mock/GrMockGpu.cpp @@ -38,11 +38,6 @@ int GrMockGpu::NextExternalRenderTargetID() { 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 5065350746..73e6a4bfc5 100644 --- a/src/gpu/mock/GrMockGpu.h +++ b/src/gpu/mock/GrMockGpu.h @@ -20,7 +20,6 @@ class GrPipeline; 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 b59d85e0bb..af9505821a 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -73,12 +73,6 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback( } #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 20df339627..7bdfbeaab3 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 @@ namespace SkSL { 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 5b512db7ba..2949cc709e 100644 --- a/tools/gpu/TestContext.h +++ b/tools/gpu/TestContext.h @@ -59,7 +59,6 @@ public: 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 cea630ac49..f5a05932a2 100644 --- a/tools/gpu/gl/GLTestContext.h +++ b/tools/gpu/gl/GLTestContext.h @@ -21,9 +21,6 @@ public: ~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 5cc5529dfe..6075bc83c2 100644 --- a/tools/gpu/mock/MockTestContext.cpp +++ b/tools/gpu/mock/MockTestContext.cpp @@ -20,9 +20,7 @@ public: ~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 38755b2ef0..cdc0f8f168 100644 --- a/tools/gpu/mtl/MtlTestContext.mm +++ b/tools/gpu/mtl/MtlTestContext.mm @@ -122,8 +122,6 @@ public: 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 5090f556b4..9fd4170d9d 100644 --- a/tools/gpu/vk/VkTestContext.h +++ b/tools/gpu/vk/VkTestContext.h @@ -18,9 +18,6 @@ namespace sk_gpu_test { 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 44810c93d2..68fd1eb709 100644 --- a/tools/sk_app/GLWindowContext.h +++ b/tools/sk_app/GLWindowContext.h @@ -31,10 +31,6 @@ public: 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 75bde03ad7..db8600acd5 100644 --- a/tools/sk_app/RasterWindowContext.h +++ b/tools/sk_app/RasterWindowContext.h @@ -16,9 +16,6 @@ class RasterWindowContext : public WindowContext { 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 df6ef33959..1fca9dc83e 100644 --- a/tools/sk_app/VulkanWindowContext.h +++ b/tools/sk_app/VulkanWindowContext.h @@ -38,10 +38,6 @@ public: 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 71c21ac089..9a12f2c04b 100644 --- a/tools/sk_app/WindowContext.h +++ b/tools/sk_app/WindowContext.h @@ -45,7 +45,6 @@ public: fSurfaceProps = props; } - virtual GrBackendContext getBackendContext() = 0; GrContext* getGrContext() const { return fContext.get(); } int width() const { return fWidth; } |