Add _cairo_pattern_create_copy()

This commit is contained in:
Adrian Johnson 2008-01-07 20:41:43 +10:30
parent 26c6159b1e
commit 6ead8feaf3
2 changed files with 32 additions and 0 deletions

View file

@ -213,6 +213,34 @@ _cairo_pattern_fini (cairo_pattern_t *pattern)
}
}
cairo_status_t
_cairo_pattern_create_copy (cairo_pattern_t **pattern,
const cairo_pattern_t *other)
{
if (other->status)
return other->status;
switch (other->type) {
case CAIRO_PATTERN_TYPE_SOLID:
*pattern = malloc (sizeof (cairo_solid_pattern_t));
break;
case CAIRO_PATTERN_TYPE_SURFACE:
*pattern = malloc (sizeof (cairo_surface_pattern_t));
break;
case CAIRO_PATTERN_TYPE_LINEAR:
*pattern = malloc (sizeof (cairo_linear_pattern_t));
break;
case CAIRO_PATTERN_TYPE_RADIAL:
*pattern = malloc (sizeof (cairo_radial_pattern_t));
break;
}
if (*pattern == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
return _cairo_pattern_init_copy (*pattern, other);
}
void
_cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
const cairo_color_t *color,

View file

@ -2222,6 +2222,10 @@ _cairo_slope_counter_clockwise (cairo_slope_t *a, cairo_slope_t *b);
/* cairo_pattern.c */
cairo_private cairo_status_t
_cairo_pattern_create_copy (cairo_pattern_t **pattern,
const cairo_pattern_t *other);
cairo_private cairo_status_t
_cairo_pattern_init_copy (cairo_pattern_t *pattern,
const cairo_pattern_t *other);