Chromium Code Reviews| Index: src/effects/SkBlurImageFilter.cpp |
| diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp |
| index 10c8a0b17b183bafd23cd36bf5fb7ac83c9352d1..28b5eb8b388da25b9a1e5fec14bc8012c2b1af7c 100644 |
| --- a/src/effects/SkBlurImageFilter.cpp |
| +++ b/src/effects/SkBlurImageFilter.cpp |
| @@ -95,7 +95,13 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, |
| const SkVector sigma = map_sigma(fSigma, ctx.ctm()); |
| #if SK_SUPPORT_GPU |
| - if (input->peekTexture() && input->peekTexture()->getContext()) { |
| + if (source->isTextureBacked()) { |
| + GrContext* context = source->getContext(); |
| + GrTexture* inputTexture = input->asTextureRef(context); |
| + if (!inputTexture) { |
|
Stephen White
2016/04/08 15:14:19
Could you change this to an assert? It should be h
robertphillips
2016/04/08 18:07:50
Done.
robertphillips
2016/04/08 18:07:50
Done.
|
| + return nullptr; |
| + } |
| + |
| if (0 == sigma.x() && 0 == sigma.y()) { |
| offset->fX = inputBounds.x(); |
| offset->fY = inputBounds.y(); |
| @@ -103,14 +109,12 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, |
| -inputOffset.y())); |
| } |
| - GrTexture* inputTexture = input->peekTexture(); |
| - |
| offset->fX = dstBounds.fLeft; |
| offset->fY = dstBounds.fTop; |
| inputBounds.offset(-inputOffset); |
| dstBounds.offset(-inputOffset); |
| SkRect inputBoundsF(SkRect::Make(inputBounds)); |
| - SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(inputTexture->getContext(), |
| + SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(context, |
| inputTexture, |
| false, |
| source->props().allowSRGBInputs(), |
| @@ -145,39 +149,39 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, |
| -inputOffset.y())); |
| } |
| - SkPixmap inputPixmap; |
| + SkBitmap inputBM; |
| - if (!input->peekPixels(&inputPixmap)) { |
| + if (!input->getROPixels(&inputBM)) { |
| return nullptr; |
| } |
| - if (inputPixmap.colorType() != kN32_SkColorType) { |
| + if (inputBM.colorType() != kN32_SkColorType) { |
| return nullptr; |
| } |
| SkImageInfo info = SkImageInfo::Make(dstBounds.width(), dstBounds.height(), |
| - inputPixmap.colorType(), inputPixmap.alphaType()); |
| + inputBM.colorType(), inputBM.alphaType()); |
| SkBitmap tmp, dst; |
| if (!tmp.tryAllocPixels(info) || !dst.tryAllocPixels(info)) { |
| return nullptr; |
| } |
| - SkAutoLockPixels tmpLock(tmp), dstLock(dst); |
| + SkAutoLockPixels inputLock(inputBM), tmpLock(tmp), dstLock(dst); |
| offset->fX = dstBounds.fLeft; |
| offset->fY = dstBounds.fTop; |
| SkPMColor* t = tmp.getAddr32(0, 0); |
| SkPMColor* d = dst.getAddr32(0, 0); |
| int w = dstBounds.width(), h = dstBounds.height(); |
| - const SkPMColor* s = inputPixmap.addr32(inputBounds.x() - inputOffset.x(), |
| - inputBounds.y() - inputOffset.y()); |
| + const SkPMColor* s = inputBM.getAddr32(inputBounds.x() - inputOffset.x(), |
| + inputBounds.y() - inputOffset.y()); |
| inputBounds.offset(-dstBounds.x(), -dstBounds.y()); |
| dstBounds.offset(-dstBounds.x(), -dstBounds.y()); |
| SkIRect inputBoundsT = SkIRect::MakeLTRB(inputBounds.top(), inputBounds.left(), |
| inputBounds.bottom(), inputBounds.right()); |
| SkIRect dstBoundsT = SkIRect::MakeWH(dstBounds.height(), dstBounds.width()); |
| - int sw = int(inputPixmap.rowBytes() >> 2); |
| + int sw = int(inputBM.rowBytes() >> 2); |
| /** |
| * |