Fix LCD distance field text color filtering

Distance field text was applying the color filter to determine any gamma
adjustments, but not any effects of the shader as well.

Bug: skia:6669
Change-Id: I73384f68141fb523ea2058e00d0a9fbb2fbc622b
Reviewed-on: https://skia-review.googlesource.com/19049
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index be9bb27..a68f6f9 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -179,7 +179,7 @@
     // to regenerate the blob on any color change
     // We use the grPaint to get any color filter effects
     if (fKey.fCanonicalColor == SK_ColorTRANSPARENT &&
-        fFilteredPaintColor != paint.filteredUnpremulColor()) {
+        fLuminanceColor != paint.luminanceColor()) {
         return true;
     }
 
@@ -266,10 +266,10 @@
 
     std::unique_ptr<GrAtlasTextOp> op;
     if (info.drawAsDistanceFields()) {
-        GrColor filteredColor = paint.filteredUnpremulColor();
+        SkColor luminanceColor = paint.luminanceColor();
         bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry());
         op = GrAtlasTextOp::MakeDistanceField(glyphCount, cache, distanceAdjustTable,
-                                              useGammaCorrectDistanceTable, filteredColor,
+                                              useGammaCorrectDistanceTable, luminanceColor,
                                               info.hasUseLCDText(), useBGR);
     } else {
         op = GrAtlasTextOp::MakeBitmap(format, glyphCount, cache);
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 4cc1028..470d26f 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -240,9 +240,9 @@
     // The color here is the GrPaint color, and it is used to determine whether we
     // have to regenerate LCD text blobs.
     // We use this color vs the SkPaint color because it has the colorfilter applied.
-    void initReusableBlob(GrColor filteredColor, const SkMatrix& viewMatrix, SkScalar x,
+    void initReusableBlob(SkColor luminanceColor, const SkMatrix& viewMatrix, SkScalar x,
                           SkScalar y) {
-        fFilteredPaintColor = filteredColor;
+        fLuminanceColor = luminanceColor;
         this->setupViewMatrix(viewMatrix, x, y);
     }
 
@@ -530,7 +530,7 @@
     SkMatrix fInitialViewMatrix;
     SkMatrix fInitialViewMatrixInverse;
     size_t fSize;
-    GrColor fFilteredPaintColor;
+    SkColor fLuminanceColor;
     SkScalar fInitialX;
     SkScalar fInitialY;
 
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 9efe466..71c410e 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -166,7 +166,7 @@
                                             uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
                                             const SkSurfaceProps& props, const SkTextBlob* blob,
                                             SkScalar x, SkScalar y, SkDrawFilter* drawFilter) {
-    cacheBlob->initReusableBlob(paint.filteredUnpremulColor(), viewMatrix, x, y);
+    cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, x, y);
 
     // Regenerate textblob
     SkTextBlobRunIterator it(blob);
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 9baf341..20001a4 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -60,14 +60,12 @@
                 fPaint->getColorFilter()->filterColor4f(filteredColor.toSkColor4f()));
         }
         fFilteredPremulColor = filteredColor.premul().toGrColor();
-        fFilteredUnpremulColor = filteredColor.toGrColor();
     } else {
         SkColor filteredSkColor = fPaint->getColor();
         if (fPaint->getColorFilter()) {
             filteredSkColor = fPaint->getColorFilter()->filterColor(filteredSkColor);
         }
         fFilteredPremulColor = SkColorToPremulGrColor(filteredSkColor);
-        fFilteredUnpremulColor = SkColorToUnpremulGrColor(filteredSkColor);
     }
 }
 
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 9f38699..bbf3ca4 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -59,7 +59,7 @@
         // These expose the paint's color run through its color filter (if any). This is only valid
         // when drawing grayscale/lcd glyph masks and not when drawing color glyphs.
         GrColor filteredPremulColor() const { return fFilteredPremulColor; }
-        GrColor filteredUnpremulColor() const { return fFilteredUnpremulColor; }
+        SkColor luminanceColor() const { return fPaint->computeLuminanceColor(); }
 
         const SkPaint& skPaint() const { return *fPaint; }
         operator const SkPaint&() const { return this->skPaint(); }
@@ -80,7 +80,6 @@
         // This is the paint's color run through its color filter, if present. This color should
         // be used except when rendering bitmap text, in which case the bitmap must be filtered in
         // the fragment shader.
-        GrColor fFilteredUnpremulColor;
         GrColor fFilteredPremulColor;
     };
 
@@ -98,7 +97,6 @@
             fDstColorSpace = fOriginalPaint->dstColorSpace();
             fColorXformFromSRGB = fOriginalPaint->colorXformFromSRGB();
             fFilteredPremulColor = fOriginalPaint->filteredPremulColor();
-            fFilteredUnpremulColor = fOriginalPaint->filteredUnpremulColor();
         }
 
         bool modifyForRun(const SkTextBlobRunIterator&);