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
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 01f4ac9..d5bde08 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -274,7 +274,7 @@
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 23fb2cb..37584ab 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -124,7 +124,6 @@
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 76f446c..9e0315f 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -1245,10 +1245,8 @@
// 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<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(context, src,
- nullptr, kIsGammaCorrect,
+ sk_sp<GrDrawContext> 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 02629f7..aad1c3f 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -183,7 +183,6 @@
sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
GrTexture* origSrc,
sk_sp<SkColorSpace> colorSpace,
- bool gammaCorrect,
const SkIRect& dstBounds,
const SkIRect* srcBounds,
float sigmaX,
@@ -227,13 +226,9 @@
const int height = dstBounds.height();
const GrPixelConfig config = srcTexture->config();
- const SkSurfaceProps props(gammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0,
- SkSurfaceProps::kLegacyFontHost_InitType);
-
sk_sp<GrDrawContext> 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<GrDrawContext> tmpDrawContext(context->newDrawContext(SkBackingFit::kApprox,
width, height, config, colorSpace,
- 0, kDefault_GrSurfaceOrigin,
- &props));
+ 0, kDefault_GrSurfaceOrigin));
if (!tmpDrawContext) {
return nullptr;
}
@@ -265,7 +259,7 @@
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 @@
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<GrTexture> tex(srcDrawContext->asTexture());
diff --git a/src/effects/SkGpuBlurUtils.h b/src/effects/SkGpuBlurUtils.h
index 550f3b8..a5de6a2 100644
--- a/src/effects/SkGpuBlurUtils.h
+++ b/src/effects/SkGpuBlurUtils.h
@@ -24,7 +24,6 @@
* @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 @@
sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
GrTexture* srcTexture,
sk_sp<SkColorSpace> colorSpace,
- bool gammaCorrect,
const SkIRect& dstBounds,
const SkIRect* srcBounds,
float sigmaX,