Keep paint color range/precision into ops and GPs (using GrColor4h)

We still degrade to bytes when creating vertices (tagged TODO4F).

Note: Guarded for Chrome (by making GrColor4h a wrapper around
GrColor).

Bug: skia:
Change-Id: Id8a1d9eec7978d52b059cd9952666bc1217ee073
Reviewed-on: https://skia-review.googlesource.com/c/165527
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/effects/GrBezierEffect.cpp b/src/gpu/effects/GrBezierEffect.cpp
index e6d6413..31cffb6 100644
--- a/src/gpu/effects/GrBezierEffect.cpp
+++ b/src/gpu/effects/GrBezierEffect.cpp
@@ -38,7 +38,7 @@
 
         if (ce.color() != fColor) {
             float c[4];
-            GrColorToRGBAFloat(ce.color(), c);
+            ce.color().toFloats(c);
             pdman.set4fv(fColorUniform, 1, c);
             fColor = ce.color();
         }
@@ -52,7 +52,7 @@
 
 private:
     SkMatrix fViewMatrix;
-    GrColor fColor;
+    GrColor4h fColor;
     uint8_t fCoverageScale;
     GrClipEdgeType fEdgeType;
     UniformHandle fColorUniform;
@@ -63,7 +63,7 @@
 };
 
 GrGLConicEffect::GrGLConicEffect(const GrGeometryProcessor& processor)
-    : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverageScale(0xff) {
+    : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor4h_ILLEGAL), fCoverageScale(0xff) {
     const GrConicEffect& ce = processor.cast<GrConicEffect>();
     fEdgeType = ce.getEdgeType();
 }
@@ -232,7 +232,7 @@
     return new GrGLConicEffect(*this);
 }
 
-GrConicEffect::GrConicEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
+GrConicEffect::GrConicEffect(GrColor4h color, const SkMatrix& viewMatrix, uint8_t coverage,
                              GrClipEdgeType edgeType, const SkMatrix& localMatrix,
                              bool usesLocalCoords)
     : INHERITED(kGrConicEffect_ClassID)
@@ -256,9 +256,9 @@
         GrClipEdgeType edgeType =
                 static_cast<GrClipEdgeType>(
                         d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
-        gp = GrConicEffect::Make(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
-                                 edgeType, *d->caps(), GrTest::TestMatrix(d->fRandom),
-                                 d->fRandom->nextBool());
+        gp = GrConicEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+                                 GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
+                                 GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
     } while (nullptr == gp);
     return gp;
 }
@@ -291,7 +291,7 @@
 
         if (qe.color() != fColor) {
             float c[4];
-            GrColorToRGBAFloat(qe.color(), c);
+            qe.color().toFloats(c);
             pdman.set4fv(fColorUniform, 1, c);
             fColor = qe.color();
         }
@@ -305,7 +305,7 @@
 
 private:
     SkMatrix fViewMatrix;
-    GrColor fColor;
+    GrColor4h fColor;
     uint8_t fCoverageScale;
     GrClipEdgeType fEdgeType;
     UniformHandle fColorUniform;
@@ -316,7 +316,7 @@
 };
 
 GrGLQuadEffect::GrGLQuadEffect(const GrGeometryProcessor& processor)
-    : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor_ILLEGAL), fCoverageScale(0xff) {
+    : fViewMatrix(SkMatrix::InvalidMatrix()), fColor(GrColor4h_ILLEGAL), fCoverageScale(0xff) {
     const GrQuadEffect& ce = processor.cast<GrQuadEffect>();
     fEdgeType = ce.getEdgeType();
 }
@@ -434,7 +434,7 @@
     return new GrGLQuadEffect(*this);
 }
 
-GrQuadEffect::GrQuadEffect(GrColor color, const SkMatrix& viewMatrix, uint8_t coverage,
+GrQuadEffect::GrQuadEffect(GrColor4h color, const SkMatrix& viewMatrix, uint8_t coverage,
                            GrClipEdgeType edgeType, const SkMatrix& localMatrix,
                            bool usesLocalCoords)
     : INHERITED(kGrQuadEffect_ClassID)
@@ -457,9 +457,9 @@
     do {
         GrClipEdgeType edgeType = static_cast<GrClipEdgeType>(
                 d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
-        gp = GrQuadEffect::Make(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom), edgeType,
-                                *d->caps(), GrTest::TestMatrix(d->fRandom),
-                                d->fRandom->nextBool());
+        gp = GrQuadEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+                                GrTest::TestMatrix(d->fRandom), edgeType, *d->caps(),
+                                GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool());
     } while (nullptr == gp);
     return gp;
 }
@@ -499,7 +499,7 @@
 
         if (ce.color() != fColor) {
             float c[4];
-            GrColorToRGBAFloat(ce.color(), c);
+            ce.color().toFloats(c);
             pdman.set4fv(fColorUniform, 1, c);
             fColor = ce.color();
         }
@@ -510,7 +510,7 @@
 private:
     SkMatrix fViewMatrix;
     SkMatrix fDevKLMMatrix;
-    GrColor fColor;
+    GrColor4h fColor;
     GrClipEdgeType fEdgeType;
     UniformHandle fColorUniform;
     UniformHandle fViewMatrixUniform;
@@ -522,7 +522,7 @@
 GrGLCubicEffect::GrGLCubicEffect(const GrGeometryProcessor& processor)
     : fViewMatrix(SkMatrix::InvalidMatrix())
     , fDevKLMMatrix(SkMatrix::InvalidMatrix())
-    , fColor(GrColor_ILLEGAL) {
+    , fColor(GrColor4h_ILLEGAL) {
     const GrCubicEffect& ce = processor.cast<GrCubicEffect>();
     fEdgeType = ce.getEdgeType();
 }
@@ -661,7 +661,7 @@
     return new GrGLCubicEffect(*this);
 }
 
-GrCubicEffect::GrCubicEffect(GrColor color, const SkMatrix& viewMatrix, const SkMatrix&
+GrCubicEffect::GrCubicEffect(GrColor4h color, const SkMatrix& viewMatrix, const SkMatrix&
                              devKLMMatrix, GrClipEdgeType edgeType)
     : INHERITED(kGrCubicEffect_ClassID)
     , fColor(color)
@@ -682,9 +682,9 @@
         GrClipEdgeType edgeType =
                 static_cast<GrClipEdgeType>(
                         d->fRandom->nextULessThan(kGrClipEdgeTypeCnt));
-        gp = GrCubicEffect::Make(GrRandomColor(d->fRandom), GrTest::TestMatrix(d->fRandom),
-                                 GrTest::TestMatrix(d->fRandom), d->fRandom->nextBool(), edgeType,
-                                 *d->caps());
+        gp = GrCubicEffect::Make(GrColor4h::FromGrColor(GrRandomColor(d->fRandom)),
+                                 GrTest::TestMatrix(d->fRandom), GrTest::TestMatrix(d->fRandom),
+                                 d->fRandom->nextBool(), edgeType, *d->caps());
     } while (nullptr == gp);
     return gp;
 }