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

Unified Diff: src/effects/SkMatrixImageFilter.cpp

Issue 920513003: Make filters use SkImage instead of SkBitmap Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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
Index: src/effects/SkMatrixImageFilter.cpp
diff --git a/src/effects/SkMatrixImageFilter.cpp b/src/effects/SkMatrixImageFilter.cpp
index 4d9b1fa33517130f083500a31092c9125d88424d..b4eaff33534f966755700f305ecf9eda37b3fc70 100644
--- a/src/effects/SkMatrixImageFilter.cpp
+++ b/src/effects/SkMatrixImageFilter.cpp
@@ -8,7 +8,7 @@
#include "SkMatrixImageFilter.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
-#include "SkDevice.h"
+#include "SkSurface.h"
#include "SkColorPriv.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
@@ -49,19 +49,18 @@ SkMatrixImageFilter::~SkMatrixImageFilter() {
}
bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
- const SkBitmap& source,
+ SkImage& source,
const Context& ctx,
- SkBitmap* result,
+ SkAutoTUnref<SkImage>& result,
SkIPoint* offset) const {
- SkBitmap src = source;
+ SkAutoTUnref<SkImage> src(SkRef(&source));
SkIPoint srcOffset = SkIPoint::Make(0, 0);
- if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
+ if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, src, &srcOffset)) {
return false;
}
SkRect dstRect;
- SkIRect srcBounds, dstBounds;
- src.getBounds(&srcBounds);
+ SkIRect srcBounds = SkIRect::MakeWH(src->width(), src->height());
srcBounds.offset(srcOffset);
SkRect srcRect = SkRect::Make(srcBounds);
SkMatrix matrix;
@@ -71,23 +70,28 @@ bool SkMatrixImageFilter::onFilterImage(Proxy* proxy,
matrix.postConcat(fTransform);
matrix.postConcat(ctx.ctm());
matrix.mapRect(&dstRect, srcRect);
+ SkIRect dstBounds;
dstRect.roundOut(&dstBounds);
- SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstBounds.width(), dstBounds.height()));
- if (NULL == device.get()) {
+ SkAutoTUnref<SkSurface> surface(proxy->createSurface(dstBounds.width(), dstBounds.height()));
+ if (NULL == surface) {
return false;
}
- SkCanvas canvas(device.get());
- canvas.translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
- canvas.concat(matrix);
+ SkCanvas* canvas = surface->getCanvas();
+ canvas->translate(-SkIntToScalar(dstBounds.x()), -SkIntToScalar(dstBounds.y()));
+ canvas->concat(matrix);
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setFilterLevel(fFilterLevel);
- canvas.drawBitmap(src, srcRect.x(), srcRect.y(), &paint);
+ canvas->drawImage(src, srcRect.x(), srcRect.y(), &paint);
- *result = device.get()->accessBitmap(false);
+ SkImage* image = surface->newImageSnapshot(SkSurface::kYes_Budgeted);
+ if (NULL == image) {
+ return false;
+ }
+ result.reset(image);
offset->fX = dstBounds.fLeft;
offset->fY = dstBounds.fTop;
return true;

Powered by Google App Engine
This is Rietveld 408576698