xcb: Clear the result of create_similar_image

The documentation of cairo_surface_create_similar_image() states that the
image's contents are initially all 0. However, the implementation didn't live up
to the documentation.

This was found via the corresponding assert in
cairo_surface_create_similar_image().

There are some cairo-xcb-internal users of this function which cleared the image
right after creating it. Obviously, this isn't needed anymore.

Fixes: Nothing. The existing call in the testsuite to
cairo_surface_create_similar_image() doesn't hit this issue, since it creates a
too small image to hit the SHM-case.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2012-10-06 15:00:51 +02:00
parent 15ef4a3248
commit 0251f0951d
2 changed files with 5 additions and 14 deletions

View file

@ -3617,14 +3617,6 @@ _cairo_xcb_surface_render_stroke_as_polygon (cairo_xcb_surface_t *dst,
return status;
}
static void
_clear_image (cairo_surface_t *surface)
{
cairo_image_surface_t *image = (cairo_image_surface_t *) surface;
memset (image->data, 0, image->stride * image->height);
surface->is_clear = TRUE;
}
static cairo_status_t
_cairo_xcb_surface_render_stroke_via_mask (cairo_xcb_surface_t *dst,
cairo_operator_t op,
@ -3650,8 +3642,6 @@ _cairo_xcb_surface_render_stroke_via_mask (cairo_xcb_surface_t *dst,
if (unlikely (image->status))
return image->status;
_clear_image (image);
clip = _cairo_clip_copy_region (extents->clip);
status = _cairo_surface_offset_stroke (image, x, y,
CAIRO_OPERATOR_ADD,
@ -3792,8 +3782,6 @@ _cairo_xcb_surface_render_fill_via_mask (cairo_xcb_surface_t *dst,
if (unlikely (image->status))
return image->status;
_clear_image (image);
clip = _cairo_clip_copy_region (extents->clip);
status = _cairo_surface_offset_fill (image, x, y,
CAIRO_OPERATOR_ADD,
@ -3904,8 +3892,6 @@ _cairo_xcb_surface_render_glyphs_via_mask (cairo_xcb_surface_t *dst,
if (unlikely (image->status))
return image->status;
_clear_image (image);
clip = _cairo_clip_copy_region (extents->clip);
status = _cairo_surface_offset_glyphs (image, x, y,
CAIRO_OPERATOR_ADD,

View file

@ -190,6 +190,11 @@ _cairo_xcb_surface_create_similar_image (void *abstract_other,
if (unlikely (status))
return _cairo_surface_create_in_error (status);
if (! image->base.is_clear) {
memset (image->data, 0, image->stride * image->height);
image->base.is_clear = TRUE;
}
return &image->base;
}