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

Unified Diff: src/effects/SkMatrixConvolutionImageFilter.cpp

Issue 1414843003: Image filters: Replace all use of tryAllocPixels() with createDevice(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix morphology: don't allocate dest or temp until we need them Created 5 years, 2 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/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/effects/SkMagnifierImageFilter.cpp ('k') | src/effects/SkMorphologyImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698