| Index: src/effects/SkAlphaThresholdFilter.cpp
|
| diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
|
| index 09dc7427e5f63bc843430e29c90176cfda9164a0..0a0f60201b254fbd97eb35fba45fa89f98c18560 100644
|
| --- a/src/effects/SkAlphaThresholdFilter.cpp
|
| +++ b/src/effects/SkAlphaThresholdFilter.cpp
|
| @@ -7,6 +7,7 @@
|
|
|
| #include "SkAlphaThresholdFilter.h"
|
| #include "SkBitmap.h"
|
| +#include "SkImagePriv.h"
|
| #include "SkReadBuffer.h"
|
| #include "SkWriteBuffer.h"
|
| #include "SkRegion.h"
|
| @@ -22,8 +23,9 @@ public:
|
| protected:
|
| void flatten(SkWriteBuffer&) const SK_OVERRIDE;
|
|
|
| - virtual bool onFilterImage(Proxy*, const SkBitmap& src, const Context&,
|
| - SkBitmap* result, SkIPoint* offset) const SK_OVERRIDE;
|
| + virtual bool onFilterImage(Proxy*, const SkImage* src, const Context&,
|
| + SkAutoTUnref<const SkImage>& result,
|
| + SkIPoint* offset) const SK_OVERRIDE;
|
| #if SK_SUPPORT_GPU
|
| virtual bool asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
|
| const SkIRect& bounds) const SK_OVERRIDE;
|
| @@ -292,8 +294,7 @@ bool SkAlphaThresholdFilterImpl::asFragmentProcessor(GrFragmentProcessor** fp,
|
|
|
| while (!iter.done()) {
|
| SkRect rect = SkRect::Make(iter.rect());
|
| - context->drawRect(maskTexture->asRenderTarget(), GrClip::WideOpen(), grPaint,
|
| - in_matrix, rect);
|
| + context->drawRect(maskRT, GrClip::WideOpen(), grPaint, in_matrix, rect);
|
| iter.next();
|
| }
|
| }
|
| @@ -314,35 +315,30 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
|
| buffer.writeRegion(fRegion);
|
| }
|
|
|
| -bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
| - const Context& ctx, SkBitmap* dst,
|
| +bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkImage* src,
|
| + const Context& ctx, SkAutoTUnref<const SkImage>& dst,
|
| SkIPoint* offset) const {
|
| - SkASSERT(src.colorType() == kN32_SkColorType);
|
| -
|
| - if (src.colorType() != kN32_SkColorType) {
|
| - return false;
|
| - }
|
| -
|
| SkMatrix localInverse;
|
| if (!ctx.ctm().invert(&localInverse)) {
|
| return false;
|
| }
|
|
|
| - SkAutoLockPixels alp(src);
|
| - SkASSERT(src.getPixels());
|
| - if (!src.getPixels() || src.width() <= 0 || src.height() <= 0) {
|
| + SkBitmap srcBitmap;
|
| + SkAutoImageAsN32Bitmap aai(src, &srcBitmap);
|
| + if (!srcBitmap.getPixels() || srcBitmap.width() <= 0 || srcBitmap.height() <= 0) {
|
| return false;
|
| }
|
|
|
| - if (!dst->tryAllocPixels(src.info())) {
|
| + SkBitmap dstBitmap;
|
| + if (!dstBitmap.tryAllocPixels(srcBitmap.info())) {
|
| return false;
|
| }
|
|
|
| U8CPU innerThreshold = (U8CPU)(fInnerThreshold * 0xFF);
|
| U8CPU outerThreshold = (U8CPU)(fOuterThreshold * 0xFF);
|
| - SkColor* sptr = src.getAddr32(0, 0);
|
| - SkColor* dptr = dst->getAddr32(0, 0);
|
| - int width = src.width(), height = src.height();
|
| + SkColor* sptr = srcBitmap.getAddr32(0, 0);
|
| + SkColor* dptr = dstBitmap.getAddr32(0, 0);
|
| + int width = srcBitmap.width(), height = srcBitmap.height();
|
| for (int y = 0; y < height; ++y) {
|
| for (int x = 0; x < width; ++x) {
|
| const SkColor& source = sptr[y * width + x];
|
| @@ -369,10 +365,18 @@ bool SkAlphaThresholdFilterImpl::onFilterImage(Proxy*, const SkBitmap& src,
|
| (U8CPU)(SkColorGetB(source) * scale));
|
| }
|
| }
|
| - dptr[y * dst->width() + x] = output_color;
|
| + dptr[y * dstBitmap.width() + x] = output_color;
|
| }
|
| }
|
| + srcBitmap = SkBitmap();
|
|
|
| + SkImage* image = SkNewImageFromBitmap(dstBitmap, NULL);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + dst.reset(image);
|
| + offset->fX = 0;
|
| + offset->fY = 0;
|
| return true;
|
| }
|
|
|
|
|