/* XXX: Perhaps this should compute a PixRegion rather than 4 doubles */ cairo_status_t _cairo_path_fixed_bounds (cairo_path_fixed_t *path, double *x1, double *y1, double *x2, double *y2) { cairo_status_t status; cairo_path_bounder_t bounder; _cairo_path_bounder_init (&bounder); status = _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD, _cairo_path_bounder_move_to, _cairo_path_bounder_line_to, _cairo_path_bounder_curve_to, _cairo_path_bounder_close_path, &bounder); if (status) { *x1 = *y1 = *x2 = *y2 = 0.0; _cairo_path_bounder_fini (&bounder); return status; } *x1 = _cairo_fixed_to_double (bounder.min_x); *y1 = _cairo_fixed_to_double (bounder.min_y); *x2 = _cairo_fixed_to_double (bounder.max_x); *y2 = _cairo_fixed_to_double (bounder.max_y); _cairo_path_bounder_fini (&bounder); return CAIRO_STATUS_SUCCESS; }
/* XXX: Perhaps this should compute a PixRegion rather than 4 doubles */ cairo_status_t _cairo_path_fixed_bounds (cairo_path_fixed_t *path, double *x1, double *y1, double *x2, double *y2, double tolerance) { cairo_path_bounder_t bounder; cairo_status_t status; _cairo_path_bounder_init (&bounder); status = _cairo_path_fixed_interpret_flat (path, CAIRO_DIRECTION_FORWARD, _cairo_path_bounder_move_to, _cairo_path_bounder_line_to, _cairo_path_bounder_close_path, &bounder, tolerance); if (status == CAIRO_STATUS_SUCCESS && bounder.has_point) { *x1 = _cairo_fixed_to_double (bounder.min_x); *y1 = _cairo_fixed_to_double (bounder.min_y); *x2 = _cairo_fixed_to_double (bounder.max_x); *y2 = _cairo_fixed_to_double (bounder.max_y); } else { *x1 = 0.0; *y1 = 0.0; *x2 = 0.0; *y2 = 0.0; } _cairo_path_bounder_fini (&bounder); return status; }
void _cairo_path_fixed_bounds (cairo_path_fixed_t *path, double *x1, double *y1, double *x2, double *y2) { cairo_path_bounder_t bounder; cairo_status_t status; _cairo_path_bounder_init (&bounder); status = _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD, _cairo_path_bounder_move_to, _cairo_path_bounder_line_to, _cairo_path_bounder_curve_to, _cairo_path_bounder_close_path, &bounder); assert (status == CAIRO_STATUS_SUCCESS); if (bounder.has_point) { *x1 = _cairo_fixed_to_double (bounder.extents.p1.x); *y1 = _cairo_fixed_to_double (bounder.extents.p1.y); *x2 = _cairo_fixed_to_double (bounder.extents.p2.x); *y2 = _cairo_fixed_to_double (bounder.extents.p2.y); } else { *x1 = 0.0; *y1 = 0.0; *x2 = 0.0; *y2 = 0.0; } _cairo_path_bounder_fini (&bounder); }
/* A slightly better approximation than above - we actually decompose the * Bezier, but we continue to ignore winding. */ void _cairo_path_fixed_approximate_fill_extents (cairo_path_fixed_t *path, cairo_rectangle_int_t *extents) { cairo_path_bounder_t bounder; cairo_status_t status; _cairo_path_bounder_init (&bounder); status = _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD, _cairo_path_bounder_move_to, _cairo_path_bounder_line_to, _cairo_path_bounder_curve_to, _cairo_path_bounder_close_path, &bounder); assert (status == CAIRO_STATUS_SUCCESS); if (bounder.has_point) { _cairo_box_round_to_rectangle (&bounder.extents, extents); } else { 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. */ void _cairo_path_fixed_approximate_stroke_extents (cairo_path_fixed_t *path, cairo_stroke_style_t *style, const cairo_matrix_t *ctm, cairo_rectangle_int_t *extents) { cairo_path_bounder_t bounder; cairo_status_t status; _cairo_path_bounder_init (&bounder); status = _cairo_path_fixed_interpret (path, CAIRO_DIRECTION_FORWARD, _cairo_path_bounder_move_to, _cairo_path_bounder_line_to, _cairo_path_bounder_curve_to, _cairo_path_bounder_close_path, &bounder); assert (status == CAIRO_STATUS_SUCCESS); if (bounder.has_point) { double dx, dy; _cairo_stroke_style_max_distance_from_path (style, ctm, &dx, &dy); bounder.extents.p1.x -= _cairo_fixed_from_double (dx); bounder.extents.p2.x += _cairo_fixed_from_double (dx); 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 { extents->x = extents->y = 0; extents->width = extents->height = 0; } _cairo_path_bounder_fini (&bounder); }