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

Unified Diff: src/effects/SkMergeImageFilter.cpp

Issue 1763223002: Switch SkMergeImageFilter over to new onFilterImage interface (Closed) Base URL: https://skia.googlesource.com/skia.git@if-follow-on
Patch Set: Remove extraneous files Created 4 years, 10 months 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
« src/core/SkImageFilter.cpp ('K') | « src/core/SkImageFilter.cpp ('k') | no next file » | 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 79e5329ef1455e0c5d57cd0512db5de956ff6a71..76a618da9927d92e26afd7f485947d2cf09f4037 100755
--- a/src/effects/SkMergeImageFilter.cpp
+++ b/src/effects/SkMergeImageFilter.cpp
@@ -6,9 +6,11 @@
*/
#include "SkMergeImageFilter.h"
+
#include "SkCanvas.h"
-#include "SkDevice.h"
#include "SkReadBuffer.h"
+#include "SkSpecialImage.h"
+#include "SkSpecialSurface.h"
#include "SkWriteBuffer.h"
#include "SkValidationUtils.h"
@@ -55,72 +57,76 @@ SkMergeImageFilter::~SkMergeImageFilter() {
}
}
-bool SkMergeImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap& src,
- const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const {
+SkSpecialImage* SkMergeImageFilter::onFilterImage(SkSpecialImage* srcIn, const Context& ctx,
Stephen White 2016/03/07 18:58:25 Let's just call it "source".
robertphillips 2016/03/08 15:44:22 Done.
+ SkIPoint* offset) const {
int inputCount = this->countInputs();
if (inputCount < 1) {
- return false;
+ return nullptr;
}
SkIRect bounds;
+ bounds.setEmpty();
- SkAutoTDeleteArray<SkBitmap> inputs(new SkBitmap[inputCount]);
+ SkAutoTDeleteArray<SkAutoTUnref<SkSpecialImage>> inputs(
+ new SkAutoTUnref<SkSpecialImage>[inputCount]);
SkAutoTDeleteArray<SkIPoint> offsets(new SkIPoint[inputCount]);
- bool didProduceResult = false;
// Filter all of the inputs.
for (int i = 0; i < inputCount; ++i) {
- inputs[i] = src;
offsets[i].setZero();
- if (!this->filterInputDeprecated(i, proxy, src, ctx, &inputs[i], &offsets[i])) {
- inputs[i].reset();
+ inputs[i].reset(this->filterInput(i, srcIn, ctx, &offsets[i]));
+ if (!inputs[i]) {
continue;
}
- SkIRect srcBounds;
- inputs[i].getBounds(&srcBounds);
- srcBounds.offset(offsets[i]);
- if (!didProduceResult) {
- bounds = srcBounds;
- didProduceResult = true;
- } else {
- bounds.join(srcBounds);
- }
+ const SkIRect srcBounds = SkIRect::MakeXYWH(offsets[i].fX, offsets[i].fY,
Stephen White 2016/03/07 18:58:25 Let's rename this to inputBounds for consistency.
robertphillips 2016/03/08 15:44:22 Done.
+ inputs[i]->width(), inputs[i]->height());
+ bounds.join(srcBounds);
}
- if (!didProduceResult) {
- return false;
+ if (bounds.isEmpty()) {
+ return nullptr;
}
// Apply the crop rect to the union of the inputs' bounds.
this->getCropRect().applyTo(bounds, ctx.ctm(), &bounds);
if (!bounds.intersect(ctx.clipBounds())) {
- return false;
+ return nullptr;
}
const int x0 = bounds.left();
const int y0 = bounds.top();
- // Allocate the destination buffer.
- SkAutoTUnref<SkBaseDevice> dst(proxy->createDevice(bounds.width(), bounds.height()));
- if (nullptr == dst) {
- return false;
+ SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(),
+ kPremul_SkAlphaType);
+
+ SkAutoTUnref<SkSpecialSurface> surf(srcIn->newSurface(info));
+ if (!surf) {
+ return nullptr;
}
- SkCanvas canvas(dst);
+
+ SkCanvas* canvas = surf->getCanvas();
+ SkASSERT(canvas);
+
+ canvas->clear(0x0);
Stephen White 2016/03/07 18:58:25 Is there a way we could just have newSurface() ret
robertphillips 2016/03/08 15:44:22 I would like to skip clears when they aren't neces
// Composite all of the filter inputs.
for (int i = 0; i < inputCount; ++i) {
+ if (!inputs[i]) {
+ continue;
+ }
+
SkPaint paint;
if (fModes) {
paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
}
- canvas.drawBitmap(inputs[i], SkIntToScalar(offsets[i].x() - x0),
- SkIntToScalar(offsets[i].y() - y0), &paint);
+
+ inputs[i]->draw(canvas,
+ SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offsets[i].y() - y0),
+ &paint);
}
offset->fX = bounds.left();
offset->fY = bounds.top();
- *result = dst->accessBitmap(false);
- return true;
+ return surf->newImageSnapshot();
}
SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
« src/core/SkImageFilter.cpp ('K') | « src/core/SkImageFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698