[cairo-commit] 2 commits - src/cairo-xcb-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Oct 4 02:09:59 PDT 2008


 src/cairo-xcb-surface.c |   47 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

New commits:
commit a593338b2c2cdaff808947436f8fb9a52d74c695
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 1 16:24:33 2008 +0100

    [xcb] Return false from _cairo_xcb_surface_is_similar().
    
    _cairo_xcb_surface_is_similar() is currently only used by the pattern
    cache to determine whether to keep the surface in the solid color cache.
    This is fundamentally broken without hooking into Display closure as it
    keeps a reference to an expired picture. So in order to prevent spurious
    application crashes, disable the caching for xcb.

diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index a378731..e52b83c 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -1657,6 +1657,12 @@ _cairo_xcb_surface_is_similar (void *surface_a,
     cairo_xcb_surface_t *b = surface_b;
     xcb_render_pictforminfo_t *xrender_format;
 
+    /* XXX: disable caching by the solid pattern cache until we implement
+     * display notification to avoid issuing xcb calls from the wrong thread
+     * or accessing the surface after the Display has been closed.
+     */
+    return FALSE;
+
     if (! _cairo_xcb_surface_same_screen (a, b))
 	return FALSE;
 
commit 65f1575f6b2392d59410f40281a52654053bd2a8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Oct 1 16:16:45 2008 +0100

    [xcb] Compile fix.
    
    Must compile xcb more often. Especially after copying code over from xlib.

diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index fc72604..a378731 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -197,7 +197,7 @@ _cairo_xcb_surface_create_similar (void		       *abstract_src,
 						      xrender_format,
 						      width, height);
     if (surface->base.status)
-	return surface;
+	return &surface->base;
 
     surface->owns_pixmap = TRUE;
 
@@ -715,6 +715,7 @@ _cairo_xcb_surface_clone_similar (void			*abstract_surface,
     } else if (_cairo_surface_is_image (src)) {
 	cairo_image_surface_t *image_src = (cairo_image_surface_t *)src;
 	cairo_content_t content = _cairo_content_from_format (image_src->format);
+	cairo_status_t status;
 
 	if (surface->base.status)
 	    return surface->base.status;
@@ -726,7 +727,8 @@ _cairo_xcb_surface_clone_similar (void			*abstract_surface,
 
 	status = _draw_image_surface (clone, image_src,
 		                      src_x, src_y,
-		                      width, height, x, y);
+		                      width, height,
+				      0, 0);
 	if (status) {
 	    cairo_surface_destroy (&clone->base);
 	    return status;
@@ -1123,6 +1125,7 @@ _cairo_xcb_surface_composite (cairo_operator_t		op,
     cairo_int_status_t		status;
     composite_operation_t       operation;
     int				itx, ity;
+    cairo_bool_t                is_integer_translation;
 
     if (!CAIRO_SURFACE_RENDER_HAS_COMPOSITE (dst))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -1212,7 +1215,9 @@ _cairo_xcb_surface_composite (cairo_operator_t		op,
 	 */
 
 	_cairo_xcb_surface_ensure_gc (dst);
-	_cairo_matrix_is_integer_translation (&src_attr.matrix, &itx, &ity);
+	is_integer_translation =
+	    _cairo_matrix_is_integer_translation (&src_attr.matrix, &itx, &ity);
+	assert (is_integer_translation == TRUE);
 	{
 	    uint32_t mask = XCB_GC_FILL_STYLE | XCB_GC_TILE
 	                  | XCB_GC_TILE_STIPPLE_ORIGIN_X
@@ -1331,7 +1336,7 @@ _create_a8_picture (cairo_xcb_surface_t *surface,
 /* Creates a temporary mask for the trapezoids covering the area
  * [@dst_x, @dst_y, @width, @height] of the destination surface.
  */
-static xcb_render_picture_t
+static cairo_status_t
 _create_trapezoid_mask (cairo_xcb_surface_t *dst,
 			cairo_trapezoid_t    *traps,
 			int                   num_traps,
@@ -1339,7 +1344,8 @@ _create_trapezoid_mask (cairo_xcb_surface_t *dst,
 			int                   dst_y,
 			int                   width,
 			int                   height,
-			xcb_render_pictforminfo_t *pict_format)
+			xcb_render_pictforminfo_t *pict_format,
+			xcb_render_picture_t *mask_picture_out)
 {
     xcb_render_color_t transparent = { 0, 0, 0, 0 };
     xcb_render_color_t solid = { 0xffff, 0xffff, 0xffff, 0xffff };
@@ -1358,10 +1364,8 @@ _create_trapezoid_mask (cairo_xcb_surface_t *dst,
     solid_picture = _create_a8_picture (dst, &solid, width, height, TRUE);
 
     offset_traps = _cairo_malloc_ab (num_traps, sizeof (xcb_render_trapezoid_t));
-    if (!offset_traps) {
-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
-	return XCB_NONE;
-    }
+    if (offset_traps == NULL)
+	return	_cairo_error (CAIRO_STATUS_NO_MEMORY);
 
     for (i = 0; i < num_traps; i++) {
 	offset_traps[i].top = _cairo_fixed_to_16_16(traps[i].top) - 0x10000 * dst_y;
@@ -1385,7 +1389,8 @@ _create_trapezoid_mask (cairo_xcb_surface_t *dst,
     xcb_render_free_picture (dst->dpy, solid_picture);
     free (offset_traps);
 
-    return mask_picture;
+    *mask_picture_out = mask_picture;
+    return CAIRO_STATUS_SUCCESS;
 }
 
 static cairo_int_status_t
@@ -1472,13 +1477,14 @@ _cairo_xcb_surface_composite_trapezoids (cairo_operator_t	op,
 	 * bounds and clip. (xcb_render_add_traps() could be used to make creating
 	 * the mask somewhat cheaper.)
 	 */
-	xcb_render_picture_t mask_picture = _create_trapezoid_mask (dst, traps, num_traps,
-						       dst_x, dst_y, width, height,
-						       render_format);
-	if (!mask_picture) {
-	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	xcb_render_picture_t mask_picture = 0; /* silence compiler */
+
+	status = _create_trapezoid_mask (dst, traps, num_traps,
+		                         dst_x, dst_y, width, height,
+					 render_format,
+					 &mask_picture);
+	if (status)
 	    goto BAIL;
-	}
 
 	xcb_render_composite (dst->dpy,
 			  _render_operator (op),
@@ -1971,9 +1977,10 @@ cairo_xcb_surface_set_size (cairo_surface_t *abstract_surface,
 			     int              height)
 {
     cairo_xcb_surface_t *surface = (cairo_xcb_surface_t *) abstract_surface;
+    cairo_status_t status_ignored;
 
     if (! _cairo_surface_is_xcb (abstract_surface)) {
-	_cairo_surface_set_error (abstract_surface,
+	status_ignored = _cairo_surface_set_error (abstract_surface,
 				  CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
 	return;
     }


More information about the cairo-commit mailing list