[cairo-commit] 4 commits - boilerplate/cairo-boilerplate-xcb.c src/cairo-xcb-connection.c src/cairo-xcb-private.h src/cairo-xcb-surface.c src/cairo-xcb-surface-render.c src/cairo-xlib-display.c src/cairo-xlib-xcb-surface.c

Uli Schlachter psychon at kemper.freedesktop.org
Thu Jul 21 07:51:33 PDT 2011


 boilerplate/cairo-boilerplate-xcb.c |   45 ++++++++--------------
 src/cairo-xcb-connection.c          |   72 ++++++++++++++++++++++++++++++++++--
 src/cairo-xcb-private.h             |   16 +++++++-
 src/cairo-xcb-surface-render.c      |   58 ++++++++++++++---------------
 src/cairo-xcb-surface.c             |   10 ++---
 src/cairo-xlib-display.c            |   22 +++++++++--
 src/cairo-xlib-xcb-surface.c        |   22 +++++++++++
 7 files changed, 171 insertions(+), 74 deletions(-)

New commits:
commit 93ab2171d036166d333d6d3f1ab15f346803d49c
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Jul 21 16:50:48 2011 +0200

    xcb: Parse $CAIRO_DEBUG just like cairo-xlib does
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 307e092..3cba883 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -312,6 +312,41 @@ has_required_depths (cairo_xcb_connection_t *connection)
     return TRUE;
 }
 
+static xcb_render_query_version_reply_t *
+_render_restrict_env(xcb_render_query_version_reply_t *version)
+{
+    const char *env;
+
+    if (version == NULL)
+	return NULL;
+
+    env = getenv ("CAIRO_DEBUG");
+    if (env != NULL)
+	env = strstr (env, "xrender-version=");
+    if (env != NULL) {
+	int max_render_major, max_render_minor;
+
+	env += sizeof ("xrender-version=") - 1;
+	if (sscanf (env, "%d.%d", &max_render_major, &max_render_minor) != 2)
+	    max_render_major = max_render_minor = -1;
+
+	if (max_render_major < 0 || max_render_minor < 0) {
+	    free (version);
+	    return NULL;
+	}
+
+	if (max_render_major < (int) version->major_version ||
+	    (max_render_major == (int) version->major_version &&
+	     max_render_minor < (int) version->minor_version))
+	{
+	    version->major_version = max_render_major;
+	    version->minor_version = max_render_minor;
+	}
+    }
+
+    return version;
+}
+
 static cairo_status_t
 _cairo_xcb_connection_query_render (cairo_xcb_connection_t *connection)
 {
@@ -329,6 +364,9 @@ _cairo_xcb_connection_query_render (cairo_xcb_connection_t *connection)
     present = has_required_depths (connection);
     version = xcb_render_query_version_reply (c, version_cookie, 0);
     formats = xcb_render_query_pict_formats_reply (c, formats_cookie, 0);
+
+    version = _render_restrict_env (version);
+
     if (! present || version == NULL || formats == NULL) {
 	free (version);
 	free (formats);
commit 0858533419dc1a38ef7c2bf6e07fb89714af5598
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Jul 21 16:03:36 2011 +0200

    Xlib,xcb: Make *_debug_[sg]et_precision() more robust
    
    This adds checks for NULL pointers, devices in an error state and devices which
    aren't owned by the right backend.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 84876de..307e092 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -870,8 +870,15 @@ void
 cairo_xcb_device_debug_set_precision (cairo_device_t *device,
 				      int precision)
 {
-    if (device->status)
-	    return;
+    if (device == NULL || device->status)
+	return;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return;
+    }
 
     ((cairo_xcb_connection_t *) device)->force_precision = precision;
 }
@@ -882,8 +889,15 @@ slim_hidden_def (cairo_xcb_device_debug_set_precision);
 int
 cairo_xcb_device_debug_get_precision (cairo_device_t *device)
 {
-    if (device->status)
-	    return -1;
+    if (device == NULL || device->status)
+	return -1;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return -1;
+    }
 
     return ((cairo_xcb_connection_t *) device)->force_precision;
 }
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index cce69ff..fe93e1c 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -749,8 +749,15 @@ void
 cairo_xlib_device_debug_set_precision (cairo_device_t *device,
 				       int precision)
 {
-    if (device->status)
-	    return;
+    if (device == NULL || device->status)
+	return;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return;
+    }
 
     ((cairo_xlib_display_t *) device)->force_precision = precision;
 }
