示例#1
0
/* 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;
}
示例#2
0
文件: cairo-path.c 项目: mgya/xCairo
static int
_cairo_path_count (cairo_path_t		*path,
		   cairo_path_fixed_t	*path_fixed,
		   double		 tolerance,
		   cairo_bool_t		 flatten)
{
    cairo_status_t status;
    cpc_t cpc;

    cpc.count = 0;

    if (flatten) {
	status = _cairo_path_fixed_interpret_flat (path_fixed,
						   _cpc_move_to,
						   _cpc_line_to,
						   _cpc_close_path,
						   &cpc,
						   tolerance);
    } else {
	status = _cairo_path_fixed_interpret (path_fixed,
					      _cpc_move_to,
					      _cpc_line_to,
					      _cpc_curve_to,
					      _cpc_close_path,
					      &cpc);
    }

    if (unlikely (status))
	return -1;

    return cpc.count;
}
void
_cairo_path_fixed_fill_extents (const cairo_path_fixed_t	*path,
				cairo_fill_rule_t	 fill_rule,
				double			 tolerance,
				cairo_rectangle_int_t	*extents)
{
    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);
    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;
    }
}
示例#4
0
cairo_status_t
_cairo_path_fixed_fill_rectilinear_to_polygon (const cairo_path_fixed_t *path,
					       cairo_antialias_t antialias,
					       cairo_polygon_t *polygon)
{
    cairo_filler_ra_t filler;
    cairo_status_t status;

    if (antialias != CAIRO_ANTIALIAS_NONE)
	return _cairo_path_fixed_fill_to_polygon (path, 0., polygon);

    filler.polygon = polygon;

    /* make sure that the closure represents a degenerate path */
    filler.current_point.x = 0;
    filler.current_point.y = 0;
    filler.last_move_to = filler.current_point;

    status = _cairo_path_fixed_interpret_flat (path,
					       _cairo_filler_ra_move_to,
					       _cairo_filler_ra_line_to,
					       _cairo_filler_ra_close,
					       &filler,
					       0.);
    if (unlikely (status))
	return status;

    return _cairo_filler_ra_close (&filler);
}
示例#5
0
static cairo_clip_t *
_cairo_clip_reduce_to_boxes (cairo_clip_t *clip)
{
    struct reduce r;
    cairo_clip_path_t *clip_path;
    cairo_status_t status;

	return clip;
    if (clip->path == NULL)
	return clip;

    r.clip = clip;
    r.extents.p1.x = r.extents.p1.y = INT_MAX;
    r.extents.p2.x = r.extents.p2.y = INT_MIN;
    r.inside = FALSE;

    r.limit.p1.x = _cairo_fixed_from_int (clip->extents.x);
    r.limit.p1.y = _cairo_fixed_from_int (clip->extents.y);
    r.limit.p2.x = _cairo_fixed_from_int (clip->extents.x + clip->extents.width);
    r.limit.p2.y = _cairo_fixed_from_int (clip->extents.y + clip->extents.height);

    clip_path = clip->path;
    do {
	r.current_point.x = 0;
	r.current_point.y = 0;
	r.last_move_to = r.current_point;

	status = _cairo_path_fixed_interpret_flat (&clip_path->path,
						   _reduce_move_to,
						   _reduce_line_to,
						   _reduce_close,
						   &r,
						   clip_path->tolerance);
	assert (status == CAIRO_STATUS_SUCCESS);
	_reduce_close (&r);
    } while ((clip_path = clip_path->prev));

    if (! r.inside) {
	_cairo_clip_path_destroy (clip->path);
	clip->path = NULL;
    }

    return _cairo_clip_intersect_box (clip, &r.extents);
}
示例#6
0
static cairo_status_t
_cairo_path_populate (cairo_path_t		*path,
		      cairo_path_fixed_t	*path_fixed,
		      cairo_gstate_t		*gstate,
		      cairo_bool_t		 flatten)
{
    cairo_status_t status;
    cpp_t cpp;

    cpp.data = path->data;
    cpp.gstate = gstate;
    cpp.current_point.x = 0;
    cpp.current_point.y = 0;

    if (flatten) {
	double tolerance = _cairo_gstate_get_tolerance (gstate);
	status = _cairo_path_fixed_interpret_flat (path_fixed,
						   CAIRO_DIRECTION_FORWARD,
						   _cpp_move_to,
						   _cpp_line_to,
						   _cpp_close_path,
						   &cpp,
						   tolerance);
    } else {
	status = _cairo_path_fixed_interpret (path_fixed,
				          CAIRO_DIRECTION_FORWARD,
					  _cpp_move_to,
					  _cpp_line_to,
					  _cpp_curve_to,
					  _cpp_close_path,
					  &cpp);
    }

    if (unlikely (status))
	return status;

    /* Sanity check the count */
    assert (cpp.data - path->data == path->num_data);

    return CAIRO_STATUS_SUCCESS;
}
示例#7
0
static cairo_status_t
_cairo_path_fixed_fill_to_scan_converter (
    cairo_path_fixed_t			*path,
    double				 tolerance,
    cairo_scan_converter_t		*converter)
{
    scan_converter_filler_t filler;
    cairo_status_t status;

    scan_converter_filler_init (&filler, converter);

    status = _cairo_path_fixed_interpret_flat (
	path, CAIRO_DIRECTION_FORWARD,
	scan_converter_filler_move_to,
	scan_converter_filler_line_to,
	scan_converter_filler_close_path,
	&filler, tolerance);
    if (status)
	return status;

    return scan_converter_filler_close_path (&filler);
}
示例#8
0
文件: cairo-path.c 项目: mgya/xCairo
static cairo_status_t
_cairo_path_populate (cairo_path_t		*path,
		      cairo_path_fixed_t	*path_fixed,
		      cairo_t			*cr,
		      cairo_bool_t		 flatten)
{
    cairo_status_t status;
    cpp_t cpp;

    cpp.data = path->data;
    cpp.cr = cr;

    if (flatten) {
	status = _cairo_path_fixed_interpret_flat (path_fixed,
						   _cpp_move_to,
						   _cpp_line_to,
						   _cpp_close_path,
						   &cpp,
						   cairo_get_tolerance (cr));
    } else {
	status = _cairo_path_fixed_interpret (path_fixed,
					  _cpp_move_to,
					  _cpp_line_to,
					  _cpp_curve_to,
					  _cpp_close_path,
					  &cpp);
    }

    if (unlikely (status))
	return status;

    /* Sanity check the count */
    XASSERT (cpp.data - path->data == path->num_data);

    return CAIRO_STATUS_SUCCESS;
}
示例#9
0
static int
_cairo_path_count (cairo_path_t		*path,
		   cairo_path_fixed_t	*path_fixed,
		   double		 tolerance,
		   cairo_bool_t		 flatten)
{
    cairo_status_t status;
    cpc_t cpc;

    cpc.count = 0;
    cpc.current_point.x = 0;
    cpc.current_point.y = 0;

    if (flatten) {
	status = _cairo_path_fixed_interpret_flat (path_fixed,
						   CAIRO_DIRECTION_FORWARD,
						   _cpc_move_to,
						   _cpc_line_to,
						   _cpc_close_path,
						   &cpc,
						   tolerance);
    } else {
	status = _cairo_path_fixed_interpret (path_fixed,
					      CAIRO_DIRECTION_FORWARD,
					      _cpc_move_to,
					      _cpc_line_to,
					      _cpc_curve_to,
					      _cpc_close_path,
					      &cpc);
    }

    if (status)
	return -1;

    return cpc.count;
}