aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar senorblanco <senorblanco@chromium.org>2015-04-13 14:27:37 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-04-13 14:27:37 -0700
commit7ef63c85c5891ca59906e3c783a7f954be3f7f62 (patch)
treefb9deab26d336be358a792e925a6499a2950c025 /src
parent22ecae88eec772be86da34015090a2eb649b9511 (diff)
Enable tessellating GPU path renderer.
This also contains a fix to remove recursion from the sorted_merge() step. This was essentially tail-recursion, and was causing stack exhaustion on some platforms. Making it iterative fixes the issue. Note: this CL will affect a large number of GPU GM results. R=bsalomon@google.com BUG= Review URL: https://codereview.chromium.org/1080113004
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAddPathRenderers_default.cpp2
-rw-r--r--src/gpu/GrTessellatingPathRenderer.cpp42
2 files changed, 28 insertions, 16 deletions
diff --git a/src/gpu/GrAddPathRenderers_default.cpp b/src/gpu/GrAddPathRenderers_default.cpp
index f5d69348f3..e60d536720 100644
--- a/src/gpu/GrAddPathRenderers_default.cpp
+++ b/src/gpu/GrAddPathRenderers_default.cpp
@@ -20,7 +20,7 @@
#endif
#ifndef GR_TESSELLATING_PATH_RENDERING
-#define GR_TESSELLATING_PATH_RENDERING 0
+#define GR_TESSELLATING_PATH_RENDERING 1
#endif
void GrPathRenderer::AddPathRenderers(GrContext* ctx, GrPathRendererChain* chain) {
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp
index e9e8da240b..14176db4ec 100644
--- a/src/gpu/GrTessellatingPathRenderer.cpp
+++ b/src/gpu/GrTessellatingPathRenderer.cpp
@@ -1072,24 +1072,36 @@ void merge_sort(Vertex** head) {
*head = sorted_merge(a, b);
}
-Vertex* sorted_merge(Vertex* a, Vertex* b) {
- if (!a) {
- return b;
- } else if (!b) {
- return a;
- }
+inline void append_vertex(Vertex* v, Vertex** head, Vertex** tail) {
+ insert<Vertex, &Vertex::fPrev, &Vertex::fNext>(v, *tail, NULL, head, tail);
+}
- Vertex* result = NULL;
+inline void append_vertex_list(Vertex* v, Vertex** head, Vertex** tail) {
+ insert<Vertex, &Vertex::fPrev, &Vertex::fNext>(v, *tail, v->fNext, head, tail);
+}
- if (sweep_lt(a->fPoint, b->fPoint)) {
- result = a;
- result->fNext = sorted_merge(a->fNext, b);
- } else {
- result = b;
- result->fNext = sorted_merge(a, b->fNext);
+Vertex* sorted_merge(Vertex* a, Vertex* b) {
+ Vertex* head = NULL;
+ Vertex* tail = NULL;
+
+ while (a && b) {
+ if (sweep_lt(a->fPoint, b->fPoint)) {
+ Vertex* next = a->fNext;
+ append_vertex(a, &head, &tail);
+ a = next;
+ } else {
+ Vertex* next = b->fNext;
+ append_vertex(b, &head, &tail);
+ b = next;
+ }
+ }
+ if (a) {
+ append_vertex_list(a, &head, &tail);
+ }
+ if (b) {
+ append_vertex_list(b, &head, &tail);
}
- result->fNext->fPrev = result;
- return result;
+ return head;
}
// Stage 4: Simplify the mesh by inserting new vertices at intersecting edges.