diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-10 13:36:53 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-10 13:36:53 +0100 |
commit | e540d040bddc717f17e0e2510cffc0bc3cb41ccd (patch) | |
tree | e5a76a9cd0c0f23d708cd6bd14136565bbbb13bf /src/cairo-xcb-connection.c | |
parent | 8b486db9a9d74b40df296382eb1833bc40ae791a (diff) | |
download | cairo-e540d040bddc717f17e0e2510cffc0bc3cb41ccd.tar.gz |
xcb: trivial memfault fixes.
The first fixes required to kick-start memfault testing of the xcb
backend.
Diffstat (limited to 'src/cairo-xcb-connection.c')
-rw-r--r-- | src/cairo-xcb-connection.c | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c index 25e821e0a..9da4eb3ee 100644 --- a/src/cairo-xcb-connection.c +++ b/src/cairo-xcb-connection.c @@ -594,6 +594,8 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection) const xcb_query_extension_reply_t *ext; cairo_status_t status; + CAIRO_MUTEX_INITIALIZE (); + CAIRO_MUTEX_LOCK (_cairo_xcb_connections_mutex); if (connections.next == NULL) { /* XXX _cairo_init () */ @@ -619,31 +621,29 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection) goto unlock; _cairo_device_init (&connection->device, &_cairo_xcb_device_backend); - CAIRO_MUTEX_INIT (connection->shm_mutex); - CAIRO_MUTEX_INIT (connection->screens_mutex); connection->xcb_connection = xcb_connection; connection->has_socket = FALSE; - xcb_prefetch_extension_data (xcb_connection, &xcb_big_requests_id); - xcb_prefetch_extension_data (xcb_connection, &xcb_render_id); -#if CAIRO_HAS_XCB_SHM_FUNCTIONS - xcb_prefetch_extension_data (xcb_connection, &xcb_shm_id); -#endif -#if 0 - xcb_prefetch_extension_data (xcb_connection, &xcb_cairo_id); -#endif -#if CAIRO_HAS_XCB_DRM_FUNCTIONS - xcb_prefetch_extension_data (xcb_connection, &xcb_dri2_id); -#endif - - xcb_prefetch_maximum_request_length (xcb_connection); - cairo_list_init (&connection->fonts); cairo_list_init (&connection->screens); - cairo_list_add (&connection->link, &connections); + cairo_list_init (&connection->link); connection->xrender_formats = _cairo_hash_table_create (_xrender_formats_equal); + if (connection->xrender_formats == NULL) { + CAIRO_MUTEX_FINI (connection->device.mutex); + free (connection); + connection = NULL; + goto unlock; + } + connection->visual_to_xrender_format = _cairo_hash_table_create (_xrender_formats_equal); + if (connection->visual_to_xrender_format == NULL) { + _cairo_hash_table_destroy (connection->xrender_formats); + CAIRO_MUTEX_FINI (connection->device.mutex); + free (connection); + connection = NULL; + goto unlock; + } cairo_list_init (&connection->free_xids); _cairo_freepool_init (&connection->xid_pool, @@ -656,14 +656,34 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection) connection->maximum_request_length = xcb_get_maximum_request_length (xcb_connection); + CAIRO_MUTEX_INIT (connection->shm_mutex); + CAIRO_MUTEX_INIT (connection->screens_mutex); + + CAIRO_MUTEX_LOCK (connection->device.mutex); + connection->flags = 0; + xcb_prefetch_extension_data (xcb_connection, &xcb_big_requests_id); + xcb_prefetch_extension_data (xcb_connection, &xcb_render_id); +#if CAIRO_HAS_XCB_SHM_FUNCTIONS + xcb_prefetch_extension_data (xcb_connection, &xcb_shm_id); +#endif +#if 0 + xcb_prefetch_extension_data (xcb_connection, &xcb_cairo_id); +#endif +#if CAIRO_HAS_XCB_DRM_FUNCTIONS + xcb_prefetch_extension_data (xcb_connection, &xcb_dri2_id); +#endif + + xcb_prefetch_maximum_request_length (xcb_connection); + connection->root = xcb_get_setup (xcb_connection); connection->render = NULL; ext = xcb_get_extension_data (xcb_connection, &xcb_render_id); if (ext != NULL && ext->present) { status = _cairo_xcb_connection_query_render (connection); if (unlikely (status)) { + CAIRO_MUTEX_UNLOCK (connection->device.mutex); _cairo_xcb_connection_destroy (connection); connection = NULL; goto unlock; @@ -696,6 +716,9 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection) } #endif + CAIRO_MUTEX_UNLOCK (connection->device.mutex); + + cairo_list_add (&connection->link, &connections); unlock: CAIRO_MUTEX_UNLOCK (_cairo_xcb_connections_mutex); |