From 2e05922737d63289a3f124699359b8d385315cbd Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 27 Aug 2009 13:58:43 +0100 Subject: [stroke] Handle degenerate stroke extents If the stroke is degenerate, i.e. the path consists only of a single move-to and no edges, then the stroke may be visible due to end-capping (as opposed to fills which are empty). So we also need to pad out the extents around the current point for the degenerate case. --- src/cairo-path-bounds.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/cairo-path-bounds.c') diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index 1a3cdf06b..d3bc449a9 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c @@ -51,13 +51,6 @@ _cairo_path_bounder_init (cairo_path_bounder_t *bounder) bounder->has_point = FALSE; } -static void -_cairo_path_bounder_fini (cairo_path_bounder_t *bounder) -{ - bounder->has_initial_point = FALSE; - bounder->has_point = FALSE; -} - static void _cairo_path_bounder_add_point (cairo_path_bounder_t *bounder, const cairo_point_t *point) @@ -79,7 +72,6 @@ _cairo_path_bounder_add_point (cairo_path_bounder_t *bounder, bounder->extents.p1.y = point->y; bounder->extents.p2.x = point->x; bounder->extents.p2.y = point->y; - bounder->has_point = TRUE; } } @@ -195,8 +187,6 @@ _cairo_path_fixed_approximate_clip_extents (const cairo_path_fixed_t *path, extents->x = extents->y = 0; extents->width = extents->height = 0; } - - _cairo_path_bounder_fini (&bounder); } /* A slightly better approximation than above - we actually decompose the @@ -225,8 +215,6 @@ _cairo_path_fixed_approximate_fill_extents (const cairo_path_fixed_t *path, extents->x = extents->y = 0; extents->width = extents->height = 0; } - - _cairo_path_bounder_fini (&bounder); } void @@ -253,8 +241,6 @@ _cairo_path_fixed_fill_extents (const cairo_path_fixed_t *path, extents->x = extents->y = 0; extents->width = extents->height = 0; } - - _cairo_path_bounder_fini (&bounder); } /* Adjusts the fill extents (above) by the device-space pen. */ @@ -287,13 +273,24 @@ _cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path, bounder.extents.p1.y -= _cairo_fixed_from_double (dy); bounder.extents.p2.y += _cairo_fixed_from_double (dy); + _cairo_box_round_to_rectangle (&bounder.extents, extents); + } else if (bounder.has_initial_point) { + double dx, dy; + + /* accommodate capping of degenerate paths */ + + _cairo_stroke_style_max_distance_from_path (style, ctm, &dx, &dy); + + bounder.extents.p1.x = bounder.current_point.x - _cairo_fixed_from_double (dx); + bounder.extents.p2.x = bounder.current_point.x + _cairo_fixed_from_double (dx); + bounder.extents.p1.y = bounder.current_point.y - _cairo_fixed_from_double (dy); + bounder.extents.p2.y = bounder.current_point.y + _cairo_fixed_from_double (dy); + _cairo_box_round_to_rectangle (&bounder.extents, extents); } else { extents->x = extents->y = 0; extents->width = extents->height = 0; } - - _cairo_path_bounder_fini (&bounder); } cairo_status_t @@ -354,6 +351,4 @@ _cairo_path_fixed_bounds (const cairo_path_fixed_t *path, *x2 = 0.0; *y2 = 0.0; } - - _cairo_path_bounder_fini (&bounder); } -- cgit v1.2.1