GrTessellator: make inverse fill types more sane.
In the screenspace AA tessellator, a path's fill types would be applied
twice: once when extracting contours, and then again when filling polys.
It was supposed to be forced to kWinding_FillType by the second call to
mesh_to_polys(), but for hysterical reasons this parameter is unused!
For kInverseWinding_FillType (the only mode where this actually caused a bug),
I unwittingly papered over the problem by reversing the outer contour for the
inverse fill types, and comparing against -1 instead of 1.
The better fix is to actually pass a winding mode of kWinding_FillType
to polys_to_triangles(), and remove the (ignored) param from mesh_to_polys().
Then we can pass a clockwise outer contour as before, and compare
against 1 instead of -1.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2404403003
Review-Url: https://codereview.chromium.org/2404403003
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 6fbcab6..7d8db23 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -676,7 +676,7 @@
if (path.isInverseFillType()) {
SkPoint quad[4];
clipBounds.toQuad(quad);
- for (int i = 0; i < 4; i++) {
+ for (int i = 3; i >= 0; i--) {
prev = append_point_to_contour(quad[i], prev, &head, alloc);
}
head->fPrev = prev;
@@ -758,7 +758,7 @@
case SkPath::kEvenOdd_FillType:
return (winding & 1) != 0;
case SkPath::kInverseWinding_FillType:
- return winding == -1;
+ return winding == 1;
case SkPath::kInverseEvenOdd_FillType:
return (winding & 1) == 1;
default:
@@ -1637,8 +1637,7 @@
return build_edges(contours, contourCnt, c, alloc);
}
-Poly* mesh_to_polys(Vertex** vertices, SkPath::FillType fillType, Comparator& c,
- SkChunkAlloc& alloc) {
+Poly* mesh_to_polys(Vertex** vertices, Comparator& c, SkChunkAlloc& alloc) {
if (!vertices || !*vertices) {
return nullptr;
}
@@ -1668,7 +1667,7 @@
c.sweep_gt = sweep_gt_vert;
}
Vertex* mesh = contours_to_mesh(contours, contourCnt, antialias, c, alloc);
- Poly* polys = mesh_to_polys(&mesh, fillType, c, alloc);
+ Poly* polys = mesh_to_polys(&mesh, c, alloc);
if (antialias) {
EdgeList* boundaries = extract_boundaries(mesh, fillType, alloc);
VertexList aaMesh;
@@ -1678,7 +1677,7 @@
boundary_to_aa_mesh(boundary, &aaMesh, c, alloc);
}
}
- return mesh_to_polys(&aaMesh.fHead, SkPath::kWinding_FillType, c, alloc);
+ return mesh_to_polys(&aaMesh.fHead, c, alloc);
}
return polys;
}
@@ -1755,7 +1754,7 @@
SkChunkAlloc alloc(sizeEstimate);
Poly* polys = path_to_polys(path, tolerance, clipBounds, contourCnt, alloc, antialias,
isLinear);
- SkPath::FillType fillType = path.getFillType();
+ SkPath::FillType fillType = antialias ? SkPath::kWinding_FillType : path.getFillType();
int count = count_points(polys, fillType);
if (0 == count) {
return 0;