static cairo_status_t
curve_to (void *closure,
          const cairo_point_t *b,
          const cairo_point_t *c,
          const cairo_point_t *d)
{
    struct stroker *stroker = closure;
    cairo_spline_t spline;
    cairo_stroke_face_t face;

    if (stroker->has_limits) {
        if (! _cairo_spline_intersects (&stroker->current_face.point, b, c, d,
                                        &stroker->limit))
            return line_to (closure, d);
    }

    if (! _cairo_spline_init (&spline, spline_to, stroker,
                              &stroker->current_face.point, b, c, d))
        return line_to (closure, d);

    compute_face (&stroker->current_face.point, &spline.initial_slope,
                  stroker, &face);

    if (stroker->has_current_face) {
        int clockwise = join_is_clockwise (&stroker->current_face, &face);
        /* Join with final face from previous segment */
        outer_join (stroker, &stroker->current_face, &face, clockwise);
        inner_join (stroker, &stroker->current_face, &face, clockwise);
    } else {
        if (! stroker->has_first_face) {
            /* Save sub path's first face in case needed for closing join */
            stroker->first_face = face;
            _cairo_tristrip_move_to (stroker->strip, &face.cw);
            stroker->has_first_face = TRUE;
        }
        stroker->has_current_face = TRUE;

        _cairo_tristrip_add_point (stroker->strip, &face.cw);
        _cairo_tristrip_add_point (stroker->strip, &face.ccw);
    }
    stroker->current_face = face;

    return _cairo_spline_decompose (&spline, stroker->tolerance);
}
Example #2
0
static cairo_status_t
_cairo_filler_curve_to (void		*closure,
			const cairo_point_t	*p1,
			const cairo_point_t	*p2,
			const cairo_point_t	*p3)
{
    cairo_filler_t *filler = closure;
    cairo_spline_t spline;

    if (filler->has_limits) {
	if (! _cairo_spline_intersects (&filler->current_point, p1, p2, p3,
					&filler->limit))
	    return _cairo_filler_line_to (filler, p3, NULL);
    }

    if (! _cairo_spline_init (&spline,
			      (cairo_spline_add_point_func_t)_cairo_filler_line_to, filler,
			      &filler->current_point, p1, p2, p3))
    {
	return _cairo_filler_line_to (closure, p3, NULL);
    }

    return _cairo_spline_decompose (&spline, filler->tolerance);
}