Regenerate LCD text blobs if GrPaint's color changes, not SkPaint.

The GrPaint's color takes into account shaders and color filters, so is a
more accurate picture of the color state.

BUG=chromium:511787

Review URL: https://codereview.chromium.org/1297053004
diff --git a/src/gpu/GrAtlasTextBlob.h b/src/gpu/GrAtlasTextBlob.h
index 63f9185..5b7b52e 100644
--- a/src/gpu/GrAtlasTextBlob.h
+++ b/src/gpu/GrAtlasTextBlob.h
@@ -184,7 +184,7 @@
     SkTArray<BigGlyph> fBigGlyphs;
     Key fKey;
     SkMatrix fViewMatrix;
-    SkColor fPaintColor;
+    GrColor fPaintColor;
     SkScalar fX;
     SkScalar fY;
 
diff --git a/src/gpu/GrAtlasTextContext.cpp b/src/gpu/GrAtlasTextContext.cpp
index 56486e9..a556128 100644
--- a/src/gpu/GrAtlasTextContext.cpp
+++ b/src/gpu/GrAtlasTextContext.cpp
@@ -242,11 +242,13 @@
 
 bool GrAtlasTextContext::MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTransY,
                                             const GrAtlasTextBlob& blob, const SkPaint& paint,
-                                            const SkMaskFilter::BlurRec& blurRec,
+                                            GrColor color, const SkMaskFilter::BlurRec& blurRec,
                                             const SkMatrix& viewMatrix, SkScalar x, SkScalar y) {
     // If we have LCD text then our canonical color will be set to transparent, in this case we have
     // to regenerate the blob on any color change
-    if (blob.fKey.fCanonicalColor == SK_ColorTRANSPARENT && blob.fPaintColor != paint.getColor()) {
+    // We use the grPaint to get any color filter effects
+    if (blob.fKey.fCanonicalColor == SK_ColorTRANSPARENT &&
+        blob.fPaintColor != color) {
         return true;
     }
 
@@ -395,7 +397,8 @@
     }
 
     if (cacheBlob) {
-        if (MustRegenerateBlob(&transX, &transY, *cacheBlob, skPaint, blurRec, viewMatrix, x, y)) {
+        if (MustRegenerateBlob(&transX, &transY, *cacheBlob, skPaint, grPaint.getColor(), blurRec,
+                               viewMatrix, x, y)) {
             // We have to remake the blob because changes may invalidate our masks.
             // TODO we could probably get away reuse most of the time if the pointer is unique,
             // but we'd have to clear the subrun information
@@ -403,7 +406,7 @@
             cacheBlob.reset(SkRef(fCache->createCachedBlob(blob, key, blurRec, skPaint,
                                                            kGrayTextVASize)));
             this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
-                                     blob, x, y, drawFilter, clipRect, rt, clip, grPaint);
+                                     blob, x, y, drawFilter, clipRect, rt, clip);
         } else {
             // If we can reuse the blob, then make sure we update the blob's viewmatrix, and x/y
             // offsets.  Note, we offset the vertex bounds right before flushing
@@ -420,7 +423,7 @@
                                                                             kGrayTextVASize));
                 GrTextBlobCache::SetupCacheBlobKey(sanityBlob, key, blurRec, skPaint);
                 this->regenerateTextBlob(sanityBlob, skPaint, grPaint.getColor(), viewMatrix,
-                                         blob, x, y, drawFilter, clipRect, rt, clip, grPaint);
+                                         blob, x, y, drawFilter, clipRect, rt, clip);
                 GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob);
             }
 
