[cairo-commit] boilerplate/Makefile.win32.features build/configure.ac.features build/Makefile.win32.features build/Makefile.win32.features-h configure.ac src/cairo-xcb-connection.c src/cairo-xcb-private.h src/cairo-xcb-surface.c src/cairo-xcb-surface-core.c src/cairo-xcb-surface-render.c src/Makefile.sources src/Makefile.win32.features

Chris Wilson ickle at kemper.freedesktop.org
Mon Jan 25 08:46:19 PST 2010


 boilerplate/Makefile.win32.features |   10 ++++++++++
 build/Makefile.win32.features       |    1 +
 build/Makefile.win32.features-h     |    3 +++
 build/configure.ac.features         |    1 +
 configure.ac                        |   14 +++++++++++++-
 src/Makefile.sources                |    8 ++++++--
 src/Makefile.win32.features         |   14 ++++++++++++++
 src/cairo-xcb-connection.c          |   22 ++++++++++++++++++----
 src/cairo-xcb-private.h             |   21 +++++++++++++++++++++
 src/cairo-xcb-surface-core.c        |    2 ++
 src/cairo-xcb-surface-render.c      |    2 ++
 src/cairo-xcb-surface.c             |   14 ++++++++++++++
 12 files changed, 105 insertions(+), 7 deletions(-)

New commits:
commit 123bdb086ad9c5725a51791458d31309c69a3f41
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jan 25 16:45:03 2010 +0000

    xcb: Make shm optional
    
    Trying to build xcb on a system without SHM wrapped by xcb. The right
    answer would be to build libxcb-shm. The quick answer is to compile out
    shm support.

diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index 8d56411..0742787 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -59,6 +59,16 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_xlib_xcb_private)
 enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xlib_xcb_sources)
 endif
 
+supported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
+all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
+all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private)
+all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources)
+ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
+enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_shm_headers)
+enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_shm_private)
+enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_shm_sources)
+endif
+
 unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers)
 all_cairo_boilerplate_headers += $(cairo_boilerplate_qt_headers)
 all_cairo_boilerplate_private += $(cairo_boilerplate_qt_private)
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features
index b8c40a8..66938fc 100644
--- a/build/Makefile.win32.features
+++ b/build/Makefile.win32.features
@@ -4,6 +4,7 @@ CAIRO_HAS_XLIB_SURFACE=0
 CAIRO_HAS_XLIB_XRENDER_SURFACE=0
 CAIRO_HAS_XCB_SURFACE=0
 CAIRO_HAS_XLIB_XCB_FUNCTIONS=0
+CAIRO_HAS_XCB_SHM_FUNCTIONS=0
 CAIRO_HAS_QT_SURFACE=0
 CAIRO_HAS_QUARTZ_SURFACE=0
 CAIRO_HAS_QUARTZ_FONT=0
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index 95e9386..ca21aba 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -17,6 +17,9 @@ endif
 ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1)
 	@echo "#define CAIRO_HAS_XLIB_XCB_FUNCTIONS 1" >> src/cairo-features.h
 endif
+ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
+	@echo "#define CAIRO_HAS_XCB_SHM_FUNCTIONS 1" >> src/cairo-features.h
+endif
 ifeq ($(CAIRO_HAS_QT_SURFACE),1)
 	@echo "#define CAIRO_HAS_QT_SURFACE 1" >> src/cairo-features.h
 endif
