[librsvg/rustification] Ensure gradient stop offsets are in nondecreasing order.



commit f3fb509b8c34fb14b5fe7a227652f03fba631459
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Nov 11 13:37:30 2016 -0600

    Ensure gradient stop offsets are in nondecreasing order.
    
    The test tests/fixtures/reftests/svg1.1/pservers-grad-16-b.svg was not
    passing.
    
    This test has gradient stop offsets in the wrong order.  Cairo
    automatically sorts them, but the SVG spec mandates that they should be
    adjusted to be in nondecreasing order.
    
    I was actually confused two commits ago; I thought the spec mandated
    that the stop offsets were invalid if they weren't ordered.

 rsvg-cairo-draw.c                                  |    8 +++-----
 .../reftests/svg1.1/pservers-grad-16-b-ref.png     |  Bin 6618 -> 4787 bytes
 2 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index 40294b0..92e3038 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -71,13 +71,11 @@ add_color_stops_for_gradient (cairo_pattern_t * pattern,
         if (!stop->is_valid)
             return FALSE;
 
-        if (stop->offset < last_offset)
-            return FALSE;
-
-        last_offset = stop->offset;
+        /* deal with unsorted stop offsets as per the spec */
+        last_offset = MAX (last_offset, stop->offset);
 
         rgba = stop->rgba;
-        cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
+        cairo_pattern_add_color_stop_rgba (pattern, last_offset,
                                            ((rgba >> 24) & 0xff) / 255.0,
                                            ((rgba >> 16) & 0xff) / 255.0,
                                            ((rgba >> 8) & 0xff) / 255.0,
diff --git a/tests/fixtures/reftests/svg1.1/pservers-grad-16-b-ref.png 
b/tests/fixtures/reftests/svg1.1/pservers-grad-16-b-ref.png
index 51a882c..9bef244 100644
Binary files a/tests/fixtures/reftests/svg1.1/pservers-grad-16-b-ref.png and 
b/tests/fixtures/reftests/svg1.1/pservers-grad-16-b-ref.png differ


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]