From 9db0427423db995618e3bbf6da5dc6d69442436a Mon Sep 17 00:00:00 2001 From: senorblanco Date: Thu, 31 Mar 2016 08:24:29 -0700 Subject: 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 --- src/effects/SkXfermodeImageFilter.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'src/effects/SkXfermodeImageFilter.cpp') diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp index 3b186039d0..db0b5e59bb 100644 --- a/src/effects/SkXfermodeImageFilter.cpp +++ b/src/effects/SkXfermodeImageFilter.cpp @@ -64,21 +64,13 @@ bool SkXfermodeImageFilter::onFilterImageDeprecated(Proxy* proxy, foreground.reset(); } - SkIRect bounds, foregroundBounds; - SkIRect foregroundSrcBounds = foreground.bounds(); - foregroundSrcBounds.offset(foregroundOffset); - if (!applyCropRect(ctx, foregroundSrcBounds, &foregroundBounds)) { - foregroundBounds.setEmpty(); - foreground.reset(); - } - SkIRect backgroundSrcBounds = background.bounds(); - backgroundSrcBounds.offset(backgroundOffset); - if (!applyCropRect(ctx, backgroundSrcBounds, &bounds)) { - bounds.setEmpty(); - background.reset(); - } - bounds.join(foregroundBounds); - if (bounds.isEmpty()) { + SkIRect foregroundBounds = foreground.bounds(); + foregroundBounds.offset(foregroundOffset); + SkIRect srcBounds = background.bounds(); + srcBounds.offset(backgroundOffset); + srcBounds.join(foregroundBounds); + SkIRect bounds; + if (!this->applyCropRect(ctx, srcBounds, &bounds)) { return false; } -- cgit v1.2.3