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
This commit is contained in:
senorblanco 2016-10-12 06:47:44 -07:00 committed by Commit bot
parent 5961bc9278
commit 7ab96e9219

View File

@ -676,7 +676,7 @@ void path_to_contours(const SkPath& path, SkScalar tolerance, const SkRect& clip
if (path.isInverseFillType()) { if (path.isInverseFillType()) {
SkPoint quad[4]; SkPoint quad[4];
clipBounds.toQuad(quad); 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); prev = append_point_to_contour(quad[i], prev, &head, alloc);
} }
head->fPrev = prev; head->fPrev = prev;
@ -758,7 +758,7 @@ inline bool apply_fill_type(SkPath::FillType fillType, Poly* poly) {
case SkPath::kEvenOdd_FillType: case SkPath::kEvenOdd_FillType:
return (winding & 1) != 0; return (winding & 1) != 0;
case SkPath::kInverseWinding_FillType: case SkPath::kInverseWinding_FillType:
return winding == -1; return winding == 1;
case SkPath::kInverseEvenOdd_FillType: case SkPath::kInverseEvenOdd_FillType:
return (winding & 1) == 1; return (winding & 1) == 1;
default: default:
@ -1637,8 +1637,7 @@ Vertex* contours_to_mesh(Vertex** contours, int contourCnt, bool antialias,
return build_edges(contours, contourCnt, c, alloc); return build_edges(contours, contourCnt, c, alloc);
} }
Poly* mesh_to_polys(Vertex** vertices, SkPath::FillType fillType, Comparator& c, Poly* mesh_to_polys(Vertex** vertices, Comparator& c, SkChunkAlloc& alloc) {
SkChunkAlloc& alloc) {
if (!vertices || !*vertices) { if (!vertices || !*vertices) {
return nullptr; return nullptr;
} }
@ -1668,7 +1667,7 @@ Poly* contours_to_polys(Vertex** contours, int contourCnt, SkPath::FillType fill
c.sweep_gt = sweep_gt_vert; c.sweep_gt = sweep_gt_vert;
} }
Vertex* mesh = contours_to_mesh(contours, contourCnt, antialias, c, alloc); 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) { if (antialias) {
EdgeList* boundaries = extract_boundaries(mesh, fillType, alloc); EdgeList* boundaries = extract_boundaries(mesh, fillType, alloc);
VertexList aaMesh; VertexList aaMesh;
@ -1678,7 +1677,7 @@ Poly* contours_to_polys(Vertex** contours, int contourCnt, SkPath::FillType fill
boundary_to_aa_mesh(boundary, &aaMesh, c, alloc); 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; return polys;
} }
@ -1755,7 +1754,7 @@ int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBo
SkChunkAlloc alloc(sizeEstimate); SkChunkAlloc alloc(sizeEstimate);
Poly* polys = path_to_polys(path, tolerance, clipBounds, contourCnt, alloc, antialias, Poly* polys = path_to_polys(path, tolerance, clipBounds, contourCnt, alloc, antialias,
isLinear); isLinear);
SkPath::FillType fillType = path.getFillType(); SkPath::FillType fillType = antialias ? SkPath::kWinding_FillType : path.getFillType();
int count = count_points(polys, fillType); int count = count_points(polys, fillType);
if (0 == count) { if (0 == count) {
return 0; return 0;