Chromium Code Reviews| Index: src/effects/SkMorphologyImageFilter.cpp |
| diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp |
| index 4e08d9dd733148b369105604461332dd09ce534e..546e6f5d93141cecf220cdd7748a78a685a8e8f2 100644 |
| --- a/src/effects/SkMorphologyImageFilter.cpp |
| +++ b/src/effects/SkMorphologyImageFilter.cpp |
| @@ -547,7 +547,8 @@ bool apply_morphology(const SkBitmap& input, |
| const SkIRect& rect, |
| GrMorphologyEffect::MorphologyType morphType, |
| SkISize radius, |
| - SkBitmap* dst) { |
| + SkBitmap* dst, |
| + GrTextureProvider::SizeConstraint constraint) { |
| SkAutoTUnref<GrTexture> srcTexture(SkRef(input.getTexture())); |
| SkASSERT(srcTexture); |
| GrContext* context = srcTexture->getContext(); |
| @@ -565,7 +566,14 @@ bool apply_morphology(const SkBitmap& input, |
| SkIRect srcRect = rect; |
| if (radius.fWidth > 0) { |
| - GrTexture* scratch = context->textureProvider()->createApproxTexture(desc); |
| + GrTextureProvider::SizeConstraint horiConstraint = constraint; |
| + if (radius.fHeight > 0) { |
| + // Optimization: we will fall through and allocate the "real" texture after this one |
|
Stephen White
2015/10/22 19:53:14
For bonus points in a followup patch, do a similar
reed1
2015/10/22 20:08:25
Indeed. I looked at the blur code, but couldn't se
|
| + // so ours can be approximate (likely faster to allocate) |
| + horiConstraint = GrTextureProvider::kApprox_SizeConstraint; |
| + } |
| + |
| + GrTexture* scratch = context->textureProvider()->createTexture(desc, horiConstraint); |
| if (nullptr == scratch) { |
| return false; |
| } |
| @@ -589,7 +597,7 @@ bool apply_morphology(const SkBitmap& input, |
| srcRect = dstRect; |
| } |
| if (radius.fHeight > 0) { |
| - GrTexture* scratch = context->textureProvider()->createApproxTexture(desc); |
| + GrTexture* scratch = context->textureProvider()->createTexture(desc, constraint); |
| if (nullptr == scratch) { |
| return false; |
| } |
| @@ -647,7 +655,8 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, |
| GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType |
| : GrMorphologyEffect::kErode_MorphologyType; |
| - if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result)) { |
| + if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result, |
| + GrTextureProvider::FromImageFilter(ctx.sizeConstraint()))) { |
| return false; |
| } |
| offset->fX = bounds.left(); |