| Index: src/effects/SkBlurImageFilter.cpp
|
| diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
|
| index 32609b8b79ba1c784aa34ea1253f6a9c2c49aa5a..383bbf13fc86188eb5f2146ad4a040fd209703c5 100644
|
| --- a/src/effects/SkBlurImageFilter.cpp
|
| +++ b/src/effects/SkBlurImageFilter.cpp
|
| @@ -8,6 +8,8 @@
|
| #include "SkBitmap.h"
|
| #include "SkBlurImageFilter.h"
|
| #include "SkColorPriv.h"
|
| +#include "SkImage_Base.h"
|
| +#include "SkImagePriv.h"
|
| #include "SkReadBuffer.h"
|
| #include "SkWriteBuffer.h"
|
| #include "SkGpuBlurUtils.h"
|
| @@ -146,32 +148,42 @@ static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo
|
| }
|
|
|
| bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
| - const SkBitmap& source, const Context& ctx,
|
| - SkBitmap* dst, SkIPoint* offset) const {
|
| - SkBitmap src = source;
|
| + SkImage& source, const Context& ctx,
|
| + SkAutoTUnref<SkImage>& dst, SkIPoint* offset) const {
|
| + SkAutoTUnref<SkImage> src(SkRef(&source));
|
| SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
| - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
| + if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, src, &srcOffset)) {
|
| return false;
|
| }
|
|
|
| - if (src.colorType() != kN32_SkColorType) {
|
| +#if 0 //TODO: colortype
|
| + if (src->colorType() != kN32_SkColorType) {
|
| return false;
|
| }
|
| +#endif
|
|
|
| SkIRect srcBounds, dstBounds;
|
| - if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, &src)) {
|
| + if (!this->applyCropRect(ctx, proxy, *src, &srcOffset, &srcBounds, src)) {
|
| + return false;
|
| + }
|
| +
|
| + SkBitmap srcBitmap;
|
| + if (!as_IB(src)->getROPixels(&srcBitmap)) {
|
| return false;
|
| }
|
| + src.reset(NULL);
|
|
|
| - SkAutoLockPixels alp(src);
|
| - if (!src.getPixels()) {
|
| + SkAutoLockPixels alp(srcBitmap);
|
| + if (!srcBitmap.getPixels()) {
|
| return false;
|
| }
|
|
|
| - if (!dst->tryAllocPixels(src.info().makeWH(srcBounds.width(), srcBounds.height()))) {
|
| + SkBitmap dstBitmap;
|
| + if (!dstBitmap.tryAllocPixels(
|
| + srcBitmap.info().makeWH(srcBounds.width(), srcBounds.height()))) {
|
| return false;
|
| }
|
| - dst->getBounds(&dstBounds);
|
| + dstBitmap.getBounds(&dstBounds);
|
|
|
| SkVector sigma = mapSigma(fSigma, ctx.ctm());
|
|
|
| @@ -185,25 +197,25 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
| }
|
|
|
| if (kernelSizeX == 0 && kernelSizeY == 0) {
|
| - src.copyTo(dst, dst->colorType());
|
| + srcBitmap.copyTo(&dstBitmap, dstBitmap.colorType());
|
| offset->fX = srcBounds.fLeft;
|
| offset->fY = srcBounds.fTop;
|
| return true;
|
| }
|
|
|
| SkBitmap temp;
|
| - if (!temp.tryAllocPixels(dst->info())) {
|
| + if (!temp.tryAllocPixels(dstBitmap.info())) {
|
| return false;
|
| }
|
|
|
| - offset->fX = srcBounds.fLeft;
|
| - offset->fY = srcBounds.fTop;
|
| + int32_t resultX = srcBounds.fLeft;
|
| + int32_t resultY = srcBounds.fTop;
|
| srcBounds.offset(-srcOffset);
|
| - const SkPMColor* s = src.getAddr32(srcBounds.left(), srcBounds.top());
|
| + const SkPMColor* s = srcBitmap.getAddr32(srcBounds.left(), srcBounds.top());
|
| SkPMColor* t = temp.getAddr32(0, 0);
|
| - SkPMColor* d = dst->getAddr32(0, 0);
|
| + SkPMColor* d = dstBitmap.getAddr32(0, 0);
|
| int w = dstBounds.width(), h = dstBounds.height();
|
| - int sw = src.rowBytesAsPixels();
|
| + int sw = srcBitmap.rowBytesAsPixels();
|
| SkBoxBlurProc boxBlurX, boxBlurY, boxBlurXY, boxBlurYX;
|
| if (!SkBoxBlurGetPlatformProcs(&boxBlurX, &boxBlurY, &boxBlurXY, &boxBlurYX)) {
|
| boxBlurX = boxBlur<kX, kX>;
|
| @@ -228,6 +240,14 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
| boxBlurX(d, h, t, kernelSizeY, highOffsetY, lowOffsetY, h, w);
|
| boxBlurXY(t, h, d, kernelSizeY3, highOffsetY, highOffsetY, h, w);
|
| }
|
| + temp = SkBitmap();
|
| + SkImage* image = SkNewImageFromBitmap(dstBitmap, true, NULL);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + dst.reset(image);
|
| + offset->fX = resultX;
|
| + offset->fY = resultY;
|
| return true;
|
| }
|
|
|
| @@ -256,19 +276,19 @@ bool SkBlurImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
|
| return true;
|
| }
|
|
|
| -bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
|
| - SkBitmap* result, SkIPoint* offset) const {
|
| +bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, SkImage& src, const Context& ctx,
|
| + SkAutoTUnref<SkImage>& result, SkIPoint* offset) const {
|
| #if SK_SUPPORT_GPU
|
| - SkBitmap input = src;
|
| + SkAutoTUnref<SkImage> input(SkRef(&src));
|
| SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
| - if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) {
|
| + if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, input, &srcOffset)) {
|
| return false;
|
| }
|
| SkIRect rect;
|
| - if (!this->applyCropRect(ctx, proxy, input, &srcOffset, &rect, &input)) {
|
| + if (!this->applyCropRect(ctx, proxy, *input, &srcOffset, &rect, input)) {
|
| return false;
|
| }
|
| - GrTexture* source = input.getTexture();
|
| + GrTexture* source = input->getTexture();
|
| SkVector sigma = mapSigma(fSigma, ctx.ctm());
|
| offset->fX = rect.fLeft;
|
| offset->fY = rect.fTop;
|
| @@ -280,7 +300,9 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
|
| true,
|
| sigma.x(),
|
| sigma.y()));
|
| - WrapTexture(tex, rect.width(), rect.height(), result);
|
| + if (!WrapTexture(tex, rect.width(), rect.height(), result)) {
|
| + return false;
|
| + }
|
| return true;
|
| #else
|
| SkDEBUGFAIL("Should not call in GPU-less build");
|
|
|