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 <michaelludwig@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
Chris Dalton 2019-09-11 10:12:48 -06:00 committed by Skia Commit-Bot
parent de4456f6f2
commit f19510e320

View File

@ -409,7 +409,6 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(
std::unique_ptr<GrRenderTargetContext> srcRenderTargetContext, std::unique_ptr<GrRenderTargetContext> srcRenderTargetContext,
const SkIRect& localSrcBounds, const SkIRect& localSrcBounds,
int scaleFactorX, int scaleFactorY, int scaleFactorX, int scaleFactorY,
GrTextureDomain::Mode mode,
int finalW, int finalW,
int finalH, int finalH,
sk_sp<SkColorSpace> finalCS, sk_sp<SkColorSpace> finalCS,
@ -417,14 +416,6 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(
const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(), const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(),
srcRenderTargetContext->height()); 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<GrTextureProxy> srcProxy = srcRenderTargetContext->asTextureProxyRef(); sk_sp<GrTextureProxy> srcProxy = srcRenderTargetContext->asTextureProxyRef();
if (!srcProxy) { if (!srcProxy) {
return nullptr; return nullptr;
@ -443,24 +434,12 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(
} }
GrPaint paint; GrPaint paint;
if (GrTextureDomain::kIgnore_Mode != mode) { SkRect domain = GrTextureDomain::MakeTexelDomain(localSrcBounds, GrTextureDomain::kClamp_Mode,
// GrTextureDomainEffect does not support kRepeat_Mode with GrSamplerState::Filter. GrTextureDomain::kClamp_Mode);
GrTextureDomain::Mode modeForScaling = GrTextureDomain::kRepeat_Mode == mode auto fp = GrTextureDomainEffect::Make(std::move(srcProxy), SkMatrix::I(), domain,
? GrTextureDomain::kDecal_Mode GrTextureDomain::kClamp_Mode,
: mode; GrSamplerState::Filter::kBilerp);
paint.addColorFragmentProcessor(std::move(fp));
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());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
GrFixedClip clip(SkIRect::MakeWH(finalW, finalH)); GrFixedClip clip(SkIRect::MakeWH(finalW, finalH));
@ -592,7 +571,7 @@ std::unique_ptr<GrRenderTargetContext> GaussianBlur(GrRecordingContext* context,
if (scaleFactorX > 1 || scaleFactorY > 1) { if (scaleFactorX > 1 || scaleFactorY > 1) {
dstRenderTargetContext = dstRenderTargetContext =
reexpand(context, std::move(dstRenderTargetContext), localSrcBounds, scaleFactorX, reexpand(context, std::move(dstRenderTargetContext), localSrcBounds, scaleFactorX,
scaleFactorY, mode, finalW, finalH, colorSpace, fit); scaleFactorY, finalW, finalH, colorSpace, fit);
} }
SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin()); SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin());