Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Unified Diff: src/effects/SkMergeImageFilter.cpp

Issue 1475793002: Fix merge crop rect computation. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix uninitialized var, and restore abort-on-no-valid-inputs behaviour. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMergeImageFilter.cpp
diff --git a/src/effects/SkMergeImageFilter.cpp b/src/effects/SkMergeImageFilter.cpp
index d6f0eaa794bcacaa7801d993bb15fe3cece0e98b..8782f89a6ef416f3c07c8a2fad0416a339655da5 100755
--- a/src/effects/SkMergeImageFilter.cpp
+++ b/src/effects/SkMergeImageFilter.cpp
@@ -63,7 +63,32 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
}
SkIRect bounds;
- if (!this->applyCropRect(ctx, src, SkIPoint::Make(0, 0), &bounds)) {
+
robertphillips 2015/11/24 20:58:16 this->countInputs() ? // Basically move the CL's
Stephen White 2015/11/24 21:15:53 Done (here and elsewhere).
+ int inputCount = countInputs();
+ SkAutoTDeleteArray<SkBitmap> inputs(new SkBitmap[inputCount]);
+ SkAutoTDeleteArray<SkIPoint> offsets(new SkIPoint[inputCount]);
+ bool didProduceResult = false;
+ for (int i = 0; i < inputCount; ++i) {
+ inputs[i] = src;
+ offsets[i].setZero();
+ if (!this->filterInput(i, proxy, src, ctx, &inputs[i], &offsets[i])) {
+ inputs[i].reset();
+ continue;
+ }
+ SkIRect srcBounds;
+ inputs[i].getBounds(&srcBounds);
+ srcBounds.offset(offsets[i]);
+ if (!didProduceResult) {
+ bounds = srcBounds;
+ didProduceResult = true;
+ } else {
+ bounds.join(srcBounds);
+ }
+ }
+ if (!didProduceResult) {
+ return false;
+ }
+ if (!this->getCropRect().applyTo(bounds, ctx, &bounds)) {
return false;
}
@@ -77,27 +102,15 @@ bool SkMergeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
SkCanvas canvas(dst);
SkPaint paint;
- bool didProduceResult = false;
- int inputCount = countInputs();
for (int i = 0; i < inputCount; ++i) {
robertphillips 2015/11/24 20:58:16 if (!inputs[i]) { continue; } ?
Stephen White 2015/11/24 21:15:53 canvas.drawBitmap() does this as its first line; I
- SkBitmap tmp;
- SkBitmap input = src;
- SkIPoint pos = SkIPoint::Make(0, 0);
- if (!this->filterInput(i, proxy, src, ctx, &input, &pos)) {
- continue;
- }
if (fModes) {
paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
} else {
robertphillips 2015/11/24 20:58:16 Do we actually need this else clause ?
Stephen White 2015/11/24 21:15:53 Good point. Fixed.
paint.setXfermode(nullptr);
}
robertphillips 2015/11/24 20:58:16 \n somewhere ?
Stephen White 2015/11/24 21:15:53 Done.
- canvas.drawBitmap(input, SkIntToScalar(pos.x() - x0), SkIntToScalar(pos.y() - y0), &paint);
- didProduceResult = true;
+ canvas.drawBitmap(inputs[i], SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offsets[i].y() - y0), &paint);
}
- if (!didProduceResult)
- return false;
-
offset->fX = bounds.left();
offset->fY = bounds.top();
*result = dst->accessBitmap(false);
« no previous file with comments | « no previous file | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698