s/SkAutoTUnref/sk_sp/ in src/ part 1

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4480

Change-Id: I7d3219b02ad5094785e1b7635a9482e69aadbc8c
Reviewed-on: https://skia-review.googlesource.com/4480
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
diff --git a/src/android/SkBitmapRegionCodec.cpp b/src/android/SkBitmapRegionCodec.cpp
index 7c51fc8..973e3c9 100644
--- a/src/android/SkBitmapRegionCodec.cpp
+++ b/src/android/SkBitmapRegionCodec.cpp
@@ -60,7 +60,7 @@
                                                dstColorType, dstAlphaType, colorSpace);
 
     // Construct a color table for the decode if necessary
-    SkAutoTUnref<SkColorTable> colorTable(nullptr);
+    sk_sp<SkColorTable> colorTable(nullptr);
     int maxColors = 256;
     SkPMColor colors[256];
     if (kIndex_8_SkColorType == dstColorType) {
diff --git a/src/codec/SkBmpRLECodec.cpp b/src/codec/SkBmpRLECodec.cpp
index b801309..0bc6f60 100644
--- a/src/codec/SkBmpRLECodec.cpp
+++ b/src/codec/SkBmpRLECodec.cpp
@@ -291,7 +291,7 @@
     }
 
     // Copy the color table to the client if necessary
-    copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount);
+    copy_color_table(dstInfo, fColorTable.get(), inputColorPtr, inputColorCount);
 
     // Initialize a buffer for encoded RLE data
     fRLEBytes = fOrigRLEBytes;
diff --git a/src/codec/SkBmpRLECodec.h b/src/codec/SkBmpRLECodec.h
index 5f34861..7cb3e9b 100644
--- a/src/codec/SkBmpRLECodec.h
+++ b/src/codec/SkBmpRLECodec.h
@@ -95,23 +95,23 @@
 
     SkSampler* getSampler(bool createIfNecessary) override;
 
-    SkAutoTUnref<SkColorTable>          fColorTable;    // owned
+    sk_sp<SkColorTable>        fColorTable;
     // fNumColors is the number specified in the header, or 0 if not present in the header.
-    const uint32_t                      fNumColors;
-    const uint32_t                      fBytesPerColor;
-    const uint32_t                      fOffset;
-    std::unique_ptr<uint8_t[]>          fStreamBuffer;
-    size_t                              fRLEBytes;
-    const size_t                        fOrigRLEBytes;
-    uint32_t                            fCurrRLEByte;
-    int                                 fSampleX;
-    std::unique_ptr<SkSampler>          fSampler;
+    const uint32_t             fNumColors;
+    const uint32_t             fBytesPerColor;
+    const uint32_t             fOffset;
+    std::unique_ptr<uint8_t[]> fStreamBuffer;
+    size_t                     fRLEBytes;
+    const size_t               fOrigRLEBytes;
+    uint32_t                   fCurrRLEByte;
+    int                        fSampleX;
+    std::unique_ptr<SkSampler> fSampler;
 
     // Scanline decodes allow the client to ask for a single scanline at a time.
     // This can be tricky when the RLE encoding instructs the decoder to jump down
     // multiple lines.  This field keeps track of lines that need to be skipped
     // on subsequent calls to decodeRows().
-    int                                 fLinesToSkip;
+    int                        fLinesToSkip;
 
     typedef SkBmpCodec INHERITED;
 };
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 9b346f3..004c257 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -215,7 +215,7 @@
     }
 
     // Copy the color table to the client if necessary
-    copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount);
+    copy_color_table(dstInfo, fColorTable.get(), inputColorPtr, inputColorCount);
 
     // Initialize a swizzler
     this->initializeSwizzler(dstInfo, options);
diff --git a/src/codec/SkBmpStandardCodec.h b/src/codec/SkBmpStandardCodec.h
index 12c12e8..61b2792 100644
--- a/src/codec/SkBmpStandardCodec.h
+++ b/src/codec/SkBmpStandardCodec.h
@@ -84,17 +84,17 @@
      */
     void decodeIcoMask(SkStream* stream, const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes);
 
-    SkAutoTUnref<SkColorTable>          fColorTable;     // owned
+    sk_sp<SkColorTable>         fColorTable;
     // fNumColors is the number specified in the header, or 0 if not present in the header.
