Switch internal testing ImageFilters over to new onFilterImage interface
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1854133002

Review URL: https://codereview.chromium.org/1854133002
diff --git a/gm/imagefiltersbase.cpp b/gm/imagefiltersbase.cpp
index be4325e..e2e9235 100644
--- a/gm/imagefiltersbase.cpp
+++ b/gm/imagefiltersbase.cpp
@@ -14,6 +14,7 @@
 #include "SkBlurImageFilter.h"
 #include "SkColorFilterImageFilter.h"
 #include "SkDropShadowImageFilter.h"
+#include "SkSpecialImage.h"
 #include "SkTestImageFilters.h"
 
 class FailImageFilter : public SkImageFilter {
@@ -36,9 +37,9 @@
 protected:
     FailImageFilter() : INHERITED(nullptr, 0, nullptr) {}
 
-    bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
-                                 SkBitmap* result, SkIPoint* offset) const override {
-        return false;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override {
+        return nullptr;
     }
 
 private:
@@ -77,11 +78,10 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(IdentityImageFilter)
 
 protected:
-    bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
-                                 SkBitmap* result, SkIPoint* offset) const override {
-        *result = src;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override {
         offset->set(0, 0);
-        return true;
+        return sk_ref_sp<SkSpecialImage>(source);
     }
 
 private:
diff --git a/gm/imagefiltersgraph.cpp b/gm/imagefiltersgraph.cpp
index dd9c37c..e7bcf70 100644
--- a/gm/imagefiltersgraph.cpp
+++ b/gm/imagefiltersgraph.cpp
@@ -8,7 +8,6 @@
 #include "gm.h"
 
 #include "SkArithmeticMode.h"
-#include "SkDevice.h"
 #include "SkBlurImageFilter.h"
 #include "SkColorFilter.h"
 #include "SkColorFilterImageFilter.h"
@@ -17,6 +16,8 @@
 #include "SkImageSource.h"
 #include "SkMatrixConvolutionImageFilter.h"
 #include "SkReadBuffer.h"
+#include "SkSpecialImage.h"
+#include "SkSpecialSurface.h"
 #include "SkWriteBuffer.h"
 #include "SkMergeImageFilter.h"
 #include "SkMorphologyImageFilter.h"
@@ -43,28 +44,38 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SimpleOffsetFilter);
 
 protected:
-    bool onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src, const Context& ctx,
-                                 SkBitmap* dst, SkIPoint* offset) const override {
-        SkBitmap source = src;
-        SkIPoint srcOffset = SkIPoint::Make(0, 0);
-        if (!this->filterInputDeprecated(0, proxy, src, ctx, &source, &srcOffset)) {
-            return false;
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
+                                        SkIPoint* offset) const override {
+        SkIPoint inputOffset = SkIPoint::Make(0, 0);
+        sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset));
+        if (!input) {
+            return nullptr;
         }
 
         SkIRect bounds;
-        if (!this->applyCropRectDeprecated(ctx, proxy, source, &srcOffset, &bounds, &source)) {
-            return false;
+        input = this->applyCropRect(ctx, input.get(), &inputOffset, &bounds);
+        if (!input) {
+            return nullptr;
         }
 
-        SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
-        SkCanvas canvas(device);
+        SkImageInfo info = SkImageInfo::MakeN32Premul(bounds.width(), bounds.height());
+
+        sk_sp<SkSpecialSurface> surf(source->makeSurface(info));
+        if (!surf) {
+            return nullptr;
+        }
+
+        SkCanvas* canvas = surf->getCanvas();
+        SkASSERT(canvas);
+
         SkPaint paint;
         paint.setXfermodeMode(SkXfermode::kSrc_Mode);
-        canvas.drawBitmap(source, fDX - bounds.left(), fDY - bounds.top(), &paint);
-        *dst = device->accessBitmap(false);
+
+        input->draw(canvas, fDX - bounds.left(), fDY - bounds.top(), &paint);
+
         offset->fX += bounds.left();
         offset->fY += bounds.top();
-        return true;
+        return surf->makeImageSnapshot();
     }
 
     void flatten(SkWriteBuffer& buffer) const override {
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index 48d3147..e6430b4 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -60,10 +60,11 @@
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(MatrixTestImageFilter)
 
 protected:
-    bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context& ctx,
-                                 SkBitmap* result, SkIPoint* offset) const override {
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context& ctx,
+                                        SkIPoint* offset) const override {
         REPORTER_ASSERT(fReporter, ctx.ctm() == fExpectedMatrix);
-        return true;
+        offset->fX = offset->fY = 0;
+        return sk_ref_sp<SkSpecialImage>(source);
     }
 
     void flatten(SkWriteBuffer& buffer) const override {
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index ac3b28b..299fcf0 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -21,6 +21,7 @@
 #include "SkPDFUtils.h"
 #include "SkReadBuffer.h"
 #include "SkScalar.h"
+#include "SkSpecialImage.h"
 #include "SkStream.h"
 #include "SkTypes.h"
 #include "Test.h"
@@ -373,12 +374,11 @@
     bool visited() const { return fVisited; }
 
 protected:
-    bool onFilterImageDeprecated(Proxy*, const SkBitmap& src, const Context&,
-                                 SkBitmap* result, SkIPoint* offset) const override {
+    sk_sp<SkSpecialImage> onFilterImage(SkSpecialImage* source, const Context&,
+                                        SkIPoint* offset) const override {
         fVisited = true;
         offset->fX = offset->fY = 0;
-        *result = src;
-        return true;
+        return sk_ref_sp<SkSpecialImage>(source);
     }
 
 private: