tools: s/SkAutoTUnref/sk_sp/
authorHal Canary <halcanary@google.com>
Thu, 3 Nov 2016 20:26:13 +0000 (16:26 -0400)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 3 Nov 2016 21:00:34 +0000 (21:00 +0000)
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 <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>

21 files changed:
tools/debugger/SkDrawCommand.cpp
tools/debugger/SkDrawCommand.h
tools/gpu/GrTest.h
tools/gpu/gl/GLTestContext.cpp
tools/gpu/gl/GLTestContext.h
tools/gpu/gl/angle/GLTestContext_angle.cpp
tools/gpu/gl/command_buffer/GLTestContext_command_buffer.cpp
tools/gpu/gl/egl/CreatePlatformGLTestContext_egl.cpp
tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp
tools/gpu/gl/iOS/CreatePlatformGLTestContext_iOS.mm
tools/gpu/gl/mac/CreatePlatformGLTestContext_mac.cpp
tools/gpu/gl/mesa/GLTestContext_mesa.cpp
tools/gpu/gl/win/CreatePlatformGLTestContext_win.cpp
tools/lua/lua_pictures.cpp
tools/sk_tool_utils_font.cpp
tools/skiaserve/Request.cpp
tools/skiaserve/Request.h
tools/skiaserve/urlhandlers/DataHandler.cpp
tools/viewer/sk_app/GLWindowContext.cpp
tools/viewer/sk_app/GLWindowContext.h
tools/viewer/sk_app/VulkanWindowContext.h

index 3ee5cdb..c8eaf98 100644 (file)
@@ -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 {
index 54ee3c6..144c6c5 100644 (file)
@@ -356,10 +356,10 @@ public:
     static SkDrawImageCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
 
 private:
-    SkAutoTUnref<const SkImage> fImage;
-    SkScalar                    fLeft;
-    SkScalar                    fTop;
-    SkTLazy<SkPaint>            fPaint;
+    sk_sp<const SkImage> fImage;
+    SkScalar             fLeft;
+    SkScalar             fTop;
+    SkTLazy<SkPaint>     fPaint;
 
     typedef SkDrawCommand INHERITED;
 };
@@ -374,7 +374,7 @@ public:
     static SkDrawImageRectCommand* fromJSON(Json::Value& command, UrlDataManager& urlDataManager);
 
 private:
-    SkAutoTUnref<const SkImage> fImage;
+    sk_sp<const SkImage>        fImage;
     SkTLazy<SkRect>             fSrc;
     SkRect                      fDst;
     SkTLazy<SkPaint>            fPaint;
@@ -456,9 +456,9 @@ public:
     bool render(SkCanvas* canvas) const override;
 
 private:
-    SkAutoTUnref<const SkPicture> fPicture;
-    SkTLazy<SkMatrix>             fMatrix;
-    SkTLazy<SkPaint>              fPaint;
+    sk_sp<const SkPicture> fPicture;
+    SkTLazy<SkMatrix>      fMatrix;
+    SkTLazy<SkPaint>       fPaint;
 
     typedef SkDrawCommand INHERITED;
 };
@@ -486,7 +486,7 @@ public:
     bool render(SkCanvas* canvas) const override;
 
 private:
-    SkAutoTUnref<const SkPicture> fPicture;
+    sk_sp<const SkPicture>        fPicture;
     SkTLazy<SkMatrix>             fMatrix;
     SkTLazy<SkPaint>              fPaint;
 #ifdef SK_EXPERIMENTAL_SHADOWING
index a991c21..0ef2140 100644 (file)
@@ -32,8 +32,8 @@ public:
     GrResourceProvider* resourceProvider() { return fContext->resourceProvider(); }
 
 private:
-    SkAutoTUnref<GrContext>                 fContext;
-    sk_sp<GrRenderTargetContext>                    fRenderTargetContext;
+    sk_sp<GrContext>             fContext;
+    sk_sp<GrRenderTargetContext> fRenderTargetContext;
 };
 
 #endif
index e6d0e40..f677193 100644 (file)
@@ -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
index a2b0455..09dce05 100644 (file)
@@ -90,7 +90,7 @@ protected:
 private:
     /** Subclass provides the gl interface object if construction was
      *  successful. */
-    SkAutoTUnref<const GrGLInterface> fGL;
+    sk_sp<const GrGLInterface> fGL;
 
     typedef TestContext INHERITED;
 };
index 24f722a..c3ec431 100644 (file)
@@ -147,7 +147,7 @@ ANGLEGLContext::ANGLEGLContext(ANGLEBackend type, ANGLEContextVersion version)
 
     eglMakeCurrent(fDisplay, fSurface, fSurface, fContext);
 
-    SkAutoTUnref<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();
index 32e5de4..888270e 100644 (file)
@@ -241,7 +241,7 @@ void CommandBufferGLTestContext::initializeGLContext(void *nativeWindow, const i
         return;
     }
 
-    SkAutoTUnref<const GrGLInterface> gl(create_command_buffer_interface());
+    sk_sp<const GrGLInterface> gl(create_command_buffer_interface());
     if (nullptr == gl.get()) {
         SkDebugf("Command Buffer: Could not create CommandBuffer GL interface.\n");
         this->destroyGLContext();
index b2517f0..a281559 100644 (file)
@@ -100,7 +100,7 @@ EGLGLTestContext::EGLGLTestContext(GrGLStandard forcedGpuAPI)
     }
     SkASSERT(forcedGpuAPI == kNone_GrGLStandard || kAPIs[api].fStandard == forcedGpuAPI);
 
