Index: src/effects/SkBitmapSource.cpp |
diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp |
index fc86f194b059909651518d6c29da3413c316e36b..6e7a6c7aa42dccfa44f3bf81b14ebe58aa76c65e 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& |
SkPaint::kNone_FilterLevel : SkPaint::kHigh_FilterLevel); |
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; |