Delay SkPaint->GrPaint conversion in text rendering.

This fixes an issue where color filters aren't correctly applied to color glyphs. Instead we apply the filter to the SkPaint's color which is correct for mask glyphs only.

Add color filter and alpha + various effects to coloremoji gm

Change-Id: If77dece71d43468fec65499857eaaaedb56428e9
Reviewed-on: https://skia-review.googlesource.com/6891
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Jim Van Verth <jvanverth@google.com>
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp
index c1ebef6..c139bc9f 100644
--- a/gm/coloremoji.cpp
+++ b/gm/coloremoji.cpp
@@ -9,9 +9,9 @@
 
 #include "Resources.h"
 #include "SkBlurImageFilter.h"
+#include "SkCanvas.h"
 #include "SkColorFilterImageFilter.h"
 #include "SkColorMatrixFilter.h"
-#include "SkCanvas.h"
 #include "SkGradientShader.h"
 #include "SkStream.h"
 #include "SkTypeface.h"
@@ -42,6 +42,11 @@
     return SkBlurImageFilter::Make(amount, amount, std::move(input));
 }
 
+static sk_sp<SkColorFilter> make_color_filter() {
+    return SkColorMatrixFilter::MakeLightingFilter(SkColorSetRGB(0x00, 0x80, 0xFF),
+                                                   SkColorSetRGB(0xFF, 0x20, 0x00));
+}
+
 namespace skiagm {
 
 class ColorEmojiGM : public GM {
@@ -64,9 +69,7 @@
         return name;
     }
 
-    SkISize onISize() override {
-        return SkISize::Make(650, 900);
-    }
+    SkISize onISize() override { return SkISize::Make(650, 1200); }
 
     void onDraw(SkCanvas* canvas) override {
 
@@ -94,26 +97,36 @@
         for (int makeLinear = 0; makeLinear < 2; makeLinear++) {
             for (int makeBlur = 0; makeBlur < 2; makeBlur++) {
                 for (int makeGray = 0; makeGray < 2; makeGray++) {
-                    SkPaint shaderPaint;
-                    shaderPaint.setTypeface(paint.refTypeface());
-                    if (SkToBool(makeLinear)) {
-                        shaderPaint.setShader(MakeLinear());
-                    }
+                    for (int makeMode = 0; makeMode < 2; ++makeMode) {
+                        for (int alpha = 0; alpha < 2; ++alpha) {
+                            SkPaint shaderPaint;
+                            shaderPaint.setTypeface(sk_ref_sp(paint.getTypeface()));
+                            if (SkToBool(makeLinear)) {
+                                shaderPaint.setShader(MakeLinear());
+                            }
 
-                    if (SkToBool(makeBlur) && SkToBool(makeGray)) {
-                        sk_sp<SkImageFilter> grayScale(make_grayscale(nullptr));
-                        sk_sp<SkImageFilter> blur(make_blur(3.0f, std::move(grayScale)));
-                        shaderPaint.setImageFilter(std::move(blur));
-                    } else if (SkToBool(makeBlur)) {
-                        shaderPaint.setImageFilter(make_blur(3.0f, nullptr));
-                    } else if (SkToBool(makeGray)) {
-                        shaderPaint.setImageFilter(make_grayscale(nullptr));
+                            if (SkToBool(makeBlur) && SkToBool(makeGray)) {
+                                sk_sp<SkImageFilter> grayScale(make_grayscale(nullptr));
+                                sk_sp<SkImageFilter> blur(make_blur(3.0f, std::move(grayScale)));
+                                shaderPaint.setImageFilter(std::move(blur));
+                            } else if (SkToBool(makeBlur)) {
+                                shaderPaint.setImageFilter(make_blur(3.0f, nullptr));
+                            } else if (SkToBool(makeGray)) {
+                                shaderPaint.setImageFilter(make_grayscale(nullptr));
+                            }
+                            if (makeMode) {
+                                shaderPaint.setColorFilter(make_color_filter());
+                            }
+                            if (alpha) {
+                                shaderPaint.setAlpha(0x80);
+                            }
+                            shaderPaint.setTextSize(30);
+                            shaderPaint.getFontMetrics(&metrics);
+                            y += -metrics.fAscent;
+                            canvas->drawText(text, strlen(text), 380, y, shaderPaint);
+                            y += metrics.fDescent + metrics.fLeading;
+                        }
                     }
-                    shaderPaint.setTextSize(30);
-                    shaderPaint.getFontMetrics(&metrics);
-                    y += -metrics.fAscent;
-                    canvas->drawText(text, strlen(text), 380, y, shaderPaint);
-                    y += metrics.fDescent + metrics.fLeading;
                 }
             }
         }