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); |