Chromium Code Reviews| Index: src/core/SkImageFilter.cpp |
| diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp |
| index d7af4e65d0656c13572683b08a429c52f13f87ad..db53dd2e39db658daeacff6c1a1b6394e7f73cd2 100644 |
| --- a/src/core/SkImageFilter.cpp |
| +++ b/src/core/SkImageFilter.cpp |
| @@ -264,9 +264,18 @@ bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, |
| bool SkImageFilter::filterInput(int index, Proxy* proxy, const SkBitmap& src, |
| const Context& context, |
| - SkBitmap* result, SkIPoint* offset) const { |
| + SkBitmap* result, SkIPoint* offset, |
| + bool relaxSizeConstraint) const { |
| SkImageFilter* input = this->getInput(index); |
| - return !input || input->filterImage(proxy, src, context, result, offset); |
| + if (!input) { |
| + return true; |
| + } |
| + if (relaxSizeConstraint && (kExact_SizeConstraint == context.sizeConstraint())) { |
|
Stephen White
2015/10/22 18:44:16
Nit: could you rewrite this one to look more like
reed1
2015/10/22 19:36:32
Done.
|
| + Context approxContext(context.ctm(), context.clipBounds(), context.cache(), |
| + kApprox_SizeConstraint); |
| + return input->filterImage(proxy, src, approxContext, result, offset); |
| + } |
| + return input->filterImage(proxy, src, context, result, offset); |
| } |
| bool SkImageFilter::filterBounds(const SkIRect& src, const SkMatrix& ctm, |
| @@ -347,7 +356,8 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont |
| desc.fHeight = bounds.height(); |
| desc.fConfig = kRGBA_8888_GrPixelConfig; |
| - SkAutoTUnref<GrTexture> dst(context->textureProvider()->createApproxTexture(desc)); |
| + SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(desc, |
| + GrTextureProvider::FromImageFilter(ctx.sizeConstraint()))); |
| if (!dst) { |
| return false; |
| } |
| @@ -466,8 +476,9 @@ void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBit |
| } |
| bool SkImageFilter::filterInputGPU(int index, SkImageFilter::Proxy* proxy, |
| - const SkBitmap& src, const Context& ctx, |
| - SkBitmap* result, SkIPoint* offset) const { |
| + const SkBitmap& src, const Context& origCtx, |
| + SkBitmap* result, SkIPoint* offset, |
| + bool relaxSizeConstraint) const { |
| SkImageFilter* input = this->getInput(index); |
| if (!input) { |
| return true; |
| @@ -477,6 +488,12 @@ bool SkImageFilter::filterInputGPU(int index, SkImageFilter::Proxy* proxy, |
| // called are restored before we return to the caller. |
| GrContext* context = src.getTexture()->getContext(); |
| + SizeConstraint constraint = origCtx.sizeConstraint(); |
| + if (relaxSizeConstraint && (kExact_SizeConstraint == constraint)) { |
| + constraint = kApprox_SizeConstraint; |
| + } |
| + Context ctx(origCtx.ctm(), origCtx.clipBounds(), origCtx.cache(), constraint); |
| + |
| if (input->canFilterImageGPU()) { |
| return input->filterImageGPU(proxy, src, ctx, result, offset); |
| } else { |