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>
This commit is contained in:
parent
c777b88c63
commit
5ad721e946
@ -417,10 +417,9 @@ struct Edge {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct EdgeList {
|
struct EdgeList {
|
||||||
EdgeList() : fHead(nullptr), fTail(nullptr), fNext(nullptr) {}
|
EdgeList() : fHead(nullptr), fTail(nullptr) {}
|
||||||
Edge* fHead;
|
Edge* fHead;
|
||||||
Edge* fTail;
|
Edge* fTail;
|
||||||
EdgeList* fNext;
|
|
||||||
void insert(Edge* edge, Edge* prev, Edge* next) {
|
void insert(Edge* edge, Edge* prev, Edge* next) {
|
||||||
list_insert<Edge, &Edge::fLeft, &Edge::fRight>(edge, prev, next, &fHead, &fTail);
|
list_insert<Edge, &Edge::fLeft, &Edge::fRight>(edge, prev, next, &fHead, &fTail);
|
||||||
}
|
}
|
||||||
@ -607,13 +606,6 @@ Poly* new_poly(Poly** head, Vertex* v, int winding, SkArenaAlloc& alloc) {
|
|||||||
return poly;
|
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,
|
Vertex* append_point_to_contour(const SkPoint& p, Vertex* prev, Vertex** head,
|
||||||
SkArenaAlloc& alloc) {
|
SkArenaAlloc& alloc) {
|
||||||
Vertex* v = alloc.make<Vertex>(p, 255);
|
Vertex* v = alloc.make<Vertex>(p, 255);
|
||||||
@ -1621,20 +1613,19 @@ void extract_boundary(EdgeList* boundary, Edge* e, SkPath::FillType fillType, Sk
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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,
|
void extract_boundaries(const VertexList& inMesh, VertexList* outMesh, SkPath::FillType fillType,
|
||||||
SkArenaAlloc& alloc) {
|
Comparator& c, SkArenaAlloc& alloc) {
|
||||||
LOG("extracting boundaries\n");
|
remove_non_boundary_edges(inMesh, fillType, alloc);
|
||||||
remove_non_boundary_edges(mesh, fillType, alloc);
|
for (Vertex* v = inMesh.fHead; v; v = v->fNext) {
|
||||||
EdgeList* boundaries = nullptr;
|
|
||||||
for (Vertex* v = mesh.fHead; v != nullptr; v = v->fNext) {
|
|
||||||
while (v->fFirstEdgeBelow) {
|
while (v->fFirstEdgeBelow) {
|
||||||
EdgeList* boundary = new_contour(&boundaries, alloc);
|
EdgeList boundary;
|
||||||
extract_boundary(boundary, v->fFirstEdgeBelow, fillType, alloc);
|
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.
|
// This is a driver function which calls stages 2-5 in turn.
|
||||||
@ -1685,12 +1676,8 @@ Poly* contours_to_polys(Vertex** contours, int contourCnt, SkPath::FillType fill
|
|||||||
contours_to_mesh(contours, contourCnt, antialias, &mesh, c, alloc);
|
contours_to_mesh(contours, contourCnt, antialias, &mesh, c, alloc);
|
||||||
sort_and_simplify(&mesh, c, alloc);
|
sort_and_simplify(&mesh, c, alloc);
|
||||||
if (antialias) {
|
if (antialias) {
|
||||||
EdgeList* boundaries = extract_boundaries(mesh, fillType, alloc);
|
|
||||||
VertexList aaMesh;
|
VertexList aaMesh;
|
||||||
for (EdgeList* boundary = boundaries; boundary != nullptr; boundary = boundary->fNext) {
|
extract_boundaries(mesh, &aaMesh, fillType, c, alloc);
|
||||||
simplify_boundary(boundary, c, alloc);
|
|
||||||
boundary_to_aa_mesh(boundary, &aaMesh, c, alloc);
|
|
||||||
}
|
|
||||||
sort_and_simplify(&aaMesh, c, alloc);
|
sort_and_simplify(&aaMesh, c, alloc);
|
||||||
return tessellate(aaMesh, alloc);
|
return tessellate(aaMesh, alloc);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user