Index: src/gpu/GrTessellatingPathRenderer.cpp |
diff --git a/src/gpu/GrTessellatingPathRenderer.cpp b/src/gpu/GrTessellatingPathRenderer.cpp |
index e9e8da240b0a93bc46b5490f237c3cf5395719fe..14176db4ecef0e2b2dbd7c31f2c3ed3658e0a41b 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. |