Switch new SkImageFilter internal methods over to sk_sp

GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1826893002

Review URL: https://codereview.chromium.org/1826893002
diff --git a/include/core/SkDevice.h b/include/core/SkDevice.h
index 5d903fd..55b08a7 100644
--- a/include/core/SkDevice.h
+++ b/include/core/SkDevice.h
@@ -381,8 +381,8 @@
     /**
      *  Calls through to drawSprite, processing the imagefilter.
      */
-    virtual void drawBitmapAsSpriteWithImageFilter(const SkDraw&, const SkBitmap&,
-                                                   int x, int y, const SkPaint&);
+    virtual void drawSpriteWithFilter(const SkDraw&, const SkBitmap&,
+                                      int x, int y, const SkPaint&);
 
 private:
     friend class SkCanvas;
diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h
index 025c8fd..ab72547 100644
--- a/include/core/SkImageFilter.h
+++ b/include/core/SkImageFilter.h
@@ -150,7 +150,7 @@
      *  TODO: Right now the imagefilters sometimes return empty result bitmaps/
      *        specialimages. That doesn't seem quite right.
      */
-    SkSpecialImage* filterImage(SkSpecialImage* src, const Context&, SkIPoint* offset) const;
+    sk_sp<SkSpecialImage> filterImage(SkSpecialImage* src, const Context&, SkIPoint* offset) const;
 
     enum MapDirection {
         kForward_MapDirection,
@@ -264,10 +264,10 @@
                                              SkFilterQuality,
                                              SkImageFilter* input = NULL);
 
-    SkSpecialImage* filterInput(int index,
-                                SkSpecialImage* src,
-                                const Context&, 
-                                SkIPoint* offset) const;
+    sk_sp<SkSpecialImage> filterInput(int index,
+                                      SkSpecialImage* src,
+                                      const Context&, 
+                                      SkIPoint* offset) const;
 
 #if SK_SUPPORT_GPU
     // Helper function which invokes GPU filter processing on the
@@ -354,8 +354,8 @@
     virtual bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
                                          SkBitmap* result, SkIPoint* offset) const;
 
-    virtual SkSpecialImage* onFilterImage(SkSpecialImage* src, const Context&,
-                                          SkIPoint* offset) const;
+    virtual sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* src, const Context&,
+                                                SkIPoint* offset) const;
 
     /**
      * This function recurses into its inputs with the given rect (first
@@ -424,8 +424,8 @@
     bool applyCropRectDeprecated(const Context&, Proxy* proxy, const SkBitmap& src,
                                  SkIPoint* srcOffset, SkIRect* bounds, SkBitmap* result) const;
 
-    SkSpecialImage* applyCropRect(const Context&, SkSpecialImage* src, SkIPoint* srcOffset,
-                                  SkIRect* bounds) const;
+    sk_sp<SkSpecialImage> applyCropRect(const Context&, SkSpecialImage* src, SkIPoint* srcOffset,
+                                        SkIRect* bounds) const;
 
     /**
      *  Returns true if the filter can be expressed a single-pass
diff --git a/include/effects/SkBlurImageFilter.h b/include/effects/SkBlurImageFilter.h
index 46d073e..682c08f 100644
--- a/include/effects/SkBlurImageFilter.h
+++ b/include/effects/SkBlurImageFilter.h
@@ -28,8 +28,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
 
 private:
diff --git a/include/effects/SkColorFilterImageFilter.h b/include/effects/SkColorFilterImageFilter.h
index 910b31a..90e6e4b 100644
--- a/include/effects/SkColorFilterImageFilter.h
+++ b/include/effects/SkColorFilterImageFilter.h
@@ -22,8 +22,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     bool onIsColorFilterNode(SkColorFilter**) const override;
     bool canComputeFastBounds() const override;
 
diff --git a/include/effects/SkComposeImageFilter.h b/include/effects/SkComposeImageFilter.h
index 8c93b56..cf73a00 100644
--- a/include/effects/SkComposeImageFilter.h
+++ b/include/effects/SkComposeImageFilter.h
@@ -32,8 +32,8 @@
         SkASSERT(inputs[0]);
         SkASSERT(inputs[1]);
     }
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     SkIRect onFilterBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
 
 private:
diff --git a/include/effects/SkDropShadowImageFilter.h b/include/effects/SkDropShadowImageFilter.h
index e3620b0..7f1aa33 100644
--- a/include/effects/SkDropShadowImageFilter.h
+++ b/include/effects/SkDropShadowImageFilter.h
@@ -36,8 +36,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     SkIRect onFilterNodeBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
 
 private:
diff --git a/include/effects/SkImageSource.h b/include/effects/SkImageSource.h
index 293a052..ab6e0c1 100644
--- a/include/effects/SkImageSource.h
+++ b/include/effects/SkImageSource.h
@@ -28,8 +28,8 @@
 protected:
     void flatten(SkWriteBuffer&) const override;
 
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
 
 private:
     explicit SkImageSource(SkImage*);
diff --git a/include/effects/SkMergeImageFilter.h b/include/effects/SkMergeImageFilter.h
index 0824731..3bf649d 100644
--- a/include/effects/SkMergeImageFilter.h
+++ b/include/effects/SkMergeImageFilter.h
@@ -35,8 +35,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
 
 private:
     SkMergeImageFilter(SkImageFilter* filters[], int count, const SkXfermode::Mode modes[],
diff --git a/include/effects/SkOffsetImageFilter.h b/include/effects/SkOffsetImageFilter.h
index 0b9ca83..908f20b 100644
--- a/include/effects/SkOffsetImageFilter.h
+++ b/include/effects/SkOffsetImageFilter.h
@@ -28,8 +28,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     SkIRect onFilterNodeBounds(const SkIRect&, const SkMatrix&, MapDirection) const override;
 
 private:
diff --git a/include/effects/SkPaintImageFilter.h b/include/effects/SkPaintImageFilter.h
index 285d0f1..51d375f 100644
--- a/include/effects/SkPaintImageFilter.h
+++ b/include/effects/SkPaintImageFilter.h
@@ -31,8 +31,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
 
 private:
     SkPaintImageFilter(const SkPaint& paint, const CropRect* rect);
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index f1c1626..6a11db5 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1412,8 +1412,7 @@
                 continue; // something disastrous happened
             }
 
-            SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx,
-                                                                       &offset));
+            sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
             if (resultImg) {
                 SkPaint tmpUnfiltered(*paint);
                 tmpUnfiltered.setImageFilter(nullptr);
@@ -2265,9 +2264,9 @@
             if (as_IB(image)->asBitmapForImageFilters(&bitmap)) {
                 SkPoint pt;
                 iter.fMatrix->mapXY(x, y, &pt);
-                iter.fDevice->drawBitmapAsSpriteWithImageFilter(iter, bitmap,
-                                                                SkScalarRoundToInt(pt.fX),
-                                                                SkScalarRoundToInt(pt.fY), pnt);
+                iter.fDevice->drawSpriteWithFilter(iter, bitmap,
+                                                   SkScalarRoundToInt(pt.fX),
+                                                   SkScalarRoundToInt(pt.fY), pnt);
             }
         } else {
             iter.fDevice->drawImage(iter, image, x, y, pnt);
@@ -2347,9 +2346,9 @@
         if (drawAsSprite && pnt.getImageFilter()) {
             SkPoint pt;
             iter.fMatrix->mapXY(x, y, &pt);
-            iter.fDevice->drawBitmapAsSpriteWithImageFilter(iter, bitmap,
-                                                            SkScalarRoundToInt(pt.fX),
-                                                            SkScalarRoundToInt(pt.fY), pnt);
+            iter.fDevice->drawSpriteWithFilter(iter, bitmap,
+                                               SkScalarRoundToInt(pt.fX),
+                                               SkScalarRoundToInt(pt.fY), pnt);
         } else {
             iter.fDevice->drawBitmap(iter, bitmap, matrix, looper.paint());
         }
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp
index df0ba5f..0ff094d 100644
--- a/src/core/SkDevice.cpp
+++ b/src/core/SkDevice.cpp
@@ -403,9 +403,9 @@
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
-void SkBaseDevice::drawBitmapAsSpriteWithImageFilter(const SkDraw& draw, const SkBitmap& bitmap,
-                                                     int x, int y,
-                                                     const SkPaint& paint) {
+void SkBaseDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitmap,
+                                        int x, int y,
+                                        const SkPaint& paint) {
     SkImageFilter* filter = paint.getImageFilter();
     SkASSERT(filter);
 
@@ -423,7 +423,7 @@
             return; // something disastrous happened
         }
 
-        SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
+        sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
         if (resultImg) {
             SkPaint tmpUnfiltered(paint);
             tmpUnfiltered.setImageFilter(nullptr);
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index edaaa16..62509c5 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -214,8 +214,8 @@
     buffer.writeUInt(fCropRect.flags());
 }
 
-SkSpecialImage* SkImageFilter::filterImage(SkSpecialImage* src, const Context& context,
-                                           SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkImageFilter::filterImage(SkSpecialImage* src, const Context& context,
+                                                 SkIPoint* offset) const {
     SkASSERT(src && offset);
 
     uint32_t srcGenID = fUsesSrcInput ? src->uniqueID() : 0;
@@ -224,13 +224,13 @@
     if (context.cache()) {
         SkSpecialImage* result = context.cache()->get(key, offset);
         if (result) {
-            return SkRef(result);
+            return sk_sp<SkSpecialImage>(SkRef(result));
         }
     }
 
-    SkSpecialImage* result = this->onFilterImage(src, context, offset);
+    sk_sp<SkSpecialImage> result(this->onFilterImage(src, context, offset));
     if (result && context.cache()) {
-        context.cache()->set(key, result, *offset);
+        context.cache()->set(key, result.get(), *offset);
         SkAutoMutexAcquire mutex(fMutex);
         fCacheKeys.push_back(key);
     }
@@ -280,9 +280,9 @@
         return false;
     }
 
-    SkAutoTUnref<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
-                                                          this->mapContext(ctx),
-                                                          offset));
+    sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
+                                                   this->mapContext(ctx),
+                                                   offset));
     if (!tmp) {
         return false;
     }
@@ -341,8 +341,8 @@
 
 // SkImageFilter-derived classes that do not yet have their own onFilterImage
 // implementation convert back to calling the deprecated filterImage method
-SkSpecialImage* SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx,
-                                             SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkImageFilter::onFilterImage(SkSpecialImage* src, const Context& ctx,
+                                                   SkIPoint* offset) const {
     SkBitmap srcBM, resultBM;
 
     if (!src->internal_getBM(&srcBM)) {
@@ -354,7 +354,7 @@
         return nullptr;
     }
 
-    return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM).release();
+    return SkSpecialImage::internal_fromBM(src->internal_getProxy(), resultBM);
 }
 
 bool SkImageFilter::canFilterImageGPU() const {
@@ -489,10 +489,10 @@
     return surf->makeImageSnapshot();
 }
 
-SkSpecialImage* SkImageFilter::applyCropRect(const Context& ctx,
-                                             SkSpecialImage* src,
-                                             SkIPoint* srcOffset,
-                                             SkIRect* bounds) const {
+sk_sp<SkSpecialImage> SkImageFilter::applyCropRect(const Context& ctx,
+                                                   SkSpecialImage* src,
+                                                   SkIPoint* srcOffset,
+                                                   SkIRect* bounds) const {
     SkIRect srcBounds;
     srcBounds = SkIRect::MakeXYWH(srcOffset->fX, srcOffset->fY, src->width(), src->height());
 
@@ -503,14 +503,14 @@
     }
 
     if (srcBounds.contains(*bounds)) {
-        return SkRef(src);
+        return sk_sp<SkSpecialImage>(SkRef(src));
     } else {
         sk_sp<SkSpecialImage> img(pad_image(src,
                                             bounds->width(), bounds->height(),
                                             srcOffset->x() - bounds->x(),
                                             srcOffset->y() - bounds->y()));
         *srcOffset = SkIPoint::Make(bounds->x(), bounds->y());
-        return img.release();
+        return img;
     }
 }
 
@@ -563,27 +563,27 @@
     return SkLocalMatrixImageFilter::Create(matrix, const_cast<SkImageFilter*>(this));
 }
 
-SkSpecialImage* SkImageFilter::filterInput(int index,
-                                           SkSpecialImage* src,
-                                           const Context& ctx,
-                                           SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkImageFilter::filterInput(int index,
+                                                 SkSpecialImage* src,
+                                                 const Context& ctx,
+                                                 SkIPoint* offset) const {
     SkImageFilter* input = this->getInput(index);
     if (!input) {
-        return SkRef(src);
+        return sk_sp<SkSpecialImage>(SkRef(src));
     }
 
-    SkAutoTUnref<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx), offset));
+    sk_sp<SkSpecialImage> result(input->filterImage(src, this->mapContext(ctx), offset));
 
 #if SK_SUPPORT_GPU
     if (src->peekTexture() && result && !result->peekTexture()) {
         // Keep the result on the GPU - this is still required for some
         // image filters that don't support GPU in all cases
         GrContext* context = src->peekTexture()->getContext();
-        return result->makeTextureImage(src->internal_getProxy(), context).release();
+        return result->makeTextureImage(src->internal_getProxy(), context);
     }
 #endif
 
-    return result.release();
+    return result;
 }
 
 #if SK_SUPPORT_GPU
@@ -601,9 +601,9 @@
         return false;
     }
 
-    SkAutoTUnref<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
-                                                          this->mapContext(ctx),
-                                                          offset));
+    sk_sp<SkSpecialImage> tmp(input->onFilterImage(specialSrc.get(),
+                                                   this->mapContext(ctx),
+                                                   offset));
     if (!tmp) {
         return false;
     }
diff --git a/src/core/SkLocalMatrixImageFilter.cpp b/src/core/SkLocalMatrixImageFilter.cpp
index f4ecb29..15f2f0e 100644
--- a/src/core/SkLocalMatrixImageFilter.cpp
+++ b/src/core/SkLocalMatrixImageFilter.cpp
@@ -7,6 +7,7 @@
 
 #include "SkLocalMatrixImageFilter.h"
 #include "SkReadBuffer.h"
+#include "SkSpecialImage.h"
 #include "SkString.h"
 
 SkImageFilter* SkLocalMatrixImageFilter::Create(const SkMatrix& localM, SkImageFilter* input) {
@@ -39,8 +40,9 @@
     buffer.writeMatrix(fLocalM);
 }
 
-SkSpecialImage* SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                        SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkLocalMatrixImageFilter::onFilterImage(SkSpecialImage* source,
+                                                              const Context& ctx,
+                                                              SkIPoint* offset) const {
     Context localCtx(SkMatrix::Concat(ctx.ctm(), fLocalM), ctx.clipBounds(), ctx.cache());
     return this->filterInput(0, source, localCtx, offset);
 }
diff --git a/src/core/SkLocalMatrixImageFilter.h b/src/core/SkLocalMatrixImageFilter.h
index f6bcb56..412b391 100644
--- a/src/core/SkLocalMatrixImageFilter.h
+++ b/src/core/SkLocalMatrixImageFilter.h
@@ -23,8 +23,8 @@
 
 protected:
     void flatten(SkWriteBuffer&) const override;
-    SkSpecialImage* onFilterImage(SkSpecialImage* source, const Context&,
-                                  SkIPoint* offset) const override;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override;
     SkIRect onFilterBounds(const SkIRect& src, const SkMatrix&, MapDirection) const override;
 
 private:
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index c2cf356..692b6c9 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -70,11 +70,12 @@
     }
 }
 
-SkSpecialImage* SkBlurImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                 SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source,
+                                                       const Context& ctx,
+                                                       SkIPoint* offset) const {
     SkIPoint inputOffset = SkIPoint::Make(0, 0);
 
-    SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
+    sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
     if (!input) {
         return nullptr;
     }
@@ -98,7 +99,7 @@
             offset->fX = inputBounds.x();
             offset->fY = inputBounds.y();
             return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(),
-                                                            -inputOffset.y())).release();
+                                                            -inputOffset.y()));
         }
 
         GrTexture* inputTexture = input->peekTexture();
@@ -122,7 +123,7 @@
         return SkSpecialImage::MakeFromGpu(source->internal_getProxy(),
                                            SkIRect::MakeWH(dstBounds.width(), dstBounds.height()),
                                            kNeedNewImageUniqueID_SpecialImage,
-                                           tex).release();
+                                           tex);
     }
 #endif
 
@@ -139,7 +140,7 @@
         offset->fX = inputBounds.x();
         offset->fY = inputBounds.y();
         return input->makeSubset(inputBounds.makeOffset(-inputOffset.x(),
-                                                        -inputOffset.y())).release();
+                                                        -inputOffset.y()));
     }
 
     SkPixmap inputPixmap;
@@ -214,7 +215,7 @@
     return SkSpecialImage::MakeFromRaster(source->internal_getProxy(), 
                                           SkIRect::MakeWH(dstBounds.width(),
                                                           dstBounds.height()),
-                                          dst).release();
+                                          dst);
 }
 
 
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index a93997f..1e2cdac 100644
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -52,10 +52,11 @@
     buffer.writeFlattenable(fColorFilter.get());
 }
 
-SkSpecialImage* SkColorFilterImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                        SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* source,
+                                                              const Context& ctx,
+                                                              SkIPoint* offset) const {
     SkIPoint inputOffset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
+    sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
     if (!input) {
         return nullptr;
     }
@@ -91,7 +92,7 @@
 
     offset->fX = bounds.fLeft;
     offset->fY = bounds.fTop;
-    return surf->makeImageSnapshot().release();
+    return surf->makeImageSnapshot();
 }
 
 bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const {
diff --git a/src/effects/SkComposeImageFilter.cpp b/src/effects/SkComposeImageFilter.cpp
index 86a4d50..c6722d5 100644
--- a/src/effects/SkComposeImageFilter.cpp
+++ b/src/effects/SkComposeImageFilter.cpp
@@ -19,8 +19,9 @@
     return outer->computeFastBounds(inner->computeFastBounds(src));
 }
 
-SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                    SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source,
+                                                          const Context& ctx,
+                                                          SkIPoint* offset) const {
     // The bounds passed to the inner filter must be filtered by the outer
     // filter, so that the inner filter produces the pixels that the outer
     // filter requires as input. This matters if the outer filter moves pixels.
@@ -28,7 +29,7 @@
     innerClipBounds = getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm());
     Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache());
     SkIPoint innerOffset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset));
+    sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &innerOffset));
     if (!inner) {
         return nullptr;
     }
@@ -40,13 +41,13 @@
     Context outerContext(outerMatrix, clipBounds, ctx.cache());
 
     SkIPoint outerOffset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> outer(this->filterInput(0, inner, outerContext, &outerOffset));
+    sk_sp<SkSpecialImage> outer(this->filterInput(0, inner.get(), outerContext, &outerOffset));
     if (!outer) {
         return nullptr;
     }
 
     *offset = innerOffset + outerOffset;
-    return outer.release();
+    return outer;
 }
 
 SkIRect SkComposeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
diff --git a/src/effects/SkDropShadowImageFilter.cpp b/src/effects/SkDropShadowImageFilter.cpp
index 2ae2a12..93c11ca 100644
--- a/src/effects/SkDropShadowImageFilter.cpp
+++ b/src/effects/SkDropShadowImageFilter.cpp
@@ -51,10 +51,11 @@
     buffer.writeInt(static_cast<int>(fShadowMode));
 }
 
-SkSpecialImage* SkDropShadowImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                       SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkDropShadowImageFilter::onFilterImage(SkSpecialImage* source,
+                                                             const Context& ctx,
+                                                             SkIPoint* offset) const {
     SkIPoint inputOffset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
+    sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
     if (!input) {
         return nullptr;
     }
@@ -101,7 +102,7 @@
     }
     offset->fX = bounds.fLeft;
     offset->fY = bounds.fTop;
-    return surf->makeImageSnapshot().release();
+    return surf->makeImageSnapshot();
 }
 
 SkRect SkDropShadowImageFilter::computeFastBounds(const SkRect& src) const {
diff --git a/src/effects/SkImageSource.cpp b/src/effects/SkImageSource.cpp
index d63eda9..f095df6 100644
--- a/src/effects/SkImageSource.cpp
+++ b/src/effects/SkImageSource.cpp
@@ -65,8 +65,8 @@
     buffer.writeImage(fImage.get());
 }
 
-SkSpecialImage* SkImageSource::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                             SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkImageSource::onFilterImage(SkSpecialImage* source, const Context& ctx,
+                                                   SkIPoint* offset) const {
     SkRect dstRect;
     ctx.ctm().mapRect(&dstRect, fDstRect);
 
@@ -76,7 +76,7 @@
         offset->fX = offset->fY = 0;
         return SkSpecialImage::MakeFromImage(source->internal_getProxy(),
                                              SkIRect::MakeWH(fImage->width(), fImage->height()),
-                                             fImage).release();
+                                             fImage);
     }
 
     const SkIRect dstIRect = dstRect.roundOut();
@@ -110,7 +110,7 @@
 
     offset->fX = dstIRect.fLeft;
     offset->fY = dstIRect.fTop;
-    return surf->makeImageSnapshot().release();
+    return surf->makeImageSnapshot();
 }
 
 SkRect SkImageSource::computeFastBounds(const SkRect& src) const {
diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp
index 01373b2..e3b99c6 100755
--- a/src/effects/SkMergeImageFilter.cpp
+++ b/src/effects/SkMergeImageFilter.cpp
@@ -57,8 +57,8 @@
     }
 }
 
-SkSpecialImage* SkMergeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
-                                                  SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkMergeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
+                                                        SkIPoint* offset) const {
     int inputCount = this->countInputs();
     if (inputCount < 1) {
         return nullptr;
@@ -67,14 +67,13 @@
     SkIRect bounds;
     bounds.setEmpty();
 
-    SkAutoTDeleteArray<SkAutoTUnref<SkSpecialImage>> inputs(
-                                                    new SkAutoTUnref<SkSpecialImage>[inputCount]);
+    SkAutoTDeleteArray<sk_sp<SkSpecialImage>> inputs(new sk_sp<SkSpecialImage>[inputCount]);
     SkAutoTDeleteArray<SkIPoint> offsets(new SkIPoint[inputCount]);
 
     // Filter all of the inputs.
     for (int i = 0; i < inputCount; ++i) {
         offsets[i].setZero();
-        inputs[i].reset(this->filterInput(i, source, ctx, &offsets[i]));
+        inputs[i] = this->filterInput(i, source, ctx, &offsets[i]);
         if (!inputs[i]) {
             continue;
         }
@@ -126,7 +125,7 @@
 
     offset->fX = bounds.left();
     offset->fY = bounds.top();
-    return surf->makeImageSnapshot().release();
+    return surf->makeImageSnapshot();
 }
 
 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp
index 8e4b878..05df229 100644
--- a/src/effects/SkOffsetImageFilter.cpp
+++ b/src/effects/SkOffsetImageFilter.cpp
@@ -15,11 +15,11 @@
 #include "SkSpecialSurface.h"
 #include "SkWriteBuffer.h"
 
-SkSpecialImage* SkOffsetImageFilter::onFilterImage(SkSpecialImage* source,
-                                                   const Context& ctx,
-                                                   SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkOffsetImageFilter::onFilterImage(SkSpecialImage* source,
+                                                         const Context& ctx,
+                                                         SkIPoint* offset) const {
     SkIPoint srcOffset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &srcOffset));
+    sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &srcOffset));
     if (!input) {
         return nullptr;
     }
@@ -30,7 +30,7 @@
     if (!this->cropRectIsSet()) {
         offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX);
         offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY);
-        return input.release();
+        return input;
     } else {
         SkIRect bounds;
         SkIRect srcBounds = SkIRect::MakeWH(input->width(), input->height());
@@ -61,7 +61,7 @@
 
         offset->fX = bounds.fLeft;
         offset->fY = bounds.fTop;
-        return surf->makeImageSnapshot().release();
+        return surf->makeImageSnapshot();
     }
 }
 
diff --git a/src/effects/SkPaintImageFilter.cpp b/src/effects/SkPaintImageFilter.cpp
index 02387ce..7056f26 100644
--- a/src/effects/SkPaintImageFilter.cpp
+++ b/src/effects/SkPaintImageFilter.cpp
@@ -33,9 +33,9 @@
     buffer.writePaint(fPaint);
 }
 
-SkSpecialImage* SkPaintImageFilter::onFilterImage(SkSpecialImage* source,
-                                                  const Context& ctx,
-                                                  SkIPoint* offset) const {
+sk_sp<SkSpecialImage> SkPaintImageFilter::onFilterImage(SkSpecialImage* source,
+                                                        const Context& ctx,
+                                                        SkIPoint* offset) const {
     SkIRect bounds;
     const SkIRect srcBounds = SkIRect::MakeWH(source->width(), source->height());
     if (!this->applyCropRect(ctx, srcBounds, &bounds)) {
@@ -67,7 +67,7 @@
 
     offset->fX = bounds.fLeft;
     offset->fY = bounds.fTop;
-    return surf->makeImageSnapshot().release();
+    return surf->makeImageSnapshot();
 }
 
 bool SkPaintImageFilter::canComputeFastBounds() const {
diff --git a/src/gpu/GrLayerHoister.cpp b/src/gpu/GrLayerHoister.cpp
index f1a51a8..80ea3cd 100644
--- a/src/gpu/GrLayerHoister.cpp
+++ b/src/gpu/GrLayerHoister.cpp
@@ -309,9 +309,9 @@
                                                           layer->texture()));
 
     SkIPoint offset = SkIPoint::Make(0, 0);
-    SkAutoTUnref<SkSpecialImage> result(layer->filter()->filterImage(img.get(),
-                                                                     filterContext,
-                                                                     &offset));
+    sk_sp<SkSpecialImage> result(layer->filter()->filterImage(img.get(),
+                                                              filterContext,
+                                                              &offset));
     if (!result) {
         // Filtering failed. Press on with the unfiltered version.
         return;
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index dc1edd4..724d77b 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -226,10 +226,10 @@
 // gpu-specific paths. This mirrors SkCanvas::internalDrawDevice (the other
 // use of SkImageFilter::filterImage) in that the source and dest will have
 // homogenous backing (e.g., raster or gpu).
-void SkGpuDevice::drawBitmapAsSpriteWithImageFilter(const SkDraw& draw, const SkBitmap& bitmap,
-                                                    int x, int y, const SkPaint& paint) {
+void SkGpuDevice::drawSpriteWithFilter(const SkDraw& draw, const SkBitmap& bitmap,
+                                       int x, int y, const SkPaint& paint) {
     if (bitmap.getTexture()) {
-        INHERITED::drawBitmapAsSpriteWithImageFilter(draw, bitmap, x, y, paint);
+        INHERITED::drawSpriteWithFilter(draw, bitmap, x, y, paint);
         return;
     }
 
@@ -250,7 +250,7 @@
     GrWrapTextureInBitmap(texture, texture->width(), texture->height(),
                           bitmap.isOpaque(), &newBitmap);
 
-    INHERITED::drawBitmapAsSpriteWithImageFilter(draw, newBitmap, x, y, paint);
+    INHERITED::drawSpriteWithFilter(draw, newBitmap, x, y, paint);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index 23e3d64..7f9041b 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -262,8 +262,8 @@
     static GrRenderTarget* CreateRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&,
                                               int sampleCount, GrTextureStorageAllocator);
 
-    void drawBitmapAsSpriteWithImageFilter(const SkDraw&, const SkBitmap&, int x, int y,
-                                           const SkPaint&) override;
+    void drawSpriteWithFilter(const SkDraw&, const SkBitmap&, int x, int y,
+                              const SkPaint&) override;
 
     friend class GrAtlasTextContext;
     friend class SkSurface_Gpu;      // for access to surfaceProps
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index acdd369..89f5061 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -459,7 +459,7 @@
         SkImageFilter* filter = filters.getFilter(i);
         SkIPoint offset;
         SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
-        SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
+        sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
         REPORTER_ASSERT_MESSAGE(reporter, resultImg, filters.getName(i));
         REPORTER_ASSERT_MESSAGE(reporter, offset.fX == 20 && offset.fY == 30, filters.getName(i));
     }
@@ -484,36 +484,34 @@
     SkIPoint offset;
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> positiveResult1(positiveFilter->filterImage(imgSrc.get(),
-                                                                             ctx, &offset));
+    sk_sp<SkSpecialImage> positiveResult1(positiveFilter->filterImage(imgSrc.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, positiveResult1);
 
-    SkAutoTUnref<SkSpecialImage> negativeResult1(negativeFilter->filterImage(imgSrc.get(),
-                                                                             ctx, &offset));
+    sk_sp<SkSpecialImage> negativeResult1(negativeFilter->filterImage(imgSrc.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, negativeResult1);
 
     SkMatrix negativeScale;
     negativeScale.setScale(-SK_Scalar1, SK_Scalar1);
     SkImageFilter::Context negativeCTX(negativeScale, SkIRect::MakeWH(32, 32), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> negativeResult2(positiveFilter->filterImage(imgSrc.get(),
-                                                                             negativeCTX,
-                                                                             &offset));
+    sk_sp<SkSpecialImage> negativeResult2(positiveFilter->filterImage(imgSrc.get(),
+                                                                      negativeCTX,
+                                                                      &offset));
     REPORTER_ASSERT(reporter, negativeResult2);
 
-    SkAutoTUnref<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc.get(),
-                                                                             negativeCTX,
-                                                                             &offset));
+    sk_sp<SkSpecialImage> positiveResult2(negativeFilter->filterImage(imgSrc.get(),
+                                                                      negativeCTX,
+                                                                      &offset));
     REPORTER_ASSERT(reporter, positiveResult2);
 
 
     SkBitmap positiveResultBM1, positiveResultBM2;
     SkBitmap negativeResultBM1, negativeResultBM2;
 
-    TestingSpecialImageAccess::GetROPixels(positiveResult1, &positiveResultBM1);
-    TestingSpecialImageAccess::GetROPixels(positiveResult2, &positiveResultBM2);
-    TestingSpecialImageAccess::GetROPixels(negativeResult1, &negativeResultBM1);
-    TestingSpecialImageAccess::GetROPixels(negativeResult2, &negativeResultBM2);
+    TestingSpecialImageAccess::GetROPixels(positiveResult1.get(), &positiveResultBM1);
+    TestingSpecialImageAccess::GetROPixels(positiveResult2.get(), &positiveResultBM2);
+    TestingSpecialImageAccess::GetROPixels(negativeResult1.get(), &negativeResultBM1);
+    TestingSpecialImageAccess::GetROPixels(negativeResult2.get(), &negativeResultBM2);
 
     SkAutoLockPixels lockP1(positiveResultBM1);
     SkAutoLockPixels lockP2(positiveResultBM2);
@@ -606,14 +604,14 @@
     SkIPoint offset;
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(32, 32), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &offset));
+    sk_sp<SkSpecialImage> result(filter->filterImage(image.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, offset.fX == 5 && offset.fY == 0);
     REPORTER_ASSERT(reporter, result);
     REPORTER_ASSERT(reporter, result->width() == 5 && result->height() == 10);
 
     SkBitmap resultBM;
 
-    TestingSpecialImageAccess::GetROPixels(result, &resultBM);
+    TestingSpecialImageAccess::GetROPixels(result.get(), &resultBM);
 
     SkAutoLockPixels lock(resultBM);
     for (int y = 0; y < resultBM.height(); y++) {
@@ -835,7 +833,7 @@
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(0, 0, 100, 100), nullptr);
     SkIPoint offset;
 
-    SkAutoTUnref<SkSpecialImage> resultImg(merge->filterImage(srcImg.get(), ctx, &offset));
+    sk_sp<SkSpecialImage> resultImg(merge->filterImage(srcImg.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, resultImg);
 
     REPORTER_ASSERT(reporter, resultImg->width() == 20 && resultImg->height() == 20);
@@ -1099,7 +1097,7 @@
     SkIPoint offset;
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeXYWH(1, 1, 1, 1), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get(), ctx, &offset));
+    sk_sp<SkSpecialImage> resultImage(imageFilter->filterImage(srcImg.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, !resultImage);
 }
 
@@ -1353,7 +1351,7 @@
     SkIPoint offset;
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.get(), ctx, &offset));
+    sk_sp<SkSpecialImage> resultImg(composedFilter->filterImage(srcImg.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, resultImg);
     REPORTER_ASSERT(reporter, offset.fX == 1 && offset.fY == 0);
 }
@@ -1424,7 +1422,7 @@
     SkIPoint offset;
     SkImageFilter::Context ctx(SkMatrix::I(), SkIRect::MakeWH(100, 100), nullptr);
 
-    SkAutoTUnref<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
+    sk_sp<SkSpecialImage> resultImg(filter->filterImage(srcImg.get(), ctx, &offset));
     REPORTER_ASSERT(reporter, resultImg);
 
     REPORTER_ASSERT(reporter, offset.fX == 0);