Rename lots of things from 'sRGB' to 'GammaCorrect', where appropriate
Trying to be much more explicit about where we really mean sRGB as a format,
and where we mean gamma-correct, as in: "not legacy behavior". Most of the
changes to rendering behavior are dependent on the latter, so let's be precise.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1884873006
Review URL: https://codereview.chromium.org/1884873006
diff --git a/dm/DMGpuSupport.h b/dm/DMGpuSupport.h
index 173befd..742ec18 100644
--- a/dm/DMGpuSupport.h
+++ b/dm/DMGpuSupport.h
@@ -37,7 +37,7 @@
bool useDIText) {
uint32_t flags = useDIText ? SkSurfaceProps::kUseDeviceIndependentFonts_Flag : 0;
if (SkImageInfoIsGammaCorrect(info)) {
- flags |= SkSurfaceProps::kAllowSRGBInputs_Flag;
+ flags |= SkSurfaceProps::kGammaCorrect_Flag;
}
SkSurfaceProps props(flags, SkSurfaceProps::kLegacyFontHost_InitType);
return SkSurface::MakeRenderTarget(grFactory->get(type, options), SkBudgeted::kNo,
diff --git a/gm/dftext.cpp b/gm/dftext.cpp
index c66064a..e6aba08 100644
--- a/gm/dftext.cpp
+++ b/gm/dftext.cpp
@@ -51,9 +51,9 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(),
inputCanvas->imageInfo().profileType());
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- uint32_t allowSRGBInputs = inputCanvas->getProps(&canvasProps)
- ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
- SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | allowSRGBInputs,
+ uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps)
+ ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
+ SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | gammaCorrect,
SkSurfaceProps::kLegacyFontHost_InitType);
auto surface(SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props));
SkCanvas* canvas = surface ? surface->getCanvas() : inputCanvas;
diff --git a/gm/surface.cpp b/gm/surface.cpp
index e104cb5..503b887 100644
--- a/gm/surface.cpp
+++ b/gm/surface.cpp
@@ -22,7 +22,7 @@
}
static sk_sp<SkSurface> make_surface(GrContext* ctx, const SkImageInfo& info, SkPixelGeometry geo,
- int disallowAA, int disallowDither, bool allowSRGBInputs) {
+ int disallowAA, int disallowDither, bool gammaCorrect) {
uint32_t flags = 0;
if (disallowAA) {
flags |= SkSurfaceProps::kDisallowAntiAlias_Flag;
@@ -30,8 +30,8 @@
if (disallowDither) {
flags |= SkSurfaceProps::kDisallowDither_Flag;
}
- if (allowSRGBInputs) {
- flags |= SkSurfaceProps::kAllowSRGBInputs_Flag;
+ if (gammaCorrect) {
+ flags |= SkSurfaceProps::kGammaCorrect_Flag;
}
SkSurfaceProps props(flags, geo);
@@ -80,7 +80,7 @@
const SkImageInfo info = SkImageInfo::MakeN32(W, H, kOpaque_SkAlphaType,
canvas->imageInfo().profileType());
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- bool allowSRGBInputs = canvas->getProps(&canvasProps) && canvasProps.allowSRGBInputs();
+ bool gammaCorrrect = canvas->getProps(&canvasProps) && canvasProps.isGammaCorrect();
const struct {
SkPixelGeometry fGeo;
@@ -99,7 +99,7 @@
SkScalar y = 0;
for (size_t i = 0; i < SK_ARRAY_COUNT(rec); ++i) {
auto surface(make_surface(ctx, info, rec[i].fGeo, disallowAA, disallowDither,
- allowSRGBInputs));
+ gammaCorrrect));
test_draw(surface->getCanvas(), rec[i].fLabel);
surface->draw(canvas, x, y, nullptr);
y += H;
diff --git a/gm/textblobgeometrychange.cpp b/gm/textblobgeometrychange.cpp
index b02bc07..87c432f 100644
--- a/gm/textblobgeometrychange.cpp
+++ b/gm/textblobgeometrychange.cpp
@@ -44,9 +44,9 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(200, 200, canvas->imageInfo().profileType());
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- uint32_t allowSRGBInputs = canvas->getProps(&canvasProps)
- ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
- SkSurfaceProps props(allowSRGBInputs, kUnknown_SkPixelGeometry);
+ uint32_t gammaCorrect = canvas->getProps(&canvasProps)
+ ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
+ SkSurfaceProps props(gammaCorrect, kUnknown_SkPixelGeometry);
auto surface = canvas->makeSurface(info, &props);
if (!surface) {
surface = SkSurface::MakeRaster(info, &props);
diff --git a/gm/textblobmixedsizes.cpp b/gm/textblobmixedsizes.cpp
index e7eda39..9e57c2f 100644
--- a/gm/textblobmixedsizes.cpp
+++ b/gm/textblobmixedsizes.cpp
@@ -106,9 +106,9 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(onISize(),
inputCanvas->imageInfo().profileType());
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- uint32_t allowSRGBInputs = inputCanvas->getProps(&canvasProps)
- ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
- SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | allowSRGBInputs,
+ uint32_t gammaCorrect = inputCanvas->getProps(&canvasProps)
+ ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
+ SkSurfaceProps props(SkSurfaceProps::kUseDeviceIndependentFonts_Flag | gammaCorrect,
SkSurfaceProps::kLegacyFontHost_InitType);
surface = SkSurface::MakeRenderTarget(ctx, SkBudgeted::kNo, info, 0, &props);
canvas = surface.get() ? surface->getCanvas() : inputCanvas;
diff --git a/gm/textblobrandomfont.cpp b/gm/textblobrandomfont.cpp
index 285ba5b..267fe7a 100644
--- a/gm/textblobrandomfont.cpp
+++ b/gm/textblobrandomfont.cpp
@@ -103,9 +103,9 @@
SkImageInfo info = SkImageInfo::MakeN32Premul(kWidth, kHeight,
canvas->imageInfo().profileType());
SkSurfaceProps canvasProps(SkSurfaceProps::kLegacyFontHost_InitType);
- uint32_t allowSRGBInputs = canvas->getProps(&canvasProps)
- ? canvasProps.flags() & SkSurfaceProps::kAllowSRGBInputs_Flag : 0;
- SkSurfaceProps props(allowSRGBInputs, kUnknown_SkPixelGeometry);
+ uint32_t gammaCorrect = canvas->getProps(&canvasProps)
+ ? canvasProps.flags() & SkSurfaceProps::kGammaCorrect_Flag : 0;
+ SkSurfaceProps props(gammaCorrect, kUnknown_SkPixelGeometry);
auto surface(canvas->makeSurface(info, &props));
if (surface) {
SkPaint paint;
diff --git a/include/core/SkSurfaceProps.h b/include/core/SkSurfaceProps.h
index bd4fa8e..c9b2564 100644
--- a/include/core/SkSurfaceProps.h
+++ b/include/core/SkSurfaceProps.h
@@ -64,7 +64,7 @@
* It is recommended to enable this flag when rendering to an sRGB or floating point
* surface.
*/
- kAllowSRGBInputs_Flag = 1 << 3,
+ kGammaCorrect_Flag = 1 << 3,
};
/** Deprecated alias used by Chromium. Will be removed. */
static const Flags kUseDistanceFieldFonts_Flag = kUseDeviceIndependentFonts_Flag;
@@ -86,7 +86,7 @@
bool isUseDeviceIndependentFonts() const {
return SkToBool(fFlags & kUseDeviceIndependentFonts_Flag);
}
- bool allowSRGBInputs() const { return SkToBool(fFlags & kAllowSRGBInputs_Flag); }
+ bool isGammaCorrect() const { return SkToBool(fFlags & kGammaCorrect_Flag); }
private:
SkSurfaceProps();
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index 06954dc..61b3907 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -276,7 +276,7 @@
int width() const { return fRenderTarget->width(); }
int height() const { return fRenderTarget->height(); }
int numColorSamples() const { return fRenderTarget->numColorSamples(); }
- bool allowSRGBInputs() const { return fSurfaceProps.allowSRGBInputs(); }
+ bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); }
GrRenderTarget* accessRenderTarget() { return fRenderTarget; }
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index 87e0368..f9633e7 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -70,6 +70,15 @@
void setAllowSRGBInputs(bool allowSRGBInputs) { fAllowSRGBInputs = allowSRGBInputs; }
bool getAllowSRGBInputs() const { return fAllowSRGBInputs; }
+ /**
+ * Should rendering be gamma-correct. Causes sRGB inputs to perform conversion to linear,
+ * and outputs to be converted from linear to sRGB (if the destination is sRGB).
+ */
+ void setGammaCorrect(bool gammaCorrect) {
+ setDisableOutputConversionToSRGB(!gammaCorrect);
+ setAllowSRGBInputs(gammaCorrect);
+ }
+
const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
fXPFactory.reset(SkSafeRef(xpFactory));
return xpFactory;
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index b8ec28f..d387c2f 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -115,7 +115,7 @@
SkAutoTUnref<GrTexture> tex(SkGpuBlurUtils::GaussianBlur(context,
inputTexture,
false,
- source->props().allowSRGBInputs(),
+ source->props().isGammaCorrect(),
SkRect::Make(dstBounds),
&inputBoundsF,
sigma.x(),
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index 90619f9..0ecc501 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -56,7 +56,7 @@
bool useBounds,
float bounds[2]) {
GrPaint paint;
- paint.setAllowSRGBInputs(drawContext->allowSRGBInputs());
+ paint.setGammaCorrect(drawContext->isGammaCorrect());
SkAutoTUnref<GrFragmentProcessor> conv(GrConvolutionEffect::CreateGaussian(
texture, direction, radius, sigma, useBounds, bounds));
paint.addColorFragmentProcessor(conv);
@@ -79,7 +79,7 @@
SkISize size = SkISize::Make(2 * radiusX + 1, 2 * radiusY + 1);
SkIPoint kernelOffset = SkIPoint::Make(radiusX, radiusY);
GrPaint paint;
- paint.setAllowSRGBInputs(drawContext->allowSRGBInputs());
+ paint.setGammaCorrect(drawContext->isGammaCorrect());
SkIRect bounds;
if (srcBounds) {
srcBounds->roundOut(&bounds);
@@ -166,7 +166,7 @@
GrTexture* GaussianBlur(GrContext* context,
GrTexture* srcTexture,
bool canClobberSrc,
- bool allowSRGBInputs,
+ bool gammaCorrect,
const SkRect& dstBounds,
const SkRect* srcBounds,
float sigmaX,
@@ -232,7 +232,7 @@
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
GrPaint paint;
- paint.setAllowSRGBInputs(allowSRGBInputs);
+ paint.setGammaCorrect(gammaCorrect);
SkMatrix matrix;
matrix.setIDiv(srcTexture->width(), srcTexture->height());
SkRect dstRect(srcRect);
@@ -272,7 +272,7 @@
localSrcBounds = srcRect;
}
- SkSurfaceProps props(allowSRGBInputs ? SkSurfaceProps::kAllowSRGBInputs_Flag : 0,
+ SkSurfaceProps props(gammaCorrect ? SkSurfaceProps::kGammaCorrect_Flag : 0,
SkSurfaceProps::kLegacyFontHost_InitType);
// For really small blurs (certainly no wider than 5x5 on desktop gpus) it is faster to just
@@ -382,7 +382,7 @@
matrix.setIDiv(srcTexture->width(), srcTexture->height());
GrPaint paint;
- paint.setAllowSRGBInputs(allowSRGBInputs);
+ paint.setGammaCorrect(gammaCorrect);
// FIXME: this should be mitchell, not bilinear.
GrTextureParams params(SkShader::kClamp_TileMode, GrTextureParams::kBilerp_FilterMode);
paint.addColorTextureProcessor(srcTexture, matrix, params);
diff --git a/src/effects/SkGpuBlurUtils.h b/src/effects/SkGpuBlurUtils.h
index e81e5da..7dbfa13 100644
--- a/src/effects/SkGpuBlurUtils.h
+++ b/src/effects/SkGpuBlurUtils.h
@@ -26,7 +26,7 @@
* @param srcTexture The source texture to be blurred.
* @param canClobberSrc If true, srcTexture may be overwritten, and
* may be returned as the result.
- * @param allowSRGBInputs Should sRGB inputs be allowed to perform sRGB to linear conversion.
+ * @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.
@@ -38,7 +38,7 @@
GrTexture* GaussianBlur(GrContext* context,
GrTexture* srcTexture,
bool canClobberSrc,
- bool allowSRGBInputs,
+ bool gammaCorrect,
const SkRect& dstBounds,
const SkRect* srcBounds,
float sigmaX,
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 0dd518f..8edc6b3 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -335,7 +335,7 @@
}
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, paint, viewMatrix, drawContext->allowSRGBInputs(),
+ if (!SkPaintToGrPaint(context, paint, viewMatrix, drawContext->isGammaCorrect(),
&grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index d972741..9bc60c2 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -397,7 +397,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -448,7 +448,7 @@
GrStrokeInfo strokeInfo(paint, SkPaint::kStroke_Style);
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
SkPath path;
@@ -469,7 +469,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -522,7 +522,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -541,7 +541,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -617,7 +617,7 @@
if (stroke.isFillStyle() && !paint.getMaskFilter() && !paint.getPathEffect()) {
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -662,7 +662,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1147,7 +1147,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, viewMatrix, fp,
kAlpha_8_SkColorType == bitmap.colorType(),
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1242,7 +1242,7 @@
fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp));
}
if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1403,7 +1403,7 @@
}
if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1543,7 +1543,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(this->context(), paint, *draw.fMatrix, fp,
producer->isAlphaOnly(),
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1611,7 +1611,7 @@
GrPaint grPaint;
// we ignore the shader if texs is null.
if (!SkPaintToGrPaintNoShader(this->context(), copy,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1683,14 +1683,14 @@
colorMode = SkXfermode::kModulate_Mode;
}
if (!SkPaintToGrPaintWithXfermode(this->context(), paint, *draw.fMatrix, colorMode,
- false, this->surfaceProps().allowSRGBInputs(),
+ false, this->surfaceProps().isGammaCorrect(),
&grPaint)) {
return;
}
} else {
// We have a shader, but no colors to blend it against.
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
}
@@ -1699,14 +1699,14 @@
// We have colors, but either have no shader or no texture coords (which implies that
// we should ignore the shader).
if (!SkPaintToGrPaintWithPrimitiveColor(this->context(), paint,
- this->surfaceProps().allowSRGBInputs(),
+ this->surfaceProps().isGammaCorrect(),
&grPaint)) {
return;
}
} else {
// No colors and no shaders. Just draw with the paint color.
if (!SkPaintToGrPaintNoShader(this->context(), paint,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
}
@@ -1744,12 +1744,12 @@
GrPaint grPaint;
if (colors) {
if (!SkPaintToGrPaintWithXfermode(this->context(), p, *draw.fMatrix, mode, true,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
} else {
if (!SkPaintToGrPaint(this->context(), p, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
}
@@ -1769,7 +1769,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
@@ -1788,7 +1788,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 8464895..9b197ef 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -206,7 +206,7 @@
GrPaint grPaint;
if (!SkPaintToGrPaintWithTexture(fContext, paint, viewMatrix, fp, producer->isAlphaOnly(),
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
diff --git a/src/gpu/batches/GrAtlasTextBatch.cpp b/src/gpu/batches/GrAtlasTextBatch.cpp
index b23a4cc..bdf6986 100644
--- a/src/gpu/batches/GrAtlasTextBatch.cpp
+++ b/src/gpu/batches/GrAtlasTextBatch.cpp
@@ -264,7 +264,7 @@
// set up any flags
uint32_t flags = viewMatrix.isSimilarity() ? kSimilarity_DistanceFieldEffectFlag : 0;
flags |= viewMatrix.isScaleTranslate() ? kScaleOnly_DistanceFieldEffectFlag : 0;
- flags |= fUseSRGBDistanceTable ? kSRGB_DistanceFieldEffectFlag : 0;
+ flags |= fUseGammaCorrectDistanceTable ? kGammaCorrect_DistanceFieldEffectFlag : 0;
// see if we need to create a new effect
if (isLCD) {
@@ -274,11 +274,14 @@
GrColor colorNoPreMul = skcolor_to_grcolor_nopremultiply(filteredColor);
float redCorrection = fDistanceAdjustTable->getAdjustment(
- GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDistanceTable);
+ GrColorUnpackR(colorNoPreMul) >> kDistanceAdjustLumShift,
+ fUseGammaCorrectDistanceTable);
float greenCorrection = fDistanceAdjustTable->getAdjustment(
- GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDistanceTable);
+ GrColorUnpackG(colorNoPreMul) >> kDistanceAdjustLumShift,
+ fUseGammaCorrectDistanceTable);
float blueCorrection = fDistanceAdjustTable->getAdjustment(
- GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift, fUseSRGBDistanceTable);
+ GrColorUnpackB(colorNoPreMul) >> kDistanceAdjustLumShift,
+ fUseGammaCorrectDistanceTable);
GrDistanceFieldLCDTextGeoProc::DistanceAdjust widthAdjust =
GrDistanceFieldLCDTextGeoProc::DistanceAdjust::Make(redCorrection,
greenCorrection,
@@ -295,7 +298,7 @@
#ifdef SK_GAMMA_APPLY_TO_A8
U8CPU lum = SkColorSpaceLuminance::computeLuminance(SK_GAMMA_EXPONENT, filteredColor);
float correction = fDistanceAdjustTable->getAdjustment(
- lum >> kDistanceAdjustLumShift, fUseSRGBDistanceTable);
+ lum >> kDistanceAdjustLumShift, fUseGammaCorrectDistanceTable);
return GrDistanceFieldA8TextGeoProc::Create(color,
viewMatrix,
texture,
diff --git a/src/gpu/batches/GrAtlasTextBatch.h b/src/gpu/batches/GrAtlasTextBatch.h
index 629027a..72e299d 100644
--- a/src/gpu/batches/GrAtlasTextBatch.h
+++ b/src/gpu/batches/GrAtlasTextBatch.h
@@ -58,7 +58,7 @@
static GrAtlasTextBatch* CreateDistanceField(
int glyphCount, GrBatchFontCache* fontCache,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useSRGBDistanceTable,
+ bool useGammaCorrectDistanceTable,
SkColor filteredColor, bool isLCD,
bool useBGR) {
GrAtlasTextBatch* batch = new GrAtlasTextBatch;
@@ -66,7 +66,7 @@
batch->fFontCache = fontCache;
batch->fMaskType = isLCD ? kLCDDistanceField_MaskType : kGrayscaleDistanceField_MaskType;
batch->fDistanceAdjustTable.reset(SkRef(distanceAdjustTable));
- batch->fUseSRGBDistanceTable = useSRGBDistanceTable;
+ batch->fUseGammaCorrectDistanceTable = useGammaCorrectDistanceTable;
batch->fFilteredColor = filteredColor;
batch->fUseBGR = useBGR;
batch->fBatch.fNumGlyphs = glyphCount;
@@ -184,7 +184,7 @@
// Distance field properties
SkAutoTUnref<const GrDistanceFieldAdjustTable> fDistanceAdjustTable;
SkColor fFilteredColor;
- bool fUseSRGBDistanceTable;
+ bool fUseGammaCorrectDistanceTable;
friend class GrBlobRegenHelper; // Needs to trigger flushes
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
index e754661..5dd70cd 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp
@@ -82,7 +82,8 @@
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
- bool srgbOutput = SkToBool(dfTexEffect.getFlags() & kSRGB_DistanceFieldEffectFlag);
+ bool isGammaCorrect =
+ SkToBool(dfTexEffect.getFlags() & kGammaCorrect_DistanceFieldEffectFlag);
varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
vertBuilder->codeAppendf("%s = %s;", uv.vsOut(), dfTexEffect.inTextureCoords()->fName);
@@ -158,7 +159,7 @@
// The smoothstep falloff compensates for the non-linear sRGB response curve. If we are
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want distance
// mapped linearly to coverage, so use a linear step:
- if (srgbOutput) {
+ if (isGammaCorrect) {
fragBuilder->codeAppend(
"float val = clamp(distance + afwidth / (2.0 * afwidth), 0.0, 1.0);");
} else {
@@ -563,7 +564,8 @@
bool isUniformScale = (dfTexEffect.getFlags() & kUniformScale_DistanceFieldEffectMask) ==
kUniformScale_DistanceFieldEffectMask;
bool isSimilarity = SkToBool(dfTexEffect.getFlags() & kSimilarity_DistanceFieldEffectFlag);
- bool srgbOutput = SkToBool(dfTexEffect.getFlags() & kSRGB_DistanceFieldEffectFlag);
+ bool isGammaCorrect =
+ SkToBool(dfTexEffect.getFlags() & kGammaCorrect_DistanceFieldEffectFlag);
GrGLSLVertToFrag recipScale(kFloat_GrSLType);
GrGLSLVertToFrag uv(kVec2f_GrSLType);
varyingHandler->addVarying("TextureCoords", &uv, kHigh_GrSLPrecision);
@@ -681,7 +683,7 @@
// The smoothstep falloff compensates for the non-linear sRGB response curve. If we are
// doing gamma-correct rendering (to an sRGB or F16 buffer), then we actually want distance
// mapped linearly to coverage, so use a linear step:
- if (srgbOutput) {
+ if (isGammaCorrect) {
fragBuilder->codeAppend("vec4 val = "
"vec4(clamp(distance + vec3(afwidth) / vec3(2.0 * afwidth), 0.0, 1.0), 1.0f);");
} else {
diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h
index 2786b7e..406c352 100644
--- a/src/gpu/effects/GrDistanceFieldGeoProc.h
+++ b/src/gpu/effects/GrDistanceFieldGeoProc.h
@@ -17,12 +17,12 @@
class GrInvariantOutput;
enum GrDistanceFieldEffectFlags {
- kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix
- kScaleOnly_DistanceFieldEffectFlag = 0x02, // ctm has only scale and translate
- kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text
- kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order
- kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait mode (not used yet)
- kSRGB_DistanceFieldEffectFlag = 0x20, // assume sRGB dest (use linstep, not smoothstep)
+ kSimilarity_DistanceFieldEffectFlag = 0x01, // ctm is similarity matrix
+ kScaleOnly_DistanceFieldEffectFlag = 0x02, // ctm has only scale and translate
+ kUseLCD_DistanceFieldEffectFlag = 0x04, // use lcd text
+ kBGR_DistanceFieldEffectFlag = 0x08, // lcd display has bgr order
+ kPortrait_DistanceFieldEffectFlag = 0x10, // lcd display is in portrait mode (not used yet)
+ kGammaCorrect_DistanceFieldEffectFlag = 0x20, // assume gamma-correct output (linear blending)
kInvalid_DistanceFieldEffectFlag = 0x80, // invalid state (for initialization)
@@ -31,13 +31,13 @@
// The subset of the flags relevant to GrDistanceFieldA8TextGeoProc
kNonLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag |
kScaleOnly_DistanceFieldEffectFlag |
- kSRGB_DistanceFieldEffectFlag,
+ kGammaCorrect_DistanceFieldEffectFlag,
// The subset of the flags relevant to GrDistanceFieldLCDTextGeoProc
kLCD_DistanceFieldEffectMask = kSimilarity_DistanceFieldEffectFlag |
kScaleOnly_DistanceFieldEffectFlag |
kUseLCD_DistanceFieldEffectFlag |
kBGR_DistanceFieldEffectFlag |
- kSRGB_DistanceFieldEffectFlag,
+ kGammaCorrect_DistanceFieldEffectFlag,
};
/**
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 60f905d..65b84dd 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -257,7 +257,7 @@
GrColor color,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useSRGBDistanceTable,
+ bool useGammaCorrectDistanceTable,
GrBatchFontCache* cache) {
GrMaskFormat format = info.maskFormat();
GrColor subRunColor;
@@ -279,7 +279,8 @@
}
bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache,
- distanceAdjustTable, useSRGBDistanceTable,
+ distanceAdjustTable,
+ useGammaCorrectDistanceTable,
filteredColor, info.hasUseLCDText(), useBGR);
} else {
batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache);
@@ -311,13 +312,13 @@
continue;
}
- bool useSRGBDistanceTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
+ bool useGammaCorrectTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
!pipelineBuilder->getDisableOutputConversionToSRGB();
SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run,
subRun, viewMatrix, x, y, color,
skPaint, props,
- distanceAdjustTable, useSRGBDistanceTable,
+ distanceAdjustTable, useGammaCorrectTable,
cache));
dc->drawBatch(pipelineBuilder, batch);
}
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 9631ef1..3fd4599 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -502,7 +502,7 @@
GrColor color,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useSRGBDistanceTable,
+ bool useGammaCorrectDistanceTable,
GrBatchFontCache* cache);
struct BigGlyph {
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 6a1f7af..52960e8 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -124,7 +124,7 @@
// Though for the time being runs in the textblob can override the paint, they only touch font
// info.
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.allowSRGBInputs(), &grPaint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, props.isGammaCorrect(), &grPaint)) {
return;
}
@@ -400,7 +400,7 @@
skPaint.setSubpixelText(random->nextBool());
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.allowSRGBInputs(),
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, gSurfaceProps.isGammaCorrect(),
&grPaint)) {
SkFAIL("couldn't convert paint\n");
}
diff --git a/src/gpu/text/GrDistanceFieldAdjustTable.cpp b/src/gpu/text/GrDistanceFieldAdjustTable.cpp
index c6da175..3aa96b5 100644
--- a/src/gpu/text/GrDistanceFieldAdjustTable.cpp
+++ b/src/gpu/text/GrDistanceFieldAdjustTable.cpp
@@ -94,5 +94,5 @@
void GrDistanceFieldAdjustTable::buildDistanceAdjustTables() {
fTable = build_distance_adjust_table(SK_GAMMA_EXPONENT, SK_GAMMA_EXPONENT);
- fSRGBTable = build_distance_adjust_table(SK_Scalar1, SK_Scalar1);
+ fGammaCorrectTable = build_distance_adjust_table(SK_Scalar1, SK_Scalar1);
}
diff --git a/src/gpu/text/GrDistanceFieldAdjustTable.h b/src/gpu/text/GrDistanceFieldAdjustTable.h
index f9b5161..0f5c6f2 100644
--- a/src/gpu/text/GrDistanceFieldAdjustTable.h
+++ b/src/gpu/text/GrDistanceFieldAdjustTable.h
@@ -18,18 +18,18 @@
GrDistanceFieldAdjustTable() { this->buildDistanceAdjustTables(); }
~GrDistanceFieldAdjustTable() {
delete[] fTable;
- delete[] fSRGBTable;
+ delete[] fGammaCorrectTable;
}
- const SkScalar& getAdjustment(int i, bool useSRGBTable) const {
- return useSRGBTable ? fSRGBTable[i] : fTable[i];
+ const SkScalar& getAdjustment(int i, bool useGammaCorrectTable) const {
+ return useGammaCorrectTable ? fGammaCorrectTable[i] : fTable[i];
}
private:
void buildDistanceAdjustTables();
SkScalar* fTable;
- SkScalar* fSRGBTable;
+ SkScalar* fGammaCorrectTable;
};
#endif
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index a8dc202..1355036 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -165,7 +165,7 @@
runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint));
GrPaint grPaint;
- if (!SkPaintToGrPaint(context, runPaint, viewMatrix, dc->allowSRGBInputs(), &grPaint)) {
+ if (!SkPaintToGrPaint(context, runPaint, viewMatrix, dc->isGammaCorrect(), &grPaint)) {
return;
}
@@ -220,7 +220,7 @@
}
GrPaint paint;
- if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->allowSRGBInputs(), &paint)) {
+ if (!SkPaintToGrPaint(context, skPaint, viewMatrix, dc->isGammaCorrect(), &paint)) {
return;
}
diff --git a/src/views/SkWindow.cpp b/src/views/SkWindow.cpp
index bcc7b02..244bc49 100644
--- a/src/views/SkWindow.cpp
+++ b/src/views/SkWindow.cpp
@@ -74,8 +74,8 @@
// Set the global flag that enables or disables "legacy" mode, depending on our format.
// With sRGB 32-bit or linear FP 16, we turn on gamma-correct handling of inputs:
SkSurfaceProps props = this->getSurfaceProps();
- uint32_t flags = (props.flags() & ~SkSurfaceProps::kAllowSRGBInputs_Flag) |
- (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kAllowSRGBInputs_Flag : 0);
+ uint32_t flags = (props.flags() & ~SkSurfaceProps::kGammaCorrect_Flag) |
+ (SkColorAndProfileAreGammaCorrect(ct, pt) ? SkSurfaceProps::kGammaCorrect_Flag : 0);
this->setSurfaceProps(SkSurfaceProps(flags, props.pixelGeometry()));
}
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index 95b7802..c707b69 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -156,7 +156,7 @@
SkMatrix mat;
mat.reset();
if (!SkPaintToGrPaint(this->context(), paint, mat,
- this->surfaceProps().allowSRGBInputs(), &grPaint)) {
+ this->surfaceProps().isGammaCorrect(), &grPaint)) {
return;
}
SkMatrix textureMat;