-    const uint32_t                      fNumColors;
-    const uint32_t                      fBytesPerColor;
-    const uint32_t                      fOffset;
-    std::unique_ptr<SkSwizzler>         fSwizzler;
-    std::unique_ptr<uint8_t[]>          fSrcBuffer;
-    const bool                          fIsOpaque;
-    const bool                          fInIco;
-    const size_t                        fAndMaskRowBytes; // only used for fInIco decodes
-    bool                                fXformOnDecode;
+    const uint32_t              fNumColors;
+    const uint32_t              fBytesPerColor;
+    const uint32_t              fOffset;
+    std::unique_ptr<SkSwizzler> fSwizzler;
+    std::unique_ptr<uint8_t[]>  fSrcBuffer;
+    const bool                  fIsOpaque;
+    const bool                  fInIco;
+    const size_t                fAndMaskRowBytes; // only used for fInIco decodes
+    bool                        fXformOnDecode;
 
     typedef SkBmpCodec INHERITED;
 };
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 8297dd4..3cf972d 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -1084,7 +1084,7 @@
     }
 
     // Copy the color table to the client if they request kIndex8 mode.
-    copy_color_table(dstInfo, fColorTable, ctable, ctableCount);
+    copy_color_table(dstInfo, fColorTable.get(), ctable, ctableCount);
 
     this->initializeSwizzler(dstInfo, options);
     return true;
diff --git a/src/codec/SkPngCodec.h b/src/codec/SkPngCodec.h
index 2c427ca..590a631 100644
--- a/src/codec/SkPngCodec.h
+++ b/src/codec/SkPngCodec.h
@@ -91,16 +91,16 @@
             SkPMColor* ctable, int* ctableCount) override;
     Result onIncrementalDecode(int*) override;
 
-    SkAutoTUnref<SkPngChunkReader> fPngChunkReader;
-    voidp                          fPng_ptr;
-    voidp                          fInfo_ptr;
+    sk_sp<SkPngChunkReader>     fPngChunkReader;
+    voidp                       fPng_ptr;
+    voidp                       fInfo_ptr;
 
     // These are stored here so they can be used both by normal decoding and scanline decoding.
-    SkAutoTUnref<SkColorTable>         fColorTable;    // May be unpremul.
-    std::unique_ptr<SkSwizzler>        fSwizzler;
-    SkAutoTMalloc<uint8_t>             fStorage;
-    uint32_t*                          fColorXformSrcRow;
-    const int                          fBitDepth;
+    sk_sp<SkColorTable>         fColorTable;    // May be unpremul.
+    std::unique_ptr<SkSwizzler> fSwizzler;
+    SkAutoTMalloc<uint8_t>      fStorage;
+    uint32_t*                   fColorXformSrcRow;
+    const int                   fBitDepth;
 
 private:
 
diff --git a/src/codec/SkWbmpCodec.h b/src/codec/SkWbmpCodec.h
index 3c8df02..6946ea0 100644
--- a/src/codec/SkWbmpCodec.h
+++ b/src/codec/SkWbmpCodec.h
@@ -46,12 +46,12 @@
 
     SkWbmpCodec(int width, int height, const SkEncodedInfo&, SkStream*);
 
-    const size_t                 fSrcRowBytes;
+    const size_t                fSrcRowBytes;
 
     // Used for scanline decodes:
-    std::unique_ptr<SkSwizzler>  fSwizzler;
-    SkAutoTUnref<SkColorTable>   fColorTable;
-    SkAutoTMalloc<uint8_t>       fSrcBuffer;
+    std::unique_ptr<SkSwizzler> fSwizzler;
+    sk_sp<SkColorTable>         fColorTable;
+    SkAutoTMalloc<uint8_t>      fSrcBuffer;
 
     int onGetScanlines(void* dst, int count, size_t dstRowBytes) override;
     bool onSkipScanlines(int count) override;
diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp
index eaa8ba9..d5ed6b7 100644
--- a/src/effects/GrCircleBlurFragmentProcessor.cpp
+++ b/src/effects/GrCircleBlurFragmentProcessor.cpp
@@ -335,13 +335,13 @@
                                                                const SkRect& circle, float sigma) {
     float solidRadius;
     float textureRadius;
-    SkAutoTUnref<GrTexture> profile(create_profile_texture(textureProvider, circle, sigma,
-                                                           &solidRadius, &textureRadius));
+    sk_sp<GrTexture> profile(create_profile_texture(textureProvider, circle, sigma,
+                                                    &solidRadius, &textureRadius));
     if (!profile) {
         return nullptr;
     }
-    return sk_sp<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(circle, textureRadius,
-                                                                        solidRadius, profile));
+    return sk_sp<GrFragmentProcessor>(
+            new GrCircleBlurFragmentProcessor(circle, textureRadius, solidRadius, profile.get()));
 }
 
 //////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index dcacf82..0a98fa8 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -777,7 +777,7 @@
             return nullptr;
         }
 
-        SkAutoTUnref<GrTexture> blurProfile(CreateBlurProfileTexture(textureProvider, sigma));
+        sk_sp<GrTexture> blurProfile(CreateBlurProfileTexture(textureProvider, sigma));
         if (!blurProfile) {
            return nullptr;
         }
