diff options
Diffstat (limited to 'src/cairo-path-stroke.c')
-rw-r--r-- | src/cairo-path-stroke.c | 108 |
1 files changed, 36 insertions, 72 deletions
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 8d3a1a93..2fba174d 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -72,51 +72,6 @@ typedef struct cairo_stroker { cairo_box_t bounds; } cairo_stroker_t; -/* private functions */ -static cairo_status_t -_cairo_stroker_init (cairo_stroker_t *stroker, - cairo_stroke_style_t *stroke_style, - cairo_matrix_t *ctm, - cairo_matrix_t *ctm_inverse, - double tolerance, - cairo_traps_t *traps); - -static void -_cairo_stroker_fini (cairo_stroker_t *stroker); - -static cairo_status_t -_cairo_stroker_move_to (void *closure, cairo_point_t *point); - -static cairo_status_t -_cairo_stroker_line_to (void *closure, cairo_point_t *point); - -static cairo_status_t -_cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point); - -static cairo_status_t -_cairo_stroker_curve_to (void *closure, - cairo_point_t *b, - cairo_point_t *c, - cairo_point_t *d); - -static cairo_status_t -_cairo_stroker_curve_to_dashed (void *closure, - cairo_point_t *b, - cairo_point_t *c, - cairo_point_t *d); - -static cairo_status_t -_cairo_stroker_close_path (void *closure); - -static void -_translate_point (cairo_point_t *point, cairo_point_t *offset); - -static int -_cairo_stroker_face_clockwise (cairo_stroke_face_t *in, cairo_stroke_face_t *out); - -static cairo_status_t -_cairo_stroker_join (cairo_stroker_t *stroker, cairo_stroke_face_t *in, cairo_stroke_face_t *out); - static void _cairo_stroker_start_dash (cairo_stroker_t *stroker) { @@ -632,7 +587,7 @@ _compute_normalized_device_slope (double *dx, double *dy, cairo_matrix_t *ctm_in } static void -_compute_face (cairo_point_t *point, cairo_slope_t *dev_slope, +_compute_face (const cairo_point_t *point, cairo_slope_t *dev_slope, double slope_dx, double slope_dy, cairo_stroker_t *stroker, cairo_stroke_face_t *face); @@ -681,7 +636,7 @@ _cairo_stroker_add_caps (cairo_stroker_t *stroker) } static void -_compute_face (cairo_point_t *point, cairo_slope_t *dev_slope, +_compute_face (const cairo_point_t *point, cairo_slope_t *dev_slope, double slope_dx, double slope_dy, cairo_stroker_t *stroker, cairo_stroke_face_t *face) { @@ -729,9 +684,13 @@ _compute_face (cairo_point_t *point, cairo_slope_t *dev_slope, } static cairo_status_t -_cairo_stroker_add_sub_edge (cairo_stroker_t *stroker, cairo_point_t *p1, cairo_point_t *p2, - cairo_slope_t *dev_slope, double slope_dx, double slope_dy, - cairo_stroke_face_t *start, cairo_stroke_face_t *end) +_cairo_stroker_add_sub_edge (cairo_stroker_t *stroker, + const cairo_point_t *p1, + const cairo_point_t *p2, + cairo_slope_t *dev_slope, + double slope_dx, double slope_dy, + cairo_stroke_face_t *start, + cairo_stroke_face_t *end) { cairo_point_t rectangle[4]; @@ -754,7 +713,8 @@ _cairo_stroker_add_sub_edge (cairo_stroker_t *stroker, cairo_point_t *p1, cairo_ } static cairo_status_t -_cairo_stroker_move_to (void *closure, cairo_point_t *point) +_cairo_stroker_move_to (void *closure, + const cairo_point_t *point) { cairo_status_t status; cairo_stroker_t *stroker = closure; @@ -775,7 +735,8 @@ _cairo_stroker_move_to (void *closure, cairo_point_t *point) } static cairo_status_t -_cairo_stroker_move_to_dashed (void *closure, cairo_point_t *point) +_cairo_stroker_move_to_dashed (void *closure, + const cairo_point_t *point) { /* reset the dash pattern for new sub paths */ cairo_stroker_t *stroker = closure; @@ -785,13 +746,13 @@ _cairo_stroker_move_to_dashed (void *closure, cairo_point_t *point) } static cairo_status_t -_cairo_stroker_line_to (void *closure, cairo_point_t *point) +_cairo_stroker_line_to (void *closure, + const cairo_point_t *p2) { cairo_status_t status; cairo_stroker_t *stroker = closure; cairo_stroke_face_t start, end; cairo_point_t *p1 = &stroker->current_point; - cairo_point_t *p2 = point; cairo_slope_t dev_slope; double slope_dx, slope_dy; @@ -805,7 +766,11 @@ _cairo_stroker_line_to (void *closure, cairo_point_t *point) slope_dy = _cairo_fixed_to_double (p2->y - p1->y); _compute_normalized_device_slope (&slope_dx, &slope_dy, stroker->ctm_inverse, NULL); - status = _cairo_stroker_add_sub_edge (stroker, p1, p2, &dev_slope, slope_dx, slope_dy, &start, &end); + status = _cairo_stroker_add_sub_edge (stroker, + p1, p2, + &dev_slope, + slope_dx, slope_dy, + &start, &end); if (unlikely (status)) return status; @@ -822,7 +787,7 @@ _cairo_stroker_line_to (void *closure, cairo_point_t *point) stroker->current_face = end; stroker->has_current_face = TRUE; - stroker->current_point = *point; + stroker->current_point = *p2; return CAIRO_STATUS_SUCCESS; } @@ -831,7 +796,8 @@ _cairo_stroker_line_to (void *closure, cairo_point_t *point) * Dashed lines. Cap each dash end, join around turns when on */ static cairo_status_t -_cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) +_cairo_stroker_line_to_dashed (void *closure, + const cairo_point_t *p2) { cairo_stroker_t *stroker = closure; double mag, remain, step_length = 0; @@ -839,7 +805,6 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) double dx2, dy2; cairo_stroke_face_t sub_start, sub_end; cairo_point_t *p1 = &stroker->current_point; - cairo_point_t *p2 = point; cairo_slope_t dev_slope; cairo_line_t segment; cairo_bool_t fully_in_bounds; @@ -948,7 +913,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) * path stroking. * On the other hand, Acroread 7 also produces the degenerate caps. */ - _compute_face (point, &dev_slope, + _compute_face (p2, &dev_slope, slope_dx, slope_dy, stroker, &stroker->current_face); @@ -961,16 +926,16 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) stroker->has_current_face = TRUE; } - stroker->current_point = *point; + stroker->current_point = *p2; return CAIRO_STATUS_SUCCESS; } static cairo_status_t _cairo_stroker_curve_to (void *closure, - cairo_point_t *b, - cairo_point_t *c, - cairo_point_t *d) + const cairo_point_t *b, + const cairo_point_t *c, + const cairo_point_t *d) { cairo_stroker_t *stroker = closure; cairo_pen_stroke_spline_t spline_pen; @@ -1072,9 +1037,9 @@ _cairo_stroker_curve_to (void *closure, */ static cairo_status_t _cairo_stroker_curve_to_dashed (void *closure, - cairo_point_t *b, - cairo_point_t *c, - cairo_point_t *d) + const cairo_point_t *b, + const cairo_point_t *c, + const cairo_point_t *d) { cairo_stroker_t *stroker = closure; cairo_spline_t spline; @@ -1242,8 +1207,8 @@ _cairo_rectilinear_stroker_fini (cairo_rectilinear_stroker_t *stroker) static cairo_status_t _cairo_rectilinear_stroker_add_segment (cairo_rectilinear_stroker_t *stroker, - cairo_point_t *p1, - cairo_point_t *p2) + const cairo_point_t *p1, + const cairo_point_t *p2) { if (stroker->num_segments == stroker->segments_size) { @@ -1395,7 +1360,7 @@ _cairo_rectilinear_stroker_emit_segments (cairo_rectilinear_stroker_t *stroker) static cairo_status_t _cairo_rectilinear_stroker_move_to (void *closure, - cairo_point_t *point) + const cairo_point_t *point) { cairo_rectilinear_stroker_t *stroker = closure; cairo_status_t status; @@ -1412,11 +1377,10 @@ _cairo_rectilinear_stroker_move_to (void *closure, static cairo_status_t _cairo_rectilinear_stroker_line_to (void *closure, - cairo_point_t *point) + const cairo_point_t *b) { cairo_rectilinear_stroker_t *stroker = closure; cairo_point_t *a = &stroker->current_point; - cairo_point_t *b = point; cairo_status_t status; /* We only support horizontal or vertical elements. */ @@ -1429,7 +1393,7 @@ _cairo_rectilinear_stroker_line_to (void *closure, status = _cairo_rectilinear_stroker_add_segment (stroker, a, b); - stroker->current_point = *point; + stroker->current_point = *b; stroker->open_sub_path = TRUE; return status; |