Remove SK_LEGACY_TESSELLATOR_CPU_COVERAGE

Bug: skia:
Change-Id: I1122518e00967cd809badd75e20d210c317c50e8
Reviewed-on: https://skia-review.googlesource.com/c/182445
Commit-Queue: Brian Salomon <bsalomon@google.com>
Auto-Submit: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index b753707..0138dbf 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -175,18 +175,6 @@
 
 /***************************************************************************************/
 
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-struct AAParams {
-    bool fTweakAlpha;
-    GrColor fColor;
-};
-#define AA_PARAM const AAParams* aaParams
-#define AA_ARG   aaParams
-#else
-#define AA_PARAM bool emitCoverage
-#define AA_ARG   emitCoverage
-#endif
-
 typedef bool (*CompareFunc)(const SkPoint& a, const SkPoint& b);
 
 bool sweep_lt_horiz(const SkPoint& a, const SkPoint& b) {
@@ -206,41 +194,32 @@
     Direction fDirection;
 };
 
-inline void* emit_vertex(Vertex* v, AA_PARAM, void* data) {
+inline void* emit_vertex(Vertex* v, bool emitCoverage, void* data) {
     GrVertexWriter verts{data};
     verts.write(v->fPoint);
 
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-    if (aaParams) {
-        if (aaParams->fTweakAlpha) {
-            verts.write(SkAlphaMulQ(aaParams->fColor, SkAlpha255To256(v->fAlpha)));
-        } else {
-            verts.write(aaParams->fColor, GrNormalizeByteToFloat(v->fAlpha));
-        }
-    }
-#else
     if (emitCoverage) {
         verts.write(GrNormalizeByteToFloat(v->fAlpha));
     }
-#endif
+
     return verts.fPtr;
 }
 
-void* emit_triangle(Vertex* v0, Vertex* v1, Vertex* v2, AA_PARAM, void* data) {
+void* emit_triangle(Vertex* v0, Vertex* v1, Vertex* v2, bool emitCoverage, void* data) {
     LOG("emit_triangle %g (%g, %g) %d\n", v0->fID, v0->fPoint.fX, v0->fPoint.fY, v0->fAlpha);
     LOG("              %g (%g, %g) %d\n", v1->fID, v1->fPoint.fX, v1->fPoint.fY, v1->fAlpha);
     LOG("              %g (%g, %g) %d\n", v2->fID, v2->fPoint.fX, v2->fPoint.fY, v2->fAlpha);
 #if TESSELLATOR_WIREFRAME
-    data = emit_vertex(v0, AA_ARG, data);
-    data = emit_vertex(v1, AA_ARG, data);
-    data = emit_vertex(v1, AA_ARG, data);
-    data = emit_vertex(v2, AA_ARG, data);
-    data = emit_vertex(v2, AA_ARG, data);
-    data = emit_vertex(v0, AA_ARG, data);
+    data = emit_vertex(v0, emitCoverage, data);
+    data = emit_vertex(v1, emitCoverage, data);
+    data = emit_vertex(v1, emitCoverage, data);
+    data = emit_vertex(v2, emitCoverage, data);
+    data = emit_vertex(v2, emitCoverage, data);
+    data = emit_vertex(v0, emitCoverage, data);
 #else
-    data = emit_vertex(v0, AA_ARG, data);
-    data = emit_vertex(v1, AA_ARG, data);
-    data = emit_vertex(v2, AA_ARG, data);
+    data = emit_vertex(v0, emitCoverage, data);
+    data = emit_vertex(v1, emitCoverage, data);
+    data = emit_vertex(v2, emitCoverage, data);
 #endif
     return data;
 }
@@ -566,7 +545,7 @@
             }
         }
 