@@ -800,8 +800,9 @@
         } else {
             precision = kDefault_GrSLPrecision;
         }
+
         return sk_sp<GrFragmentProcessor>(
-            new GrRectBlurEffect(rect, sigma, blurProfile, precision));
+                new GrRectBlurEffect(rect, sigma, blurProfile.get(), precision));
     }
 
     const SkRect& getRect() const { return fRect; }
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index 2a921d8..2c8ab6f 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -313,18 +313,17 @@
     desc.fConfig = kRGBA_8888_GrPixelConfig;
     desc.fIsMipMapped = false;
 
-    SkAutoTUnref<GrTexture> textureCube(
-        context->textureProvider()->findAndRefTextureByUniqueKey(key));
+    sk_sp<GrTexture> textureCube(context->textureProvider()->findAndRefTextureByUniqueKey(key));
     if (!textureCube) {
         textureCube.reset(context->textureProvider()->createTexture(
             desc, SkBudgeted::kYes, fCubeData->data(), 0));
         if (textureCube) {
-            context->textureProvider()->assignUniqueKeyToTexture(key, textureCube);
+            context->textureProvider()->assignUniqueKeyToTexture(key, textureCube.get());
         } else {
             return nullptr;
         }
     }
 
-    return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube));
+    return sk_sp<GrFragmentProcessor>(GrColorCubeEffect::Make(textureCube.get()));
 }
 #endif
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index fc10691..703930d 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1763,7 +1763,7 @@
     GrTexture* tex = d->fTextures[texIdx];
     SkScalar surfaceScale = d->fRandom->nextSScalar1();
     SkScalar kd = d->fRandom->nextUScalar1();
-    SkAutoTUnref<SkImageFilterLight> light(create_random_light(d->fRandom));
+    sk_sp<SkImageFilterLight> light(create_random_light(d->fRandom));
     SkMatrix matrix;
     for (int i = 0; i < 9; i++) {
         matrix[i] = d->fRandom->nextUScalar1();
@@ -1773,7 +1773,8 @@
                                           d->fRandom->nextRangeU(0, tex->width()),
                                           d->fRandom->nextRangeU(0, tex->height()));
     BoundaryMode mode = static_cast<BoundaryMode>(d->fRandom->nextU() % kBoundaryModeCount);
-    return GrDiffuseLightingEffect::Make(tex, light, surfaceScale, matrix, kd, mode, &srcBounds);
+    return GrDiffuseLightingEffect::Make(tex, light.get(), surfaceScale, matrix, kd, mode,
+                                         &srcBounds);
 }
 
 
@@ -1899,10 +1900,10 @@
     float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
     pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
     pdman.set1f(fSurfaceScaleUni, lighting.surfaceScale());
-    SkAutoTUnref<SkImageFilterLight> transformedLight(
-                                            lighting.light()->transform(lighting.filterMatrix()));
+    sk_sp<SkImageFilterLight> transformedLight(
+            lighting.light()->transform(lighting.filterMatrix()));
     fDomain.setData(pdman, lighting.domain(), texture->origin());
-    fLight->setData(pdman, transformedLight);
+    fLight->setData(pdman, transformedLight.get());
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -1981,7 +1982,7 @@
     SkScalar surfaceScale = d->fRandom->nextSScalar1();
     SkScalar ks = d->fRandom->nextUScalar1();
     SkScalar shininess = d->fRandom->nextUScalar1();
-    SkAutoTUnref<SkImageFilterLight> light(create_random_light(d->fRandom));
+    sk_sp<SkImageFilterLight> light(create_random_light(d->fRandom));
     SkMatrix matrix;
     for (int i = 0; i < 9; i++) {
         matrix[i] = d->fRandom->nextUScalar1();
@@ -1992,7 +1993,7 @@
                                           d->fRandom->nextRangeU(0, tex->width()),
                                           d->fRandom->nextRangeU(0, tex->height()));
     return GrSpecularLightingEffect::Make(d->fTextures[GrProcessorUnitTest::kAlphaTextureIdx],
-                                          light, surfaceScale, matrix, ks, shininess, mode,
+                                          light.get(), surfaceScale, matrix, ks, shininess, mode,
                                           &srcBounds);
 }
 
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 06bf813..87db93d 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -924,10 +924,10 @@
 
     SkPerlinNoiseShader::PaintingData* paintingData =
             new PaintingData(fTileSize, fSeed, fBaseFrequencyX, fBaseFrequencyY, matrix);
