diff options
author | Adrian Johnson <ajohnson@redneon.com> | 2022-05-15 14:05:05 +0930 |
---|---|---|
committer | Adrian Johnson <ajohnson@redneon.com> | 2022-05-28 16:03:50 +0930 |
commit | 47a21c6e30eef91db503a5a183d5c8cf558aaa56 (patch) | |
tree | 83a6c0ab4beb5aa7d08d42082ef95f6a9c1d2517 /src/cairo-default-context.c | |
parent | 5dafd7411660f153219abceab64d5cc3be1c59a6 (diff) | |
download | cairo-47a21c6e30eef91db503a5a183d5c8cf558aaa56.tar.gz |
Clamp path coordinates
Fixes https://gitlab.freedesktop.org/poppler/poppler/-/issues/1250
Diffstat (limited to 'src/cairo-default-context.c')
-rw-r--r-- | src/cairo-default-context.c | 26 |
1 files changed, 16 insertions, 10 deletions
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, |