| Index: src/effects/SkBitmapSource.cpp
|
| diff --git a/src/effects/SkBitmapSource.cpp b/src/effects/SkBitmapSource.cpp
|
| index fc86f194b059909651518d6c29da3413c316e36b..384a55eba81a35ac67f8b652164af1b07374a2b7 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 "SkImagePriv.h"
|
| #include "SkReadBuffer.h"
|
| -#include "SkWriteBuffer.h"
|
| +#include "SkSurface.h"
|
| #include "SkValidationUtils.h"
|
| +#include "SkWriteBuffer.h"
|
|
|
| SkBitmapSource::SkBitmapSource(const SkBitmap& bitmap)
|
| : INHERITED(0, 0)
|
| @@ -43,25 +44,29 @@ 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, SkImage&, const Context& ctx,
|
| + SkAutoTUnref<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, true, NULL);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + result.reset(image);
|
| offset->fX = offset->fY = 0;
|
| return true;
|
| }
|
|
|
| const SkIRect dstIRect = dstRect.roundOut();
|
| - SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(dstIRect.width(), dstIRect.height()));
|
| - if (NULL == device.get()) {
|
| + SkAutoTUnref<SkSurface> surface(proxy->createSurface(dstIRect.width(), dstIRect.height()));
|
| + if (NULL == surface) {
|
| return false;
|
| }
|
|
|
| - SkCanvas canvas(device.get());
|
| + SkCanvas* canvas = surface->getCanvas();
|
| SkPaint paint;
|
|
|
| // Subtract off the integer component of the translation (will be applied in loc, below).
|
| @@ -72,9 +77,14 @@ bool SkBitmapSource::onFilterImage(Proxy* proxy, const SkBitmap&, const Context&
|
| paint.setFilterLevel(
|
| fSrcRect.width() == dstRect.width() && fSrcRect.height() == dstRect.height() ?
|
| SkPaint::kNone_FilterLevel : SkPaint::kHigh_FilterLevel);
|
| - canvas.drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
|
| + canvas->drawBitmapRectToRect(fBitmap, &fSrcRect, dstRect, &paint);
|
| +
|
| + SkImage* image = surface->newImageSnapshot(SkSurface::kYes_Budgeted);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + result.reset(image);
|
|
|
| - *result = device.get()->accessBitmap(false);
|
| offset->fX = dstIRect.fLeft;
|
| offset->fY = dstIRect.fTop;
|
| return true;
|
|
|