create_bits (pixman_format_code_t format,
int width,
int height,
- int * rowstride_bytes)
+ int * rowstride_bytes,
+ pixman_bool_t clear)
{
int stride;
size_t buf_size;
if (rowstride_bytes)
*rowstride_bytes = stride;
- return calloc (buf_size, 1);
+ if (clear)
+ return calloc (buf_size, 1);
+ else
+ return malloc (buf_size);
}
pixman_bool_t
int width,
int height,
uint32_t * bits,
- int rowstride)
+ int rowstride,
+ pixman_bool_t clear)
{
uint32_t *free_me = NULL;
{
int rowstride_bytes;
- free_me = bits = create_bits (format, width, height, &rowstride_bytes);
+ free_me = bits = create_bits (format, width, height, &rowstride_bytes, clear);
if (!bits)
return FALSE;
return TRUE;
}
-PIXMAN_EXPORT pixman_image_t *
-pixman_image_create_bits (pixman_format_code_t format,
- int width,
- int height,
- uint32_t * bits,
- int rowstride_bytes)
+static pixman_image_t *
+create_bits_image_internal (pixman_format_code_t format,
+ int width,
+ int height,
+ uint32_t * bits,
+ int rowstride_bytes,
+ pixman_bool_t clear)
{
pixman_image_t *image;
return NULL;
if (!_pixman_bits_image_init (image, format, width, height, bits,
- rowstride_bytes / (int) sizeof (uint32_t)))
+ rowstride_bytes / (int) sizeof (uint32_t),
+ clear))
{
free (image);
return NULL;
return image;
}
+
+/* If bits is NULL, a buffer will be allocated and initialized to 0 */
+PIXMAN_EXPORT pixman_image_t *
+pixman_image_create_bits (pixman_format_code_t format,
+ int width,
+ int height,
+ uint32_t * bits,
+ int rowstride_bytes)
+{
+ return create_bits_image_internal (
+ format, width, height, bits, rowstride_bytes, TRUE);
+}
+
+
+/* If bits is NULL, a buffer will be allocated and _not_ initialized */
+PIXMAN_EXPORT pixman_image_t *
+pixman_image_create_bits_no_clear (pixman_format_code_t format,
+ int width,
+ int height,
+ uint32_t * bits,
+ int rowstride_bytes)
+{
+ return create_bits_image_internal (
+ format, width, height, bits, rowstride_bytes, FALSE);
+}
/* Initialize/validate stack-allocated temporary image */
_pixman_bits_image_init (&extended_src_image, src_image->bits.format,
- src_width, 1, &extended_src[0], src_stride);
+ src_width, 1, &extended_src[0], src_stride,
+ FALSE);
_pixman_image_validate (&extended_src_image);
info2.src_image = &extended_src_image;