From 7ef63c85c5891ca59906e3c783a7f954be3f7f62 Mon Sep 17 00:00:00 2001 From: senorblanco Date: Mon, 13 Apr 2015 14:27:37 -0700 Subject: 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 --- src/gpu/GrAddPathRenderers_default.cpp | 2 +- src/gpu/GrTessellatingPathRenderer.cpp | 42 ++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 16 deletions(-) (limited to 'src') 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(v, *tail, NULL, head, tail); +} - Vertex* result = NULL; +inline void append_vertex_list(Vertex* v, Vertex** head, Vertex** tail) { + insert(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. -- cgit v1.2.3