-    SkAutoTUnref<GrTexture> permutationsTexture(
+    sk_sp<GrTexture> permutationsTexture(
         GrRefCachedBitmapTexture(args.fContext, paintingData->getPermutationsBitmap(),
                                  GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
-    SkAutoTUnref<GrTexture> noiseTexture(
+    sk_sp<GrTexture> noiseTexture(
         GrRefCachedBitmapTexture(args.fContext, paintingData->getNoiseBitmap(),
                                  GrTextureParams::ClampNoFilter(), args.fGammaTreatment));
 
@@ -940,7 +940,7 @@
                                       fNumOctaves,
                                       fStitchTiles,
                                       paintingData,
-                                      permutationsTexture, noiseTexture,
+                                      permutationsTexture.get(), noiseTexture.get(),
                                       m));
         return GrFragmentProcessor::MulOutputByInputAlpha(std::move(inner));
     }
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 7591088..289dee7 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -470,7 +470,7 @@
     desc.fConfig = SkImageInfo2GrPixelConfig(bitmap.info(), *context->caps());
     GrTextureStripAtlas* atlas = GrTextureStripAtlas::GetAtlas(desc);
     int row = atlas->lockRow(bitmap);
-    SkAutoTUnref<GrTexture> texture;
+    sk_sp<GrTexture> texture;
     if (-1 == row) {
         atlas = nullptr;
         texture.reset(GrRefCachedBitmapTexture(context, bitmap, GrTextureParams::ClampNoFilter(),
@@ -479,7 +479,7 @@
         texture.reset(SkRef(atlas->getTexture()));
     }
 
-    return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture, atlas, row, flags));
+    return sk_sp<GrFragmentProcessor>(new ColorTableEffect(texture.get(), atlas, row, flags));
 }
 
 ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row,
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index 96817a0..0bd9c87 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -666,7 +666,7 @@
  *  The gradient holds a cache for the most recent value of alpha. Successive
  *  callers with the same alpha value will share the same cache.
  */