@@ -434,7 +437,7 @@
             cacheBlob.reset(fCache->createBlob(blob, kGrayTextVASize));
         }
         this->regenerateTextBlob(cacheBlob, skPaint, grPaint.getColor(), viewMatrix,
-                                 blob, x, y, drawFilter, clipRect, rt, clip, grPaint);
+                                 blob, x, y, drawFilter, clipRect, rt, clip);
     }
 
     this->flush(blob, cacheBlob, rt, skPaint, grPaint, drawFilter,
@@ -485,9 +488,11 @@
                                             const SkMatrix& viewMatrix,
                                             const SkTextBlob* blob, SkScalar x, SkScalar y,
                                             SkDrawFilter* drawFilter, const SkIRect& clipRect,
-                                            GrRenderTarget* rt, const GrClip& clip,
-                                            const GrPaint& paint) {
-    cacheBlob->fPaintColor = skPaint.getColor();
+                                            GrRenderTarget* rt, const GrClip& clip) {
+    // 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.
+    cacheBlob->fPaintColor = color;
     cacheBlob->fViewMatrix = viewMatrix;
     cacheBlob->fX = x;
     cacheBlob->fY = y;
@@ -566,7 +571,7 @@
                 }
             }
             if (fallbackTxt.count()) {
-                this->fallbackDrawPosText(cacheBlob, run, rt, clip, paint, runPaint, viewMatrix,
+                this->fallbackDrawPosText(cacheBlob, run, rt, clip, color, runPaint, viewMatrix,
                                           fallbackTxt, fallbackPos, scalarsPerPosition, dfOffset,
                                           clipRect);
             }
@@ -662,7 +667,7 @@
 inline void GrAtlasTextContext::fallbackDrawPosText(GrAtlasTextBlob* blob,
                                                     int runIndex,
                                                     GrRenderTarget* rt, const GrClip& clip,
-                                                    const GrPaint& paint,
+                                                    GrColor color,
                                                     const SkPaint& skPaint,
                                                     const SkMatrix& viewMatrix,
                                                     const SkTDArray<char>& fallbackTxt,
@@ -680,7 +685,7 @@
                                        fSurfaceProps, &viewMatrix, false);
     SkGlyphCache* cache = SkGlyphCache::DetachCache(run.fTypeface,
                                                     run.fOverrideDescriptor->getDesc());
-    this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, paint.getColor(), viewMatrix,
+    this->internalDrawBMPPosText(blob, runIndex, cache, skPaint, color, viewMatrix,
                                  fallbackTxt.begin(), fallbackTxt.count(),
                                  fallbackPos.begin(), scalarsPerPosition, offset, clipRect);
     SkGlyphCache::AttachCache(cache);
@@ -729,8 +734,8 @@
                                  &offset, skPaint);
         SkGlyphCache::AttachCache(cache);
         if (fallbackTxt.count()) {
-            this->fallbackDrawPosText(blob, 0, rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
-                                      fallbackPos, 2, offset, clipRect);
+            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix, 
+                                      fallbackTxt, fallbackPos, 2, offset, clipRect);
         }
     } else {
         blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
@@ -770,8 +775,9 @@
                                     textRatio, &fallbackTxt, &fallbackPos);
         SkGlyphCache::AttachCache(cache);
         if (fallbackTxt.count()) {
-            this->fallbackDrawPosText(blob, 0, rt, clip, paint, skPaint, viewMatrix, fallbackTxt,
-                                      fallbackPos, scalarsPerPosition, offset, clipRect);
+            this->fallbackDrawPosText(blob, 0, rt, clip, paint.getColor(), skPaint, viewMatrix, 
+                                      fallbackTxt, fallbackPos, scalarsPerPosition, offset, 
+                                      clipRect);
         }
     } else {
         blob = fCache->createBlob(glyphCount, 1, kGrayTextVASize);
diff --git a/src/gpu/GrAtlasTextContext.h b/src/gpu/GrAtlasTextContext.h
index 2945b02..7ebe42e 100644
--- a/src/gpu/GrAtlasTextContext.h
+++ b/src/gpu/GrAtlasTextContext.h
@@ -96,8 +96,7 @@
 
     // A helper for drawing BitmapText in a run of distance fields
     inline void fallbackDrawPosText(GrAtlasTextBlob*, int runIndex,
-                                    GrRenderTarget*, const GrClip&,
-                                    const GrPaint&,
+                                    GrRenderTarget*, const GrClip&, GrColor color,
                                     const SkPaint&, const SkMatrix& viewMatrix,
                                     const SkTDArray<char>& fallbackTxt,
                                     const SkTDArray<SkScalar>& fallbackPos,
@@ -136,14 +135,14 @@
     inline static GrColor ComputeCanonicalColor(const SkPaint&, bool lcd);
     inline SkGlyphCache* setupCache(Run*, const SkPaint&, const SkMatrix* viewMatrix, bool noGamma);
     static inline bool MustRegenerateBlob(SkScalar* outTransX, SkScalar* outTransY,
-                                          const GrAtlasTextBlob&, const SkPaint&,
+                                          const GrAtlasTextBlob&, const SkPaint&, GrColor,
                                           const SkMaskFilter::BlurRec&,
                                           const SkMatrix& viewMatrix, SkScalar x, SkScalar y);
     void regenerateTextBlob(GrAtlasTextBlob* bmp, const SkPaint& skPaint, GrColor,
                             const SkMatrix& viewMatrix,
                             const SkTextBlob* blob, SkScalar x, SkScalar y,
                             SkDrawFilter* drawFilter, const SkIRect& clipRect, GrRenderTarget*,
-                            const GrClip&, const GrPaint&);
+                            const GrClip&);
     inline static bool HasLCD(const SkTextBlob*);
     inline void initDistanceFieldPaint(GrAtlasTextBlob*, SkPaint*, SkScalar* textRatio,
                                        const SkMatrix&);