Chromium Code Reviews| Index: src/gpu/GrTessellator.h |
| diff --git a/src/gpu/GrTessellator.h b/src/gpu/GrTessellator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c08de2c7c9f5c2a8bf6e45c84709d66b3f30eef4 |
| --- /dev/null |
| +++ b/src/gpu/GrTessellator.h |
| @@ -0,0 +1,85 @@ |
| +/* |
| + * Copyright 2015 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrTessellator_DEFINED |
| +#define GrTessellator_DEFINED |
| + |
| +#include "SkChunkAlloc.h" |
| +#include "GrPathRenderer.h" |
| + |
| +/** |
| + * Provides utility functions for converting paths to a collection of triangles. |
| + */ |
| + |
| +#define TESSELLATOR_WIREFRAME 0 |
| + |
| +namespace GrTessellator { |
| + |
| +struct Poly; |
| +struct Edge; |
| +struct Vertex; |
| + |
| +struct EdgeList { |
| + EdgeList() : fHead(nullptr), fTail(nullptr) {} |
| + Edge* fHead; |
| + Edge* fTail; |
| +}; |
| + |
| +struct Edge { |
|
Stephen White
2016/01/05 15:59:04
Does this (and EdgeList) need to be public? It onl
ethannicholas
2016/01/05 16:09:22
It did at one point, but you are of course correct
|
| + Edge(Vertex* top, Vertex* bottom, int winding) |
| + : fTop(top) |
| + , fBottom(bottom) |
| + , fWinding(winding) |
| + , fLeft(nullptr) |
| + , fRight(nullptr) |
| + , fPrevEdgeAbove(nullptr) |
| + , fNextEdgeAbove(nullptr) |
| + , fPrevEdgeBelow(nullptr) |
| + , fNextEdgeBelow(nullptr) |
| + , fLeftPoly(nullptr) |
| + , fRightPoly(nullptr) { |
| + recompute(); |
| + } |
| + Vertex* fTop; // The top vertex in vertex-sort-order (sweep_lt). |
| + Vertex* fBottom; // The bottom vertex in vertex-sort-order. |
| + int fWinding; // 1 == edge goes downward; -1 = edge goes upward. |
| + Edge* fLeft; // The linked list of edges in the active edge list. |
| + Edge* fRight; // " |
| + Edge* fPrevEdgeAbove; // The linked list of edges in the bottom Vertex's "edges above". |
| + Edge* fNextEdgeAbove; // " |
| + Edge* fPrevEdgeBelow; // The linked list of edges in the top Vertex's "edges below". |
| + Edge* fNextEdgeBelow; // " |
| + Poly* fLeftPoly; // The Poly to the left of this edge, if any. |
| + Poly* fRightPoly; // The Poly to the right of this edge, if any. |
| + double fDX; // The line equation for this edge, in implicit form. |
| + double fDY; // fDY * x + fDX * y + fC = 0, for point (x, y) on the line. |
| + double fC; |
| + double dist(const SkPoint& p) const; |
| + bool isRightOf(Vertex* v) const; |
| + bool isLeftOf(Vertex* v) const; |
| + void recompute(); |
| + bool intersect(const Edge& other, SkPoint* p); |
| + bool isActive(EdgeList* activeEdges) const; |
| +}; |
| + |
| +struct WindingVertex { |
| + SkPoint fPos; |
| + int fWinding; |
| +}; |
| + |
| +// creates an array of (point, winding) vertices and sets the 'verts' out parameter to point to it. |
| +// CALLER IS RESPONSIBLE for deleting this buffer to avoid a memory leak! |
| +int PathToVertices(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds, |
| + WindingVertex** verts); |
| + |
| +int PathToTriangles(const SkPath& path, SkScalar tolerance, const SkRect& clipBounds, |
| + GrResourceProvider* resourceProvider, |
| + SkAutoTUnref<GrVertexBuffer>& vertexBuffer, bool canMapVB, bool* isLinear); |
| + |
| +} |
| + |
| +#endif |