-SkGradientShaderBase::GradientShaderCache* SkGradientShaderBase::refCache(U8CPU alpha,
+sk_sp<SkGradientShaderBase::GradientShaderCache> SkGradientShaderBase::refCache(U8CPU alpha,
                                                                           bool dither) const {
     SkAutoMutexAcquire ama(fCacheMutex);
     if (!fCache || fCache->getAlpha() != alpha || fCache->getDither() != dither) {
@@ -675,7 +675,6 @@
     // Increment the ref counter inside the mutex to ensure the returned pointer is still valid.
     // Otherwise, the pointer may have been overwritten on a different thread before the object's
     // ref count was incremented.
-    fCache.get()->ref();
     return fCache;
 }
 
@@ -691,7 +690,7 @@
 void SkGradientShaderBase::getGradientTableBitmap(SkBitmap* bitmap,
                                                   GradientBitmapType bitmapType) const {
     // our caller assumes no external alpha, so we ensure that our cache is built with 0xFF
-    SkAutoTUnref<GradientShaderCache> cache(this->refCache(0xFF, true));
+    sk_sp<GradientShaderCache> cache(this->refCache(0xFF, true));
 
     // build our key: [numColors + colors[] + {positions[]} + flags + colorType ]
     int count = 1 + fColorCount + 1 + 1;
@@ -1662,14 +1661,14 @@
                 fCoordTransform.reset(*args.fMatrix, fAtlas->getTexture(), params.filterMode());
                 fTextureAccess.reset(fAtlas->getTexture(), params);
             } else {
-                SkAutoTUnref<GrTexture> texture(
+                sk_sp<GrTexture> texture(
                     GrRefCachedBitmapTexture(args.fContext, bitmap, params,
                                              SkSourceGammaTreatment::kRespect));
                 if (!texture) {
                     return;
                 }
-                fCoordTransform.reset(*args.fMatrix, texture, params.filterMode());
-                fTextureAccess.reset(texture, params);
+                fCoordTransform.reset(*args.fMatrix, texture.get(), params.filterMode());
+                fTextureAccess.reset(texture.get(), params);
                 fYCoord = SK_ScalarHalf;
             }
 
diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
index cbffea1..2e447ca 100644
--- a/src/effects/gradients/SkGradientShaderPriv.h
+++ b/src/effects/gradients/SkGradientShaderPriv.h
@@ -167,7 +167,7 @@
         uint8_t     fFlags;
         bool        fDither;
 
-        SkAutoTUnref<GradientShaderCache> fCache;
+        sk_sp<GradientShaderCache> fCache;
 
     private:
         typedef SkShader::Context INHERITED;
@@ -267,9 +267,9 @@
 private:
     bool                fColorsAreOpaque;
 
-    GradientShaderCache* refCache(U8CPU alpha, bool dither) const;
-    mutable SkMutex                           fCacheMutex;
-    mutable SkAutoTUnref<GradientShaderCache> fCache;
+    sk_sp<GradientShaderCache> refCache(U8CPU alpha, bool dither) const;
+    mutable SkMutex                    fCacheMutex;
+    mutable sk_sp<GradientShaderCache> fCache;
 
     void initCommon();
 
diff --git a/src/fonts/SkFontMgr_indirect.cpp b/src/fonts/SkFontMgr_indirect.cpp
index 41447ac..f594e2d 100644
--- a/src/fonts/SkFontMgr_indirect.cpp
+++ b/src/fonts/SkFontMgr_indirect.cpp
@@ -55,9 +55,9 @@
         return this->matchStyleCSS3(pattern);
     }
 private:
-    SkAutoTUnref<const SkFontMgr_Indirect> fOwner;
+    sk_sp<const SkFontMgr_Indirect> fOwner;
     int fFamilyIndex;
-    SkAutoTUnref<SkRemotableFontIdentitySet> fData;
+    sk_sp<SkRemotableFontIdentitySet> fData;
 };
 
 void SkFontMgr_Indirect::set_up_family_names(const SkFontMgr_Indirect* self) {
@@ -97,7 +97,7 @@
 
     SkAutoMutexAcquire ama(fDataCacheMutex);
 
-    SkAutoTUnref<SkTypeface> dataTypeface;
+    sk_sp<SkTypeface> dataTypeface;
     int dataTypefaceIndex = 0;
     for (int i = 0; i < fDataCache.count(); ++i) {
         const DataEntry& entry = fDataCache[i];
@@ -135,7 +135,7 @@
         return nullptr;
     }
 
-    SkAutoTUnref<SkTypeface> typeface(fImpl->createFromStream(stream.release(), id.fTtcIndex));
+    sk_sp<SkTypeface> typeface(fImpl->createFromStream(stream.release(), id.fTtcIndex));
     if (typeface.get() == nullptr) {
         return nullptr;
     }
@@ -186,7 +186,7 @@
 
 SkTypeface* SkFontMgr_Indirect::onLegacyCreateTypeface(const char familyName[],
                                                        SkFontStyle style) const {
-    SkAutoTUnref<SkTypeface> face(this->matchFamilyStyle(familyName, style));
+    sk_sp<SkTypeface> face(this->matchFamilyStyle(familyName, style));
 
     if (nullptr == face.get()) {
         face.reset(this->matchFamilyStyle(nullptr, style));
diff --git a/src/image/SkImage.cpp b/src/image/SkImage.cpp
index 334984d..22cb5cb 100644
--- a/src/image/SkImage.cpp
+++ b/src/image/SkImage.cpp
@@ -109,7 +109,7 @@
 }
 
 SkData* SkImage::encode(SkPixelSerializer* serializer) const {
-    SkAutoTUnref<SkPixelSerializer> defaultSerializer;
+    sk_sp<SkPixelSerializer> defaultSerializer;
     SkPixelSerializer* effectiveSerializer = serializer;
     if (!effectiveSerializer) {
         defaultSerializer.reset(SkImageEncoder::CreatePixelSerializer());
@@ -321,7 +321,7 @@
         return nullptr;
     }
 
-    SkAutoTUnref<SkImageFilterCache> cache(
+    sk_sp<SkImageFilterCache> cache(
         SkImageFilterCache::Create(SkImageFilterCache::kDefaultTransientSize));
     SkImageFilter::OutputProperties outputProperties(as_IB(this)->onImageInfo().colorSpace());
     SkImageFilter::Context context(SkMatrix::I(), clipBounds, cache.get(), outputProperties);
diff --git a/src/image/SkImageShader.cpp b/src/image/SkImageShader.cpp
index a1882ab..f58228c 100644
--- a/src/image/SkImageShader.cpp
+++ b/src/image/SkImageShader.cpp
@@ -210,8 +210,8 @@
     GrSkFilterQualityToGrFilterMode(args.fFilterQuality, *args.fViewMatrix, this->getLocalMatrix(),
                                     &doBicubic);
     GrTextureParams params(tm, textureFilterMode);
-    SkAutoTUnref<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params,
-                                                                args.fGammaTreatment));
+    sk_sp<GrTexture> texture(as_IB(fImage)->asTextureRef(args.fContext, params,
+                                                         args.fGammaTreatment));
     if (!texture) {
         return nullptr;
     }
@@ -221,9 +221,10 @@
                                                                        args.fDstColorSpace);
     sk_sp<GrFragmentProcessor> inner;
     if (doBicubic) {
-        inner = GrBicubicEffect::Make(texture, std::move(colorSpaceXform), matrix, tm);
+        inner = GrBicubicEffect::Make(texture.get(), std::move(colorSpaceXform), matrix, tm);
     } else {
-        inner = GrSimpleTextureEffect::Make(texture, std::move(colorSpaceXform), matrix, params);
+        inner = GrSimpleTextureEffect::Make(texture.get(), std::move(colorSpaceXform),
+                                            matrix, params);
     }
 
     if (GrPixelConfigIsAlphaOnly(texture->config())) {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index e993002..5e2d1a5 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -663,7 +663,7 @@
     if (!context || context->uniqueID() != dti->fContextUniqueID) {
         return nullptr;
     }
-    SkAutoTUnref<SkColorTable> colorTable;
+    sk_sp<SkColorTable> colorTable;
     if (dti->fColorTableCnt) {
         SkASSERT(dti->fColorTableData);
         colorTable.reset(new SkColorTable(dti->fColorTableData, dti->fColorTableCnt));
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index c27e1bc..987ff2b 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -208,12 +208,12 @@
         return nullptr;
     }
 
-    SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, nullptr));
-    if (nullptr == pr.get()) {
+    sk_sp<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, nullptr));
+    if (!pr) {
         return nullptr;
     }
     if (rowBytes) {
         SkASSERT(pr->rowBytes() == rowBytes);
     }
