From 9dc935fa11521d4a6c7875699c050044a45d0871 Mon Sep 17 00:00:00 2001 From: brianosman Date: Tue, 26 Jul 2016 10:21:54 -0700 Subject: [PATCH] Remove all usage of SkSurfaceProps::isGammaCorrect() DrawContext's isGammaCorrect now just based on presence of color space. Next change will remove the function and flag entirely, but I wanted to land this separately. This alters a few GMs in srgb/f16 mode, generally those that are creating off-screen surfaces in ways that were somewhat lossy before. No unexplained changes. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2186633002 Review-Url: https://codereview.chromium.org/2186633002 --- include/gpu/GrDrawContext.h | 2 +- src/effects/SkBlurImageFilter.cpp | 1 - src/effects/SkBlurMaskFilter.cpp | 4 +--- src/effects/SkGpuBlurUtils.cpp | 14 ++++---------- src/effects/SkGpuBlurUtils.h | 2 -- 5 files changed, 6 insertions(+), 17 deletions(-) diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h index 01f4ac963b..d5bde08288 100644 --- a/include/gpu/GrDrawContext.h +++ b/include/gpu/GrDrawContext.h @@ -274,7 +274,7 @@ public: int height() const { return fRenderTarget->height(); } GrPixelConfig config() const { return fRenderTarget->config(); } int numColorSamples() const { return fRenderTarget->numColorSamples(); } - bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); } + bool isGammaCorrect() const { return SkToBool(fColorSpace.get()); } SkSourceGammaTreatment sourceGammaTreatment() const { return this->isGammaCorrect() ? SkSourceGammaTreatment::kRespect : SkSourceGammaTreatment::kIgnore; diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 23fb2cb53d..37584ab3ad 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -124,7 +124,6 @@ sk_sp SkBlurImageFilter::onFilterImage(SkSpecialImage* source, context, inputTexture.get(), sk_ref_sp(source->getColorSpace()), - source->props().isGammaCorrect(), dstBounds, &inputBounds, sigma.x(), diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index 76f446c2c2..9e0315f2b7 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -1245,10 +1245,8 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src, // If we're doing a normal blur, we can clobber the pathTexture in the // gaussianBlur. Otherwise, we need to save it for later compositing. - static const bool kIsGammaCorrect = false; bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle); - sk_sp drawContext(SkGpuBlurUtils::GaussianBlur(context, src, - nullptr, kIsGammaCorrect, + sk_sp drawContext(SkGpuBlurUtils::GaussianBlur(context, src, nullptr, clipRect, nullptr, xformedSigma, xformedSigma)); if (!drawContext) { diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp index 02629f7087..aad1c3f24a 100644 --- a/src/effects/SkGpuBlurUtils.cpp +++ b/src/effects/SkGpuBlurUtils.cpp @@ -183,7 +183,6 @@ namespace SkGpuBlurUtils { sk_sp GaussianBlur(GrContext* context, GrTexture* origSrc, sk_sp colorSpace, - bool gammaCorrect, const SkIRect& dstBounds, const SkIRect* srcBounds, float sigmaX, @@ -227,13 +226,9 @@ sk_sp GaussianBlur(GrContext* context, const int height = dstBounds.height(); const GrPixelConfig config = srcTexture->config(); - const SkSurfaceProps props(gammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0, - SkSurfaceProps::kLegacyFontHost_InitType); - sk_sp dstDrawContext(context->newDrawContext(SkBackingFit::kApprox, width, height, config, colorSpace, - 0, kDefault_GrSurfaceOrigin, - &props)); + 0, kDefault_GrSurfaceOrigin)); if (!dstDrawContext) { return nullptr; } @@ -253,8 +248,7 @@ sk_sp GaussianBlur(GrContext* context, sk_sp tmpDrawContext(context->newDrawContext(SkBackingFit::kApprox, width, height, config, colorSpace, - 0, kDefault_GrSurfaceOrigin, - &props)); + 0, kDefault_GrSurfaceOrigin)); if (!tmpDrawContext) { return nullptr; } @@ -265,7 +259,7 @@ sk_sp GaussianBlur(GrContext* context, for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { GrPaint paint; - paint.setGammaCorrect(gammaCorrect); + paint.setGammaCorrect(dstDrawContext->isGammaCorrect()); SkMatrix matrix; matrix.setIDiv(srcTexture->width(), srcTexture->height()); SkIRect dstRect(srcRect); @@ -359,7 +353,7 @@ sk_sp GaussianBlur(GrContext* context, matrix.setIDiv(srcDrawContext->width(), srcDrawContext->height()); GrPaint paint; - paint.setGammaCorrect(gammaCorrect); + paint.setGammaCorrect(dstDrawContext->isGammaCorrect()); // FIXME: this should be mitchell, not bilinear. GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode); sk_sp tex(srcDrawContext->asTexture()); diff --git a/src/effects/SkGpuBlurUtils.h b/src/effects/SkGpuBlurUtils.h index 550f3b8d6f..a5de6a242a 100644 --- a/src/effects/SkGpuBlurUtils.h +++ b/src/effects/SkGpuBlurUtils.h @@ -24,7 +24,6 @@ namespace SkGpuBlurUtils { * @param context The GPU context * @param srcTexture The source texture to be blurred. * @param colorSpace Color space of the source (used for the drawContext result, too). - * @param gammaCorrect Should blur be gamma-correct (sRGB to linear, etc...) * @param dstBounds The destination bounds, relative to the source texture. * @param srcBounds The source bounds, relative to the source texture. If non-null, * no pixels will be sampled outside of this rectangle. @@ -35,7 +34,6 @@ namespace SkGpuBlurUtils { sk_sp GaussianBlur(GrContext* context, GrTexture* srcTexture, sk_sp colorSpace, - bool gammaCorrect, const SkIRect& dstBounds, const SkIRect* srcBounds, float sigmaX,