aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Stephen White <senorblanco@chromium.org>2017-03-03 12:24:16 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-03-03 21:18:05 +0000
commit651cbe9af67b49c5a3ad3788c3a50a003827a8e2 (patch)
tree41d49889df48c98a64b8cf9f9471578b104a774d
parentfec1729b9e9fdb802715dd8619684aa47e5856a7 (diff)
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 <senorblanco@chromium.org> Reviewed-by: Brian Salomon <bsalomon@google.com>
-rw-r--r--src/gpu/GrTessellator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gpu/GrTessellator.cpp b/src/gpu/GrTessellator.cpp
index 80a813f802..10f6edf7da 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<double>(curr->fPoint.fX) - prev->fPoint.fX;
double ay = static_cast<double>(curr->fPoint.fY) - prev->fPoint.fY;
double bx = static_cast<double>(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 {