(color->blue >> 8);
}
+static pixman_image_t *
+allocate_image (void)
+{
+ return malloc (sizeof (pixman_image_t *));
+}
+
+/* Destructor */
void
-pixman_image_init_solid_fill (pixman_image_t *image,
- pixman_color_t *color,
- int *error)
+pixman_image_destroy (pixman_image_t *image)
{
- image_t *priv = (image_t *)image;
- init_source_image (&priv->solid.common);
+}
+
+/* Constructors */
+
+pixman_image_t *
+pixman_image_create_solid_fill (pixman_color_t *color,
+ int *error)
+{
+ pixman_image_t *img = allocate_image();
+ if (!img)
+ return NULL;
+
+ init_source_image (&img->solid.common);
- priv->type = SOLID;
- priv->solid.color = color_to_uint32 (color);
+ img->type = SOLID;
+ img->solid.color = color_to_uint32 (color);
+
+ return img;
}
-void
-pixman_image_init_linear_gradient (pixman_image_t *image,
- pixman_point_fixed_t *p1,
- pixman_point_fixed_t *p2,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error)
+pixman_image_t *
+pixman_image_create_linear_gradient (pixman_point_fixed_t *p1,
+ pixman_point_fixed_t *p2,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error)
{
- image_t *priv = (image_t *)image;
- linear_gradient_t *linear = &priv->linear;
+ pixman_image_t *image = allocate_image();
+ linear_gradient_t *linear = &image->linear;
+
+ if (!image)
+ {
+ *error = PIXMAN_BAD_ALLOC;
+ return NULL;
+ }
if (n_stops < 2)
{
*error = PIXMAN_BAD_VALUE;
- return;
+ return NULL;
}
init_gradient (&linear->common, n_stops, stops, colors, error);
linear->p1 = *p1;
linear->p2 = *p2;
- priv->type = LINEAR;
+ image->type = LINEAR;
+
+ return image;
}
-void
-pixman_image_init_radial_gradient (pixman_image_t *image,
- pixman_point_fixed_t *inner,
- pixman_point_fixed_t *outer,
- pixman_fixed_t inner_radius,
- pixman_fixed_t outer_radius,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error)
+pixman_image_t *
+pixman_image_create_radial_gradient (pixman_point_fixed_t *inner,
+ pixman_point_fixed_t *outer,
+ pixman_fixed_t inner_radius,
+ pixman_fixed_t outer_radius,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error)
{
- image_t *priv = (image_t *)image;
- radial_gradient_t *radial = &priv->radial;
+ pixman_image_t *image = allocate_image();
+ radial_gradient_t *radial = &image->radial;
+ if (!image)
+ {
+ *error = PIXMAN_BAD_ALLOC;
+ return NULL;
+ }
+
if (n_stops < 2)
{
*error = PIXMAN_BAD_VALUE;
- return;
+ return NULL;
}
init_gradient (&radial->common, n_stops, stops, colors, error);
- priv->type = RADIAL;
+ image->type = RADIAL;
radial->c1.x = inner->x;
radial->c1.y = inner->y;
radial->A = ( radial->cdx * radial->cdx
+ radial->cdy * radial->cdy
- radial->dr * radial->dr);
+
+ return image;
}
-void
-pixman_image_init_conical_gradient (pixman_image_t *image,
- pixman_point_fixed_t *center,
- pixman_fixed_t angle,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error)
+pixman_image_t *
+pixman_image_create_conical_gradient (pixman_point_fixed_t *center,
+ pixman_fixed_t angle,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error)
{
- image_t *priv = (image_t *)image;
- conical_gradient_t *conical = &priv->conical;
+ pixman_image_t *image = allocate_image();
+ conical_gradient_t *conical = &image->conical;
+ if (!image)
+ {
+ *error = PIXMAN_BAD_ALLOC;
+ return NULL;
+ }
+
if (n_stops < 2)
{
*error = PIXMAN_BAD_VALUE;
- return;
+ return NULL;
}
init_gradient (&conical->common, n_stops, stops, colors, error);
- priv->type = CONICAL;
+ image->type = CONICAL;
conical->center = *center;
conical->angle = angle;
+
+ return image;
}
-void
-pixman_image_init_bits (pixman_image_t *image,
- pixman_format_code_t format,
- int width,
- int height,
- uint32_t *bits,
- int rowstride)
+pixman_image_t *
+pixman_image_create_bits (pixman_format_code_t format,
+ int width,
+ int height,
+ uint32_t *bits,
+ int rowstride,
+ int *error)
{
- image_t *img = (image_t *)image;
+ pixman_image_t *image = allocate_image();
- init_common (&img->common);
-
- if (rowstride & 0x3)
+ if (!image)
{
- /* we should probably spew some warning here */
+ *error = PIXMAN_BAD_ALLOC;
+ return NULL;
}
- img->type = BITS;
- img->bits.format = format;
- img->bits.width = width;
- img->bits.height = height;
- img->bits.bits = bits;
- img->bits.rowstride = rowstride / 4; /* we store it in number of uint32_t's */
- img->bits.indexed = NULL;
-
- if (sizeof (pixman_image_t) < sizeof (image_t))
- {
- fprintf (stderr, "BUG in pixman: sizeof pixman_image_t < sizeof (image_t)\n");
- exit (1);
- }
- else
+ init_common (&image->common);
+
+ if (rowstride & 0x3)
{
- fprintf (stderr, "sizeof pixman_image_t: %d\n", sizeof (pixman_image_t));
- fprintf (stderr, "sizeof image_t: %d\n", sizeof (image_t));
+ /* we should probably spew some warning here */
}
+ image->type = BITS;
+ image->bits.format = format;
+ image->bits.width = width;
+ image->bits.height = height;
+ image->bits.bits = bits;
+ image->bits.rowstride = rowstride / 4; /* we store it in number of uint32_t's */
+ image->bits.indexed = NULL;
+
+ return image;
}
void
pixman_image_set_clip_region (pixman_image_t *image,
pixman_region16_t *region)
{
- image_t *priv = (image_t *)image;
-
- priv->common.clip_region = region;
+ image->common.clip_region = region;
}
void
pixman_image_set_transform (pixman_image_t *image,
pixman_transform_t *transform)
{
- image_t *priv = (image_t *)image;
-
- priv->common.transform = transform;
+ image->common.transform = transform;
}
void
pixman_image_set_repeat (pixman_image_t *image,
pixman_repeat_t repeat)
{
- image_t *priv = (image_t *)image;
-
- priv->common.repeat = repeat;
+ image->common.repeat = repeat;
}
void
pixman_image_set_filter (pixman_image_t *image,
pixman_filter_t filter)
{
- image_t *priv = (image_t *)image;
-
- priv->common.filter = filter;
+ image->common.filter = filter;
}
void
pixman_fixed_t *params,
int n_params)
{
- image_t *priv = (image_t *)image;
-
- priv->common.filter_params = params;
- priv->common.n_filter_params = n_params;
+ image->common.filter_params = params;
+ image->common.n_filter_params = n_params;
}
void
int16_t x,
int16_t y)
{
- image_t *priv = (image_t *)image;
- image_t *alpha_priv = (image_t *)alpha_map;
-
- if (alpha_priv && alpha_priv->type != BITS)
+ if (alpha_map && alpha_map->type != BITS)
{
- priv->common.alpha_map = NULL;
+ image->common.alpha_map = NULL;
return;
}
- priv->common.alpha_map = (bits_image_t *)alpha_map;
- priv->common.alpha_origin.x = x;
- priv->common.alpha_origin.y = y;
+ image->common.alpha_map = (bits_image_t *)alpha_map;
+ image->common.alpha_origin.x = x;
+ image->common.alpha_origin.y = y;
}
void
pixman_image_set_component_alpha (pixman_image_t *image,
pixman_bool_t component_alpha)
{
- image_t *priv = (image_t *)image;
-
- priv->common.component_alpha = component_alpha;
+ image->common.component_alpha = component_alpha;
}
}
compose_data.op = op;
- compose_data.src = (image_t *)src_img;
- compose_data.mask = (image_t *)mask_img;
- compose_data.dest = (image_t *)dest_img;
+ compose_data.src = src_img;
+ compose_data.mask = mask_img;
+ compose_data.dest = dest_img;
compose_data.xSrc = src_x;
compose_data.ySrc = src_y;
compose_data.xMask = mask_x;
/*
* Images
*/
+typedef union pixman_image pixman_image_t;
typedef struct pixman_indexed pixman_indexed_t;
+
#define PIXMAN_MAX_INDEXED 256 /* XXX depth must be <= 8 */
#if PIXMAN_MAX_INDEXED <= 256
PIXMAN_g1 = PIXMAN_FORMAT(1,PIXMAN_TYPE_GRAY,0,0,0,0),
} pixman_format_code_t;
-typedef struct
-{
- /* All of this struct is considered private to libcomp */
- unsigned char reserved [128];
-} pixman_image_t;
-
-/* Initialize */
-void pixman_image_init_solid_fill (pixman_image_t *image,
- pixman_color_t *color,
- int *error);
-void pixman_image_init_linear_gradient (pixman_image_t *image,
- pixman_point_fixed_t *p1,
- pixman_point_fixed_t *p2,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error);
-void pixman_image_init_radial_gradient (pixman_image_t *image,
- pixman_point_fixed_t *inner,
- pixman_point_fixed_t *outer,
- pixman_fixed_t inner_radius,
- pixman_fixed_t outer_radius,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error);
-void pixman_image_init_conical_gradient (pixman_image_t *image,
- pixman_point_fixed_t *center,
- pixman_fixed_t angle,
- int n_stops,
- pixman_fixed_t *stops,
- pixman_color_t *colors,
- int *error);
-void pixman_image_init_bits (pixman_image_t *image,
- pixman_format_code_t format,
- int width,
- int height,
- uint32_t *bits,
- int rowstride_bytes);
+/* Constructors */
+pixman_image_t *pixman_image_create_solid_fill (pixman_color_t *color,
+ int *error);
+pixman_image_t *pixman_image_create_linear_gradient (pixman_point_fixed_t *p1,
+ pixman_point_fixed_t *p2,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error);
+pixman_image_t *pixman_image_create_radial_gradient (pixman_point_fixed_t *inner,
+ pixman_point_fixed_t *outer,
+ pixman_fixed_t inner_radius,
+ pixman_fixed_t outer_radius,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error);
+pixman_image_t *pixman_image_create_conical_gradient (pixman_point_fixed_t *center,
+ pixman_fixed_t angle,
+ int n_stops,
+ pixman_fixed_t *stops,
+ pixman_color_t *colors,
+ int *error);
+pixman_image_t *pixman_image_create_bits (pixman_format_code_t format,
+ int width,
+ int height,
+ uint32_t *bits,
+ int rowstride_bytes,
+ int *error);
+
+/* Destructor */
+void pixman_image_destroy (pixman_image_t *image);
+
/* Set properties */
-void pixman_image_set_clip_region (pixman_image_t *image,
- pixman_region16_t *region);
-void pixman_image_set_transform (pixman_image_t *image,
- pixman_transform_t *transform);
-void pixman_image_set_repeat (pixman_image_t *image,
- pixman_repeat_t repeat);
-void pixman_image_set_filter (pixman_image_t *image,
- pixman_filter_t filter);
-void pixman_image_set_filter_params (pixman_image_t *image,
- pixman_fixed_t *params,
- int n_params);
-void pixman_image_set_alpha_map (pixman_image_t *image,
- pixman_image_t *alpha_map,
- int16_t x,
- int16_t y);
-void pixman_image_set_component_alpha (pixman_image_t *image,
- pixman_bool_t component_alpha);
+void pixman_image_set_clip_region (pixman_image_t *image,
+ pixman_region16_t *region);
+void pixman_image_set_transform (pixman_image_t *image,
+ pixman_transform_t *transform);
+void pixman_image_set_repeat (pixman_image_t *image,
+ pixman_repeat_t repeat);
+void pixman_image_set_filter (pixman_image_t *image,
+ pixman_filter_t filter);
+void pixman_image_set_filter_params (pixman_image_t *image,
+ pixman_fixed_t *params,
+ int n_params);
+void pixman_image_set_alpha_map (pixman_image_t *image,
+ pixman_image_t *alpha_map,
+ int16_t x,
+ int16_t y);
+void pixman_image_set_component_alpha (pixman_image_t *image,
+ pixman_bool_t component_alpha);
/* Composite */
-void pixman_image_composite (pixman_op_t op,
- pixman_image_t *src,
- pixman_image_t *mask,
- pixman_image_t *dest,
- int src_x,
- int src_y,
- int mask_x,
- int mask_y,
- int dest_x,
- int dest_y,
- int width,
- int height);
+void pixman_image_composite (pixman_op_t op,
+ pixman_image_t *src,
+ pixman_image_t *mask,
+ pixman_image_t *dest,
+ int src_x,
+ int src_y,
+ int mask_x,
+ int mask_y,
+ int dest_x,
+ int dest_y,
+ int width,
+ int height);
+
+