[cairo-commit] 5 commits - .gitlab-ci/ignore-pdf-argb32.txt .gitlab-ci/ignore-pdf-rgb24.txt src/cairo-default-context.c src/cairo-fixed-private.h test/long-lines.c test/reference

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat May 28 23:13:25 UTC 2022


 .gitlab-ci/ignore-pdf-argb32.txt              |    2 ++
 .gitlab-ci/ignore-pdf-rgb24.txt               |    2 ++
 dev/null                                      |binary
 src/cairo-default-context.c                   |   26 ++++++++++++++++----------
 src/cairo-fixed-private.h                     |   16 ++++++++++++++++
 test/long-lines.c                             |    9 ++++++---
 test/reference/big-trap.ref.png               |binary
 test/reference/huge-linear.pdf.xfail.png      |binary
 test/reference/huge-radial.pdf.xfail.png      |binary
 test/reference/long-lines.pdf.ref.png         |binary
 test/reference/long-lines.ps.xfail.png        |binary
 test/reference/long-lines.ref.png             |binary
 test/reference/long-lines.xcb-window&.ref.png |binary
 test/reference/long-lines.xcb-window.ref.png  |binary
 test/reference/long-lines.xcb.ref.png         |binary
 test/reference/long-lines.xlib-window.ref.png |binary
 test/reference/long-lines.xlib.ref.png        |binary
 17 files changed, 42 insertions(+), 13 deletions(-)

New commits:
commit 451dcd3143681450a00cac2bf45fc2e75b4f7a3c
Merge: 9fbf8f485 9fadf0a11
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat May 28 23:13:23 2022 +0000

    Merge branch 'clamp-coordinates' into 'master'
    
    Clamp path coordinates
    
    Closes poppler/poppler#1250
    
    See merge request cairo/cairo!325

commit 9fadf0a116549b1fb24512309613bee0251e92fb
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat May 28 17:31:58 2022 +0930

    Update huge-linear and huge-radial pdf ref images
    
    pdf output is correct but the poppler rendering is incorrect

diff --git a/.gitlab-ci/ignore-pdf-argb32.txt b/.gitlab-ci/ignore-pdf-argb32.txt
index cea0d4256..b3be4e9ae 100644
--- a/.gitlab-ci/ignore-pdf-argb32.txt
+++ b/.gitlab-ci/ignore-pdf-argb32.txt
@@ -13,6 +13,8 @@ ft-show-glyphs-positioning
 ft-text-vertical-layout-type1
 ft-text-vertical-layout-type3
 halo-transform
+huge-linear
+huge-radial
 linear-gradient-reflect
 mask
 overlapping-glyphs
diff --git a/.gitlab-ci/ignore-pdf-rgb24.txt b/.gitlab-ci/ignore-pdf-rgb24.txt
index 380d37710..d0e31a95d 100644
--- a/.gitlab-ci/ignore-pdf-rgb24.txt
+++ b/.gitlab-ci/ignore-pdf-rgb24.txt
@@ -23,6 +23,8 @@ ft-text-vertical-layout-type3
 gradient-zero-stops
 gradient-zero-stops-mask
 halo-transform
+huge-linear
+huge-radial
 image-surface-source
 linear-gradient-one-stop
 linear-gradient-reflect
diff --git a/test/reference/huge-linear.pdf.ref.png b/test/reference/huge-linear.pdf.ref.png
deleted file mode 100644
index cdafafa24..000000000
Binary files a/test/reference/huge-linear.pdf.ref.png and /dev/null differ
diff --git a/test/reference/huge-linear.pdf.xfail.png b/test/reference/huge-linear.pdf.xfail.png
new file mode 100644
index 000000000..db4cf2e9b
Binary files /dev/null and b/test/reference/huge-linear.pdf.xfail.png differ
diff --git a/test/reference/huge-radial.pdf.ref.png b/test/reference/huge-radial.pdf.ref.png
deleted file mode 100644
index 8aa088b44..000000000
Binary files a/test/reference/huge-radial.pdf.ref.png and /dev/null differ
diff --git a/test/reference/huge-radial.pdf.xfail.png b/test/reference/huge-radial.pdf.xfail.png
new file mode 100644
index 000000000..db4cf2e9b
Binary files /dev/null and b/test/reference/huge-radial.pdf.xfail.png differ
commit 1aa53f2ed45397505c926e5e98239eb5c863e92e
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat May 28 16:55:07 2022 +0930

    big-trap test works

diff --git a/test/reference/big-trap.base.argb32.ref.png b/test/reference/big-trap.base.argb32.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.base.argb32.ref.png and /dev/null differ
diff --git a/test/reference/big-trap.base.rgb24.ref.png b/test/reference/big-trap.base.rgb24.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.base.rgb24.ref.png and /dev/null differ
diff --git a/test/reference/big-trap.mask.argb32.ref.png b/test/reference/big-trap.mask.argb32.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.mask.argb32.ref.png and /dev/null differ
diff --git a/test/reference/big-trap.mask.rgb24.ref.png b/test/reference/big-trap.mask.rgb24.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.mask.rgb24.ref.png and /dev/null differ
diff --git a/test/reference/big-trap.ref.png b/test/reference/big-trap.ref.png
new file mode 100644
index 000000000..dd91ff04b
Binary files /dev/null and b/test/reference/big-trap.ref.png differ
diff --git a/test/reference/big-trap.traps.argb32.ref.png b/test/reference/big-trap.traps.argb32.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.traps.argb32.ref.png and /dev/null differ
diff --git a/test/reference/big-trap.traps.rgb24.ref.png b/test/reference/big-trap.traps.rgb24.ref.png
deleted file mode 100644
index c0975c9b5..000000000
Binary files a/test/reference/big-trap.traps.rgb24.ref.png and /dev/null differ
commit e7da8451f8e85007abddf349bd2aa74a0791f728
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat May 28 16:13:21 2022 +0930

    Update long-lines test

diff --git a/test/long-lines.c b/test/long-lines.c
index 69b64e9c4..ff28edbd8 100644
--- a/test/long-lines.c
+++ b/test/long-lines.c
@@ -29,6 +29,9 @@
 #define LINE_WIDTH	1.
 #define SIZE		10
 #define LINE_NBR	6
+#define WIDTH (SIZE * (LINE_NBR + 1))
+#define HEIGHT (SIZE * (LINE_NBR + 1))
+
 
 struct {
     double length;
@@ -66,8 +69,8 @@ draw (cairo_t *cr, int width, int height)
     }
 
     /* This should display a perfect vertically centered black line */
-    cairo_move_to (cr, 0.5, -1e100);
-    cairo_line_to (cr, pos,  1e100);
+    cairo_move_to (cr, -1e100, HEIGHT/2);
+    cairo_line_to (cr, 1e100, HEIGHT/2);
     cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
     cairo_stroke (cr);
 
@@ -80,6 +83,6 @@ CAIRO_TEST (long_lines,
 	    "\nLong lines are not drawn due to the limitations of the internal 16.16 fixed-point coordinates",
 	    "stroke, stress", /* keywords */
 	    NULL, /* requirements */
-	    SIZE * (LINE_NBR + 1), SIZE * (LINE_NBR + 1),
+	    WIDTH, HEIGHT,
 	    NULL, draw)
 
