summaryrefslogtreecommitdiff
path: root/src/cairo-path-bounds.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-08-27 13:58:43 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-08-29 17:07:38 +0100
commit2e05922737d63289a3f124699359b8d385315cbd (patch)
tree39d3e947a04fe65dd376834e7a0c8aa9854ab3a4 /src/cairo-path-bounds.c
parentcfd78393f357bc69233d4d00d0fb3a2ff736f1a7 (diff)
downloadcairo-2e05922737d63289a3f124699359b8d385315cbd.tar.gz
[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.
Diffstat (limited to 'src/cairo-path-bounds.c')
-rw-r--r--src/cairo-path-bounds.c31
1 files changed, 13 insertions, 18 deletions
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
@@ -52,13 +52,6 @@ _cairo_path_bounder_init (cairo_path_bounder_t *bounder)
}
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. */
@@ -288,12 +274,23 @@ _cairo_path_fixed_approximate_stroke_extents (const cairo_path_fixed_t *path,
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);
}