@@ -758,8 +765,15 @@ cairo_xlib_device_debug_set_precision (cairo_device_t *device,
 int
 cairo_xlib_device_debug_get_precision (cairo_device_t *device)
 {
-    if (device->status)
-	    return -1;
+    if (device == NULL || device->status)
+	return -1;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return -1;
+    }
 
     return ((cairo_xlib_display_t *) device)->force_precision;
 }
diff --git a/src/cairo-xlib-xcb-surface.c b/src/cairo-xlib-xcb-surface.c
index f4e25a1..7fc27e2 100644
--- a/src/cairo-xlib-xcb-surface.c
+++ b/src/cairo-xlib-xcb-surface.c
@@ -755,6 +755,17 @@ cairo_xlib_device_debug_set_precision (cairo_device_t *device,
 				       int precision)
 {
     cairo_xlib_xcb_display_t *display = (cairo_xlib_xcb_display_t *) device;
+
+    if (device == NULL || device->status)
+	return;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return;
+    }
+
     cairo_xcb_device_debug_set_precision (display->xcb_device, precision);
 }
 
@@ -762,6 +773,17 @@ int
 cairo_xlib_device_debug_get_precision (cairo_device_t *device)
 {
     cairo_xlib_xcb_display_t *display = (cairo_xlib_xcb_display_t *) device;
+
+    if (device == NULL || device->status)
+	return -1;
+    if (device->backend->type != CAIRO_DEVICE_TYPE_XLIB) {
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
+	return -1;
+    }
+
     return cairo_xcb_device_debug_get_precision (display->xcb_device);
 }
 
commit 7c2ccef3eb636661ee45c501c8345b6bde9a827c
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Jul 21 15:41:25 2011 +0200

    xcb: Make it possible to undo _cairo_xcb_device_debug_cap_*
    
    We now remember the original flags before any call to
    cairo_xcb_device_debug_cap_xshm_version() or
    cairo_xcb_device_debug_cap_xrender_version() was done and re-set these flags on
    any new call to these functions. This makes it possible to raise e.g. the used
    RENDER version again.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 19d5462..84876de 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -673,6 +673,8 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
     }
 #endif
 
+    connection->original_flags = connection->flags;
+
     CAIRO_MUTEX_UNLOCK (connection->device.mutex);
 
     cairo_list_add (&connection->link, &connections);
@@ -780,6 +782,11 @@ cairo_xcb_device_debug_cap_xshm_version (cairo_device_t *device,
 	return;
     }
 