diff --git a/build/configure.ac.features b/build/configure.ac.features
index c55b4ef..8c96ed0 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -395,6 +395,7 @@ AC_DEFUN([CAIRO_REPORT],
 	echo "  Eagle functions: $use_eagle"
 	echo "  X11-xcb functions: $use_xlib_xcb"
 	echo "  XCB-drm functions: $use_xcb_drm"
+	echo "  XCB-shm functions: $use_xcb_shm"
 	echo ""
 	echo "The following features and utilies:"
 	echo "  cairo-trace:                $use_trace"
diff --git a/configure.ac b/configure.ac
index 30d3e98..b4f5aa7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,7 @@ CAIRO_ENABLE_SURFACE_BACKEND(xlib_xrender, Xlib Xrender, auto, [
 dnl ===========================================================================
 
 CAIRO_ENABLE_SURFACE_BACKEND(xcb, XCB, no, [
-  xcb_REQUIRES="xcb >= 0.9.92 xcb-render >= 0.9.92 xcb-shm"
+  xcb_REQUIRES="xcb >= 0.9.92 xcb-render >= 0.9.92"
   PKG_CHECK_MODULES(xcb, $xcb_REQUIRES, ,
 		    [AC_MSG_RESULT(no)
 		    use_xcb="no (requires $xcb_REQUIRES http://xcb.freedesktop.org)"])
@@ -126,6 +126,18 @@ CAIRO_ENABLE_FUNCTIONS(xlib_xcb, Xlib/XCB, no, [
 ])
 AM_CONDITIONAL(BUILD_XLIB_XCB, test "x$use_xlib_xcb" = "xyes")
 
+CAIRO_ENABLE_FUNCTIONS(xcb_shm, XCB/SHM, auto, [
+  if test "x$use_xcb" == "xyes"; then
+      xcb_shm_REQUIRES="xcb-shm"
+      PKG_CHECK_MODULES(xcb_shm, $xcb_shm_REQUIRES, ,
+			[AC_MSG_RESULT(no)
+			use_xcb_shm="no (requires $xcb_shm http://xcb.freedesktop.org)"])
+  else
+    use_xcb_drm="no (requires both --enable-xcb)"
+  fi
+])
+AM_CONDITIONAL(BUILD_XCB_SHM, test "x$use_xcb_shm" = "xyes")
+
 dnl ===========================================================================
 
 CAIRO_ENABLE_SURFACE_BACKEND(qt, Qt, no, [
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 0f77f0e..a7f5839 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -269,14 +269,18 @@ cairo_xcb_sources = \
 		    cairo-xcb-connection.c \
 		    cairo-xcb-connection-core.c \
 		    cairo-xcb-connection-render.c \
-		    cairo-xcb-connection-shm.c \
 		    cairo-xcb-screen.c \
-		    cairo-xcb-shm.c \
 		    cairo-xcb-surface.c \
 		    cairo-xcb-surface-cairo.c \
 		    cairo-xcb-surface-core.c \
 		    cairo-xcb-surface-render.c \
 		    $(NULL)
+if BUILD_XCB_SHM
+cairo_xcb_sources += \
+		    cairo-xcb-shm.c \
+		    cairo-xcb-connection-shm.c \
+		    $(NULL)
+endif
 
 cairo_qt_headers = cairo-qt.h
 cairo_qt_sources = cairo-qt-surface.cpp
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index 3575057..daf88a7 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -77,6 +77,20 @@ ifeq ($(CAIRO_HAS_XLIB_XCB_FUNCTIONS),1)
 enabled_cairo_pkgconf += cairo-xlib-xcb.pc
 endif
 
+supported_cairo_headers += $(cairo_xcb_shm_headers)
+all_cairo_headers += $(cairo_xcb_shm_headers)
+all_cairo_private += $(cairo_xcb_shm_private)
+all_cairo_sources += $(cairo_xcb_shm_sources)
+ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
+enabled_cairo_headers += $(cairo_xcb_shm_headers)
+enabled_cairo_private += $(cairo_xcb_shm_private)
+enabled_cairo_sources += $(cairo_xcb_shm_sources)
+endif
+all_cairo_pkgconf += cairo-xcb-shm.pc
+ifeq ($(CAIRO_HAS_XCB_SHM_FUNCTIONS),1)
+enabled_cairo_pkgconf += cairo-xcb-shm.pc
+endif
+
 unsupported_cairo_headers += $(cairo_qt_headers)
 all_cairo_headers += $(cairo_qt_headers)
 all_cairo_private += $(cairo_qt_private)
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index e2293a6..18ccd4a 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -37,13 +37,19 @@
 #include "cairo-freelist-private.h"
 #include "cairo-list-private.h"
 
-#include <sys/ipc.h>
-#include <sys/shm.h>
 #include <xcb/xcbext.h>
 #include <xcb/bigreq.h>
+#include <errno.h>
+
+#if CAIRO_HAS_XCB_DRM_FUNCTIONS
 #include <xcb/dri2.h>
+#endif
+
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
+#include <sys/ipc.h>
+#include <sys/shm.h>
 #include <xcb/shm.h>
-#include <errno.h>
+#endif
 
 typedef struct _cairo_xcb_xrender_format {
     cairo_hash_entry_t key;
@@ -383,6 +389,7 @@ _cairo_xcb_connection_query_cairo (cairo_xcb_connection_t *connection)
 }
 #endif
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
 static cairo_bool_t
 can_use_shm (cairo_xcb_connection_t *connection)
 {
@@ -438,6 +445,7 @@ _cairo_xcb_connection_query_shm (cairo_xcb_connection_t *connection)
     if (can_use_shm (connection))
 	connection->flags |= CAIRO_XCB_HAS_SHM;
 }
+#endif
 
 #if CAIRO_HAS_XCB_DRM_FUNCTIONS
 static void
@@ -544,7 +552,9 @@ _device_destroy (void *device)
 			       connection->visual_to_xrender_format);
     _cairo_hash_table_destroy (connection->visual_to_xrender_format);
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     _cairo_xcb_connection_shm_mem_pools_fini (connection);
+#endif
     _cairo_freepool_fini (&connection->shm_info_freelist);
 
     _cairo_freepool_fini (&connection->xid_pool);
@@ -604,8 +614,10 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
     connection->has_socket = FALSE;
 
     xcb_prefetch_extension_data (xcb_connection, &xcb_big_requests_id);
-    xcb_prefetch_extension_data (xcb_connection, &xcb_shm_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
@@ -655,11 +667,13 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
 #endif
 
     connection->shm = NULL;
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     ext = xcb_get_extension_data (xcb_connection, &xcb_shm_id);
     if (ext != NULL && ext->present) {
 	_cairo_xcb_connection_query_shm (connection);
 	connection->shm = ext;
     }
+#endif
 
     connection->dri2 = NULL;
 #if CAIRO_HAS_XCB_DRM_FUNCTIONS
diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index 18a485c..f6b8c05 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -541,6 +541,7 @@ _cairo_xcb_connection_poly_fill_rectangle (cairo_xcb_connection_t *connection,
 					   uint32_t num_rectangles,
 					   xcb_rectangle_t *rectangles);
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
 cairo_private uint32_t
 _cairo_xcb_connection_shm_attach (cairo_xcb_connection_t *connection,
 				  uint32_t id,
@@ -575,6 +576,26 @@ _cairo_xcb_connection_shm_get_image (cairo_xcb_connection_t *connection,
 cairo_private void
 _cairo_xcb_connection_shm_detach (cairo_xcb_connection_t *connection,
 				  uint32_t segment);
+#else
+static inline uint64_t
+_cairo_xcb_connection_shm_put_image (cairo_xcb_connection_t *connection,
+				     xcb_drawable_t dst,
+				     xcb_gcontext_t gc,
+				     uint16_t total_width,
+				     uint16_t total_height,
+				     int16_t src_x,
+				     int16_t src_y,
+				     uint16_t width,
+				     uint16_t height,
+				     int16_t dst_x,
+				     int16_t dst_y,
+				     uint8_t depth,
+				     uint32_t shm,
+				     uint32_t offset)
+{
+    return 0;
+}
+#endif
 
 cairo_private void
 _cairo_xcb_connection_render_spans (cairo_xcb_connection_t *connection,
diff --git a/src/cairo-xcb-surface-core.c b/src/cairo-xcb-surface-core.c
index 6f1002a..2788bdf 100644
--- a/src/cairo-xcb-surface-core.c
+++ b/src/cairo-xcb-surface-core.c
@@ -153,6 +153,7 @@ _cairo_xcb_shm_image_create (cairo_xcb_connection_t *connection,
     cairo_xcb_shm_info_t *shm_info = NULL;
     cairo_status_t status;
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     if ((connection->flags & CAIRO_XCB_HAS_SHM)) {
 	size_t size, stride;
 
@@ -185,6 +186,7 @@ _cairo_xcb_shm_image_create (cairo_xcb_connection_t *connection,
 	    }
 	}
     }
+#endif
 
     if (image == NULL) {
 	image = _cairo_image_surface_create_with_pixman_format (NULL,
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index e07f575..5d19792 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -776,6 +776,7 @@ _cairo_xcb_shm_image_create (cairo_xcb_connection_t *connection,
     cairo_xcb_shm_info_t *shm_info = NULL;
     cairo_status_t status;
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     if ((connection->flags & CAIRO_XCB_HAS_SHM)) {
 	size_t size, stride;
 
@@ -808,6 +809,7 @@ _cairo_xcb_shm_image_create (cairo_xcb_connection_t *connection,
 	    }
 	}
     }
+#endif
 
     if (image == NULL) {
 	image = _cairo_image_surface_create_with_pixman_format (NULL,
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 2e08c64..c61ddb3 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -59,6 +59,7 @@ slim_hidden_proto (cairo_xcb_surface_create_with_xrender_format);
 #include "drm/cairo-drm-private.h"
 #endif
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
 static cairo_status_t
 _cairo_xcb_surface_create_similar_shm (cairo_xcb_surface_t *other,
 				       pixman_format_code_t pixman_format,
@@ -103,6 +104,7 @@ _cairo_xcb_surface_create_similar_shm (cairo_xcb_surface_t *other,
     *out = image;
     return CAIRO_STATUS_SUCCESS;
 }
+#endif
 
 cairo_surface_t *
 _cairo_xcb_surface_create_similar_image (cairo_xcb_surface_t *other,
@@ -127,6 +129,7 @@ _cairo_xcb_surface_create_similar_image (cairo_xcb_surface_t *other,
 	break;
     }
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     if (other->flags & CAIRO_XCB_HAS_SHM) {
 	cairo_status_t status;
 
@@ -137,6 +140,7 @@ _cairo_xcb_surface_create_similar_image (cairo_xcb_surface_t *other,
 	if (_cairo_status_is_error (status))
 	    return _cairo_surface_create_in_error (status);
     }
+#endif
 
     if (image == NULL) {
 	image = _cairo_image_surface_create_with_pixman_format (NULL,
@@ -288,6 +292,7 @@ _destroy_image (pixman_image_t *image, void *data)
     free (data);
 }
 
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
 static cairo_int_status_t
 _cairo_xcb_surface_create_shm_image (cairo_xcb_surface_t *target,
 				     cairo_image_surface_t **image_out,
@@ -340,11 +345,13 @@ _cairo_xcb_surface_create_shm_image (cairo_xcb_surface_t *target,
     *shm_info_out = shm_info;
     return CAIRO_STATUS_SUCCESS;
 }
+#endif
 
 static cairo_status_t
 _get_shm_image (cairo_xcb_surface_t     *surface,
 		cairo_image_surface_t  **image_out)
 {
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     cairo_image_surface_t *image;
     cairo_xcb_shm_info_t *shm_info;
     cairo_status_t status;
@@ -369,6 +376,9 @@ _get_shm_image (cairo_xcb_surface_t     *surface,
 
     *image_out = image;
     return CAIRO_STATUS_SUCCESS;
+#else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+#endif
 }
 
 static cairo_status_t
@@ -588,6 +598,7 @@ _put_shm_image (cairo_xcb_surface_t    *surface,
 		xcb_gcontext_t		gc,
 		cairo_image_surface_t  *image)
 {
+#if CAIRO_HAS_XCB_SHM_FUNCTIONS
     cairo_xcb_shm_info_t *shm_info;
 
     shm_info = _cairo_user_data_array_get_data (&image->base.user_data,
@@ -608,6 +619,9 @@ _put_shm_image (cairo_xcb_surface_t    *surface,
 					     shm_info->offset);
 
     return CAIRO_STATUS_SUCCESS;
+#else
+    return CAIRO_INT_STATUS_UNSUPPORTED;
+#endif
 }
 
 static cairo_status_t


More information about the cairo-commit mailing list