GrTessellator (AA): simplify boundary extraction.
Perform boundary simplification and meshing inline with extraction.
Removed EdgeList::fNext (don't need to concatenate edge lists).
Removed new_contour() (don't need to heap-allocate them either).
BUG=skia:
Change-Id: I0f89bad105c03f3021b0d2f021064f408a361b59
Reviewed-on: https://skia-review.googlesource.com/8794
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 7994775..979418a 100644
--- a/src/gpu/GrTessellator.cpp
+++ b/src/gpu/GrTessellator.cpp
@@ -417,10 +417,9 @@
};
struct EdgeList {
- EdgeList() : fHead(nullptr), fTail(nullptr), fNext(nullptr) {}
+ EdgeList() : fHead(nullptr), fTail(nullptr) {}
Edge* fHead;
Edge* fTail;
- EdgeList* fNext;
void insert(Edge* edge, Edge* prev, Edge* next) {
list_insert<Edge, &Edge::fLeft, &Edge::fRight>(edge, prev, next, &fHead, &fTail);
}
@@ -607,13 +606,6 @@
return poly;
}
-EdgeList* new_contour(EdgeList** head, SkArenaAlloc& alloc) {
- EdgeList* contour = alloc.make<EdgeList>();
- contour->fNext = *head;
- *head = contour;
- return contour;
-}
-
Vertex* append_point_to_contour(const SkPoint& p, Vertex* prev, Vertex** head,
SkArenaAlloc& alloc) {
Vertex* v = alloc.make<Vertex>(p, 255);
@@ -1621,20 +1613,19 @@
}
}
-// Stage 5b: Extract boundary edges.
+// Stage 5b: Extract boundaries from mesh, simplify and stroke them into a new mesh.
-EdgeList* extract_boundaries(const VertexList& mesh, SkPath::FillType fillType,
- SkArenaAlloc& alloc) {
- LOG("extracting boundaries\n");
- remove_non_boundary_edges(mesh, fillType, alloc);
- EdgeList* boundaries = nullptr;
- for (Vertex* v = mesh.fHead; v != nullptr; v = v->fNext) {
+void extract_boundaries(const VertexList& inMesh, VertexList* outMesh, SkPath::FillType fillType,
+ Comparator& c, SkArenaAlloc& alloc) {
+ remove_non_boundary_edges(inMesh, fillType, alloc);
+ for (Vertex* v = inMesh.fHead; v; v = v->fNext) {
while (v->fFirstEdgeBelow) {
- EdgeList* boundary = new_contour(&boundaries, alloc);
- extract_boundary(boundary, v->fFirstEdgeBelow, fillType, alloc);
+ EdgeList boundary;
+ extract_boundary(&boundary, v->fFirstEdgeBelow, fillType, alloc);
+ simplify_boundary(&boundary, c, alloc);
+ boundary_to_aa_mesh(&boundary, outMesh, c, alloc);
}
}
- return boundaries;
}
// This is a driver function which calls stages 2-5 in turn.
@@ -1685,12 +1676,8 @@
contours_to_mesh(contours, contourCnt, antialias, &mesh, c, alloc);
sort_and_simplify(&mesh, c, alloc);
if (antialias) {
- EdgeList* boundaries = extract_boundaries(mesh, fillType, alloc);
VertexList aaMesh;
- for (EdgeList* boundary = boundaries; boundary != nullptr; boundary = boundary->fNext) {
- simplify_boundary(boundary, c, alloc);
- boundary_to_aa_mesh(boundary, &aaMesh, c, alloc);
- }
+ extract_boundaries(mesh, &aaMesh, fillType, c, alloc);
sort_and_simplify(&aaMesh, c, alloc);
return tessellate(aaMesh, alloc);
} else {