[cairo-commit] src/cairo-xcb-surface.c src/cairo-xcb-surface-render.c

Uli Schlachter psychon at kemper.freedesktop.org
Sat Oct 6 06:06:33 PDT 2012


 src/cairo-xcb-surface-render.c |   14 --------------
 src/cairo-xcb-surface.c        |    5 +++++
 2 files changed, 5 insertions(+), 14 deletions(-)

New commits:
commit 0251f0951d8dcdd198912326c11489823989a3eb
Author: Uli Schlachter <psychon at znc.in>
Date:   Sat Oct 6 15:00:51 2012 +0200

    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 at znc.in>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index dff62af..27ed113 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 bde03ff..746fb45 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;
 }
 


More information about the cairo-commit mailing list