aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/xfermodeimagefilter.cpp
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2016-01-13 13:48:54 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-13 13:48:54 -0800
commit06d54ad09a03edd62d597b2ba67ad3c05944fd92 (patch)
treeee49b7753bb88f67f2161dd0283344c141428e8b /gm/xfermodeimagefilter.cpp
parentf8aec588bfd2df17130ee93593a8f4ae781afe1f (diff)
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
Diffstat (limited to 'gm/xfermodeimagefilter.cpp')
-rw-r--r--gm/xfermodeimagefilter.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp
index bb86ceffa8..85bbf44765 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 @@ protected:
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: