[cairo] Making cairo_image_surface_create zero out the surface

Mike Shaver mike.shaver at gmail.com
Sat Apr 15 07:41:47 PDT 2006


On 4/14/06, Carl Worth <cworth at cworth.org> wrote:
> diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c
> index cdec492..2ad34f4 100644
> --- a/pixman/src/icpixels.c
> +++ b/pixman/src/icpixels.c
> @@ -70,6 +70,7 @@ FbPixelsCreate (int width, int height, i
>         return NULL;
>
>      buf = (pixman_bits_t *) ((char *)pixels + base + adjust);
> +    memset (buf, 0, height * stride);
>
>      FbPixelsInit (pixels, buf, width, height, depth, bpp, stride);

If you just use calloc instead of malloc to allocate pixels, I suspect
you'll get the zeroing basically for free, since most operating
systems have optimized paths for pages of zeroes.

Mike


More information about the cairo mailing list