Chromium Code Reviews| Index: src/effects/SkMorphologyImageFilter.cpp |
| diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp |
| index b5c3700da01e7ed031dce2d29f22c25944612f8a..b1561869904c514c03df46acf9ccc72f52d07a2a 100644 |
| --- a/src/effects/SkMorphologyImageFilter.cpp |
| +++ b/src/effects/SkMorphologyImageFilter.cpp |
| @@ -138,7 +138,8 @@ bool SkMorphologyImageFilter::filterImageGeneric(SkMorphologyImageFilter::Proc p |
| SkIPoint* offset) const { |
| SkBitmap src = source; |
| SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) { |
| + if (this->getInput(0) && |
| + !this->getInput(0)->filterImage(proxy, source, ctx, &src, &srcOffset)) { |
| return false; |
| } |
| @@ -228,8 +229,8 @@ bool SkDilateImageFilter::onFilterImage(Proxy* proxy, |
| } |
| void SkMorphologyImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) const { |
| - if (getInput(0)) { |
| - getInput(0)->computeFastBounds(src, dst); |
| + if (this->getInput(0)) { |
| + this->getInput(0)->computeFastBounds(src, dst); |
| } else { |
| *dst = src; |
| } |
| @@ -243,7 +244,7 @@ bool SkMorphologyImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& |
| SkIntToScalar(this->radius().height())); |
| ctm.mapVectors(&radius, 1); |
| bounds.outset(SkScalarCeilToInt(radius.x()), SkScalarCeilToInt(radius.y())); |
| - if (getInput(0) && !getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
| + if (this->getInput(0) && !this->getInput(0)->filterBounds(bounds, ctm, &bounds)) { |
| return false; |
| } |
| *dst = bounds; |
| @@ -670,18 +671,18 @@ bool apply_morphology(const SkBitmap& input, |
| desc.fConfig = kSkia8888_GrPixelConfig; |
| SkIRect srcRect = rect; |
| - GrDrawContext* drawContext = context->drawContext(); |
| - if (!drawContext) { |
| - return false; |
| - } |
| - |
| if (radius.fWidth > 0) { |
| - GrTexture* texture = context->textureProvider()->refScratchTexture( |
| + GrTexture* dst = context->textureProvider()->refScratchTexture( |
|
brucedawson
2015/07/23 17:52:12
'dst' is a confusing variable name to use here bec
|
| desc, GrTextureProvider::kApprox_ScratchTexMatch); |
| - if (NULL == texture) { |
| + if (NULL == dst) { |
| return false; |
| } |
| - apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture, |
| + GrDrawContext* dstDrawContext = context->drawContext(); |
| + if (!dstDrawContext) { |
| + return false; |
| + } |
| + |
| + apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture, |
| srcRect, dstRect, radius.fWidth, morphType, |
| Gr1DKernelEffect::kX_Direction); |
| SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, |
| @@ -689,20 +690,27 @@ bool apply_morphology(const SkBitmap& input, |
| GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphType ? |
| SK_ColorWHITE : |
| SK_ColorTRANSPARENT; |
| - drawContext->clear(texture->asRenderTarget(), &clearRect, clearColor, false); |
| - srcTexture.reset(texture); |
| + dstDrawContext->clear(dst->asRenderTarget(), &clearRect, clearColor, false); |
| + |
| + srcTexture.reset(dst); |
| srcRect = dstRect; |
| } |
| if (radius.fHeight > 0) { |
| - GrTexture* texture = context->textureProvider()->refScratchTexture(desc, |
| + GrTexture* dst = context->textureProvider()->refScratchTexture(desc, |
|
brucedawson
2015/07/23 17:52:11
Ditto. FWIW.
|
| GrTextureProvider::kApprox_ScratchTexMatch); |
| - if (NULL == texture) { |
| + if (NULL == dst) { |
| + return false; |
| + } |
| + GrDrawContext* dstDrawContext = context->drawContext(); |
| + if (!dstDrawContext) { |
| return false; |
| } |
| - apply_morphology_pass(drawContext, texture->asRenderTarget(), clip, srcTexture, |
| + |
| + apply_morphology_pass(dstDrawContext, dst->asRenderTarget(), clip, srcTexture, |
| srcRect, dstRect, radius.fHeight, morphType, |
| Gr1DKernelEffect::kY_Direction); |
| - srcTexture.reset(texture); |
| + |
| + srcTexture.reset(dst); |
| } |
| SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst); |
|
brucedawson
2015/07/23 17:52:12
This appears to be the only one of the seven refer
|
| return true; |
| @@ -718,7 +726,8 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, |
| SkIPoint* offset) const { |
| SkBitmap input = src; |
| SkIPoint srcOffset = SkIPoint::Make(0, 0); |
| - if (getInput(0) && !getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) { |
| + if (this->getInput(0) && |
| + !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffset)) { |
| return false; |
| } |
| SkIRect bounds; |
| @@ -744,9 +753,9 @@ bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, |
| return true; |
| } |
| - GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType : GrMorphologyEffect::kErode_MorphologyType; |
| - if (!apply_morphology(input, srcBounds, type, |
| - SkISize::Make(width, height), result)) { |
| + GrMorphologyEffect::MorphologyType type = dilate ? GrMorphologyEffect::kDilate_MorphologyType |
| + : GrMorphologyEffect::kErode_MorphologyType; |
| + if (!apply_morphology(input, srcBounds, type, SkISize::Make(width, height), result)) { |
| return false; |
| } |
| offset->fX = bounds.left(); |