diff --git a/test/reference/long-lines.base.argb32.ref.png b/test/reference/long-lines.base.argb32.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.base.argb32.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.base.rgb24.ref.png b/test/reference/long-lines.base.rgb24.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.base.rgb24.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.mask.argb32.ref.png b/test/reference/long-lines.mask.argb32.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.mask.argb32.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.mask.rgb24.ref.png b/test/reference/long-lines.mask.rgb24.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.mask.rgb24.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.pdf.ref.png b/test/reference/long-lines.pdf.ref.png
new file mode 100644
index 000000000..e19309407
Binary files /dev/null and b/test/reference/long-lines.pdf.ref.png differ
diff --git a/test/reference/long-lines.ps.xfail.png b/test/reference/long-lines.ps.xfail.png
new file mode 100644
index 000000000..766efb75b
Binary files /dev/null and b/test/reference/long-lines.ps.xfail.png differ
diff --git a/test/reference/long-lines.ref.png b/test/reference/long-lines.ref.png
new file mode 100644
index 000000000..6e9674346
Binary files /dev/null and b/test/reference/long-lines.ref.png differ
diff --git a/test/reference/long-lines.traps.argb32.ref.png b/test/reference/long-lines.traps.argb32.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.traps.argb32.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.traps.rgb24.ref.png b/test/reference/long-lines.traps.rgb24.ref.png
deleted file mode 100644
index fe9116312..000000000
Binary files a/test/reference/long-lines.traps.rgb24.ref.png and /dev/null differ
diff --git a/test/reference/long-lines.xcb-window&.ref.png b/test/reference/long-lines.xcb-window&.ref.png
new file mode 100644
index 000000000..ae94477a7
Binary files /dev/null and b/test/reference/long-lines.xcb-window&.ref.png differ
diff --git a/test/reference/long-lines.xcb-window.ref.png b/test/reference/long-lines.xcb-window.ref.png
new file mode 100644
index 000000000..ae94477a7
Binary files /dev/null and b/test/reference/long-lines.xcb-window.ref.png differ
diff --git a/test/reference/long-lines.xcb.ref.png b/test/reference/long-lines.xcb.ref.png
new file mode 100644
index 000000000..ae94477a7
Binary files /dev/null and b/test/reference/long-lines.xcb.ref.png differ
diff --git a/test/reference/long-lines.xlib-window.ref.png b/test/reference/long-lines.xlib-window.ref.png
new file mode 100644
index 000000000..ae94477a7
Binary files /dev/null and b/test/reference/long-lines.xlib-window.ref.png differ
diff --git a/test/reference/long-lines.xlib.ref.png b/test/reference/long-lines.xlib.ref.png
new file mode 100644
index 000000000..ae94477a7
Binary files /dev/null and b/test/reference/long-lines.xlib.ref.png differ
commit 47a21c6e30eef91db503a5a183d5c8cf558aaa56
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sun May 15 14:05:05 2022 +0930

    Clamp path coordinates
    
    Fixes https://gitlab.freedesktop.org/poppler/poppler/-/issues/1250

diff --git a/src/cairo-default-context.c b/src/cairo-default-context.c
index 567c5d4d5..87370cdc7 100644
--- a/src/cairo-default-context.c
+++ b/src/cairo-default-context.c
@@ -713,10 +713,12 @@ _cairo_default_context_move_to (void *abstract_cr, double x, double y)
 {
     cairo_default_context_t *cr = abstract_cr;
     cairo_fixed_t x_fixed, y_fixed;
+    double width;
 
     _cairo_gstate_user_to_backend (cr->gstate, &x, &y);
-    x_fixed = _cairo_fixed_from_double (x);
-    y_fixed = _cairo_fixed_from_double (y);
+    width = _cairo_gstate_get_line_width (cr->gstate);
+    x_fixed = _cairo_fixed_from_double_clamped (x, width);
+    y_fixed = _cairo_fixed_from_double_clamped (y, width);
 
     return _cairo_path_fixed_move_to (cr->path, x_fixed, y_fixed);
 }
@@ -726,10 +728,12 @@ _cairo_default_context_line_to (void *abstract_cr, double x, double y)
 {
     cairo_default_context_t *cr = abstract_cr;
     cairo_fixed_t x_fixed, y_fixed;
+    double width;
 
     _cairo_gstate_user_to_backend (cr->gstate, &x, &y);
-    x_fixed = _cairo_fixed_from_double (x);
-    y_fixed = _cairo_fixed_from_double (y);
+    width = _cairo_gstate_get_line_width (cr->gstate);
+    x_fixed = _cairo_fixed_from_double_clamped (x, width);
+    y_fixed = _cairo_fixed_from_double_clamped (y, width);
 
     return _cairo_path_fixed_line_to (cr->path, x_fixed, y_fixed);
 }
