From 1c431eb5477388dbcf94b24a382efc1fb63b639a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20B=C3=BCnzli?= Date: Sun, 21 Jul 2013 10:49:42 +0200 Subject: fix gradient ordering edge case Gradients in XPS code are ordered by offset. If however two offsets are equal, the order of the colors depends on the sort algorithm instead of the original order in the document. This is shown e.g. in 2245*.xps: Tracking the original order of gradient stops and always sorting earlier stops first makes gradient ordering consistent. --- source/xps/xps-gradient.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/xps') diff --git a/source/xps/xps-gradient.c b/source/xps/xps-gradient.c index 88ed470b..7d03f89d 100644 --- a/source/xps/xps-gradient.c +++ b/source/xps/xps-gradient.c @@ -14,6 +14,7 @@ struct stop { float offset; float r, g, b, a; + int index; }; static int cmp_stop(const void *a, const void *b) @@ -25,7 +26,7 @@ static int cmp_stop(const void *a, const void *b) return -1; if (diff > 0) return 1; - return 0; + return astop->index - bstop->index; } static inline float lerp(float a, float b, float x) @@ -57,6 +58,7 @@ xps_parse_gradient_stops(xps_document *doc, char *base_uri, fz_xml *node, if (offset && color) { stops[count].offset = fz_atof(offset); + stops[count].index = count; xps_parse_color(doc, base_uri, color, &colorspace, sample); -- cgit v1.2.3