Simplify gamma-correctness for text rendering.
authorbrianosman <brianosman@google.com>
Thu, 14 Apr 2016 13:02:59 +0000 (06:02 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 14 Apr 2016 13:02:59 +0000 (06:02 -0700)
Just use the DC flag, independent of the destination pixel config or the
special output override flag (which is only to be used internally be
special effects that will never hit this code path.)

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1888473003

Review URL: https://codereview.chromium.org/1888473003

src/gpu/text/GrAtlasTextBlob.cpp
src/gpu/text/GrAtlasTextContext.cpp
src/gpu/text/GrAtlasTextContext.h

index 65b84ddbc8fe57b99c51d4cdd923724db117014a..7d807da06f7555c7c07448c6a966756cf8e52830 100644 (file)
@@ -312,13 +312,10 @@ void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui
             continue;
         }
 
-        bool useGammaCorrectTable = GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
-                                    !pipelineBuilder->getDisableOutputConversionToSRGB();
-
         SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run,
                                                           subRun, viewMatrix, x, y, color,
                                                           skPaint, props,
-                                                          distanceAdjustTable, useGammaCorrectTable,
+                                                          distanceAdjustTable, dc->isGammaCorrect(),
                                                           cache));
         dc->drawBatch(pipelineBuilder, batch);
     }
index 52960e879bc659b27f52c892e9af8e1017439c3a..22fd8a35811438b086ebc9869a7e113ffe3f5ac3 100644 (file)
@@ -53,12 +53,10 @@ GrColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd
     return canonicalColor;
 }
 
-uint32_t GrAtlasTextContext::ComputeScalerContextFlags(GrDrawContext* dc, const GrPaint& grPaint) {
-    // If we're rendering to an sRGB render target, and we aren't forcing sRGB blending off,
-    // then we can disable the gamma hacks. Otherwise, leave them on. In either case, we still
-    // want the contrast boost:
-    if (GrPixelConfigIsSRGB(dc->accessRenderTarget()->config()) &&
-        !grPaint.getDisableOutputConversionToSRGB()) {
+uint32_t GrAtlasTextContext::ComputeScalerContextFlags(GrDrawContext* dc) {
+    // If we're doing gamma-correct rendering, then we can disable the gamma hacks.
+    // Otherwise, leave them on. In either case, we still want the contrast boost:
+    if (dc->isGammaCorrect()) {
         return SkPaint::kBoostContrast_ScalerContextFlag;
     } else {
         return SkPaint::kFakeGammaAndBoostContrast_ScalerContextFlags;
@@ -128,7 +126,7 @@ void GrAtlasTextContext::drawTextBlob(GrContext* context, GrDrawContext* dc,
         return;
     }
 
-    uint32_t scalerContextFlags = ComputeScalerContextFlags(dc, grPaint);
+    uint32_t scalerContextFlags = ComputeScalerContextFlags(dc);
 
     if (cacheBlob) {
         if (cacheBlob->mustRegenerate(skPaint, grPaint.getColor(), blurRec, viewMatrix, x, y)) {
@@ -329,7 +327,7 @@ void GrAtlasTextContext::drawText(GrContext* context,
             CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFontCache(),
                                *context->caps()->shaderCaps(),
                                paint, skPaint,
-                               ComputeScalerContextFlags(dc, paint),
+                               ComputeScalerContextFlags(dc),
                                viewMatrix, props,
                                text, byteLength, x, y));
         blob->flushThrowaway(context, dc, props, fDistanceAdjustTable, skPaint, paint,
@@ -359,7 +357,7 @@ void GrAtlasTextContext::drawPosText(GrContext* context,
                                   context->getBatchFontCache(),
                                   *context->caps()->shaderCaps(),
                                   paint, skPaint,
-                                  ComputeScalerContextFlags(dc, paint),
+                                  ComputeScalerContextFlags(dc),
                                   viewMatrix, props,
                                   text, byteLength,
                                   pos, scalarsPerPosition,
index 6d9378304418de7ae360b16afc049dda03992187..928ce0abed3869059127e04b5d4b9d1d27604928 100644 (file)
@@ -53,7 +53,7 @@ private:
     // sets up the descriptor on the blob and returns a detached cache.  Client must attach
     inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
     // Determines if we need to use fake gamma (and contrast boost):
-    inline static uint32_t ComputeScalerContextFlags(GrDrawContext*, const GrPaint&);
+    inline static uint32_t ComputeScalerContextFlags(GrDrawContext*);
     static void RegenerateTextBlob(GrAtlasTextBlob* bmp,
                                    GrBatchFontCache*,
                                    const GrShaderCaps&,