Delete GrTriangulator::Mode
Bug: skia:10419
Change-Id: Ia81c615538ff1f0fe2372ea2e7bf437ceec08d7e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/349336
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/GrTriangulator.cpp b/src/gpu/GrTriangulator.cpp
index 7d3b2a7..8c374c5 100644
--- a/src/gpu/GrTriangulator.cpp
+++ b/src/gpu/GrTriangulator.cpp
@@ -33,7 +33,6 @@
struct Event;
-using Mode = GrTriangulator::Mode;
using Vertex = GrTriangulator::Vertex;
using VertexList = GrTriangulator::VertexList;
using Edge = GrTriangulator::Edge;
@@ -750,8 +749,6 @@
void GrTriangulator::pathToContours(float tolerance, const SkRect& clipBounds,
VertexList* contours) {
SkScalar toleranceSqd = tolerance * tolerance;
- bool innerPolygons = (Mode::kSimpleInnerPolygons == fMode);
-
SkPoint pts[4];
fIsLinear = true;
VertexList* contour = contours;
@@ -770,7 +767,7 @@
switch (verb) {
case SkPath::kConic_Verb: {
fIsLinear = false;
- if (innerPolygons) {
+ if (fSimpleInnerPolygons) {
this->appendPointToContour(pts[2], contour);
break;
}
@@ -794,7 +791,7 @@
}
case SkPath::kQuad_Verb: {
fIsLinear = false;
- if (innerPolygons) {
+ if (fSimpleInnerPolygons) {
this->appendPointToContour(pts[2], contour);
break;
}
@@ -803,7 +800,7 @@
}
case SkPath::kCubic_Verb: {
fIsLinear = false;
- if (innerPolygons) {
+ if (fSimpleInnerPolygons) {
this->appendPointToContour(pts[3], contour);
break;
}
@@ -1313,16 +1310,14 @@
}
void GrTriangulator::sanitizeContours(VertexList* contours, int contourCnt) {
- bool approximate = (Mode::kEdgeAntialias == fMode);
- bool removeCollinearVertices = (Mode::kSimpleInnerPolygons != fMode);
for (VertexList* contour = contours; contourCnt > 0; --contourCnt, ++contour) {
SkASSERT(contour->fHead);
Vertex* prev = contour->fTail;
- if (approximate) {
+ if (fRoundVerticesToQuarterPixel) {
round(&prev->fPoint);
}
for (Vertex* v = contour->fHead; v;) {
- if (approximate) {
+ if (fRoundVerticesToQuarterPixel) {
round(&v->fPoint);
}
Vertex* next = v->fNext;
@@ -1333,7 +1328,7 @@
} else if (!v->fPoint.isFinite()) {
TESS_LOG("vertex %g,%g non-finite; removing\n", v->fPoint.fX, v->fPoint.fY);
contour->remove(v);
- } else if (removeCollinearVertices &&
+ } else if (fCullCollinearVertices &&
Line(prev->fPoint, nextWrap->fPoint).dist(v->fPoint) == 0.0) {
TESS_LOG("vertex %g,%g collinear; removing\n", v->fPoint.fX, v->fPoint.fY);
contour->remove(v);
@@ -1561,7 +1556,7 @@
leftEnclosingEdge, edge, &activeEdges, &v, mesh, c) ||
this->checkForIntersection(
edge, rightEnclosingEdge, &activeEdges, &v, mesh, c)) {
- if (Mode::kSimpleInnerPolygons == fMode) {
+ if (fSimpleInnerPolygons) {
return SimplifyResult::kAbort;
}
result = SimplifyResult::kFoundSelfIntersection;
@@ -1572,7 +1567,7 @@
} else {
if (this->checkForIntersection(leftEnclosingEdge, rightEnclosingEdge, &activeEdges,
&v, mesh, c)) {
- if (Mode::kSimpleInnerPolygons == fMode) {
+ if (fSimpleInnerPolygons) {
return SimplifyResult::kAbort;
}
result = SimplifyResult::kFoundSelfIntersection;
@@ -1602,7 +1597,7 @@
Poly* GrTriangulator::tessellate(const VertexList& vertices) {
TESS_LOG("\ntessellating simple polygons\n");
int maxWindMagnitude = std::numeric_limits<int>::max();
- if (Mode::kSimpleInnerPolygons == fMode && !SkPathFillType_IsEvenOdd(fPath.getFillType())) {
+ if (fSimpleInnerPolygons && !SkPathFillType_IsEvenOdd(fPath.getFillType())) {
maxWindMagnitude = 1;
}
EdgeList activeEdges;
@@ -2240,7 +2235,7 @@
}
TESS_LOG("\nsimplified mesh:\n");
dump_mesh(mesh);
- if (Mode::kEdgeAntialias == fMode) {
+ if (fEmitCoverage) {
VertexList innerMesh;
extract_boundaries(mesh, &innerMesh, outerMesh, fPath.getFillType(), c, fAlloc);
SortMesh(&innerMesh, c);
@@ -2289,10 +2284,9 @@
// Stage 6: Triangulate the monotone polygons into a vertex buffer.
void* GrTriangulator::polysToTriangles(Poly* polys, void* data, SkPathFillType overrideFillType) {
- bool emitCoverage = (Mode::kEdgeAntialias == fMode);
for (Poly* poly = polys; poly; poly = poly->fNext) {
if (apply_fill_type(overrideFillType, poly)) {
- data = poly->emit(emitCoverage, data);
+ data = poly->emit(fEmitCoverage, data);
}
}
return data;
@@ -2379,20 +2373,6 @@
// Stage 6: Triangulate the monotone polygons into a vertex buffer.
-int GrTriangulator::PathToTriangles(const SkPath& path, SkScalar tolerance,
- const SkRect& clipBounds,
- GrEagerVertexAllocator* vertexAllocator, Mode mode,
- bool* isLinear) {
- GrTriangulator triangulator(path, mode);
- SkPathFillType overrideFillType = (GrTriangulator::Mode::kEdgeAntialias == mode)
- ? SkPathFillType::kWinding
- : path.getFillType();
- int count = triangulator.pathToTriangles(tolerance, clipBounds, vertexAllocator,
- overrideFillType);
- *isLinear = triangulator.fIsLinear;
- return count;
-}
-
int GrTriangulator::pathToTriangles(float tolerance, const SkRect& clipBounds,
GrEagerVertexAllocator* vertexAllocator,
SkPathFillType overrideFillType) {
@@ -2404,7 +2384,7 @@
VertexList outerMesh;
Poly* polys = this->pathToPolys(tolerance, clipBounds, contourCnt, &outerMesh);
int64_t count64 = count_points(polys, overrideFillType);
- if (GrTriangulator::Mode::kEdgeAntialias == fMode) {
+ if (fEmitCoverage) {
count64 += count_outer_mesh_points(outerMesh);
}
if (0 == count64 || count64 > SK_MaxS32) {
@@ -2412,7 +2392,10 @@
}
int count = count64;
- size_t vertexStride = GetVertexStride(fMode);
+ size_t vertexStride = sizeof(SkPoint);
+ if (fEmitCoverage) {
+ vertexStride += sizeof(float);
+ }
void* verts = vertexAllocator->lock(vertexStride, count);
if (!verts) {
SkDebugf("Could not allocate vertices\n");
@@ -2437,7 +2420,7 @@
*verts = nullptr;
return 0;
}
- GrTriangulator triangulator(path, Mode::kNormal);
+ GrTriangulator triangulator(path);
Poly* polys = triangulator.pathToPolys(tolerance, clipBounds, contourCnt, nullptr);
SkPathFillType fillType = path.getFillType();
int64_t count64 = count_points(polys, fillType);