From f19510e320a08c76c9c1fddfbe28701c103d348a Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Wed, 11 Sep 2019 10:12:48 -0600 Subject: [PATCH] Use "clamp" when reexpanding gaussian blurs Bug: skia: Change-Id: Ib0a59a56b38eb743f0c78de2cf717d04c775c8df Reviewed-on: https://skia-review.googlesource.com/c/skia/+/240666 Reviewed-by: Michael Ludwig Commit-Queue: Chris Dalton --- src/core/SkGpuBlurUtils.cpp | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index 5a1864ce3c..038ab9c68d 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -409,7 +409,6 @@ static std::unique_ptr reexpand( std::unique_ptr srcRenderTargetContext, const SkIRect& localSrcBounds, int scaleFactorX, int scaleFactorY, - GrTextureDomain::Mode mode, int finalW, int finalH, sk_sp finalCS, @@ -417,14 +416,6 @@ static std::unique_ptr reexpand( const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(), srcRenderTargetContext->height()); - // Clear one pixel to the right and below, to accommodate bilinear upsampling. - // TODO: it seems like we should actually be clamping here rather than darkening - // the bottom right edges. - SkIRect clearRect = SkIRect::MakeXYWH(srcRect.fLeft, srcRect.fBottom, srcRect.width() + 1, 1); - srcRenderTargetContext->priv().absClear(&clearRect); - clearRect = SkIRect::MakeXYWH(srcRect.fRight, srcRect.fTop, 1, srcRect.height()); - srcRenderTargetContext->priv().absClear(&clearRect); - sk_sp srcProxy = srcRenderTargetContext->asTextureProxyRef(); if (!srcProxy) { return nullptr; @@ -443,24 +434,12 @@ static std::unique_ptr reexpand( } GrPaint paint; - if (GrTextureDomain::kIgnore_Mode != mode) { - // GrTextureDomainEffect does not support kRepeat_Mode with GrSamplerState::Filter. - GrTextureDomain::Mode modeForScaling = GrTextureDomain::kRepeat_Mode == mode - ? GrTextureDomain::kDecal_Mode - : mode; - - SkRect domain = SkRect::Make(localSrcBounds); - auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), - SkMatrix::I(), - domain, - modeForScaling, - GrSamplerState::Filter::kBilerp); - paint.addColorFragmentProcessor(std::move(fp)); - } else { - // FIXME: this should be mitchell, not bilinear. - paint.addColorTextureProcessor(std::move(srcProxy), SkMatrix::I(), - GrSamplerState::ClampBilerp()); - } + SkRect domain = GrTextureDomain::MakeTexelDomain(localSrcBounds, GrTextureDomain::kClamp_Mode, + GrTextureDomain::kClamp_Mode); + auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), SkMatrix::I(), domain, + GrTextureDomain::kClamp_Mode, + GrSamplerState::Filter::kBilerp); + paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); GrFixedClip clip(SkIRect::MakeWH(finalW, finalH)); @@ -592,7 +571,7 @@ std::unique_ptr GaussianBlur(GrRecordingContext* context, if (scaleFactorX > 1 || scaleFactorY > 1) { dstRenderTargetContext = reexpand(context, std::move(dstRenderTargetContext), localSrcBounds, scaleFactorX, - scaleFactorY, mode, finalW, finalH, colorSpace, fit); + scaleFactorY, finalW, finalH, colorSpace, fit); } SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin());