| Index: src/effects/SkBlurImageFilter.cpp
|
| diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
|
| index 01eeddd9ca4ba688e9c9761551d6a16f9f34455a..a772f30fe48ecf836771a011a44885eaf2edc75d 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"
|
| @@ -145,32 +147,31 @@ 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;
|
| + const SkImage* source, const Context& ctx,
|
| + SkAutoTUnref<const SkImage>& dst, SkIPoint* offset) const {
|
| + SkAutoTUnref<const SkImage> src(SkRef(source));
|
| SkIPoint srcOffset = SkIPoint::Make(0, 0);
|
| - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) {
|
| - return false;
|
| - }
|
| -
|
| - if (src.colorType() != kN32_SkColorType) {
|
| + if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, src, &srcOffset)) {
|
| return false;
|
| }
|
|
|
| SkIRect srcBounds, dstBounds;
|
| - if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, &src)) {
|
| + if (!this->applyCropRect(ctx, proxy, src, &srcOffset, &srcBounds, src)) {
|
| return false;
|
| }
|
|
|
| - SkAutoLockPixels alp(src);
|
| - if (!src.getPixels()) {
|
| + SkBitmap srcBitmap;
|
| + SkAutoAdoptImageAsN32Bitmap aai(src, &srcBitmap);
|
| + if (NULL == 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());
|
|
|
| @@ -184,25 +185,31 @@ bool SkBlurImageFilter::onFilterImage(Proxy* proxy,
|
| }
|
|
|
| if (kernelSizeX == 0 && kernelSizeY == 0) {
|
| - src.copyTo(dst, dst->colorType());
|
| + srcBitmap.copyTo(&dstBitmap, dstBitmap.colorType());
|
| + srcBitmap = SkBitmap();
|
| + SkImage* image = SkNewImageFromBitmap(dstBitmap, NULL);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + dst.reset(image);
|
| 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>;
|
| @@ -227,6 +234,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, NULL);
|
| + if (NULL == image) {
|
| + return false;
|
| + }
|
| + dst.reset(image);
|
| + offset->fX = resultX;
|
| + offset->fY = resultY;
|
| return true;
|
| }
|
|
|
| @@ -255,19 +270,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, const SkImage* src, const Context& ctx,
|
| + SkAutoTUnref<const SkImage>& result, SkIPoint* offset) const {
|
| #if SK_SUPPORT_GPU
|
| - SkBitmap input = src;
|
| + SkAutoTUnref<const 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;
|
| @@ -282,7 +297,9 @@ bool SkBlurImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const
|
| if (!tex) {
|
| return false;
|
| }
|
| - 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");
|
|
|