From 651cbe9af67b49c5a3ad3788c3a50a003827a8e2 Mon Sep 17 00:00:00 2001 From: Stephen White Date: Fri, 3 Mar 2017 12:24:16 -0500 Subject: [PATCH] GrTessellator: Implement a fast path in poly emission. When there's a single triangle remaining in the monotone, emit early and skip a convexity check. BUG=skia: Change-Id: I591acf4b7f567dbbf7681ba72181e578ca4623ec Reviewed-on: https://skia-review.googlesource.com/8797 Commit-Queue: Stephen White Reviewed-by: Brian Salomon --- src/gpu/GrTessellator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp index 80a813f..10f6edf 100644 --- a/src/gpu/GrTessellator.cpp +++ b/src/gpu/GrTessellator.cpp @@ -481,6 +481,7 @@ struct Poly { Edge* e = fFirstEdge; VertexList vertices; vertices.append(e->fTop); + int count = 1; while (e != nullptr) { if (kRight_Side == fSide) { vertices.append(e->fBottom); @@ -489,6 +490,7 @@ struct Poly { vertices.prepend(e->fBottom); e = e->fLeftPolyNext; } + count++; } Vertex* first = vertices.fHead; Vertex* v = first->fNext; @@ -497,6 +499,9 @@ struct Poly { Vertex* prev = v->fPrev; Vertex* curr = v; Vertex* next = v->fNext; + if (count == 3) { + return emit_triangle(prev, curr, next, aaParams, data); + } double ax = static_cast(curr->fPoint.fX) - prev->fPoint.fX; double ay = static_cast(curr->fPoint.fY) - prev->fPoint.fY; double bx = static_cast(next->fPoint.fX) - curr->fPoint.fX; @@ -505,6 +510,7 @@ struct Poly { data = emit_triangle(prev, curr, next, aaParams, data); v->fPrev->fNext = v->fNext; v->fNext->fPrev = v->fPrev; + count--; if (v->fPrev == first) { v = v->fNext; } else { -- 2.7.4