Index: src/effects/SkMatrixConvolutionImageFilter.cpp |
diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp |
index 67813fd25910ac4f4ef1204cf91345cf6d94f9ca..e58eec10f4e25d99c2fff2a262b232ea9bbda72b 100644 |
--- a/src/effects/SkMatrixConvolutionImageFilter.cpp |
+++ b/src/effects/SkMatrixConvolutionImageFilter.cpp |
@@ -8,6 +8,7 @@ |
#include "SkMatrixConvolutionImageFilter.h" |
#include "SkBitmap.h" |
#include "SkColorPriv.h" |
+#include "SkDevice.h" |
#include "SkReadBuffer.h" |
#include "SkWriteBuffer.h" |
#include "SkRect.h" |
@@ -241,16 +242,18 @@ void SkMatrixConvolutionImageFilter::filterBorderPixels(const SkBitmap& src, |
// FIXME: This should be refactored to SkImageFilterUtils for |
// use by other filters. For now, we assume the input is always |
// premultiplied and unpremultiply it |
-static SkBitmap unpremultiplyBitmap(const SkBitmap& src) |
+static SkBitmap unpremultiplyBitmap(SkImageFilter::Proxy* proxy, const SkBitmap& src) |
{ |
SkAutoLockPixels alp(src); |
if (!src.getPixels()) { |
return SkBitmap(); |
} |
- SkBitmap result; |
- if (!result.tryAllocPixels(src.info())) { |
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(src.width(), src.height())); |
+ if (!device) { |
return SkBitmap(); |
} |
+ SkBitmap result = device->accessBitmap(false); |
+ SkAutoLockPixels alp_result(result); |
for (int y = 0; y < src.height(); ++y) { |
const uint32_t* srcRow = src.getAddr32(0, y); |
uint32_t* dstRow = result.getAddr32(0, y); |
@@ -282,7 +285,7 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy, |
} |
if (!fConvolveAlpha && !src.isOpaque()) { |
- src = unpremultiplyBitmap(src); |
+ src = unpremultiplyBitmap(proxy, src); |
} |
SkAutoLockPixels alp(src); |
@@ -290,9 +293,12 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy, |
return false; |
} |
- if (!result->tryAllocPixels(src.info().makeWH(bounds.width(), bounds.height()))) { |
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bounds.height())); |
+ if (!device) { |
return false; |
} |
+ *result = device->accessBitmap(false); |
+ SkAutoLockPixels alp_result(*result); |
offset->fX = bounds.fLeft; |
offset->fY = bounds.fTop; |