diff options
author | 2016-11-03 14:40:50 -0400 | |
---|---|---|
committer | 2016-11-03 19:03:40 +0000 | |
commit | 145dbcd165d9d27298eb8888bc240e2d06a95464 (patch) | |
tree | 461ac2a3fe607bdf1d72fd72ae9451a58490a1bc /tools/gpu/gl | |
parent | b1c7f88df9ec40b4efb52d314304adfbaf95697c (diff) |
Remove SkAutoTDelete.
Replace with std::unique_ptr.
Change-Id: I5806cfbb30515fcb20e5e66ce13fb5f3b8728176
Reviewed-on: https://skia-review.googlesource.com/4381
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tools/gpu/gl')
-rw-r--r-- | tools/gpu/gl/GLTestContext.cpp | 28 | ||||
-rw-r--r-- | tools/gpu/gl/GLTestContext.h | 4 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.cpp | 15 | ||||
-rw-r--r-- | tools/gpu/gl/angle/GLTestContext_angle.h | 2 | ||||
-rw-r--r-- | tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp | 14 |
5 files changed, 34 insertions, 29 deletions
diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp index 20a9908381..e6d0e40db8 100644 --- a/tools/gpu/gl/GLTestContext.cpp +++ b/tools/gpu/gl/GLTestContext.cpp @@ -14,7 +14,7 @@ namespace { class GLFenceSync : public sk_gpu_test::FenceSync { public: - static GLFenceSync* CreateIfSupported(const sk_gpu_test::GLTestContext*); + static std::unique_ptr<GLFenceSync> MakeIfSupported(const sk_gpu_test::GLTestContext*); sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override; bool waitFence(sk_gpu_test::PlatformFence fence) const override; @@ -43,8 +43,8 @@ private: typedef FenceSync INHERITED; }; -GLFenceSync* GLFenceSync::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) { - SkAutoTDelete<GLFenceSync> ret; +std::unique_ptr<GLFenceSync> GLFenceSync::MakeIfSupported(const sk_gpu_test::GLTestContext* ctx) { + std::unique_ptr<GLFenceSync> ret; if (kGL_GrGLStandard == ctx->gl()->fStandard) { if (GrGLGetVersion(ctx->gl()) < GR_GL_VER(3,2) && !ctx->gl()->hasExtension("GL_ARB_sync")) { return nullptr; @@ -56,7 +56,10 @@ GLFenceSync* GLFenceSync::CreateIfSupported(const sk_gpu_test::GLTestContext* ct } ret.reset(new GLFenceSync(ctx, "APPLE")); } - return ret->validate() ? ret.release() : nullptr; + if (!ret->validate()) { + ret = nullptr; + } + return ret; } GLFenceSync::GLFenceSync(const sk_gpu_test::GLTestContext* ctx, const char* ext) { @@ -82,7 +85,7 @@ void GLFenceSync::deleteFence(sk_gpu_test::PlatformFence fence) const { class GLGpuTimer : public sk_gpu_test::GpuTimer { public: - static GLGpuTimer* CreateIfSupported(const sk_gpu_test::GLTestContext*); + static std::unique_ptr<GLGpuTimer> MakeIfSupported(const sk_gpu_test::GLTestContext*); QueryStatus checkQueryStatus(sk_gpu_test::PlatformTimerQuery) override; std::chrono::nanoseconds getTimeElapsed(sk_gpu_test::PlatformTimerQuery) override; @@ -121,8 +124,8 @@ private: typedef sk_gpu_test::GpuTimer INHERITED; }; -GLGpuTimer* GLGpuTimer::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) { - SkAutoTDelete<GLGpuTimer> ret; +std::unique_ptr<GLGpuTimer> GLGpuTimer::MakeIfSupported(const sk_gpu_test::GLTestContext* ctx) { + std::unique_ptr<GLGpuTimer> ret; const GrGLInterface* gl = ctx->gl(); if (gl->fExtensions.has("GL_EXT_disjoint_timer_query")) { ret.reset(new GLGpuTimer(true, ctx, "EXT")); @@ -132,7 +135,10 @@ GLGpuTimer* GLGpuTimer::CreateIfSupported(const sk_gpu_test::GLTestContext* ctx) } else if (gl->fExtensions.has("GL_EXT_timer_query")) { ret.reset(new GLGpuTimer(false, ctx, "EXT")); } - return ret && ret->validate() ? ret.release() : nullptr; + if (ret && !ret->validate()) { + ret = nullptr; + } + return ret; } GLGpuTimer::GLGpuTimer(bool disjointSupport, const sk_gpu_test::GLTestContext* ctx, const char* ext) @@ -219,11 +225,11 @@ GLTestContext::~GLTestContext() { SkASSERT(nullptr == fGL.get()); } -void GLTestContext::init(const GrGLInterface* gl, FenceSync* fenceSync) { +void GLTestContext::init(const GrGLInterface* gl, std::unique_ptr<FenceSync> fenceSync) { SkASSERT(!fGL.get()); fGL.reset(gl); - fFenceSync = fenceSync ? fenceSync : GLFenceSync::CreateIfSupported(this); - fGpuTimer = GLGpuTimer::CreateIfSupported(this); + fFenceSync = fenceSync ? std::move(fenceSync) : GLFenceSync::MakeIfSupported(this); + fGpuTimer = GLGpuTimer::MakeIfSupported(this); } void GLTestContext::teardown() { diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h index 0cd9762f8b..a2b04553d3 100644 --- a/tools/gpu/gl/GLTestContext.h +++ b/tools/gpu/gl/GLTestContext.h @@ -57,7 +57,7 @@ public: * Creates a new GL context of the same type and makes the returned context current * (if not null). */ - virtual GLTestContext *createNew() const { return nullptr; } + virtual std::unique_ptr<GLTestContext> makeNew() const { return nullptr; } template<typename Ret, typename... Args> void getGLProcAddress(Ret(GR_GL_FUNCTION_TYPE** out)(Args...), @@ -81,7 +81,7 @@ protected: /* * Methods that sublcasses must call from their constructors and destructors. */ - void init(const GrGLInterface *, FenceSync* = nullptr); + void init(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 449e14c8f8..aa55bf3475 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.cpp +++ b/tools/gpu/gl/angle/GLTestContext_angle.cpp @@ -82,7 +82,7 @@ public: GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; void destroyEGLImage(GrEGLImage) const override; GrGLuint eglImageToExternalTexture(GrEGLImage) const override; - sk_gpu_test::GLTestContext* createNew() const override; + std::unique_ptr<sk_gpu_test::GLTestContext> makeNew() const override; private: void destroyGLContext(); @@ -216,8 +216,9 @@ GrGLuint ANGLEGLContext::eglImageToExternalTexture(GrEGLImage image) const { return texID; } -sk_gpu_test::GLTestContext* ANGLEGLContext::createNew() const { - sk_gpu_test::GLTestContext* ctx = sk_gpu_test::CreateANGLETestContext(fType, fVersion); +std::unique_ptr<sk_gpu_test::GLTestContext> ANGLEGLContext::makeNew() const { + std::unique_ptr<sk_gpu_test::GLTestContext> ctx = + sk_gpu_test::MakeANGLETestContext(fType, fVersion); if (ctx) { ctx->makeCurrent(); } @@ -286,12 +287,10 @@ const GrGLInterface* CreateANGLEGLInterface() { return GrGLAssembleGLESInterface(&gLibs, angle_get_gl_proc); } -GLTestContext* CreateANGLETestContext(ANGLEBackend type, - ANGLEContextVersion version) { - ANGLEGLContext* ctx = new ANGLEGLContext(type, version); +std::unique_ptr<GLTestContext> MakeANGLETestContext(ANGLEBackend type, ANGLEContextVersion version){ + std::unique_ptr<ANGLEGLContext> ctx(new ANGLEGLContext(type, version)); if (!ctx->isValid()) { - delete ctx; - return NULL; + return nullptr; } return ctx; } diff --git a/tools/gpu/gl/angle/GLTestContext_angle.h b/tools/gpu/gl/angle/GLTestContext_angle.h index 0da747f30f..9314710276 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.h +++ b/tools/gpu/gl/angle/GLTestContext_angle.h @@ -30,7 +30,7 @@ enum class ANGLEContextVersion { }; /** Creates a GLTestContext backed by ANGLE. */ -GLTestContext* CreateANGLETestContext(ANGLEBackend, ANGLEContextVersion); +std::unique_ptr<GLTestContext> MakeANGLETestContext(ANGLEBackend, ANGLEContextVersion); } // namespace sk_gpu_test #endif diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp index 06bd70f852..b2517f090e 100644 --- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp +++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp @@ -22,7 +22,7 @@ namespace { // TODO: Share this class with ANGLE if/when it gets support for EGL_KHR_fence_sync. class EGLFenceSync : public sk_gpu_test::FenceSync { public: - static EGLFenceSync* CreateIfSupported(EGLDisplay); + static std::unique_ptr<EGLFenceSync> MakeIfSupported(EGLDisplay); sk_gpu_test::PlatformFence SK_WARN_UNUSED_RESULT insertFence() const override; bool waitFence(sk_gpu_test::PlatformFence fence) const override; @@ -44,7 +44,7 @@ public: GrEGLImage texture2DToEGLImage(GrGLuint texID) const override; void destroyEGLImage(GrEGLImage) const override; GrGLuint eglImageToExternalTexture(GrEGLImage) const override; - sk_gpu_test::GLTestContext* createNew() const override; + std::unique_ptr<sk_gpu_test::GLTestContext> makeNew() const override; private: void destroyGLContext(); @@ -180,7 +180,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI) continue; } - this->init(gl.release(), EGLFenceSync::CreateIfSupported(fDisplay)); + this->init(gl.release(), EGLFenceSync::MakeIfSupported(fDisplay)); break; } } @@ -255,8 +255,8 @@ GrGLuint EGLGLTestContext::eglImageToExternalTexture(GrEGLImage image) const { return texID; } -sk_gpu_test::GLTestContext* EGLGLTestContext::createNew() const { - sk_gpu_test::GLTestContext* ctx = new EGLGLTestContext(this->gl()->fStandard); +std::unique_ptr<sk_gpu_test::GLTestContext> EGLGLTestContext::makeNew() const { + std::unique_ptr<sk_gpu_test::GLTestContext> ctx(new EGLGLTestContext(this->gl()->fStandard)); if (ctx) { ctx->makeCurrent(); } @@ -294,11 +294,11 @@ static bool supports_egl_extension(EGLDisplay display, const char* extension) { return false; } -EGLFenceSync* EGLFenceSync::CreateIfSupported(EGLDisplay display) { +std::unique_ptr<EGLFenceSync> EGLFenceSync::MakeIfSupported(EGLDisplay display) { if (!display || !supports_egl_extension(display, "EGL_KHR_fence_sync")) { return nullptr; } - return new EGLFenceSync(display); + return std::unique_ptr<EGLFenceSync>(new EGLFenceSync(display)); } sk_gpu_test::PlatformFence EGLFenceSync::insertFence() const { |