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

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, 9 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
« no previous file with comments | « src/effects/SkOffsetImageFilter.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkPictureImageFilter.cpp
diff --git a/src/effects/SkPictureImageFilter.cpp b/src/effects/SkPictureImageFilter.cpp
index baae6f8c674c9fc22b9eafbf4d5f68f7015eea80..dfedc37e7045e459fc4a1968f8d13f78f8b489ca 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,8 +178,8 @@ void SkPictureImageFilter::drawPictureAtLocalResolution(Proxy* proxy, SkBaseDevi
canvas.concat(ctx.ctm());
SkPaint paint;
paint.setFilterQuality(fFilterQuality);
- canvas.drawBitmap(localDevice.get()->accessBitmap(false), SkIntToScalar(localIBounds.fLeft),
- SkIntToScalar(localIBounds.fTop), &paint);
+ canvas.drawImage(image, SkIntToScalar(localIBounds.fLeft),
+ SkIntToScalar(localIBounds.fTop), &paint);
//canvas.drawPicture(fPicture);
}
« no previous file with comments | « src/effects/SkOffsetImageFilter.cpp ('k') | src/effects/SkRectShaderImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698