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.
This commit is contained in:
Chris Wilson 2010-01-25 16:45:03 +00:00
parent e1b3330376
commit 123bdb086a
12 changed files with 106 additions and 8 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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, [

View file

@ -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

View file

@ -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)

View file

@ -37,14 +37,20 @@
#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 <xcb/dri2.h>
#include <xcb/shm.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>
#endif
typedef struct _cairo_xcb_xrender_format {
cairo_hash_entry_t key;
xcb_render_pictformat_t xrender_format;
@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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