-    SkAutoTUnref<const GrGLInterface> gl;
+    sk_sp<const GrGLInterface> gl;
 
     for (; nullptr == gl.get() && api < apiLimit; ++api) {
         fDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
index b8e1996..76b6d21 100644 (file)
@@ -221,7 +221,7 @@ GLXGLTestContext::GLXGLTestContext(GrGLStandard forcedGpuAPI, GLXGLTestContext*
         return;
     }
 
-    SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
+    sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
     if (nullptr == gl.get()) {
         SkDebugf("Failed to create gl interface");
         this->destroyGLContext();
index f2bcd5d..4c1aa01 100644 (file)
@@ -37,7 +37,7 @@ IOSGLTestContext::IOSGLTestContext()
     fEAGLContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
     [EAGLContext setCurrentContext:EAGLCTX];
 
-    SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
+    sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
     if (NULL == gl.get()) {
         SkDebugf("Failed to create gl interface");
         this->destroyGLContext();
index b2cdaac..2a908f8 100644 (file)
@@ -60,7 +60,7 @@ MacGLTestContext::MacGLTestContext()
 
     CGLSetCurrentContext(fContext);
 
-    SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
+    sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
     if (nullptr == gl.get()) {
         SkDebugf("Context could not create GL interface.\n");
         this->destroyGLContext();
index e0cf9c1..1a1c79d 100644 (file)
@@ -88,7 +88,7 @@ MesaGLContext::MesaGLContext() : fContext(static_cast<Context>(0)), fImage(nullp
         return;
     }
 
-    SkAutoTUnref<const GrGLInterface> gl(create_mesa_interface());
+    sk_sp<const GrGLInterface> gl(create_mesa_interface());
     if (nullptr == gl.get()) {
         SkDebugf("Could not create GL interface!\n");
         this->destroyGLContext();
index 1b482bc..a37413e 100644 (file)
@@ -114,7 +114,7 @@ WinGLTestContext::WinGLTestContext(GrGLStandard forcedGpuAPI)
         return;
     }
 
-    SkAutoTUnref<const GrGLInterface> gl(GrGLCreateNativeInterface());
+    sk_sp<const GrGLInterface> gl(GrGLCreateNativeInterface());
     if (nullptr == gl.get()) {
         SkDebugf("Could not create GL interface.\n");
         this->destroyGLContext();
index 58983f4..015244f 100644 (file)
@@ -144,7 +144,7 @@ int tool_main(int argc, char** argv) {
 
             auto pic(load_picture(path));
             if (pic.get()) {
-                SkAutoTUnref<SkLuaCanvas> canvas(
+                sk_sp<SkLuaCanvas> canvas(
                                     new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()),
                                                     SkScalarCeilToInt(pic->cullRect().height()),
                                                     L.get(), gAccumulateFunc));
index a1d50dd..bdd88d0 100644 (file)
@@ -47,7 +47,7 @@ sk_sp<SkTypeface> 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<SkFontMgr> fm(SkFontMgr::RefDefault());
+            sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
             return sk_sp<SkTypeface>(fm->legacyCreateTypeface(name, style));
         }
     } else {
index 134fdf0..c1b3b25 100644 (file)
@@ -117,8 +117,8 @@ sk_sp<SkData> Request::writeOutSkp() {
 
     SkDynamicMemoryWStream outStream;
 
-    SkAutoTUnref<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer());
-    picture->serialize(&outStream, serializer);
+    sk_sp<SkPixelSerializer> serializer(SkImageEncoder::CreatePixelSerializer());
+    picture->serialize(&outStream, serializer.get());
 
     return outStream.detachAsData();
 }
@@ -280,7 +280,7 @@ sk_sp<SkData> Request::getJsonBatchList(int n) {
 
 sk_sp<SkData> Request::getJsonInfo(int n) {
     // drawTo
-    SkAutoTUnref<SkSurface> surface(this->createCPUSurface());
+    sk_sp<SkSurface> surface(this->createCPUSurface());
     SkCanvas* canvas = surface->getCanvas();
 
     // TODO this is really slow and we should cache the matrix and clip
index cadf15c..6b065a2 100644 (file)
@@ -63,7 +63,7 @@ struct Request {
     SkColor getPixel(int x, int y);
 
     UploadContext* fUploadContext;
-    SkAutoTUnref<SkDebugCanvas> fDebugCanvas;
+    sk_sp<SkDebugCanvas> fDebugCanvas;
     UrlDataManager fUrlDataManager;
 
 private:
@@ -76,7 +76,7 @@ private:
 
     sk_sp<SkPicture> fPicture;
     sk_gpu_test::GrContextFactory* fContextFactory;
-    SkAutoTUnref<SkSurface> fSurface;
+    sk_sp<SkSurface> fSurface;
     bool fGPUEnabled;
     bool fOverdraw;
     int fColorMode;
index 397be8f..83a9be4 100644 (file)
@@ -29,7 +29,7 @@ int DataHandler::handle(Request* request, MHD_Connection* connection,
         return MHD_NO;
     }
 
-    SkAutoTUnref<UrlDataManager::UrlData> urlData(
+    sk_sp<UrlDataManager::UrlData> urlData(
         SkRef(request->fUrlDataManager.getDataFromUrl(SkString(url))));
 
     if (urlData) {
index 3b9af39..dd51b7e 100644 (file)
@@ -30,7 +30,7 @@ GLWindowContext::GLWindowContext(const DisplayParams& params)
 
 void GLWindowContext::initializeContext() {
     this->onInitializeContext();
-    SkAutoTUnref<const GrGLInterface> glInterface;
+    sk_sp<const GrGLInterface> glInterface;
     glInterface.reset(GrGLCreateNativeInterface());
     fBackendContext.reset(GrGLInterfaceRemoveNVPR(glInterface.get()));
 
@@ -74,7 +74,7 @@ sk_sp<SkSurface> 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);
index 2ebc39f..7a3256e 100644 (file)
@@ -50,16 +50,16 @@ protected:
 
     virtual void onSwapBuffers() = 0;
 
-    SkAutoTUnref<const GrGLInterface> fBackendContext;
-    sk_sp<SkSurface>                  fSurface;
+    sk_sp<const GrGLInterface> fBackendContext;
+    sk_sp<SkSurface>           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
index c1ed871..cafaead 100644 (file)
@@ -63,7 +63,7 @@ private:
     void createBuffers(VkFormat format);
     void destroyBuffers();
 
-    SkAutoTUnref<const GrVkBackendContext> fBackendContext;
+    sk_sp<const GrVkBackendContext> fBackendContext;
 
     // simple wrapper class that exists only to initialize a pointer to NULL
     template <typename FNPTR_TYPE> class VkPtr {