Pre-multiply gradient colors the right way

Alpha pre-multiplication must be done after applying the
opto-electronic transfer function when linear blending is
disabled. The correct way would be to pre-multiply before
gamma encoding but this leads to improper blending which
cannot be corrected without using sRGB frame buffers and
texture sampling.

Bug: 33010587
Test: cts-tradefed run singleCommand cts-dev --module CtsUiRenderingTestCases --test android.uirendering.cts.testclasses.GradientTests
Change-Id: I5f04bda4cb9f63674537aef5931621c14d601884
diff --git a/libs/hwui/SkiaShader.cpp b/libs/hwui/SkiaShader.cpp
index 34e6a06..0f6651b 100644
--- a/libs/hwui/SkiaShader.cpp
+++ b/libs/hwui/SkiaShader.cpp
@@ -81,7 +81,7 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-// gradient shader matrix helpers
+// Gradient shader matrix helpers
 ///////////////////////////////////////////////////////////////////////////////
 
 static void toLinearUnitMatrix(const SkPoint pts[2], SkMatrix* matrix) {
@@ -161,7 +161,7 @@
     gradInfo.fColorOffsets = &colorOffsets[0];
     shader.asAGradient(&gradInfo);
 
-    if (CC_UNLIKELY(!isSimpleGradient(gradInfo))) {
+    if (CC_UNLIKELY(!description->isSimpleGradient)) {
         outData->gradientSampler = (*textureUnit)++;
 
 #ifndef SK_SCALAR_IS_FLOAT
@@ -174,8 +174,8 @@
         outData->gradientSampler = 0;
         outData->gradientTexture = nullptr;
 
-        outData->startColor.setSRGB(gradInfo.fColors[0]);
-        outData->endColor.setSRGB(gradInfo.fColors[1]);
+        outData->startColor.setUnPreMultipliedSRGB(gradInfo.fColors[0]);
+        outData->endColor.setUnPreMultipliedSRGB(gradInfo.fColors[1]);
     }
 
     return true;