summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2012-10-06 15:00:51 +0200
committerUli Schlachter <psychon@znc.in>2012-10-06 15:00:51 +0200
commit0251f0951d8dcdd198912326c11489823989a3eb (patch)
tree2a14ebf3ad0decfd06256fd19c5d3fca2f28c3e4
parent15ef4a3248bbf32d05da7ed2480a2ce58c26d9bc (diff)
downloadcairo-0251f0951d8dcdd198912326c11489823989a3eb.tar.gz
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>
-rw-r--r--src/cairo-xcb-surface-render.c14
-rw-r--r--src/cairo-xcb-surface.c5
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;
}