diff options
author | brianosman <brianosman@google.com> | 2016-04-13 13:10:14 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-04-13 13:10:14 -0700 |
commit | b461d3457567cf79a3efac3123c00f7afc37fecb (patch) | |
tree | 6b1600d0da18cefc3e29568419354bd68c9e5b41 /src | |
parent | 54ef1a7c95bcc8e507f7d6ccd9a49bd9a110ba90 (diff) |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/effects/SkBlurImageFilter.cpp | 2 | ||||
-rw-r--r-- | src/effects/SkGpuBlurUtils.cpp | 12 | ||||
-rw-r--r-- | src/effects/SkGpuBlurUtils.h | 4 | ||||
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 2 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 40 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice_drawTexture.cpp | 2 | ||||
-rw-r--r-- | src/gpu/batches/GrAtlasTextBatch.cpp | 13 | ||||
-rw-r--r-- | src/gpu/batches/GrAtlasTextBatch.h | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrDistanceFieldGeoProc.h | 16 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.cpp | 9 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextBlob.h | 2 | ||||
-rw-r--r-- | src/gpu/text/GrAtlasTextContext.cpp | 4 | ||||
-rw-r--r-- | src/gpu/text/GrDistanceFieldAdjustTable.cpp | 2 | ||||
-rw-r--r-- | src/gpu/text/GrDistanceFieldAdjustTable.h | 8 | ||||
-rw-r--r-- | src/gpu/text/GrStencilAndCoverTextContext.cpp | 4 | ||||
-rw-r--r-- | src/views/SkWindow.cpp | 4 |
17 files changed, 73 insertions, 67 deletions
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index b8ec28f051..d387c2fda4 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -115,7 +115,7 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source, 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 90619f9dc8..0ecc5010c3 100644 --- a/src/effects/SkGpuBlurUtils.cpp +++ b/src/effects/SkGpuBlurUtils.cpp @@ -56,7 +56,7 @@ static void convolve_gaussian_1d(GrDrawContext* drawContext, 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 @@ static void convolve_gaussian_2d(GrDrawContext* drawContext, 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 @@ static void convolve_gaussian(GrDrawContext* drawContext, GrTexture* GaussianBlur(GrContext* context, GrTexture* srcTexture, bool canClobberSrc, - bool allowSRGBInputs, + bool gammaCorrect, const SkRect& dstBounds, const SkRect* srcBounds, float sigmaX, @@ -232,7 +232,7 @@ GrTexture* GaussianBlur(GrContext* context, 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 @@ GrTexture* GaussianBlur(GrContext* context, 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 @@ GrTexture* GaussianBlur(GrContext* context, 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 e81e5daddb..7dbfa138ea 100644 --- a/src/effects/SkGpuBlurUtils.h +++ b/src/effects/SkGpuBlurUtils.h @@ -26,7 +26,7 @@ namespace SkGpuBlurUtils { * @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 @@ namespace SkGpuBlurUtils { 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 0dd518fdf7..8edc6b3977 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -335,7 +335,7 @@ void GrBlurUtils::drawPathWithMaskFilter(GrContext* context, } 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 d9727415b2..9bc60c2036 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -397,7 +397,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) { GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -448,7 +448,7 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, 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 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -522,7 +522,7 @@ void SkGpuDevice::drawRect(const SkDraw& draw, const SkRect& rect, const SkPaint GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -541,7 +541,7 @@ void SkGpuDevice::drawRRect(const SkDraw& draw, const SkRRect& rect, GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -617,7 +617,7 @@ void SkGpuDevice::drawDRRect(const SkDraw& draw, const SkRRect& outer, 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 @@ void SkGpuDevice::drawOval(const SkDraw& draw, const SkRect& oval, const SkPaint GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -1147,7 +1147,7 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, 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 @@ void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap, fp.reset(GrFragmentProcessor::MulOutputByInputAlpha(fp)); } if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -1403,7 +1403,7 @@ void SkGpuDevice::drawDevice(const SkDraw& draw, SkBaseDevice* device, } if (!SkPaintToGrPaintReplaceShader(this->context(), paint, fp, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -1543,7 +1543,7 @@ void SkGpuDevice::drawProducerNine(const SkDraw& draw, GrTextureProducer* produc 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 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 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 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, 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 @@ void SkGpuDevice::drawVertices(const SkDraw& draw, SkCanvas::VertexMode vmode, // 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 @@ void SkGpuDevice::drawAtlas(const SkDraw& draw, const SkImage* atlas, const SkRS 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 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text, GrPaint grPaint; if (!SkPaintToGrPaint(this->context(), paint, *draw.fMatrix, - this->surfaceProps().allowSRGBInputs(), &grPaint)) { + this->surfaceProps().isGammaCorrect(), &grPaint)) { return; } @@ -1788,7 +1788,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteL 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 8464895eab..9b197efa51 100644 --- a/src/gpu/SkGpuDevice_drawTexture.cpp +++ b/src/gpu/SkGpuDevice_drawTexture.cpp @@ -206,7 +206,7 @@ void SkGpuDevice::drawTextureProducerImpl(GrTextureProducer* producer, 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 b23a4ccd7b..bdf69861a4 100644 --- a/src/gpu/batches/GrAtlasTextBatch.cpp +++ b/src/gpu/batches/GrAtlasTextBatch.cpp @@ -264,7 +264,7 @@ GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr // 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 @@ GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr 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 @@ GrGeometryProcessor* GrAtlasTextBatch::setupDfProcessor(const SkMatrix& viewMatr #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 629027a003..72e299d3fa 100644 --- a/src/gpu/batches/GrAtlasTextBatch.h +++ b/src/gpu/batches/GrAtlasTextBatch.h @@ -58,7 +58,7 @@ public: 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 @@ public: 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 @@ private: // 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 e754661065..5dd70cd0b8 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -82,7 +82,8 @@ public: 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 @@ public: // 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 @@ public: 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 @@ public: // 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 2786b7e823..406c352409 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.h +++ b/src/gpu/effects/GrDistanceFieldGeoProc.h @@ -17,12 +17,12 @@ class GrGLDistanceFieldLCDTextGeoProc; 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 @@ enum GrDistanceFieldEffectFlags { // 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 60f905df5f..65b84ddbc8 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrAtlasTextBlob.cpp @@ -257,7 +257,7 @@ inline GrDrawBatch* GrAtlasTextBlob::createBatch( 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 @@ inline GrDrawBatch* GrAtlasTextBlob::createBatch( } 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 @@ void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui 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 9631ef1024..3fd45990eb 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrAtlasTextBlob.h @@ -502,7 +502,7 @@ private: 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 6a1f7af4b3..52960e879b 100644 --- a/src/gpu/text/GrAtlasTextContext.cpp +++ b/src/gpu/text/GrAtlasTextContext.cpp @@ -124,7 +124,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc, // 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 @@ DRAW_BATCH_TEST_DEFINE(TextBlobBatch) { 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 c6da175e0b..3aa96b5f2d 100644 --- a/src/gpu/text/GrDistanceFieldAdjustTable.cpp +++ b/src/gpu/text/GrDistanceFieldAdjustTable.cpp @@ -94,5 +94,5 @@ SkScalar* build_distance_adjust_table(SkScalar paintGamma, SkScalar deviceGamma) 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 f9b5161e95..0f5c6f29ab 100644 --- a/src/gpu/text/GrDistanceFieldAdjustTable.h +++ b/src/gpu/text/GrDistanceFieldAdjustTable.h @@ -18,18 +18,18 @@ struct GrDistanceFieldAdjustTable : public SkNVRefCnt<GrDistanceFieldAdjustTable 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 a8dc20215a..1355036ffe 100644 --- a/src/gpu/text/GrStencilAndCoverTextContext.cpp +++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp @@ -165,7 +165,7 @@ void GrStencilAndCoverTextContext::uncachedDrawTextBlob(GrContext* context, 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 @@ void GrStencilAndCoverTextContext::drawTextBlob(GrContext* context, GrDrawContex } 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 bcc7b0298f..244bc49742 100644 --- a/src/views/SkWindow.cpp +++ b/src/views/SkWindow.cpp @@ -74,8 +74,8 @@ void SkWindow::setColorType(SkColorType ct, SkColorProfileType pt) { // 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())); } |