@@ -744,19 +748,21 @@ _cairo_default_context_curve_to (void *abstract_cr,
     cairo_fixed_t x1_fixed, y1_fixed;
     cairo_fixed_t x2_fixed, y2_fixed;
     cairo_fixed_t x3_fixed, y3_fixed;
+    double width;
 
     _cairo_gstate_user_to_backend (cr->gstate, &x1, &y1);
     _cairo_gstate_user_to_backend (cr->gstate, &x2, &y2);
     _cairo_gstate_user_to_backend (cr->gstate, &x3, &y3);
+    width = _cairo_gstate_get_line_width (cr->gstate);
 
-    x1_fixed = _cairo_fixed_from_double (x1);
-    y1_fixed = _cairo_fixed_from_double (y1);
+    x1_fixed = _cairo_fixed_from_double_clamped (x1, width);
+    y1_fixed = _cairo_fixed_from_double_clamped (y1, width);
 
-    x2_fixed = _cairo_fixed_from_double (x2);
-    y2_fixed = _cairo_fixed_from_double (y2);
+    x2_fixed = _cairo_fixed_from_double_clamped (x2, width);
+    y2_fixed = _cairo_fixed_from_double_clamped (y2, width);
 
-    x3_fixed = _cairo_fixed_from_double (x3);
-    y3_fixed = _cairo_fixed_from_double (y3);
+    x3_fixed = _cairo_fixed_from_double_clamped (x3, width);
+    y3_fixed = _cairo_fixed_from_double_clamped (y3, width);
 
     return _cairo_path_fixed_curve_to (cr->path,
 				       x1_fixed, y1_fixed,
diff --git a/src/cairo-fixed-private.h b/src/cairo-fixed-private.h
index 5f9ce684c..2259f113b 100644
--- a/src/cairo-fixed-private.h
+++ b/src/cairo-fixed-private.h
@@ -53,6 +53,11 @@
 #define CAIRO_FIXED_ONE_DOUBLE ((double)(1 << CAIRO_FIXED_FRAC_BITS))
 #define CAIRO_FIXED_EPSILON    ((cairo_fixed_t)(1))
 
+#define CAIRO_FIXED_MAX        INT32_MAX /* Maximum fixed point value */
+#define CAIRO_FIXED_MIN        INT32_MIN /* Minimum fixed point value */
+#define CAIRO_FIXED_MAX_DOUBLE (((double) CAIRO_FIXED_MAX) / CAIRO_FIXED_ONE_DOUBLE)
+#define CAIRO_FIXED_MIN_DOUBLE (((double) CAIRO_FIXED_MIN) / CAIRO_FIXED_ONE_DOUBLE)
+
 #define CAIRO_FIXED_ERROR_DOUBLE (1. / (2 * CAIRO_FIXED_ONE_DOUBLE))
 
 #define CAIRO_FIXED_FRAC_MASK  ((cairo_fixed_t)(((cairo_fixed_unsigned_t)(-1)) >> (CAIRO_FIXED_BITS - CAIRO_FIXED_FRAC_BITS)))
@@ -128,6 +133,17 @@ _cairo_fixed_from_double (double d)
 # error See cairo-fixed-private.h for details.
 #endif
 
+static inline cairo_fixed_t
+_cairo_fixed_from_double_clamped (double d, double tolerance)
+{
+    if (d > CAIRO_FIXED_MAX_DOUBLE - tolerance)
+       d = CAIRO_FIXED_MAX_DOUBLE - tolerance;
+    else if (d < CAIRO_FIXED_MIN_DOUBLE + tolerance)
+       d = CAIRO_FIXED_MIN_DOUBLE + tolerance;
+
+    return _cairo_fixed_from_double (d);
+}
+
 static inline cairo_fixed_t
 _cairo_fixed_from_26_6 (uint32_t i)
 {


More information about the cairo-commit mailing list