-        void* emit(AA_PARAM, void* data) {
+        void* emit(bool emitCoverage, void* data) {
             Edge* e = fFirstEdge;
             VertexList vertices;
             vertices.append(e->fTop);
@@ -589,14 +568,14 @@
                 Vertex* curr = v;
                 Vertex* next = v->fNext;
                 if (count == 3) {
-                    return emit_triangle(prev, curr, next, AA_ARG, data);
+                    return emit_triangle(prev, curr, next, emitCoverage, data);
                 }
                 double ax = static_cast<double>(curr->fPoint.fX) - prev->fPoint.fX;
                 double ay = static_cast<double>(curr->fPoint.fY) - prev->fPoint.fY;
                 double bx = static_cast<double>(next->fPoint.fX) - curr->fPoint.fX;
                 double by = static_cast<double>(next->fPoint.fY) - curr->fPoint.fY;
                 if (ax * by - ay * bx >= 0.0) {
-                    data = emit_triangle(prev, curr, next, AA_ARG, data);
+                    data = emit_triangle(prev, curr, next, emitCoverage, data);
                     v->fPrev->fNext = v->fNext;
                     v->fNext->fPrev = v->fPrev;
                     count--;
@@ -653,13 +632,13 @@
         }
         return poly;
     }
-    void* emit(AA_PARAM, void *data) {
+    void* emit(bool emitCoverage, void *data) {
         if (fCount < 3) {
             return data;
         }
         LOG("emit() %d, size %d\n", fID, fCount);
         for (MonotonePoly* m = fHead; m != nullptr; m = m->fNext) {
-            data = m->emit(AA_ARG, data);
+            data = m->emit(emitCoverage, data);
         }
         return data;
     }
@@ -2179,10 +2158,10 @@
 }
 
 // Stage 6: Triangulate the monotone polygons into a vertex buffer.
-void* polys_to_triangles(Poly* polys, SkPath::FillType fillType, AA_PARAM, void* data) {
+void* polys_to_triangles(Poly* polys, SkPath::FillType fillType, bool emitCoverage, void* data) {
     for (Poly* poly = polys; poly; poly = poly->fNext) {
         if (apply_fill_type(fillType, poly)) {
-            data = poly->emit(AA_ARG, data);
+            data = poly->emit(emitCoverage, data);
         }
     }
     return data;
@@ -2231,15 +2210,15 @@
     return count;
 }
 
-void* outer_mesh_to_triangles(const VertexList& outerMesh, AA_PARAM, void* data) {
+void* outer_mesh_to_triangles(const VertexList& outerMesh, bool emitCoverage, void* data) {
     for (Vertex* v = outerMesh.fHead; v; v = v->fNext) {
         for (Edge* e = v->fFirstEdgeBelow; e; e = e->fNextEdgeBelow) {
             Vertex* v0 = e->fTop;
             Vertex* v1 = e->fBottom;
             Vertex* v2 = e->fBottom->fPartner;
             Vertex* v3 = e->fTop->fPartner;
-            data = emit_triangle(v0, v1, v2, AA_ARG, data);
-            data = emit_triangle(v0, v2, v3, AA_ARG, data);
+            data = emit_triangle(v0, v1, v2, emitCoverage, data);
+            data = emit_triangle(v0, v2, v3, emitCoverage, data);
         }
     }
     return data;
@@ -2252,11 +2231,7 @@
 // Stage 6: Triangulate the monotone polygons into a vertex buffer.
 
 int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
-                    VertexAllocator* vertexAllocator, bool antialias,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                    const GrColor& color, bool canTweakAlphaForCoverage,
-#endif
-                    bool* isLinear) {
+                    VertexAllocator* vertexAllocator, bool antialias, bool* isLinear) {
     int contourCnt = get_contour_count(path, tolerance);
     if (contourCnt <= 0) {
         *isLinear = true;
@@ -2283,16 +2258,8 @@
     }
 
     LOG("emitting %d verts\n", count);
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-    AAParams aaParams;
-    aaParams.fTweakAlpha = canTweakAlphaForCoverage;
-    aaParams.fColor = color;
-    void* end = polys_to_triangles(polys, fillType, antialias ? &aaParams : nullptr, verts);
-    end = outer_mesh_to_triangles(outerMesh, &aaParams, end);
-#else
     void* end = polys_to_triangles(polys, fillType, antialias, verts);
     end = outer_mesh_to_triangles(outerMesh, true, end);
-#endif
 
     int actualCount = static_cast<int>((static_cast<uint8_t*>(end) - static_cast<uint8_t*>(verts))
                                        / vertexAllocator->stride());
@@ -2327,11 +2294,7 @@
     for (Poly* poly = polys; poly; poly = poly->fNext) {
         if (apply_fill_type(fillType, poly)) {
             SkPoint* start = pointsEnd;
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-            pointsEnd = static_cast<SkPoint*>(poly->emit(nullptr, pointsEnd));
-#else
             pointsEnd = static_cast<SkPoint*>(poly->emit(false, pointsEnd));
-#endif
             while (start != pointsEnd) {
                 vertsEnd->fPos = *start;
                 vertsEnd->fWinding = poly->fWinding;
diff --git a/src/gpu/GrTessellator.h b/src/gpu/GrTessellator.h
index 324a72c..ae5376e 100644
--- a/src/gpu/GrTessellator.h
+++ b/src/gpu/GrTessellator.h
@@ -47,11 +47,7 @@
                    WindingVertex** verts);
 
 int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds,
-                    VertexAllocator*, bool antialias,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                    const GrColor& color, bool canTweakAlphaForCoverage,
-#endif
-                    bool *isLinear);
+                    VertexAllocator*, bool antialias, bool *isLinear);
 }
 
 #endif
diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
index 1b36698..b007245 100644
--- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp
@@ -82,29 +82,12 @@
 // extract the result vertices and indices from the GrAAConvexTessellator
 static void extract_verts(const GrAAConvexTessellator& tess,
                           void* vertData,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                          GrColor color,
-#else
                           const GrVertexColor& color,
-#endif
                           uint16_t firstIndex,
-                          uint16_t* idxs,
-                          bool tweakAlphaForCoverage) {
+                          uint16_t* idxs) {
     GrVertexWriter verts{vertData};
     for (int i = 0; i < tess.numPts(); ++i) {
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-        verts.write(tess.point(i));
-        if (tweakAlphaForCoverage) {
-            SkASSERT(SkScalarRoundToInt(255.0f * tess.coverage(i)) <= 255);
-            unsigned scale = SkScalarRoundToInt(255.0f * tess.coverage(i));
-            GrColor scaledColor = (0xff == scale) ? color : SkAlphaMulQ(color, scale);
-            verts.write(scaledColor);
-        } else {
-            verts.write(color, tess.coverage(i));
-        }
-#else
         verts.write(tess.point(i), color, tess.coverage(i));
-#endif
     }
 
     for (int i = 0; i < tess.numIndices(); ++i) {
@@ -119,13 +102,8 @@
                                                        bool wideColor) {
     using namespace GrDefaultGeoProcFactory;
 
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-    Coverage::Type coverageType =
-        tweakAlphaForCoverage ? Coverage::kSolid_Type : Coverage::kAttribute_Type;
-#else
     Coverage::Type coverageType =
         tweakAlphaForCoverage ? Coverage::kAttributeTweakAlpha_Type : Coverage::kAttribute_Type;
-#endif
     LocalCoords::Type localCoordsType =
         usesLocalCoords ? LocalCoords::kUsePosition_Type : LocalCoords::kUnused_Type;
     Color::Type colorType =
@@ -182,11 +160,7 @@
             bounds.outset(w, w);
         }
         this->setTransformedBounds(bounds, viewMatrix, HasAABloat::kYes, IsZeroArea::kNo);
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-        fWideColor = false;
-#else
         fWideColor = !SkPMColor4fFitsInBytes(color);
-#endif
     }
 
     const char* name() const override { return "AAFlatteningConvexPathOp"; }
@@ -311,13 +285,8 @@
             }
 
             extract_verts(tess, vertices + vertexStride * vertexCount,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                          args.fColor.toBytes_RGBA(),
-#else
-                          GrVertexColor(args.fColor, fWideColor),
-#endif
-                          vertexCount, indices + indexCount,
-                          fHelper.compatibleWithAlphaAsCoverage());
+                          GrVertexColor(args.fColor, fWideColor), vertexCount,
+                          indices + indexCount);
             vertexCount += currentVertices;
             indexCount += currentIndices;
         }
diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp
index 28ad083..39031e2 100644
--- a/src/gpu/ops/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp
@@ -278,9 +278,6 @@
         bool canMapVB = GrCaps::kNone_MapFlags != target->caps().mapBufferFlags();
         StaticVertexAllocator allocator(vertexStride, rp, canMapVB);
         int count = GrTessellator::PathToTriangles(getPath(), tol, clipBounds, &allocator, false,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                                                   GrColor(), false,
-#endif
                                                    &isLinear);
         if (count == 0) {
             return;
@@ -306,10 +303,6 @@
         bool isLinear;
         DynamicVertexAllocator allocator(vertexStride, target);
         int count = GrTessellator::PathToTriangles(path, tol, clipBounds, &allocator, true,
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                                                   fColor.toBytes_RGBA(),
-                                                   fHelper.compatibleWithAlphaAsCoverage(),
-#endif
                                                    &isLinear);
         if (count == 0) {
             return;
@@ -329,15 +322,8 @@
                                                         : LocalCoords::kUnused_Type;
             Coverage::Type coverageType;
             if (fAntiAlias) {
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                color = Color(Color::kPremulGrColorAttribute_Type);
-#endif
                 if (fHelper.compatibleWithAlphaAsCoverage()) {
-#ifdef SK_LEGACY_TESSELLATOR_CPU_COVERAGE
-                    coverageType = Coverage::kSolid_Type;
-#else
                     coverageType = Coverage::kAttributeTweakAlpha_Type;
-#endif
                 } else {
                     coverageType = Coverage::kAttribute_Type;
                 }