Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/memononen/nanosvg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortpechot <tomas.pecholt@eccam.com>2017-04-20 15:32:02 +0300
committertpechot <tomas.pecholt@eccam.com>2017-04-20 15:32:02 +0300
commitf76c596d8ac03ecf115b6517136416b30e60d660 (patch)
tree52952163c41466daa97bd0adcb72e47764a31d74 /src
parent46c7ae0ef9a6d148ec1e0c4ebf7c1a1bd27b980f (diff)
add new shapes to the head due to performance, reverse list of shapes later
Diffstat (limited to 'src')
-rw-r--r--src/nanosvg.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/nanosvg.h b/src/nanosvg.h
index 109c2bf..40ebac7 100644
--- a/src/nanosvg.h
+++ b/src/nanosvg.h
@@ -996,17 +996,9 @@ static void nsvg__addShape(NSVGparser* p)
// Set flags
shape->flags = (attr->visible ? NSVG_FLAGS_VISIBLE : 0x00);
- // Add to tail
- prev = NULL;
- cur = p->image->shapes;
- while (cur != NULL) {
- prev = cur;
- cur = cur->next;
- }
- if (prev == NULL)
- p->image->shapes = shape;
- else
- prev->next = shape;
+ // Add to head due to performance, reverse list later
+ shape->next = p->image->shapes;
+ p->image->shapes = shape;
return;
@@ -2795,6 +2787,7 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
{
NSVGparser* p;
NSVGimage* ret = 0;
+ NSVGshape* cur, *tmp;
p = nsvg__createParser();
if (p == NULL) {
@@ -2803,6 +2796,16 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi)
p->dpi = dpi;
nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
+
+ //reverse the list of shapes to match svg order
+ cur = p->image->shapes;
+ while (cur && cur->next != NULL) {
+ tmp = cur->next;
+ cur->next = cur->next->next;
+ tmp->next = p->image->shapes;
+ p->image->shapes = tmp;
+ cur = cur->next;
+ }
// Scale to viewBox
nsvg__scaleToViewbox(p, units);