diff options
author | senorblanco <senorblanco@chromium.org> | 2016-03-31 08:24:29 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-31 08:24:30 -0700 |
commit | 9db0427423db995618e3bbf6da5dc6d69442436a (patch) | |
tree | 5859d33dffbe10425f82e30723828d07c3e32a16 /gm/xfermodeimagefilter.cpp | |
parent | 2ae4b2e95ddd36ede0d3cbc4d274b6d6618a049d (diff) |
Image filters: fix crop rect application in SkXfermodeImageFilter.
The crop rect was being incorrectly applied in SkXfermodeImageFilter:
the background and foreground bounds were having the crop rect applied
individually to them, and then unioned. The correct approach is to take
the union of their bounds, and apply the crop rect to that. (A similar
bug in SkMergeImageFilter was fixed a while back.)
This is important when applying a compositing mode
which affects pixels outside the foreground bounds
(e.g., SrcIn, SrcOut).
NOTE: this will change the results of the xfermodeimagefilter GM (new
test case).
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1842033005
Review URL: https://codereview.chromium.org/1842033005
Diffstat (limited to 'gm/xfermodeimagefilter.cpp')
-rw-r--r-- | gm/xfermodeimagefilter.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gm/xfermodeimagefilter.cpp b/gm/xfermodeimagefilter.cpp index 90e2dd0c2b..5603c78456 100644 --- a/gm/xfermodeimagefilter.cpp +++ b/gm/xfermodeimagefilter.cpp @@ -183,6 +183,18 @@ protected: x = 0; y += fBitmap.height() + MARGIN; } + // Test small fg, large bg with SrcIn with a crop that forces it to full size. + // This tests that SkXfermodeImageFilter correctly applies the compositing mode to + // the region outside the foreground. + mode = SkXfermode::Make(SkXfermode::kSrcIn_Mode); + SkImageFilter::CropRect cropRectFull(SkRect::MakeXYWH(0, 0, 80, 80)); + paint.setImageFilter(SkXfermodeImageFilter::Make(mode, background, cropped, &cropRectFull)); + DrawClippedPaint(canvas, clipRect, paint, x, y); + x += fBitmap.width() + MARGIN; + if (x + fBitmap.width() > WIDTH) { + x = 0; + y += fBitmap.height() + MARGIN; + } } private: |