diff options
author | Brian Salomon <bsalomon@google.com> | 2017-12-11 10:06:31 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-11 17:54:38 +0000 |
commit | 3d6801eeee6b036de9f8d09e2ae8fa99df5a397c (patch) | |
tree | cbdcd23fe4924fbe25afae209d01bb6527244abf /tools/gpu | |
parent | d67e5189802e89e74217244b36cc7263883d5dba (diff) |
Add GrGLMakeNativeInterface factory that returns sk_sp<const GrGLInterface>.
Removes the concept of a configurable "default" interface and makes the default
always be the "native" interface.
Also removes unused functions: GrGLInterfaceAddTestDebugMarker and
GrGLInterface::NewClone.
Keeps around legacy GrGLCreateNativeInterface() until clients can be weened.
Change-Id: I4a3bdafa8cf8c68ed13318393abd55686b045ccb
Reviewed-on: https://skia-review.googlesource.com/83000
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'tools/gpu')
-rw-r--r-- | tools/gpu/gl/GLTestContext.cpp | 5 | ||||
-rw-r--r-- | tools/gpu/gl/GLTestContext.h | 2 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.h | 2 | ||||
-rw-r--r-- | tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp | 8 | ||||
-rw-r--r-- | tools/gpu/gl/debug/DebugGLTestContext.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm | 2 | ||||
-rw-r--r-- | tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/null/NullGLTestContext.cpp | 6 | ||||
-rw-r--r-- | tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp | 6 |
12 files changed, 30 insertions, 31 deletions
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp index 2c1d977b76..7a67a8a969 100644 --- a/tools/gpu/gl/GLTestContext.cpp +++ b/tools/gpu/gl/GLTestContext.cpp @@ -284,9 +284,8 @@ GLTestContext::~GLTestContext() { SkASSERT(nullptr == fGL.get()); } -void GLTestContext::init(const GrGLInterface* gl, std::unique_ptr<FenceSync> fenceSync) { - SkASSERT(!fGL.get()); - fGL.reset(gl); +void GLTestContext::init(sk_sp<const GrGLInterface> gl, std::unique_ptr<FenceSync> fenceSync) { + fGL = std::move(gl); fFenceSync = fenceSync ? std::move(fenceSync) : GLFenceSync::MakeIfSupported(this); fGpuTimer = GLGpuTimer::MakeIfSupported(this); } diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h index 02fe78e33e..cea630ac49 100644 --- a/tools/gpu/gl/GLTestContext.h +++ b/tools/gpu/gl/GLTestContext.h @@ -83,7 +83,7 @@ protected: /* * Methods that sublcasses must call from their constructors and destructors. */ - void init(const GrGLInterface *, std::unique_ptr<FenceSync> = nullptr); + void init(sk_sp<const GrGLInterface>, std::unique_ptr<FenceSync> = nullptr); void teardown() override; diff --git a/tools/gpu/gl/angle/GLTestContext_angle.cpp b/tools/gpu/gl/angle/GLTestContext_angle.cpp index 3b55c40bac..7de709feae 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.cpp +++ b/tools/gpu/gl/angle/GLTestContext_angle.cpp @@ -232,7 +232,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version, return; } - sk_sp<const GrGLInterface> gl(sk_gpu_test::CreateANGLEGLInterface()); + sk_sp<const GrGLInterface> gl = sk_gpu_test::CreateANGLEGLInterface(); if (nullptr == gl.get()) { SkDebugf("Could not create ANGLE GL interface!\n"); this->destroyGLContext(); @@ -262,7 +262,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version, } #endif - this->init(gl.release()); + this->init(std::move(gl)); } ANGLEGLContext::~ANGLEGLContext() { @@ -389,7 +389,7 @@ GrGLFuncPtr ANGLEGLContext::onPlatformGetProcAddress(const char* name) const { } // anonymous namespace namespace sk_gpu_test { -const GrGLInterface* CreateANGLEGLInterface() { +sk_sp<const GrGLInterface> CreateANGLEGLInterface() { static Libs gLibs = { nullptr, nullptr }; if (nullptr == gLibs.fGLLib) { diff --git a/tools/gpu/gl/angle/GLTestContext_angle.h b/tools/gpu/gl/angle/GLTestContext_angle.h index 5a72b93428..de7659a7a5 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.h +++ b/tools/gpu/gl/angle/GLTestContext_angle.h @@ -16,7 +16,7 @@ namespace sk_gpu_test { * Creates a GrGLInterface for the current ANGLE GLES Context. Here current means bound in ANGLE's * implementation of EGL. */ -const GrGLInterface* CreateANGLEGLInterface(); +sk_sp<const GrGLInterface> CreateANGLEGLInterface(); enum class ANGLEBackend { kD3D9, diff --git a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp index be2b6ad5e6..1924257be7 100644 --- a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp +++ b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp @@ -130,7 +130,7 @@ static void load_command_buffer_once() { once(load_command_buffer_functions); } -static const GrGLInterface* create_command_buffer_interface() { +static sk_sp<const GrGLInterface> create_command_buffer_interface() { load_command_buffer_once(); if (!gfFunctionsLoadedSuccessfully) { return nullptr; @@ -289,8 +289,8 @@ CommandBufferGLTestContext::CommandBufferGLTestContext(CommandBufferGLTestContex return; } - sk_sp<const GrGLInterface> gl(create_command_buffer_interface()); - if (nullptr == gl.get()) { + auto gl = create_command_buffer_interface(); + if (!gl) { SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n"); this->destroyGLContext(); return; @@ -301,7 +301,7 @@ CommandBufferGLTestContext::CommandBufferGLTestContext(CommandBufferGLTestContex return; } - this->init(gl.release()); + this->init(std::move(gl)); } CommandBufferGLTestContext::~CommandBufferGLTestContext() { diff --git a/tools/gpu/gl/debug/DebugGLTestContext.cpp b/tools/gpu/gl/debug/DebugGLTestContext.cpp index e28a3a7f13..4152997b4d 100644 --- a/tools/gpu/gl/debug/DebugGLTestContext.cpp +++ b/tools/gpu/gl/debug/DebugGLTestContext.cpp @@ -1195,11 +1195,9 @@ const char* DebugInterface::kExtensions[] = { class DebugGLContext : public sk_gpu_test::GLTestContext { public: - DebugGLContext() { - this->init(new DebugInterface()); - } + DebugGLContext() { this->init(sk_make_sp<DebugInterface>()); } - ~DebugGLContext() override { this->teardown(); } + ~DebugGLContext() override { this->teardown(); } private: void onPlatformMakeCurrent() const override {} diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp index 4a09d2202a..03a211d603 100644 --- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp +++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp @@ -186,8 +186,8 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext* continue; } - gl.reset(GrGLCreateNativeInterface()); - if (nullptr == gl.get()) { + gl = GrGLMakeNativeInterface(); + if (!gl) { SkDebugf("Failed to create gl interface.\n"); this->destroyGLContext(); continue; @@ -199,7 +199,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI, EGLGLTestContext* continue; } - this->init(gl.release(), EGLFenceSync::MakeIfSupported(fDisplay)); + this->init(std::move(gl), EGLFenceSync::MakeIfSupported(fDisplay)); break; } } diff --git a/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp b/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp index 066784df69..3df45bda17 100644 --- a/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp +++ b/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp @@ -239,8 +239,8 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext* return; } - sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface()); - if (nullptr == gl.get()) { + auto gl = GrGLMakeNativeInterface(); + if (!gl) { SkDebugf("Failed to create gl interface"); this->destroyGLContext(); return; @@ -252,7 +252,7 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext* return; } - this->init(gl.release()); + this->init(std::move(gl)); } diff --git a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm index 65d2861483..c62a330715 100644 --- a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm +++ b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm @@ -66,7 +66,7 @@ IOSGLTestContext::IOSGLTestContext(IOSGLTestContext* shareContext) "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib", RTLD_LAZY); - this->init(gl.release()); + this->init(std::move(gl)); } IOSGLTestContext::~IOSGLTestContext() { diff --git a/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp b/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp index 9f1c61e564..5b11227125 100644 --- a/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp +++ b/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp @@ -68,8 +68,8 @@ MacGLTestContext::MacGLTestContext(MacGLTestContext* shareContext) SkScopeExit restorer(context_restorer()); CGLSetCurrentContext(fContext); - sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface()); - if (nullptr == gl.get()) { + auto gl = GrGLMakeNativeInterface(); + if (!gl) { SkDebugf("Context could not create GL interface.\n"); this->destroyGLContext(); return; @@ -84,7 +84,7 @@ MacGLTestContext::MacGLTestContext(MacGLTestContext* shareContext) "/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib", RTLD_LAZY); - this->init(gl.release()); + this->init(std::move(gl)); } MacGLTestContext::~MacGLTestContext() { diff --git a/tools/gpu/gl/null/NullGLTestContext.cpp b/tools/gpu/gl/null/NullGLTestContext.cpp index 9e7279b501..de33a40e08 100644 --- a/tools/gpu/gl/null/NullGLTestContext.cpp +++ b/tools/gpu/gl/null/NullGLTestContext.cpp @@ -17,8 +17,10 @@ namespace { class NullGLContext : public sk_gpu_test::GLTestContext { public: - NullGLContext(bool enableNVPR) { this->init(GrGLCreateNullInterface(enableNVPR)); } - ~NullGLContext() override { this->teardown(); } + NullGLContext(bool enableNVPR) { + this->init(sk_sp<const GrGLInterface>(GrGLCreateNullInterface(enableNVPR))); + } + ~NullGLContext() override { this->teardown(); } private: void onPlatformMakeCurrent() const override {} diff --git a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp b/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp index 5fc355a22a..669d6d0182 100644 --- a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp +++ b/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp @@ -127,8 +127,8 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI, WinGLTestContext* return; } - sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface()); - if (nullptr == gl.get()) { + auto gl = GrGLMakeNativeInterface(); + if (!gl) { SkDebugf("Could not create GL interface.\n"); this->destroyGLContext(); return; @@ -139,7 +139,7 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI, WinGLTestContext* return; } - this->init(gl.release()); + this->init(std::move(gl)); } WinGLTestContext::~WinGLTestContext() { |