+    /* First reset all the SHM flags to their original value. This works
+     * because we only ever clear bits after the connection was created.
+     */
+    connection->flags |= (connection->original_flags & CAIRO_XCB_SHM_MASK);
+
     /* clear any flags that are inappropriate for the desired version */
     if (major_version < 0 && minor_version < 0) {
 	connection->flags &= ~(CAIRO_XCB_HAS_SHM);
@@ -812,6 +819,11 @@ cairo_xcb_device_debug_cap_xrender_version (cairo_device_t *device,
 	return;
     }
 
+    /* First reset all the RENDER flags to their original value. This works
+     * because we only ever clear bits after the connection was created.
+     */
+    connection->flags |= (connection->original_flags & CAIRO_XCB_RENDER_MASK);
+
     /* clear any flags that are inappropriate for the desired version */
     if (major_version < 0 && minor_version < 0) {
 	connection->flags &= ~(CAIRO_XCB_HAS_RENDER |
diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index f2e9516..2897b07 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -202,6 +202,7 @@ struct _cairo_xcb_connection {
 
     unsigned int maximum_request_length;
     unsigned int flags;
+    unsigned int original_flags;
 
     int force_precision;
 
@@ -237,7 +238,19 @@ enum {
     CAIRO_XCB_RENDER_HAS_EXTENDED_REPEAT	= 0x0100,
     CAIRO_XCB_RENDER_HAS_GRADIENTS		= 0x0200,
 
-    CAIRO_XCB_HAS_SHM				= 0x80000000
+    CAIRO_XCB_HAS_SHM				= 0x80000000,
+
+    CAIRO_XCB_RENDER_MASK = CAIRO_XCB_HAS_RENDER |
+			    CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES |
+			    CAIRO_XCB_RENDER_HAS_COMPOSITE |
+			    CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
+			    CAIRO_XCB_RENDER_HAS_COMPOSITE_GLYPHS |
+			    CAIRO_XCB_RENDER_HAS_PICTURE_TRANSFORM |
+			    CAIRO_XCB_RENDER_HAS_FILTERS |
+			    CAIRO_XCB_RENDER_HAS_PDF_OPERATORS |
+			    CAIRO_XCB_RENDER_HAS_EXTENDED_REPEAT |
+			    CAIRO_XCB_RENDER_HAS_GRADIENTS,
+    CAIRO_XCB_SHM_MASK    = CAIRO_XCB_HAS_SHM
 };
 
 #define CAIRO_XCB_SHM_SMALL_IMAGE 8192
commit 83df0ab2b6ccaf623303b606a99303b5d054b145
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Jul 21 15:28:18 2011 +0200

    XCB: Store the flags per-connection only
    
    Every xcb surface had its own copy of the flags from the time that it was
    created. This means that, if you want to make use of
    cairo_xcb_device_debug_cap_xrender_version() and
    cairo_xcb_device_debug_cap_xshm_version(), you first had to create a dummy xcb
    surface, use that to get access to the cairo_device_t so that you can use these
    functions and only then create your real surface, because the change only
    affected new surfaces.
    
    This commit changes everything to use the connection's flag and removes the
    per-surface flags. This avoids the dummy surfaces completely.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index b607a29..34a0b02 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -562,7 +562,7 @@ _cairo_boilerplate_xcb_create_render_0_0 (const char		    *name,
     xcb_render_pictforminfo_t *render_format;
     int depth;
     xcb_void_cookie_t cookie;
-    cairo_surface_t *surface, *tmp;
+    cairo_surface_t *surface;
     cairo_status_t status;
     void *formats;
 
@@ -621,27 +621,20 @@ _cairo_boilerplate_xcb_create_render_0_0 (const char		    *name,
 	return NULL;
     }
 
-    tmp = cairo_xcb_surface_create_with_xrender_format (c, root,
-							xtc->drawable,
-							render_format,
-							width, height);
-    if (cairo_surface_status (tmp)) {
+    surface = cairo_xcb_surface_create_with_xrender_format (c, root,
+							    xtc->drawable,
+							    render_format,
+							    width, height);
+    if (cairo_surface_status (surface)) {
 	free (formats);
 	xcb_disconnect (c);
 	free (xtc);
-	return tmp;
+	return surface;
     }
 
-    xtc->device = cairo_device_reference (cairo_surface_get_device (tmp));
+    xtc->device = cairo_device_reference (cairo_surface_get_device (surface));
     cairo_xcb_device_debug_cap_xrender_version (xtc->device, 0, 0);
 
-    /* recreate with impaired connection */
-    surface = cairo_xcb_surface_create_with_xrender_format (c, root,
-							    xtc->drawable,
-							    render_format,
-							    width, height);
-    cairo_surface_destroy (tmp);
-
     assert (cairo_surface_get_device (surface) == xtc->device);
 
     status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL);
@@ -669,7 +662,7 @@ _cairo_boilerplate_xcb_create_fallback (const char		  *name,
     xcb_connection_t *c;
     xcb_screen_t *s;
     xcb_void_cookie_t cookie;
-    cairo_surface_t *tmp, *surface;
+    cairo_surface_t *surface;
     cairo_status_t status;
     uint32_t values[] = { 1 };
 
@@ -714,24 +707,18 @@ _cairo_boilerplate_xcb_create_fallback (const char		  *name,
 	return NULL;
     }
 
-    tmp = cairo_xcb_surface_create (c,
-				    xtc->drawable,
-				    lookup_visual (s, s->root_visual),
-				    width, height);
-    if (cairo_surface_status (tmp)) {
+    surface = cairo_xcb_surface_create (c,
+					xtc->drawable,
+					lookup_visual (s, s->root_visual),
+					width, height);
+    if (cairo_surface_status (surface)) {
 	xcb_disconnect (c);
 	free (xtc);
-	return tmp;
+	return surface;
     }
 
-    cairo_xcb_device_debug_cap_xrender_version (cairo_surface_get_device (tmp),
+    cairo_xcb_device_debug_cap_xrender_version (cairo_surface_get_device (surface),
 						-1, -1);
-    /* recreate with impaired connection */
-    surface = cairo_xcb_surface_create (c,
-					xtc->drawable,
-					lookup_visual (s, s->root_visual),
-					width, height);
-    cairo_surface_destroy (tmp);
 
     xtc->device = cairo_device_reference (cairo_surface_get_device (surface));
     status = cairo_surface_set_user_data (surface, &xcb_closure_key, xtc, NULL);
diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index 1a81cef..f2e9516 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -96,7 +96,6 @@ struct _cairo_xcb_surface {
     int height;
     int depth;
 
-    unsigned int flags;
     xcb_render_picture_t picture;
     xcb_render_pictformat_t xrender_format;
     pixman_format_code_t pixman_format;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 6ebe134..faa91ce 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -599,7 +599,7 @@ _solid_picture (cairo_xcb_surface_t *target,
     if (unlikely (picture->base.status))
 	return picture;
 
-    if (target->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS) {
+    if (target->connection->flags & CAIRO_XCB_RENDER_HAS_GRADIENTS) {
 	_cairo_xcb_connection_render_create_solid_fill (target->connection,
 							picture->picture,
 							xcb_color);
@@ -615,7 +615,7 @@ _solid_picture (cairo_xcb_surface_t *target,
 						     xrender_format,
 						     XCB_RENDER_CP_REPEAT,
 						     values);
-	if (target->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
+	if (target->connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
 	    xcb_rectangle_t rect;
 
 	    rect.x = rect.y = 0;
@@ -1216,7 +1216,7 @@ _cairo_xcb_picture_for_pattern (cairo_xcb_surface_t *target,
     if (pattern == NULL)
 	return _cairo_xcb_white_picture (target);
 
-    if (! _pattern_is_supported (target->flags, pattern))
+    if (! _pattern_is_supported (target->connection->flags, pattern))
 	return _render_to_picture (target, pattern, extents);
 
     switch (pattern->type) {
@@ -1721,7 +1721,7 @@ _create_composite_mask (cairo_clip_t		*clip,
 	return (cairo_xcb_surface_t *) _cairo_surface_create_in_error (status);
     }
 
-    if (surface->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
+    if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
 	int i;
 
 	for (i = 0; i < clip->num_boxes; i++) {
@@ -1842,7 +1842,7 @@ _clip_and_composite_combine (cairo_clip_t		*clip,
     } else {
 	/* Initialize the temporary surface from the destination surface */
 	if (! dst->base.is_clear ||
-	    (dst->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) == 0)
+	    (dst->connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) == 0)
 	{
 	    /* XCopyArea may actually be quicker here.
 	     * A good driver should translate if appropriate.
@@ -2072,7 +2072,7 @@ _cairo_xcb_surface_fixup_unbounded (cairo_xcb_surface_t *dst,
 	}
     }
 
-    if (dst->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
+    if (dst->connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES) {
 	xcb_render_color_t color;
 
 	color.red   = 0;
@@ -2279,7 +2279,7 @@ _cairo_xcb_surface_clear (cairo_xcb_surface_t *dst)
     rect.width  = dst->width;
     rect.height = dst->height;
 
-    if (dst->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
+    if (dst->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
 	xcb_render_color_t color;
 	uint8_t op;
 
@@ -2494,7 +2494,7 @@ _composite_boxes (cairo_xcb_surface_t *dst,
 	return status;
 
     _cairo_xcb_surface_ensure_picture (dst);
-    if (dst->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES && ! need_clip_mask &&
+    if (dst->connection->flags & CAIRO_XCB_RENDER_HAS_FILL_RECTANGLES && ! need_clip_mask &&
 	(op == CAIRO_OPERATOR_CLEAR || src->type == CAIRO_PATTERN_TYPE_SOLID))
     {
 	const cairo_color_t *color;
@@ -2999,7 +2999,7 @@ _clip_and_composite_boxes (cairo_xcb_surface_t *dst,
 	    return status;
     }
 
-    if ((dst->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) == 0)
+    if ((dst->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) == 0)
 	return _core_boxes (dst, op, src, boxes, extents);
 
     /* Use a fast path if the boxes are pixel aligned */
@@ -3007,7 +3007,7 @@ _clip_and_composite_boxes (cairo_xcb_surface_t *dst,
     if (status != CAIRO_INT_STATUS_UNSUPPORTED)
 	return status;
 
-    if ((dst->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) == 0)
+    if ((dst->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) == 0)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     /* Otherwise render via a mask and composite in the usual fashion.  */
@@ -3353,11 +3353,11 @@ _cairo_xcb_surface_render_paint (cairo_xcb_surface_t	*surface,
     cairo_boxes_t boxes;
     cairo_status_t status;
 
-    if (unlikely (! _operator_is_supported (surface->flags, op)))
+    if (unlikely (! _operator_is_supported (surface->connection->flags, op)))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if ((surface->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
-			   CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
+    if ((surface->connection->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
+				       CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
     {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
@@ -3409,10 +3409,10 @@ _cairo_xcb_surface_render_mask (cairo_xcb_surface_t	*surface,
     cairo_composite_rectangles_t extents;
     cairo_status_t status;
 
-    if (unlikely (! _operator_is_supported (surface->flags, op)))
+    if (unlikely (! _operator_is_supported (surface->connection->flags, op)))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if ((surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) == 0)
+    if ((surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) == 0)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_composite_rectangles_init_for_mask (&extents,
@@ -3430,7 +3430,7 @@ _cairo_xcb_surface_render_mask (cairo_xcb_surface_t	*surface,
 				      &extents, need_unbounded_clip (&extents));
     } else {
 	xcb_draw_func_t mask_func = NULL;
-	if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS)
+	if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS)
 	    mask_func = extents.clip->path ? _composite_mask_clip : _composite_mask_clip_boxes;
 	status = _clip_and_composite (surface, op, source,
 				      _composite_mask, mask_func,
@@ -3553,10 +3553,10 @@ _cairo_xcb_surface_render_stroke (cairo_xcb_surface_t	*surface,
     cairo_composite_rectangles_t extents;
     cairo_int_status_t status;
 
-    if (unlikely (! _operator_is_supported (surface->flags, op)))
+    if (unlikely (! _operator_is_supported (surface->connection->flags, op)))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if ((surface->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
+    if ((surface->connection->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
 			   CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
     {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
@@ -3589,13 +3589,13 @@ _cairo_xcb_surface_render_stroke (cairo_xcb_surface_t	*surface,
     }
 
     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-	if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) {
+	if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) {
 	    status = _cairo_xcb_surface_render_stroke_as_polygon (surface, op, source,
 								  path, style,
 								  ctm, ctm_inverse,
 								  tolerance, antialias,
 								  &extents);
-	} else if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
+	} else if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
 	    status = _cairo_xcb_surface_render_stroke_via_mask (surface, op, source,
 								path, style,
 								ctm, ctm_inverse,
@@ -3704,11 +3704,11 @@ _cairo_xcb_surface_render_fill (cairo_xcb_surface_t	*surface,
     cairo_composite_rectangles_t extents;
     cairo_int_status_t status;
 
-    if (unlikely (! _operator_is_supported (surface->flags, op)))
+    if (unlikely (! _operator_is_supported (surface->connection->flags, op)))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if ((surface->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
-			   CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
+    if ((surface->connection->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS |
+				       CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
     {
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
@@ -3738,11 +3738,11 @@ _cairo_xcb_surface_render_fill (cairo_xcb_surface_t	*surface,
     }
 
     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-	if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) {
+	if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_TRAPEZOIDS) {
 	    status = _cairo_xcb_surface_render_fill_as_polygon (surface, op, source, path,
 								fill_rule, tolerance, antialias,
 								&extents);
-	} else if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
+	} else if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE) {
 	    status = _cairo_xcb_surface_render_fill_via_mask (surface, op, source, path,
 							      fill_rule, tolerance, antialias,
 							      &extents);
@@ -4691,10 +4691,10 @@ _cairo_xcb_surface_render_glyphs (cairo_xcb_surface_t	*surface,
     cairo_int_status_t status;
     cairo_bool_t overlap;
 
-    if (unlikely (! _operator_is_supported (surface->flags, op)))
+    if (unlikely (! _operator_is_supported (surface->connection->flags, op)))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
-    if ((surface->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_GLYPHS | CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
+    if ((surface->connection->flags & (CAIRO_XCB_RENDER_HAS_COMPOSITE_GLYPHS | CAIRO_XCB_RENDER_HAS_COMPOSITE)) == 0)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     status = _cairo_composite_rectangles_init_for_glyphs (&extents,
@@ -4708,7 +4708,7 @@ _cairo_xcb_surface_render_glyphs (cairo_xcb_surface_t	*surface,
 	return status;
 
     status = CAIRO_INT_STATUS_UNSUPPORTED;
-    if (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_GLYPHS) {
+    if (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE_GLYPHS) {
 	_cairo_scaled_font_freeze_cache (scaled_font);
 
 	if (_surface_owns_font (surface, scaled_font)) {
@@ -4736,7 +4736,7 @@ _cairo_xcb_surface_render_glyphs (cairo_xcb_surface_t	*surface,
     }
 
     if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
-	assert (surface->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE);
+	assert (surface->connection->flags & CAIRO_XCB_RENDER_HAS_COMPOSITE);
 	status =
 	    _cairo_xcb_surface_render_glyphs_via_mask (surface, op, source,
 						       scaled_font, glyphs, num_glyphs,
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 2014ae7..4fdc5b4 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -144,7 +144,7 @@ _cairo_xcb_surface_create_similar_image (cairo_xcb_surface_t *other,
     }
 
 #if CAIRO_HAS_XCB_SHM_FUNCTIONS
-    if (other->flags & CAIRO_XCB_HAS_SHM) {
+    if (other->connection->flags & CAIRO_XCB_HAS_SHM) {
 	cairo_status_t status;
 
 	status = _cairo_xcb_surface_create_similar_shm (other,
@@ -183,7 +183,7 @@ _cairo_xcb_surface_create_similar (void			*abstract_other,
 		 height <= 0))
 	return _cairo_xcb_surface_create_similar_image (other, content, width, height);
 
-    if ((other->flags & CAIRO_XCB_HAS_RENDER) == 0)
+    if ((other->connection->flags & CAIRO_XCB_HAS_RENDER) == 0)
 	return _cairo_xcb_surface_create_similar_image (other, content, width, height);
 
     connection = other->connection;
@@ -293,14 +293,14 @@ _cairo_xcb_surface_create_shm_image (cairo_xcb_surface_t *target,
     cairo_status_t status;
     size_t size, stride;
 
-    if ((target->flags & CAIRO_XCB_HAS_SHM) == 0)
+    if ((target->connection->flags & CAIRO_XCB_HAS_SHM) == 0)
 	return CAIRO_INT_STATUS_UNSUPPORTED;
 
     stride = CAIRO_STRIDE_FOR_WIDTH_BPP (target->width,
 					 PIXMAN_FORMAT_BPP (target->pixman_format));
     size = stride * target->height;
     if (size < CAIRO_XCB_SHM_SMALL_IMAGE) {
-	target->flags &= ~CAIRO_XCB_HAS_SHM;
+	target->connection->flags &= ~CAIRO_XCB_HAS_SHM;
 	return CAIRO_INT_STATUS_UNSUPPORTED;
     }
 
@@ -942,8 +942,6 @@ _cairo_xcb_surface_create_internal (cairo_xcb_screen_t		*screen,
     surface->pixman_format = pixman_format;
     surface->xrender_format = xrender_format;
 
-    surface->flags = screen->connection->flags;
-
     return &surface->base;
 }
 


More information about the cairo-commit mailing list