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

Unified Diff: src/effects/SkBitmapSource.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/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkBitmapSource.cpp
diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp
index 87c6053cc4a61e179f66dd8ae11bde744eafa7b7..28375c13032bd5e620c27451ede0588d640f94d6 100644
--- a/src/effects/SkBitmapSource.cpp
+++ b/src/effects/SkBitmapSource.cpp
@@ -6,11 +6,12 @@
*/
#include "SkBitmapSource.h"
-#include "SkDevice.h"
#include "SkCanvas.h"
+#include "SkDevice.h"
+#include "SkImagePriv.h"
#include "SkReadBuffer.h"
-#include "SkWriteBuffer.h"
#include "SkValidationUtils.h"
+#include "SkWriteBuffer.h"
SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap)
: INHERITED(0, 0)
@@ -43,14 +44,18 @@ void SkBitmapSource::flatten(SkWriteBuffer& buffer) const {
buffer.writeBitmap(fBitmap);
}
-bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context& ctx,
- SkBitmap* result, SkIPoint* offset) const {
+bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkImage*, const Context& ctx,
+ SkAutoTUnref<const SkImage>& result, SkIPoint* offset) const {
SkRect bounds, dstRect;
fBitmap.getBounds(&bounds);
ctx.ctm().mapRect(&dstRect, fDstRect);
if (fSrcRect == bounds && dstRect == bounds) {
// No regions cropped out or resized; return entire bitmap.
- *result = fBitmap;
+ SkImage* image = SkNewImageFromBitmap(fBitmap, NULL);
+ if (NULL == image) {
+ return false;
+ }
+ result.reset(image);
offset->fX = offset->fY = 0;
return true;
}
@@ -74,7 +79,12 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
kNone_SkFilterQuality : kHigh_SkFilterQuality);
canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
- *result = device.get()->accessBitmap(false);
+ SkImage* image = device->newImageSnapshot();
+ if (NULL == image) {
+ return false;
+ }
+ result.reset(image);
+
offset->fX = dstIRect.fLeft;
offset->fY = dstIRect.fTop;
return true;
« no previous file with comments | « src/effects/SkAlphaThresholdFilter.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698