From 0251f0951d8dcdd198912326c11489823989a3eb Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 6 Oct 2012 15:00:51 +0200 Subject: [PATCH] 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 --- src/cairo-xcb-surface-render.c | 14 -------------- src/cairo-xcb-surface.c | 5 +++++ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c index dff62afdf..27ed11312 100644 --- a/src/cairo-xcb-surface-render.c +++ b/src/cairo-xcb-surface-render.c @@ -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, diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index bde03ffd0..746fb4534 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -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; }