From 1b612a89fba2275e3effe12bdc9b6cdc2f4d9eee Mon Sep 17 00:00:00 2001 From: Hal Canary Date: Thu, 3 Nov 2016 16:26:13 -0400 Subject: tools: s/SkAutoTUnref/sk_sp/ BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4391 Change-Id: Iae8b032b00d3579c77f3b86370dde71c4649da45 Reviewed-on: https://skia-review.googlesource.com/4391 Reviewed-by: Ben Wagner Commit-Queue: Hal Canary --- tools/debugger/SkDrawCommand.cpp | 6 ++--- tools/debugger/SkDrawCommand.h | 18 +++++++------- tools/gpu/GrTest.h | 4 ++-- tools/gpu/gl/GLTestContext.cpp | 28 +++++++++++----------- tools/gpu/gl/GLTestContext.h | 2 +- tools/gpu/gl/angle/GLTestContext_angle.cpp | 2 +- .../GLTestContext_command_buffer.cpp | 2 +- .../gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp | 2 +- .../gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp | 2 +- .../gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm | 2 +- .../gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp | 2 +- tools/gpu/gl/mesa/GLTestContext_mesa.cpp | 2 +- .../gpu/gl/win/CreatePlatformGLTestContext_win.cpp | 2 +- tools/lua/lua_pictures.cpp | 2 +- tools/sk_tool_utils_font.cpp | 2 +- tools/skiaserve/Request.cpp | 6 ++--- tools/skiaserve/Request.h | 4 ++-- tools/skiaserve/urlhandlers/DataHandler.cpp | 2 +- tools/viewer/sk_app/GLWindowContext.cpp | 4 ++-- tools/viewer/sk_app/GLWindowContext.h | 12 +++++----- tools/viewer/sk_app/VulkanWindowContext.h | 2 +- 21 files changed, 54 insertions(+), 54 deletions(-) diff --git a/tools/debugger/SkDrawCommand.cpp b/tools/debugger/SkDrawCommand.cpp index 3ee5cdb7f4..c8eaf98851 100644 --- a/tools/debugger/SkDrawCommand.cpp +++ b/tools/debugger/SkDrawCommand.cpp @@ -2099,7 +2099,7 @@ SkDrawImageCommand::SkDrawImageCommand(const SkImage* image, SkScalar left, SkSc } void SkDrawImageCommand::execute(SkCanvas* canvas) const { - canvas->drawImage(fImage, fLeft, fTop, fPaint.getMaybeNull()); + canvas->drawImage(fImage.get(), fLeft, fTop, fPaint.getMaybeNull()); } bool SkDrawImageCommand::render(SkCanvas* canvas) const { @@ -2193,8 +2193,8 @@ SkDrawImageRectCommand::SkDrawImageRectCommand(const SkImage* image, const SkRec } void SkDrawImageRectCommand::execute(SkCanvas* canvas) const { - canvas->legacy_drawImageRect(fImage, fSrc.getMaybeNull(), fDst, fPaint.getMaybeNull(), - fConstraint); + canvas->legacy_drawImageRect(fImage.get(), fSrc.getMaybeNull(), fDst, + fPaint.getMaybeNull(), fConstraint); } bool SkDrawImageRectCommand::render(SkCanvas* canvas) const { diff --git a/tools/debugger/SkDrawCommand.h b/tools/debugger/SkDrawCommand.h index 54ee3c6354..144c6c560e 100644 --- a/tools/debugger/SkDrawCommand.h +++ b/tools/debugger/SkDrawCommand.h @@ -356,10 +356,10 @@ public: static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager); private: - SkAutoTUnref fImage; - SkScalar fLeft; - SkScalar fTop; - SkTLazy fPaint; + sk_sp fImage; + SkScalar fLeft; + SkScalar fTop; + SkTLazy fPaint; typedef SkDrawCommand INHERITED; }; @@ -374,7 +374,7 @@ public: static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager); private: - SkAutoTUnref fImage; + sk_sp fImage; SkTLazy fSrc; SkRect fDst; SkTLazy fPaint; @@ -456,9 +456,9 @@ public: bool render(SkCanvas* canvas) const override; private: - SkAutoTUnref fPicture; - SkTLazy fMatrix; - SkTLazy fPaint; + sk_sp fPicture; + SkTLazy fMatrix; + SkTLazy fPaint; typedef SkDrawCommand INHERITED; }; @@ -486,7 +486,7 @@ public: bool render(SkCanvas* canvas) const override; private: - SkAutoTUnref fPicture; + sk_sp fPicture; SkTLazy fMatrix; SkTLazy fPaint; #ifdef SK_EXPERIMENTAL_SHADOWING diff --git a/tools/gpu/GrTest.h b/tools/gpu/GrTest.h index a991c21bb2..0ef2140389 100644 --- a/tools/gpu/GrTest.h +++ b/tools/gpu/GrTest.h @@ -32,8 +32,8 @@ public: GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); } private: - SkAutoTUnref fContext; - sk_sp fRenderTargetContext; + sk_sp fContext; + sk_sp fRenderTargetContext; }; #endif diff --git a/tools/gpu/gl/GLTestContext.cpp b/tools/gpu/gl/GLTestContext.cpp index e6d0e40db8..f6771934f8 100644 --- a/tools/gpu/gl/GLTestContext.cpp +++ b/tools/gpu/gl/GLTestContext.cpp @@ -259,28 +259,28 @@ void GLTestContext::finish() { GrGLint GLTestContext::createTextureRectangle(int width, int height, GrGLenum internalFormat, GrGLenum externalFormat, GrGLenum externalType, GrGLvoid* data) { - if (!(kGL_GrGLStandard == fGL->fStandard && GrGLGetVersion(fGL) >= GR_GL_VER(3, 1)) && + if (!(kGL_GrGLStandard == fGL->fStandard && GrGLGetVersion(fGL.get()) >= GR_GL_VER(3, 1)) && !fGL->fExtensions.has("GL_ARB_texture_rectangle")) { return 0; } - if (GrGLGetGLSLVersion(fGL) < GR_GLSL_VER(1, 40)) { + if (GrGLGetGLSLVersion(fGL.get()) < GR_GLSL_VER(1, 40)) { return 0; } GrGLuint id; - GR_GL_CALL(fGL, GenTextures(1, &id)); - GR_GL_CALL(fGL, BindTexture(GR_GL_TEXTURE_RECTANGLE, id)); - GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MAG_FILTER, - GR_GL_NEAREST)); - GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MIN_FILTER, - GR_GL_NEAREST)); - GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_S, - GR_GL_CLAMP_TO_EDGE)); - GR_GL_CALL(fGL, TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_T, - GR_GL_CLAMP_TO_EDGE)); - GR_GL_CALL(fGL, TexImage2D(GR_GL_TEXTURE_RECTANGLE, 0, internalFormat, width, height, 0, - externalFormat, externalType, data)); + GR_GL_CALL(fGL.get(), GenTextures(1, &id)); + GR_GL_CALL(fGL.get(), BindTexture(GR_GL_TEXTURE_RECTANGLE, id)); + GR_GL_CALL(fGL.get(), TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MAG_FILTER, + GR_GL_NEAREST)); + GR_GL_CALL(fGL.get(), TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_MIN_FILTER, + GR_GL_NEAREST)); + GR_GL_CALL(fGL.get(), TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_S, + GR_GL_CLAMP_TO_EDGE)); + GR_GL_CALL(fGL.get(), TexParameteri(GR_GL_TEXTURE_RECTANGLE, GR_GL_TEXTURE_WRAP_T, + GR_GL_CLAMP_TO_EDGE)); + GR_GL_CALL(fGL.get(), TexImage2D(GR_GL_TEXTURE_RECTANGLE, 0, internalFormat, width, height, 0, + externalFormat, externalType, data)); return id; } } // namespace sk_gpu_test diff --git a/tools/gpu/gl/GLTestContext.h b/tools/gpu/gl/GLTestContext.h index a2b04553d3..09dce05685 100644 --- a/tools/gpu/gl/GLTestContext.h +++ b/tools/gpu/gl/GLTestContext.h @@ -90,7 +90,7 @@ protected: private: /** Subclass provides the gl interface object if construction was * successful. */ - SkAutoTUnref fGL; + sk_sp fGL; typedef TestContext INHERITED; }; diff --git a/tools/gpu/gl/angle/GLTestContext_angle.cpp b/tools/gpu/gl/angle/GLTestContext_angle.cpp index 24f722a01f..c3ec431b7e 100644 --- a/tools/gpu/gl/angle/GLTestContext_angle.cpp +++ b/tools/gpu/gl/angle/GLTestContext_angle.cpp @@ -147,7 +147,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version) eglMakeCurrent(fDisplay, fSurface, fSurface, fContext); - SkAutoTUnref gl(sk_gpu_test::CreateANGLEGLInterface()); + sk_sp gl(sk_gpu_test::CreateANGLEGLInterface()); if (nullptr == gl.get()) { SkDebugf("Could not create ANGLE GL interface!\n"); this->destroyGLContext(); diff --git a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp index 32e5de4626..888270e41b 100644 --- a/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp +++ b/tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp @@ -241,7 +241,7 @@ void CommandBufferGLTestContext::initializeGLContext(void *nativeWindow, const i return; } - SkAutoTUnref gl(create_command_buffer_interface()); + sk_sp gl(create_command_buffer_interface()); if (nullptr == gl.get()) { SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n"); this->destroyGLContext(); diff --git a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp index b2517f090e..a281559a6d 100644 --- a/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp +++ b/tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp @@ -100,7 +100,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI) } SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == forcedGpuAPI); - SkAutoTUnref gl; + sk_sp gl; for (; nullptr == gl.get() && api < apiLimit; ++api) { fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY); diff --git a/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp b/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp index b8e1996d37..76b6d21661 100644 --- a/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp +++ b/tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp @@ -221,7 +221,7 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext* return; } - SkAutoTUnref gl(GrGLCreateNativeInterface()); + sk_sp gl(GrGLCreateNativeInterface()); if (nullptr == gl.get()) { SkDebugf("Failed to create gl interface"); this->destroyGLContext(); diff --git a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm index f2bcd5d402..4c1aa0119d 100644 --- a/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm +++ b/tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm @@ -37,7 +37,7 @@ IOSGLTestContext::IOSGLTestContext() fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; [EAGLContext setCurrentContext:EAGLCTX]; - SkAutoTUnref gl(GrGLCreateNativeInterface()); + sk_sp gl(GrGLCreateNativeInterface()); if (NULL == gl.get()) { SkDebugf("Failed to create gl interface"); this->destroyGLContext(); diff --git a/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp b/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp index b2cdaacd8a..2a908f8625 100644 --- a/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp +++ b/tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp @@ -60,7 +60,7 @@ MacGLTestContext::MacGLTestContext() CGLSetCurrentContext(fContext); - SkAutoTUnref gl(GrGLCreateNativeInterface()); + sk_sp gl(GrGLCreateNativeInterface()); if (nullptr == gl.get()) { SkDebugf("Context could not create GL interface.\n"); this->destroyGLContext(); diff --git a/tools/gpu/gl/mesa/GLTestContext_mesa.cpp b/tools/gpu/gl/mesa/GLTestContext_mesa.cpp index e0cf9c198a..1a1c79d27a 100644 --- a/tools/gpu/gl/mesa/GLTestContext_mesa.cpp +++ b/tools/gpu/gl/mesa/GLTestContext_mesa.cpp @@ -88,7 +88,7 @@ MesaGLContext::MesaGLContext() : fContext(static_cast(0)), fImage(nullp return; } - SkAutoTUnref gl(create_mesa_interface()); + sk_sp gl(create_mesa_interface()); if (nullptr == gl.get()) { SkDebugf("Could not create GL interface!\n"); this->destroyGLContext(); diff --git a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp b/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp index 1b482bc290..a37413ef19 100644 --- a/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp +++ b/tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp @@ -114,7 +114,7 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI) return; } - SkAutoTUnref gl(GrGLCreateNativeInterface()); + sk_sp gl(GrGLCreateNativeInterface()); if (nullptr == gl.get()) { SkDebugf("Could not create GL interface.\n"); this->destroyGLContext(); diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp index 58983f4d58..015244f7bc 100644 --- a/tools/lua/lua_pictures.cpp +++ b/tools/lua/lua_pictures.cpp @@ -144,7 +144,7 @@ int tool_main(int argc, char** argv) { auto pic(load_picture(path)); if (pic.get()) { - SkAutoTUnref canvas( + sk_sp canvas( new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()), SkScalarCeilToInt(pic->cullRect().height()), L.get(), gAccumulateFunc)); diff --git a/tools/sk_tool_utils_font.cpp b/tools/sk_tool_utils_font.cpp index a1d50ddef7..bdd88d07f9 100644 --- a/tools/sk_tool_utils_font.cpp +++ b/tools/sk_tool_utils_font.cpp @@ -47,7 +47,7 @@ sk_sp create_font(const char* name, SkFontStyle style) { name, style.weight(), style.width(), style.slant()); // If we called SkTypeface::CreateFromName() here we'd recurse infinitely, // so we reimplement its core logic here inline without the recursive aspect. - SkAutoTUnref fm(SkFontMgr::RefDefault()); + sk_sp fm(SkFontMgr::RefDefault()); return sk_sp(fm->legacyCreateTypeface(name, style)); } } else { diff --git a/tools/skiaserve/Request.cpp b/tools/skiaserve/Request.cpp index 134fdf03c2..c1b3b25cdd 100644 --- a/tools/skiaserve/Request.cpp +++ b/tools/skiaserve/Request.cpp @@ -117,8 +117,8 @@ sk_sp Request::writeOutSkp() { SkDynamicMemoryWStream outStream; - SkAutoTUnref serializer(SkImageEncoder::CreatePixelSerializer()); - picture->serialize(&outStream, serializer); + sk_sp serializer(SkImageEncoder::CreatePixelSerializer()); + picture->serialize(&outStream, serializer.get()); return outStream.detachAsData(); } @@ -280,7 +280,7 @@ sk_sp Request::getJsonBatchList(int n) { sk_sp Request::getJsonInfo(int n) { // drawTo - SkAutoTUnref surface(this->createCPUSurface()); + sk_sp surface(this->createCPUSurface()); SkCanvas* canvas = surface->getCanvas(); // TODO this is really slow and we should cache the matrix and clip diff --git a/tools/skiaserve/Request.h b/tools/skiaserve/Request.h index cadf15c6ba..6b065a2bf8 100644 --- a/tools/skiaserve/Request.h +++ b/tools/skiaserve/Request.h @@ -63,7 +63,7 @@ struct Request { SkColor getPixel(int x, int y); UploadContext* fUploadContext; - SkAutoTUnref fDebugCanvas; + sk_sp fDebugCanvas; UrlDataManager fUrlDataManager; private: @@ -76,7 +76,7 @@ private: sk_sp fPicture; sk_gpu_test::GrContextFactory* fContextFactory; - SkAutoTUnref fSurface; + sk_sp fSurface; bool fGPUEnabled; bool fOverdraw; int fColorMode; diff --git a/tools/skiaserve/urlhandlers/DataHandler.cpp b/tools/skiaserve/urlhandlers/DataHandler.cpp index 397be8f224..83a9be4d12 100644 --- a/tools/skiaserve/urlhandlers/DataHandler.cpp +++ b/tools/skiaserve/urlhandlers/DataHandler.cpp @@ -29,7 +29,7 @@ int DataHandler::handle(Request* request, MHD_Connection* connection, return MHD_NO; } - SkAutoTUnref urlData( + sk_sp urlData( SkRef(request->fUrlDataManager.getDataFromUrl(SkString(url)))); if (urlData) { diff --git a/tools/viewer/sk_app/GLWindowContext.cpp b/tools/viewer/sk_app/GLWindowContext.cpp index 3b9af390fb..dd51b7e160 100644 --- a/tools/viewer/sk_app/GLWindowContext.cpp +++ b/tools/viewer/sk_app/GLWindowContext.cpp @@ -30,7 +30,7 @@ GLWindowContext::GLWindowContext(const DisplayParams& params) void GLWindowContext::initializeContext() { this->onInitializeContext(); - SkAutoTUnref glInterface; + sk_sp glInterface; glInterface.reset(GrGLCreateNativeInterface()); fBackendContext.reset(GrGLInterfaceRemoveNVPR(glInterface.get())); @@ -74,7 +74,7 @@ sk_sp GLWindowContext::getBackbufferSurface() { desc.fSampleCnt = fSampleCount; desc.fStencilBits = fStencilBits; GrGLint buffer; - GR_GL_CALL(fBackendContext, GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer)); + GR_GL_CALL(fBackendContext.get(), GetIntegerv(GR_GL_FRAMEBUFFER_BINDING, &buffer)); desc.fRenderTargetHandle = buffer; fSurface = this->createRenderSurface(desc, fActualColorBits); diff --git a/tools/viewer/sk_app/GLWindowContext.h b/tools/viewer/sk_app/GLWindowContext.h index 2ebc39f4b7..7a3256eb9e 100644 --- a/tools/viewer/sk_app/GLWindowContext.h +++ b/tools/viewer/sk_app/GLWindowContext.h @@ -50,16 +50,16 @@ protected: virtual void onSwapBuffers() = 0; - SkAutoTUnref fBackendContext; - sk_sp fSurface; + sk_sp fBackendContext; + sk_sp fSurface; // parameters obtained from the native window // Note that the platform .cpp file is responsible for // initializing fSampleCount, fStencilBits, and fColorBits! - int fSampleCount; - int fStencilBits; - int fColorBits; - int fActualColorBits; + int fSampleCount; + int fStencilBits; + int fColorBits; + int fActualColorBits; }; } // namespace sk_app diff --git a/tools/viewer/sk_app/VulkanWindowContext.h b/tools/viewer/sk_app/VulkanWindowContext.h index c1ed871e8e..cafaeada1b 100644 --- a/tools/viewer/sk_app/VulkanWindowContext.h +++ b/tools/viewer/sk_app/VulkanWindowContext.h @@ -63,7 +63,7 @@ private: void createBuffers(VkFormat format); void destroyBuffers(); - SkAutoTUnref fBackendContext; + sk_sp fBackendContext; // simple wrapper class that exists only to initialize a pointer to NULL template class VkPtr { -- cgit v1.2.3