Fix SkXfermodeImageFilter GPU fast path for differing sizes.
The GPU fast path was not doing the correct thing for input bitmaps of
differing sizes. This change brings the fast path in line with the
slow path: use the union of foreground and background bounds as bounds,
offset the draw context by the bounds translation, and translate the
foreground and background independently by their respective offsets.
Finally, we add a texture domain for the background fragment
processor, since we may access texels outside its domain.
Note: this adds two new test cases to the xfermodeimagefilter GM, so
those will need to be rebaselined.
BUG=568196
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1588633002
Review URL: https://codereview.chromium.org/1588633002
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index bb86cef..85bbf44 100644
--- a/gm/xfermodeimagefilter.cpp
+++ b/gm/xfermodeimagefilter.cpp
@@ -14,7 +14,7 @@
#include "SkXfermodeImageFilter.h"
#define WIDTH 600
-#define HEIGHT 600
+#define HEIGHT 700
#define MARGIN 12
namespace skiagm {
@@ -169,6 +169,28 @@
y += fBitmap.height() + MARGIN;
}
}
+ // Test small bg, large fg with Screen (uses shader blend)
+ mode.reset(SkXfermode::Create(SkXfermode::kScreen_Mode));
+ SkImageFilter::CropRect cropRect(SkRect::MakeXYWH(10, 10, 60, 60));
+ SkAutoTUnref<SkImageFilter> cropped(
+ SkOffsetImageFilter::Create(0, 0, foreground, &cropRect));
+ filter.reset(SkXfermodeImageFilter::Create(mode, cropped, background));
+ paint.setImageFilter(filter);
+ DrawClippedPaint(canvas, clipRect, paint, x, y);
+ x += fBitmap.width() + MARGIN;
+ if (x + fBitmap.width() > WIDTH) {
+ x = 0;
+ y += fBitmap.height() + MARGIN;
+ }
+ // Test small fg, large bg with Screen (uses shader blend)
+ filter.reset(SkXfermodeImageFilter::Create(mode, background, cropped));
+ paint.setImageFilter(filter);
+ DrawClippedPaint(canvas, clipRect, paint, x, y);
+ x += fBitmap.width() + MARGIN;
+ if (x + fBitmap.width() > WIDTH) {
+ x = 0;
+ y += fBitmap.height() + MARGIN;
+ }
}
private: