change SkImage_Gpu to handle all filters (w/ and w/o gpu support
The result is that the set of "generic" imagefilters (e.g. SkColorFilterImageFilter) that use drawing commands to return their results will now stay in the same domain as their src (i.e. gpu-src --> gpu-dst).
ApplyFilterGM exercises this, and now asserts this same-domain invariant.
BUG=skia:4467
Review URL: https://codereview.chromium.org/1401053003
diff --git a/gm/spritebitmap.cpp b/gm/spritebitmap.cpp
index 5cf0ece..6aac09f 100644
--- a/gm/spritebitmap.cpp
+++ b/gm/spritebitmap.cpp
@@ -141,6 +141,11 @@
// hence this cast function
template <typename T> ImageFilterFactory IFCCast(T arg) { return arg; }
+// We expect that applying the filter will keep us in the same domain (raster or gpu)
+static void check_same_domain(SkImage* a, SkImage* b) {
+ SkASSERT(a->isTextureBacked() == b->isTextureBacked());
+}
+
/**
* Compare output of drawSprite and drawBitmap (esp. clipping and imagefilters)
*/
@@ -180,6 +185,9 @@
SkAutoTUnref<SkImage> image1(image0->applyFilter(filter, &offset1, true));
SkAutoTUnref<SkImage> image2(image0->applyFilter(filter, &offset2, false));
+ check_same_domain(image0, image1);
+ check_same_domain(image0, image2);
+
canvas->save();
canvas->translate(30, 30);
show_image(canvas, image0, SkIPoint::Make(0, 0)); // original