-    return sk_make_sp<SkSurface_Raster>(pr, props);
+    return sk_make_sp<SkSurface_Raster>(pr.get(), props);
 }
diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp
index 88bcc84..a04b380 100644
--- a/src/pdf/SkPDFDevice.cpp
+++ b/src/pdf/SkPDFDevice.cpp
@@ -2289,7 +2289,7 @@
         SkMatrix matrix = *draw.fMatrix;
         matrix.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
         const SkIRect clipBounds = draw.fRC->getBounds().makeOffset(-x, -y);
-        SkAutoTUnref<SkImageFilterCache> cache(this->getImageFilterCache());
+        sk_sp<SkImageFilterCache> cache(this->getImageFilterCache());
         // TODO: Should PDF be operating in a specified color space? For now, run the filter
         // in the same color space as the source (this is different from all other backends).
         SkImageFilter::OutputProperties outputProperties(srcImg->getColorSpace());
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index 6023375..a9b9a2a 100644
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -2317,7 +2317,7 @@
 
     virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
                                            const SkFontStyle& fontStyle) const override {
-        SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
+        sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
         return sset->matchStyle(fontStyle);
     }
 
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index a3264a8..77465ce 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -2435,7 +2435,7 @@
     virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
                                            const SkFontStyle& fontstyle) const override {
         // could be in base impl
-        SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
+        sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
         return sset->matchStyle(fontstyle);
     }
 
diff --git a/src/ports/SkFontMgr_FontConfigInterface.cpp b/src/ports/SkFontMgr_FontConfigInterface.cpp
index 404ae98..a883804 100644
--- a/src/ports/SkFontMgr_FontConfigInterface.cpp
+++ b/src/ports/SkFontMgr_FontConfigInterface.cpp
@@ -114,7 +114,7 @@
         SkDiscardableMemory* diagnostic_only_getDiscardable() const override { return nullptr; }
 
         std::unique_ptr<Request> fRequest;
-        SkAutoTUnref<SkTypeface> fFace;
+        sk_sp<SkTypeface> fFace;
     };
 
     SkResourceCache fCachedResults;
@@ -133,7 +133,7 @@
             const Result& result = static_cast<const Result&>(rec);
             SkTypeface** face = static_cast<SkTypeface**>(context);
 
-            *face = result.fFace;
+            *face = result.fFace.get();
             return true;
         }, &face);
         return SkSafeRef(face);
diff --git a/src/ports/SkFontMgr_android.cpp b/src/ports/SkFontMgr_android.cpp
index 3a84eca..116bc01 100644
--- a/src/ports/SkFontMgr_android.cpp
+++ b/src/ports/SkFontMgr_android.cpp
@@ -237,7 +237,7 @@
     }
 
 private:
-    SkTArray<SkAutoTUnref<SkTypeface_AndroidSystem>, true> fStyles;
+    SkTArray<sk_sp<SkTypeface_AndroidSystem>, true> fStyles;
 
     friend struct NameToFamily;
     friend class SkFontMgr_Android;
@@ -323,7 +323,7 @@
 
     virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
                                            const SkFontStyle& style) const override {
-        SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
+        sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
         return sset->matchStyle(style);
     }
 
@@ -331,7 +331,7 @@
                                          const SkFontStyle& style) const override {
         for (int i = 0; i < fStyleSets.count(); ++i) {
             for (int j = 0; j < fStyleSets[i]->fStyles.count(); ++j) {
-                if (fStyleSets[i]->fStyles[j] == typeface) {
+                if (fStyleSets[i]->fStyles[j].get() == typeface) {
                     return fStyleSets[i]->matchStyle(style);
                 }
             }
diff --git a/src/ports/SkFontMgr_custom.cpp b/src/ports/SkFontMgr_custom.cpp
index 9a8aa49..c081064 100644
--- a/src/ports/SkFontMgr_custom.cpp
+++ b/src/ports/SkFontMgr_custom.cpp
@@ -237,7 +237,7 @@
     SkTypeface* onMatchFamilyStyle(const char familyName[],
                                    const SkFontStyle& fontStyle) const override
     {
-        SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
+        sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
         return sset->matchStyle(fontStyle);
     }
 
diff --git a/src/ports/SkFontMgr_fontconfig.cpp b/src/ports/SkFontMgr_fontconfig.cpp
index 1f00558..3592fec 100644
--- a/src/ports/SkFontMgr_fontconfig.cpp
+++ b/src/ports/SkFontMgr_fontconfig.cpp
@@ -581,7 +581,7 @@
         }
 
     private:
-        SkAutoTUnref<const SkFontMgr_fontconfig> fFontMgr;
+        sk_sp<const SkFontMgr_fontconfig> fFontMgr;
         SkAutoFcFontSet fFontSet;
     };
 
@@ -944,7 +944,7 @@
     }
 
     SkTypeface* onLegacyCreateTypeface(const char familyName[], SkFontStyle style) const override {
-        SkAutoTUnref<SkTypeface> typeface(this->matchFamilyStyle(familyName, style));
+        sk_sp<SkTypeface> typeface(this->matchFamilyStyle(familyName, style));
         if (typeface.get()) {
             return typeface.release();
         }
diff --git a/src/ports/SkFontMgr_win_dw.cpp b/src/ports/SkFontMgr_win_dw.cpp
index cd0b665..547cbe3 100644
--- a/src/ports/SkFontMgr_win_dw.cpp
+++ b/src/ports/SkFontMgr_win_dw.cpp
@@ -340,7 +340,7 @@
     SkTypeface* matchStyle(const SkFontStyle& pattern) override;
 
 private:
-    SkAutoTUnref<const SkFontMgr_DirectWrite> fFontMgr;
+    sk_sp<const SkFontMgr_DirectWrite> fFontMgr;
     SkTScopedComPtr<IDWriteFontFamily> fFontFamily;
 };
 
@@ -509,7 +509,7 @@
 
 SkTypeface* SkFontMgr_DirectWrite::onMatchFamilyStyle(const char familyName[],
                                                       const SkFontStyle& fontstyle) const {
-    SkAutoTUnref<SkFontStyleSet> sset(this->matchFamily(familyName));
+    sk_sp<SkFontStyleSet> sset(this->matchFamily(familyName));
     return sset->matchStyle(fontstyle);
 }
 
@@ -634,7 +634,7 @@
 
 protected:
     ULONG fRefCount;
-    SkAutoTUnref<const SkFontMgr_DirectWrite> fOuter;
+    sk_sp<const SkFontMgr_DirectWrite> fOuter;
     UINT32 fCharacter;
     SkTypeface* fResolvedTypeface;
 };
diff --git a/src/ports/SkRemotableFontMgr_win_dw.cpp b/src/ports/SkRemotableFontMgr_win_dw.cpp
index a4c895a..c07c81f 100644
--- a/src/ports/SkRemotableFontMgr_win_dw.cpp
+++ b/src/ports/SkRemotableFontMgr_win_dw.cpp
@@ -148,7 +148,7 @@
 
         int count = fontFamily->GetFontCount();
         SkFontIdentity* fontIds;
-        SkAutoTUnref<SkRemotableFontIdentitySet> fontIdSet(
+        sk_sp<SkRemotableFontIdentitySet> fontIdSet(
             new SkRemotableFontIdentitySet(count, &fontIds));
         for (int fontIndex = 0; fontIndex < count; ++fontIndex) {
             SkTScopedComPtr<IDWriteFont> font;
@@ -365,7 +365,7 @@
 
     protected:
         ULONG fRefCount;
-        SkAutoTUnref<const SkRemotableFontMgr_DirectWrite> fOuter;
+        sk_sp<const SkRemotableFontMgr_DirectWrite> fOuter;
         UINT32 fCharacter;
         SkFontIdentity fIdentity;
     };
diff --git a/src/svg/SkSVGCanvas.cpp b/src/svg/SkSVGCanvas.cpp
index b6634b8..d3511c0 100644
--- a/src/svg/SkSVGCanvas.cpp
+++ b/src/svg/SkSVGCanvas.cpp
@@ -11,7 +11,7 @@
 SkCanvas* SkSVGCanvas::Create(const SkRect& bounds, SkXMLWriter* writer) {
     // TODO: pass full bounds to the device
     SkISize size = bounds.roundOut().size();
-    SkAutoTUnref<SkBaseDevice> device(SkSVGDevice::Create(size, writer));
+    sk_sp<SkBaseDevice> device(SkSVGDevice::Create(size, writer));
 
-    return new SkCanvas(device);
+    return new SkCanvas(device.get());
 }
diff --git a/src/svg/SkSVGDevice.cpp b/src/svg/SkSVGDevice.cpp
index 203be3a..ffdf034 100644
--- a/src/svg/SkSVGDevice.cpp
+++ b/src/svg/SkSVGDevice.cpp
@@ -546,7 +546,7 @@
         this->addAttribute("font-weight", "bold");
     }
 
