Apply paint color to alpha-only textures in drawEdgeAAImageSet

This makes batch texture ops consistent with singleton texture ops, and
images drawn through a texture producer.

Bug: chromium:1102578
Change-Id: I490b20940ef6f1899396b786369271ce7130e8a9
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/301540
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 6dee700..b6fd72d 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -323,6 +323,17 @@
             !paint.getImageFilter() && paint.getFilterQuality() < kMedium_SkFilterQuality);
 }
 
+static SkPMColor4f texture_color(SkColor4f paintColor, float entryAlpha, GrColorType srcColorType,
+                                 const GrColorInfo& dstColorInfo) {
+    paintColor.fA *= entryAlpha;
+    if (GrColorTypeIsAlphaOnly(srcColorType)) {
+        return SkColor4fPrepForDst(paintColor, dstColorInfo).premul();
+    } else {
+        float paintAlpha = SkTPin(paintColor.fA, 0.f, 1.f);
+        return { paintAlpha, paintAlpha, paintAlpha, paintAlpha };
+    }
+}
+
 // Assumes srcRect and dstRect have already been optimized to fit the proxy
 static void draw_texture(GrRenderTargetContext* rtc, const GrClip* clip, const SkMatrix& ctm,
                          const SkPaint& paint, const SkRect& srcRect, const SkRect& dstRect,
@@ -359,14 +370,8 @@
             constraint = SkCanvas::kStrict_SrcRectConstraint;
         }
     }
-    SkPMColor4f color;
-    if (GrColorTypeIsAlphaOnly(srcColorInfo.colorType())) {
-        color = SkColor4fPrepForDst(paint.getColor4f(), dstInfo).premul();
-    } else {
-        float paintAlpha = paint.getColor4f().fA;
-        color = { paintAlpha, paintAlpha, paintAlpha, paintAlpha };
-    }
 
+    SkPMColor4f color = texture_color(paint.getColor4f(), 1.f, srcColorInfo.colorType(), dstInfo);
     if (dstClip) {
         // Get source coords corresponding to dstClip
         SkPoint srcQuad[4];
@@ -851,7 +856,9 @@
         textures[i].fDstClipQuad = clip;
         textures[i].fPreViewMatrix =
                 set[i].fMatrixIndex < 0 ? nullptr : preViewMatrices + set[i].fMatrixIndex;
-        textures[i].fAlpha = set[i].fAlpha * paint.getAlphaf();
+        textures[i].fColor = texture_color(paint.getColor4f(), set[i].fAlpha,
+                                           SkColorTypeToGrColorType(image->colorType()),
+                                           fRenderTargetContext->colorInfo());
         textures[i].fAAFlags = SkToGrQuadAAFlags(set[i].fAAFlags);
 
         if (n > 0 &&