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

Unified Diff: src/effects/SkAlphaThresholdFilter.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 | « no previous file | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkAlphaThresholdFilter.cpp
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 32de52250a36f081e7ecc7232a8bfe92cab97ec1..e7a4c4ffd46b7c22c0c7999ef835714ceb80854d 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -7,6 +7,7 @@
#include "SkAlphaThresholdFilter.h"
#include "SkBitmap.h"
+#include "SkDevice.h"
#include "SkReadBuffer.h"
#include "SkWriteBuffer.h"
#include "SkRegion.h"
@@ -303,7 +304,7 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
buffer.writeRegion(fRegion);
}
-bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
+bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy* proxy, const SkBitmap& src,
const Context& ctx, SkBitmap* dst,
SkIPoint* offset) const {
SkASSERT(src.colorType() == kN32_SkColorType);
@@ -323,9 +324,12 @@ bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
return false;
}
- if (!dst->tryAllocPixels(src.info())) {
+ SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(src.width(), src.height()));
+ if (!device) {
return false;
}
+ *dst = device->accessBitmap(false);
+ SkAutoLockPixels alp_dst(*dst);
U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
« no previous file with comments | « no previous file | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698