-    SkAutoTUnref<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamilyNameIterator());
+    sk_sp<SkTypeface::LocalizedStrings> familyNameIter(tface->createFamilyNameIterator());
     SkTypeface::LocalizedString familyString;
     while (familyNameIter->next(&familyString)) {
         if (familySet.contains(familyString.fString)) {
@@ -661,7 +661,7 @@
 
 void SkSVGDevice::drawBitmapCommon(const SkDraw& draw, const SkBitmap& bm,
                                    const SkPaint& paint) {
-    SkAutoTUnref<const SkData> pngData(
+    sk_sp<const SkData> pngData(
         SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, SkImageEncoder::kDefaultQuality));
     if (!pngData) {
         return;
diff --git a/src/utils/SkCanvasStateUtils.cpp b/src/utils/SkCanvasStateUtils.cpp
index 3426126..062dc13 100644
--- a/src/utils/SkCanvasStateUtils.cpp
+++ b/src/utils/SkCanvasStateUtils.cpp
@@ -304,7 +304,7 @@
     SkASSERT(!bitmap.empty());
     SkASSERT(!bitmap.isNull());
 
-    SkAutoTUnref<SkCanvas> canvas(new SkCanvas(bitmap));
+    sk_sp<SkCanvas> canvas(new SkCanvas(bitmap));
 
     // setup the matrix and clip
     setup_canvas_from_MC_state(layerState.mcState, canvas.get());
@@ -323,14 +323,14 @@
         return nullptr;
     }
 
-    SkAutoTUnref<SkCanvasStack> canvas(new SkCanvasStack(state->width, state->height));
+    sk_sp<SkCanvasStack> canvas(new SkCanvasStack(state->width, state->height));
 
     // setup the matrix and clip on the n-way canvas
-    setup_canvas_from_MC_state(state_v1->mcState, canvas);
+    setup_canvas_from_MC_state(state_v1->mcState, canvas.get());
 
     // Iterate over the layers and add them to the n-way canvas
     for (int i = state_v1->layerCount - 1; i >= 0; --i) {
-        SkAutoTUnref<SkCanvas> canvasLayer(create_canvas_from_canvas_layer(state_v1->layers[i]));
+        sk_sp<SkCanvas> canvasLayer(create_canvas_from_canvas_layer(state_v1->layers[i]));
         if (!canvasLayer.get()) {
             return nullptr;
         }
diff --git a/src/utils/SkWhitelistTypefaces.cpp b/src/utils/SkWhitelistTypefaces.cpp
index 007def6..f51a3b3 100644
--- a/src/utils/SkWhitelistTypefaces.cpp
+++ b/src/utils/SkWhitelistTypefaces.cpp
@@ -40,7 +40,7 @@
 static int whitelist_name_index(const SkTypeface* tf) {
 
     SkString fontNameStr;
-    SkAutoTUnref<SkTypeface::LocalizedStrings> nameIter(
+    sk_sp<SkTypeface::LocalizedStrings> nameIter(
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*tf));
     SkTypeface::LocalizedString familyNameLocalized;
     while (nameIter->next(&familyNameLocalized)) {
@@ -53,7 +53,7 @@
         }
     }
 #if WHITELIST_DEBUG
-    SkAutoTUnref<SkTypeface::LocalizedStrings> debugIter(
+    sk_sp<SkTypeface::LocalizedStrings> debugIter(
         SkOTUtils::LocalizedStrings_NameTable::CreateForFamilyNames(*tf));
     while (debugIter->next(&familyNameLocalized)) {
         SkDebugf("no match fontName=\"%s\"\n", familyNameLocalized.fString.c_str());
diff --git a/src/xps/SkDocument_XPS.cpp b/src/xps/SkDocument_XPS.cpp
index cb4938b..e333b5a 100644
--- a/src/xps/SkDocument_XPS.cpp
+++ b/src/xps/SkDocument_XPS.cpp
@@ -58,7 +58,7 @@
 
 private:
     SkXPSDevice fDevice;
-    SkAutoTUnref<SkCanvas> fCanvas;
+    sk_sp<SkCanvas> fCanvas;
     SkVector fUnitsPerMeter;
     SkVector fPixelsPerMeter;
 };