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

Unified Diff: src/effects/SkPictureImageFilter.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/SkPictureImageFilter.cpp
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index 391af1116927aca5903923a65b28aa780e52f5ed..72a8d86ef4721d80a79f601111707ea453d48fb3 100644
--- a/src/effects/SkPictureImageFilter.cpp
+++ b/src/effects/SkPictureImageFilter.cpp
@@ -90,8 +90,8 @@ void SkPictureImageFilter::flatten(SkWriteBuffer& buffer) const {
}
}
-bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const {
+bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkImage*, const Context& ctx,
+ SkAutoTUnref<const SkImage>& result, SkIPoint* offset) const {
if (!fPicture) {
offset->fX = offset->fY = 0;
return true;
@@ -121,7 +121,12 @@ bool SkPictureImageFilter::onFilterImage(Proxy* proxy, const SkBitmap&, const Co
drawPictureAtLocalResolution(proxy, device.get(), bounds, ctx);
}
- *result = device.get()->accessBitmap(false);
+ SkImage* snapshot = device->newImageSnapshot();
+ if (NULL == snapshot) {
+ return false;
+ }
+ result.reset(snapshot);
+
offset->fX = bounds.fLeft;
offset->fY = bounds.fTop;
return true;
@@ -160,6 +165,10 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
localCanvas.translate(-SkIntToScalar(localIBounds.fLeft), -SkIntToScalar(localIBounds.fTop));
localCanvas.drawPicture(fPicture);
+ SkAutoTUnref<SkImage> image(localDevice->newImageSnapshot());
+ if (NULL == image) {
+ return;
+ }
// Pass explicit surface props, as the simplified canvas constructor discards device properties.
// FIXME: switch back to the public constructor (and unfriend) after
// https://code.google.com/p/skia/issues/detail?id=3142 is fixed.
@@ -169,7 +178,7 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
canvas.concat(ctx.ctm());
SkPaint paint;
paint.setFilterLevel(fFilterLevel);
- canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(localIBounds.fLeft),
+ canvas.drawImage(image, SkIntToScalar(localIBounds.fLeft),
SkIntToScalar(localIBounds.fTop), &paint);
//canvas.drawPicture(fPicture);
}

Powered by Google App Engine
This is Rietveld 408576698