summaryrefslogtreecommitdiff
path: root/src/cairo-path-stroke.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-08-26 10:21:22 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-08-26 11:15:53 +0100
commitb66065537cec5f03b33f7513f06e26630c28b5f1 (patch)
treef660521fe82d215629a6734a573dc267dbfbfd6b /src/cairo-path-stroke.c
parent99593538a9d054aa1bb9fa620fced8c8b8ccdc9d (diff)
downloadcairo-b66065537cec5f03b33f7513f06e26630c28b5f1.tar.gz
stroke: Compute bounds for fallback stroker (typically dashing)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-path-stroke.c')
-rw-r--r--src/cairo-path-stroke.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 8f9fa92ff..5ef212c3d 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -90,10 +90,13 @@ typedef struct cairo_stroker {
static cairo_status_t
_cairo_stroker_init (cairo_stroker_t *stroker,
+ const cairo_path_fixed_t *path,
const cairo_stroke_style_t *stroke_style,
const cairo_matrix_t *ctm,
const cairo_matrix_t *ctm_inverse,
- double tolerance)
+ double tolerance,
+ const cairo_box_t *limits,
+ int num_limits)
{
cairo_status_t status;
@@ -111,8 +114,6 @@ _cairo_stroker_init (cairo_stroker_t *stroker,
if (unlikely (status))
return status;
- stroker->has_bounds = FALSE;
-
stroker->has_current_face = FALSE;
stroker->has_first_face = FALSE;
stroker->has_initial_sub_path = FALSE;
@@ -121,6 +122,31 @@ _cairo_stroker_init (cairo_stroker_t *stroker,
stroker->add_external_edge = NULL;
+ stroker->has_bounds = num_limits;
+ if (stroker->has_bounds) {
+ /* Extend the bounds in each direction to account for the maximum area
+ * we might generate trapezoids, to capture line segments that are
+ * outside of the bounds but which might generate rendering that's
+ * within bounds.
+ */
+ double dx, dy;
+ cairo_fixed_t fdx, fdy;
+ int i;
+
+ stroker->bounds = limits[0];
+ for (i = 1; i < num_limits; i++)
+ _cairo_box_add_box (&stroker->bounds, &limits[i]);
+
+ _cairo_stroke_style_max_distance_from_path (stroke_style, path, ctm, &dx, &dy);
+ fdx = _cairo_fixed_from_double (dx);
+ fdy = _cairo_fixed_from_double (dy);
+
+ stroker->bounds.p1.x -= fdx;
+ stroker->bounds.p2.x += fdx;
+ stroker->bounds.p1.y -= fdy;
+ stroker->bounds.p2.y += fdy;
+ }
+
return CAIRO_STATUS_SUCCESS;
}
@@ -1261,8 +1287,9 @@ _cairo_path_fixed_stroke_to_shaper (cairo_path_fixed_t *path,
cairo_stroker_t stroker;
cairo_status_t status;
- status = _cairo_stroker_init (&stroker, stroke_style,
- ctm, ctm_inverse, tolerance);
+ status = _cairo_stroker_init (&stroker, path, stroke_style,
+ ctm, ctm_inverse, tolerance,
+ NULL, 0);
if (unlikely (status))
return status;
@@ -1303,8 +1330,9 @@ _cairo_path_fixed_stroke_dashed_to_polygon (const cairo_path_fixed_t *path,
cairo_stroker_t stroker;
cairo_status_t status;
- status = _cairo_stroker_init (&stroker, stroke_style,
- ctm, ctm_inverse, tolerance);
+ status = _cairo_stroker_init (&stroker, path, stroke_style,
+ ctm, ctm_inverse, tolerance,
+ polygon->limits, polygon->num_limits);
if (unlikely (status))
return status;