[cairo-commit] 2 commits - boilerplate/Makefile.win32.features build/configure.ac.features build/Makefile.win32.features build/Makefile.win32.features-h configure.ac src/cairo-drm-xr.h src/cairo-xcb-connection.c src/cairo-xcb-private.h src/cairo-xcb-screen.c src/cairo-xcb-surface.c src/cairo-xcb-surface-render.c src/drm src/Makefile.sources src/Makefile.win32.features

Chris Wilson ickle at kemper.freedesktop.org
Thu Jul 14 04:49:48 PDT 2011


 boilerplate/Makefile.win32.features |   24 
 build/Makefile.win32.features       |    2 
 build/Makefile.win32.features-h     |    6 
 build/configure.ac.features         |    2 
 configure.ac                        |   24 
 src/Makefile.sources                |    5 
 src/Makefile.win32.features         |   32 
 src/cairo-drm-xr.h                  |   66 
 src/cairo-xcb-connection.c          |   47 
 src/cairo-xcb-private.h             |    2 
 src/cairo-xcb-screen.c              |   88 -
 src/cairo-xcb-surface-render.c      |   73 -
 src/cairo-xcb-surface.c             |  104 -
 src/drm/cairo-drm-i915-shader.c     |   24 
 src/drm/cairo-drm-i965-shader.c     |   24 
 src/drm/cairo-drm-xr.c              | 2378 ------------------------------------
 16 files changed, 2901 deletions(-)

New commits:
commit 507b8abcf6326bbbe8c188016043b21438256b71
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 14 12:46:26 2011 +0100

    Excise xcb-drm
    
    The experiment was at best a pyrrhic victory. Whilst it did show that
    you could successfully subvert cairo_xcb_surface_t and provide the
    rendering locally faster (than the xlib driver at that time), any
    performance benefits were lost in the synchronisation overheads and
    server-side buffer allocation.
    
    Once cairo-gl is mature, we need to look at how we can overcome these to
    improve client-side rendering
    
    In the meantime, cairo-xcb is no longer my playground for
    experimentation and is shaping up to become a stable backend...
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index 14263a8..0cf7095 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -211,18 +211,6 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_gallium_cxx_sources
 enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources)
 endif
 
-unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_drm_headers)
-all_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_drm_headers)
-all_cairo_boilerplate_private += $(cairo_boilerplate_xcb_drm_private)
-all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_drm_cxx_sources)
-all_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_drm_sources)
-ifeq ($(CAIRO_HAS_XCB_DRM_FUNCTIONS),1)
-enabled_cairo_boilerplate_headers += $(cairo_boilerplate_xcb_drm_headers)
-enabled_cairo_boilerplate_private += $(cairo_boilerplate_xcb_drm_private)
-enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_xcb_drm_cxx_sources)
-enabled_cairo_boilerplate_sources += $(cairo_boilerplate_xcb_drm_sources)
-endif
-
 supported_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
 all_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
 all_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
diff --git a/build/Makefile.win32.features b/build/Makefile.win32.features
index 0d0261d..5d75ba3 100644
--- a/build/Makefile.win32.features
+++ b/build/Makefile.win32.features
@@ -15,9 +15,7 @@ CAIRO_HAS_SKIA_SURFACE=0
 CAIRO_HAS_OS2_SURFACE=0
 CAIRO_HAS_BEOS_SURFACE=0
 CAIRO_HAS_DRM_SURFACE=0
-CAIRO_HAS_DRM_XR_FUNCTIONS=0
 CAIRO_HAS_GALLIUM_SURFACE=0
-CAIRO_HAS_XCB_DRM_FUNCTIONS=0
 CAIRO_HAS_PNG_FUNCTIONS=1
 CAIRO_HAS_GL_SURFACE=0
 CAIRO_HAS_GLESV2_SURFACE=0
diff --git a/build/Makefile.win32.features-h b/build/Makefile.win32.features-h
index c1883b9..e35cc6c 100644
--- a/build/Makefile.win32.features-h
+++ b/build/Makefile.win32.features-h
@@ -50,15 +50,9 @@ endif
 ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
 	@echo "#define CAIRO_HAS_DRM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
-ifeq ($(CAIRO_HAS_DRM_XR_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_DRM_XR_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
-endif
 ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
 	@echo "#define CAIRO_HAS_GALLIUM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
 endif
-ifeq ($(CAIRO_HAS_XCB_DRM_FUNCTIONS),1)
-	@echo "#define CAIRO_HAS_XCB_DRM_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
-endif
 ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
 	@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
 endif
diff --git a/build/configure.ac.features b/build/configure.ac.features
index 352003b..4cccd9c 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -400,7 +400,6 @@ AC_DEFUN([CAIRO_REPORT],
 	echo "  WGL functions:   $use_wgl"
 	echo "  EGL functions:   $use_egl"
 	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 utilities:"
diff --git a/configure.ac b/configure.ac
index 6096007..9748f08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,17 +259,6 @@ CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
   fi
 ])
 
-CAIRO_ENABLE_FUNCTIONS(xcb_drm, XCB/DRM, no, [
-  if test "x$use_xcb" = "xyes" -a "x$use_drm" = "xyes"; then
-      xcb_drm_REQUIRES="xcb-dri2"
-      PKG_CHECK_MODULES(xcb_drm, $xcb_drm_REQUIRES, ,
-			[AC_MSG_RESULT(no)
-			use_xcb_drm="no (requires $xcb_drm_REQUIRES http://xcb.freedesktop.org)"])
-  else
-    use_xcb_drm="no (requires both --enable-xcb and --enable-drm)"
-  fi
-])
-
 dnl ===========================================================================
 
 CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index d36bacf..640df73 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -277,22 +277,6 @@ ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
 enabled_cairo_pkgconf += cairo-gallium.pc
 endif
 
-unsupported_cairo_headers += $(cairo_xcb_drm_headers)
-all_cairo_headers += $(cairo_xcb_drm_headers)
-all_cairo_private += $(cairo_xcb_drm_private)
-all_cairo_cxx_sources += $(cairo_xcb_drm_cxx_sources)
-all_cairo_sources += $(cairo_xcb_drm_sources)
-ifeq ($(CAIRO_HAS_XCB_DRM_FUNCTIONS),1)
-enabled_cairo_headers += $(cairo_xcb_drm_headers)
-enabled_cairo_private += $(cairo_xcb_drm_private)
-enabled_cairo_cxx_sources += $(cairo_xcb_drm_cxx_sources)
-enabled_cairo_sources += $(cairo_xcb_drm_sources)
-endif
-all_cairo_pkgconf += cairo-xcb-drm.pc
-ifeq ($(CAIRO_HAS_XCB_DRM_FUNCTIONS),1)
-enabled_cairo_pkgconf += cairo-xcb-drm.pc
-endif
-
 supported_cairo_headers += $(cairo_png_headers)
 all_cairo_headers += $(cairo_png_headers)
 all_cairo_private += $(cairo_png_private)
diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index de1bb17..19d5462 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -41,10 +41,6 @@
 #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>
@@ -446,32 +442,10 @@ _cairo_xcb_connection_query_shm (cairo_xcb_connection_t *connection)
 }
 #endif
 
-#if CAIRO_HAS_XCB_DRM_FUNCTIONS
-static void
-_cairo_xcb_connection_query_dri2 (cairo_xcb_connection_t *connection)
-{
-    xcb_connection_t *c = connection->xcb_connection;
-    xcb_dri2_query_version_reply_t *version;
-
-    version = xcb_dri2_query_version_reply (c,
-					    xcb_dri2_query_version (c,
-								    XCB_DRI2_MAJOR_VERSION,
-								    XCB_DRI2_MINOR_VERSION),
-					    0);
-    if (version == NULL)
-	return;
-
-    free (version);
-
-    connection->flags |= CAIRO_XCB_HAS_DRI2;
-}
-#endif
-
 static cairo_status_t
 _device_flush (void *device)
 {
     cairo_xcb_connection_t *connection = device;
-    cairo_xcb_screen_t *screen;
     cairo_status_t status;
 
     status = cairo_device_acquire (&connection->device);
@@ -482,15 +456,6 @@ _device_flush (void *device)
     _cairo_xcb_connection_shm_mem_pools_flush (connection);
 #endif
 
-    CAIRO_MUTEX_LOCK (connection->screens_mutex);
-    cairo_list_foreach_entry (screen, cairo_xcb_screen_t,
-			      &connection->screens, link)
-    {
-	if (screen->device != NULL)
-	    cairo_device_flush (screen->device);
-    }
-    CAIRO_MUTEX_UNLOCK (connection->screens_mutex);
-
     xcb_flush (connection->xcb_connection);
 
     cairo_device_release (&connection->device);
@@ -675,9 +640,6 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
 #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);
 
@@ -711,15 +673,6 @@ _cairo_xcb_connection_get (xcb_connection_t *xcb_connection)
     }
 #endif
 
-    connection->dri2 = NULL;
-#if CAIRO_HAS_XCB_DRM_FUNCTIONS
-    ext = xcb_get_extension_data (xcb_connection, &xcb_dri2_id);
-    if (ext != NULL && ext->present) {
-	_cairo_xcb_connection_query_dri2 (connection);
-	connection->dri2 = ext;
-    }
-#endif
-
     CAIRO_MUTEX_UNLOCK (connection->device.mutex);
 
     cairo_list_add (&connection->link, &connections);
diff --git a/src/cairo-xcb-private.h b/src/cairo-xcb-private.h
index 3f085e0..ec6aeb5 100644
--- a/src/cairo-xcb-private.h
+++ b/src/cairo-xcb-private.h
@@ -173,7 +173,6 @@ struct _cairo_xcb_screen {
     cairo_xcb_connection_t *connection;
 
     xcb_screen_t	    *xcb_screen;
-    cairo_device_t	    *device;
 
     xcb_gcontext_t gc[4];
     int gc_depths; /* 4 x uint8_t */
@@ -211,7 +210,6 @@ struct _cairo_xcb_connection {
     const xcb_setup_t *root;
     const xcb_query_extension_reply_t *render;
     const xcb_query_extension_reply_t *shm;
-    const xcb_query_extension_reply_t *dri2;
 
     cairo_list_t free_xids;
     cairo_freepool_t xid_pool;
diff --git a/src/cairo-xcb-screen.c b/src/cairo-xcb-screen.c
index efe42cf..2097475 100644
--- a/src/cairo-xcb-screen.c
+++ b/src/cairo-xcb-screen.c
@@ -84,9 +84,6 @@ _cairo_xcb_screen_finish (cairo_xcb_screen_t *screen)
     _cairo_cache_fini (&screen->radial_pattern_cache);
     _cairo_freelist_fini (&screen->pattern_cache_entry_freelist);
 
-    cairo_device_finish (screen->device);
-    cairo_device_destroy (screen->device);
-
     free (screen);
 }
 
@@ -124,85 +121,6 @@ _pattern_cache_entry_destroy (void *closure)
     _cairo_freelist_free (&entry->screen->pattern_cache_entry_freelist, entry);
 }
 
-#if CAIRO_HAS_DRM_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-#include "drm/cairo-drm-private.h"
-
-#include <drm/drm.h>
-#include <sys/ioctl.h>
-#include <xcb/dri2.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-static int drm_magic (int fd, uint32_t *magic)
-{
-    drm_auth_t auth;
-
-    if (ioctl (fd, DRM_IOCTL_GET_MAGIC, &auth))
-	return -errno;
-
-    *magic = auth.magic;
-    return 0;
-}
-
-static cairo_device_t *
-_xcb_drm_device (xcb_connection_t	*xcb_connection,
-		 xcb_screen_t		*xcb_screen)
-{
-    cairo_device_t *device = NULL;
-    xcb_dri2_connect_reply_t *connect;
-    drm_magic_t magic;
-    int fd;
-
-    connect = xcb_dri2_connect_reply (xcb_connection,
-				      xcb_dri2_connect (xcb_connection,
-							xcb_screen->root,
-							0),
-				      0);
-    if (connect == NULL)
-	return NULL;
-
-    fd = open (xcb_dri2_connect_device_name (connect), O_RDWR);
-    free (connect);
-
-    if (fd < 0)
-	return NULL;
-
-    device = cairo_drm_device_get_for_fd (fd);
-    close (fd);
-
-    if (device != NULL) {
-	xcb_dri2_authenticate_reply_t *authenticate;
-
-	if (drm_magic (((cairo_drm_device_t *) device)->fd, &magic) < 0) {
-	    cairo_device_destroy (device);
-	    return NULL;
-	}
-
-	authenticate = xcb_dri2_authenticate_reply (xcb_connection,
-						    xcb_dri2_authenticate (xcb_connection,
-									   xcb_screen->root,
-									   magic),
-						    0);
-	if (authenticate == NULL) {
-	    cairo_device_destroy (device);
-	    return NULL;
-	}
-
-	free (authenticate);
-    }
-
-    return device;
-}
-#else
-static cairo_device_t *
-_xcb_drm_device (xcb_connection_t	*xcb_connection,
-		 xcb_screen_t		*xcb_screen)
-{
-    return NULL;
-}
-#endif
-
 cairo_xcb_screen_t *
 _cairo_xcb_screen_get (xcb_connection_t *xcb_connection,
 		       xcb_screen_t *xcb_screen)
@@ -245,11 +163,6 @@ _cairo_xcb_screen_get (xcb_connection_t *xcb_connection,
     cairo_list_init (&screen->surfaces);
     cairo_list_init (&screen->pictures);
 
-    if (connection->flags & CAIRO_XCB_HAS_DRI2)
-	screen->device = _xcb_drm_device (xcb_connection, xcb_screen);
-    else
-	screen->device = NULL;
-
     screen->gc_depths = 0;
     memset (screen->gc, 0, sizeof (screen->gc));
 
@@ -284,7 +197,6 @@ error_linear:
     _cairo_cache_fini (&screen->linear_pattern_cache);
 error_screen:
     CAIRO_MUTEX_UNLOCK (connection->screens_mutex);
-    cairo_device_destroy (screen->device);
     free (screen);
 
     return NULL;
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 4f4b1dc..5a0bb22 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -40,10 +40,6 @@
 #include "cairo-surface-subsurface-private.h"
 #include "cairo-xcb-private.h"
 
-#if CAIRO_HAS_XCB_DRM_FUNCTIONS && CAIRO_HAS_DRM_SURFACE
-#include "drm/cairo-drm-private.h"
-#endif
-
 #define PIXMAN_MAX_INT ((pixman_fixed_1 >> 1) - pixman_fixed_e) /* need to ensure deltas also fit */
 
 /**
@@ -1117,75 +1113,6 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 	}
     }
 #endif
-#if CAIRO_HAS_XCB_DRM_FUNCTIONS && CAIRO_HAS_DRM_SURFACE
-    else if (source->type == CAIRO_SURFACE_TYPE_DRM &&
-	     target->drm != NULL &&
-	     target->drm->device == source->device)
-    {
-	cairo_drm_surface_t *drm = (cairo_drm_surface_t *) source;
-	cairo_xcb_surface_t *tmp;
-	xcb_pixmap_t pixmap;
-	pixman_format_code_t pixman_format;
-	cairo_surface_pattern_t pattern;
-	cairo_status_t status;
-
-	/* XXX XRenderCreatePictureForNative:
-	 * Copy the source to a temporary pixmap if possible.
-	 * Still cheaper than pushing the image via the CPU.
-	 */
-
-	switch (drm->format) {
-	case CAIRO_FORMAT_A1:
-	    pixman_format = PIXMAN_a1;
-	    break;
-	case CAIRO_FORMAT_A8:
-	    pixman_format = PIXMAN_a8;
-	    break;
-	case CAIRO_FORMAT_RGB24:
-	    pixman_format = PIXMAN_x8r8g8b8;
-	    break;
-	default:
-	case CAIRO_FORMAT_ARGB32:
-	    pixman_format = PIXMAN_a8r8g8b8;
-	    break;
-	}
-
-	pixmap =
-	    _cairo_xcb_connection_create_pixmap (target->connection,
-						 PIXMAN_FORMAT_DEPTH (pixman_format),
-						 target->drawable,
-						 drm->width, drm->height);
-
-	tmp = (cairo_xcb_surface_t *)
-	    _cairo_xcb_surface_create_internal (target->screen,
-						pixmap, TRUE,
-						pixman_format,
-						target->connection->standard_formats[drm->format],
-						drm->width, drm->height);
-	if (unlikely (tmp->base.status)) {
-	    _cairo_xcb_connection_free_pixmap (target->connection, pixmap);
-	    return (cairo_xcb_picture_t *) tmp;
-	}
-
-	_cairo_pattern_init_for_surface (&pattern, source);
-	status = _cairo_surface_paint (&tmp->base,
-				       CAIRO_OPERATOR_SOURCE,
-				       &pattern.base,
-				       NULL);
-	_cairo_pattern_fini (&pattern.base);
-
-	if (unlikely (status)) {
-	    cairo_surface_destroy (&tmp->base);
-	    return (cairo_xcb_picture_t *) _cairo_surface_create_in_error (status);
-	}
-
-	picture = _copy_to_picture (tmp);
-	cairo_surface_destroy (&tmp->base);
-
-	if (unlikely (picture->base.status))
-	    return picture;
-    }
-#endif
 #if CAIRO_HAS_GL_FUNCTIONS
     else if (source->type == CAIRO_SURFACE_TYPE_GL)
     {
diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index 261e6f3..bba7a9c 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -43,10 +43,6 @@
 #include "cairo-xcb.h"
 #include "cairo-xcb-private.h"
 
-#if CAIRO_HAS_XCB_DRM_FUNCTIONS
-#include <xcb/dri2.h>
-#endif
-
 #define AllPlanes ((unsigned) -1)
 #define CAIRO_ASSUME_PIXMAP 20
 #define XLIB_COORD_MAX 32767
@@ -57,10 +53,6 @@ slim_hidden_proto (cairo_xcb_surface_create_for_bitmap);
 slim_hidden_proto (cairo_xcb_surface_create_with_xrender_format);
 #endif
 
-#if CAIRO_HAS_DRM_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-#include "drm/cairo-drm-private.h"
-#endif
-
 /**
  * SECTION:cairo-xcb
  * @Title: XCB Surfaces
@@ -191,16 +183,6 @@ _cairo_xcb_surface_create_similar (void			*abstract_other,
 		 height <= 0))
 	return _cairo_xcb_surface_create_similar_image (other, content, width, height);
 
-#if CAIRO_HAS_DRM_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-    if (other->drm != NULL) {
-	cairo_surface_t *drm;
-
-	drm = other->drm->backend->create_similar (other->drm, content, width, height);
-	if (drm != NULL)
-	    return drm;
-    }
-#endif
-
     if ((other->flags & CAIRO_XCB_HAS_RENDER) == 0)
 	return _cairo_xcb_surface_create_similar_image (other, content, width, height);
 
@@ -277,16 +259,6 @@ _cairo_xcb_surface_finish (void *abstract_surface)
 
     cairo_list_del (&surface->link);
 
-#if CAIRO_HAS_DRM_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-    if (surface->drm != NULL) {
-	cairo_surface_finish (surface->drm);
-	cairo_surface_destroy (surface->drm);
-
-	xcb_dri2_destroy_drawable (surface->connection->xcb_connection,
-				   surface->drawable);
-    }
-#endif
-
     status = _cairo_xcb_connection_acquire (surface->connection);
     if (status == CAIRO_STATUS_SUCCESS) {
 	if (surface->picture != XCB_NONE) {
@@ -982,74 +954,6 @@ const cairo_surface_backend_t _cairo_xcb_surface_backend = {
     _cairo_xcb_surface_glyphs,
 };
 
-#if CAIRO_HAS_DRM_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-static cairo_surface_t *
-_xcb_drm_create_surface_for_drawable (cairo_xcb_connection_t *connection,
-				      cairo_xcb_screen_t *screen,
-				      xcb_drawable_t drawable,
-				      pixman_format_code_t pixman_format,
-				      int width, int height)
-{
-    uint32_t attachments[] = { XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT };
-    xcb_dri2_get_buffers_reply_t *buffers;
-    xcb_dri2_dri2_buffer_t *buffer;
-    cairo_surface_t *surface;
-
-    if (! _cairo_drm_size_is_valid (screen->device, width, height))
-	return NULL;
-
-    xcb_dri2_create_drawable (connection->xcb_connection,
-			      drawable);
-
-    buffers = xcb_dri2_get_buffers_reply (connection->xcb_connection,
-					  xcb_dri2_get_buffers (connection->xcb_connection,
-								drawable, 1,
-								ARRAY_LENGTH (attachments),
-								attachments),
-					  0);
-    if (buffers == NULL) {
-	xcb_dri2_destroy_drawable (connection->xcb_connection,
-				   drawable);
-	return NULL;
-    }
-
-    /* If the drawable is a window, we expect to receive an extra fake front,
-     * which would involve copying on each flush - contrary to the user
-     * expectations. But that is likely to be preferable to mixing drm/xcb
-     * operations.
-     */
-    buffer = xcb_dri2_get_buffers_buffers (buffers);
-    if (buffers->count == 1 && buffer[0].attachment == XCB_DRI2_ATTACHMENT_BUFFER_FRONT_LEFT) {
-	assert (buffer[0].cpp == PIXMAN_FORMAT_BPP (pixman_format) / 8);
-	surface = cairo_drm_surface_create_for_name (screen->device,
-						     buffer[0].name,
-						     _cairo_format_from_pixman_format (pixman_format),
-						     width, height,
-						     buffer[0].pitch);
-    } else {
-	xcb_dri2_destroy_drawable (connection->xcb_connection,
-				   drawable);
-	surface = NULL;
-    }
-    free (buffers);
-
-    return surface;
-}
-
-#else
-
-static cairo_surface_t *
-_xcb_drm_create_surface_for_drawable (cairo_xcb_connection_t *connection,
-				      cairo_xcb_screen_t *screen,
-				      xcb_drawable_t drawable,
-				      pixman_format_code_t pixman_format,
-				      int width, int height)
-{
-    return NULL;
-}
-
-#endif
-
 cairo_surface_t *
 _cairo_xcb_surface_create_internal (cairo_xcb_screen_t		*screen,
 				    xcb_drawable_t		 drawable,
@@ -1095,14 +999,6 @@ _cairo_xcb_surface_create_internal (cairo_xcb_screen_t		*screen,
     surface->flags = screen->connection->flags;
 
     surface->marked_dirty = FALSE;
-    surface->drm = NULL;
-    if (screen->device != NULL) {
-	surface->drm = _xcb_drm_create_surface_for_drawable (surface->connection,
-							     surface->screen,
-							     drawable,
-							     pixman_format,
-							     width, height);
-    }
 
     return &surface->base;
 }
diff --git a/src/drm/cairo-drm-i915-shader.c b/src/drm/cairo-drm-i915-shader.c
index b67608a..a1911d0 100644
--- a/src/drm/cairo-drm-i915-shader.c
+++ b/src/drm/cairo-drm-i915-shader.c
@@ -39,11 +39,6 @@
 #include "cairo-surface-subsurface-private.h"
 #include "cairo-surface-snapshot-private.h"
 
-#if CAIRO_HAS_XCB_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-/* for DRI2/DRM interoperability */
-#include "cairo-xcb-private.h"
-#endif
-
 #if 0
 static cairo_status_t
 i915_packed_pixel_surface_finish (void *abstract_surface)
@@ -1531,25 +1526,6 @@ i915_shader_acquire_surface (i915_shader_t *shader,
     src->base.matrix = pattern->base.matrix;
     filter = sampled_area (pattern, extents, &sample);
 
-#if CAIRO_HAS_XCB_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-    if (surface->type == CAIRO_SURFACE_TYPE_XCB) {
-	cairo_surface_t *xcb = surface;
-
-	if (xcb->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
-	    xcb = ((cairo_surface_subsurface_t *) surface)->target;
-	} else if (xcb->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
-	    xcb = ((cairo_surface_snapshot_t *) surface)->target;
-	}
-
-	/* XXX copy windows (IncludeInferiors) to a pixmap/drm surface
-	 * xcb = _cairo_xcb_surface_to_drm (xcb)
-	 */
-	xcb = ((cairo_xcb_surface_t *) xcb)->drm;
-	if (xcb != NULL)
-	    drm = xcb;
-    }
-#endif
-
     if (surface->type == CAIRO_SURFACE_TYPE_DRM) {
 	if (surface->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
 	    drm = ((cairo_surface_subsurface_t *) surface)->target;
diff --git a/src/drm/cairo-drm-i965-shader.c b/src/drm/cairo-drm-i965-shader.c
index 03d7d44..f88e5a4 100644
--- a/src/drm/cairo-drm-i965-shader.c
+++ b/src/drm/cairo-drm-i965-shader.c
@@ -43,11 +43,6 @@
 
 #include "cairo-drm-intel-brw-eu.h"
 
-#if CAIRO_HAS_XCB_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-/* for DRI2/DRM interoperability */
-#include "cairo-xcb-private.h"
-#endif
-
 /* Theory of shaders:
  *
  * 3 types of rectangular inputs:
@@ -400,25 +395,6 @@ i965_shader_acquire_surface (i965_shader_t *shader,
     assert (src->type.fragment == FS_NONE);
     drm = surface = pattern->surface;
 
-#if CAIRO_HAS_XCB_SURFACE && CAIRO_HAS_XCB_DRM_FUNCTIONS
-    if (surface->type == CAIRO_SURFACE_TYPE_XCB) {
-	cairo_surface_t *xcb = surface;
-
-	if (xcb->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
-	    xcb = ((cairo_surface_subsurface_t *) surface)->target;
-	} else if (xcb->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
-	    xcb = ((cairo_surface_snapshot_t *) surface)->target;
-	}
-
-	/* XXX copy windows (IncludeInferiors) to a pixmap/drm surface
-	 * xcb = _cairo_xcb_surface_to_drm (xcb)
-	 */
-	xcb = ((cairo_xcb_surface_t *) xcb)->drm;
-	if (xcb != NULL)
-	    drm = xcb;
-    }
-#endif
-
     if (surface->type == CAIRO_SURFACE_TYPE_DRM) {
 	if (surface->backend->type == CAIRO_SURFACE_TYPE_SUBSURFACE) {
 	    drm = ((cairo_surface_subsurface_t *) surface)->target;
commit 5d9da3decff06015d03413713714552095dfa616
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 14 12:35:19 2011 +0100

    Excise DRM-Xr
    
    I've since incorporated (nearly) all the features from cairo-drm into
    xf86-video-intel, making this experiment defunct.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/boilerplate/Makefile.win32.features b/boilerplate/Makefile.win32.features
index d0b184d..14263a8 100644
--- a/boilerplate/Makefile.win32.features
+++ b/boilerplate/Makefile.win32.features
@@ -199,18 +199,6 @@ enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_cxx_sources)
 enabled_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources)
 endif
 
-unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_drm_xr_headers)
-all_cairo_boilerplate_headers += $(cairo_boilerplate_drm_xr_headers)
-all_cairo_boilerplate_private += $(cairo_boilerplate_drm_xr_private)
-all_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_xr_cxx_sources)
-all_cairo_boilerplate_sources += $(cairo_boilerplate_drm_xr_sources)
-ifeq ($(CAIRO_HAS_DRM_XR_FUNCTIONS),1)
-enabled_cairo_boilerplate_headers += $(cairo_boilerplate_drm_xr_headers)
-enabled_cairo_boilerplate_private += $(cairo_boilerplate_drm_xr_private)
-enabled_cairo_boilerplate_cxx_sources += $(cairo_boilerplate_drm_xr_cxx_sources)
-enabled_cairo_boilerplate_sources += $(cairo_boilerplate_drm_xr_sources)
-endif
-
 unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
 all_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
 all_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private)
diff --git a/build/configure.ac.features b/build/configure.ac.features
index b4185a0..352003b 100644
--- a/build/configure.ac.features
+++ b/build/configure.ac.features
@@ -402,7 +402,6 @@ AC_DEFUN([CAIRO_REPORT],
 	echo "  X11-xcb functions: $use_xlib_xcb"
 	echo "  XCB-drm functions: $use_xcb_drm"
 	echo "  XCB-shm functions: $use_xcb_shm"
-	echo "  DRM-Xr functions: $use_drm_xr"
 	echo ""
 	echo "The following features and utilities:"
 	echo "  cairo-trace:                $use_trace"
diff --git a/configure.ac b/configure.ac
index 6687791..6096007 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,19 +242,6 @@ CAIRO_ENABLE_SURFACE_BACKEND(drm, DRM, no, [
   use_drm="no (requires $drm_REQUIRES, udev is available from git://git.kernel.org/pub/scm/linux/hotplug/udev.git)"])
 ])
 
-CAIRO_ENABLE_FUNCTIONS(drm_xr, DRM Xr (DDX), no, [
-  if test "x$use_drm" = "xyes"; then
-      drm_xr_REQUIRES="xorg-server >= 1.6 xproto xextproto >= 7.0.99.1 renderproto x11"
-      PKG_CHECK_MODULES(drm_xr, $drm_xr_REQUIRES, ,
-			[AC_MSG_RESULT(no)
-			use_drm_xr="no (requires $drm_xr)"])
-      drm_xr_CFLAGS=`echo "$drm_xr_CFLAGS" | $SED -e 's/-fvisibility=hidden//g'`
-  else
-    use_drm_xr="no (requires --enable-drm)"
-  fi
-])
-AM_CONDITIONAL(BUILD_DRM_XR, test "x$use_drm_xr" = "xyes")
-
 CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
   if test "x$use_drm" = "xyes"; then
       AC_ARG_WITH([gallium],
diff --git a/src/Makefile.sources b/src/Makefile.sources
index c7a0540..966e03d 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -364,11 +364,6 @@ cairo_drm_sources = drm/cairo-drm.c \
 		    drm/cairo-drm-radeon-surface.c
 cairo_gallium_sources = drm/cairo-drm-gallium-surface.c
 
-cairo_drm_xr_headers = cairo-drm-xr.h
-cairo_drm_xr_sources = \
-		    drm/cairo-drm-xr.c \
-		    $(NULL)
-
 cairo_script_headers = cairo-script.h
 cairo_script_sources = cairo-script-surface.c
 
diff --git a/src/Makefile.win32.features b/src/Makefile.win32.features
index d7cc77e..d36bacf 100644
--- a/src/Makefile.win32.features
+++ b/src/Makefile.win32.features
@@ -261,22 +261,6 @@ ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
 enabled_cairo_pkgconf += cairo-drm.pc
 endif
 
-unsupported_cairo_headers += $(cairo_drm_xr_headers)
-all_cairo_headers += $(cairo_drm_xr_headers)
-all_cairo_private += $(cairo_drm_xr_private)
-all_cairo_cxx_sources += $(cairo_drm_xr_cxx_sources)
-all_cairo_sources += $(cairo_drm_xr_sources)
-ifeq ($(CAIRO_HAS_DRM_XR_FUNCTIONS),1)
-enabled_cairo_headers += $(cairo_drm_xr_headers)
-enabled_cairo_private += $(cairo_drm_xr_private)
-enabled_cairo_cxx_sources += $(cairo_drm_xr_cxx_sources)
-enabled_cairo_sources += $(cairo_drm_xr_sources)
-endif
-all_cairo_pkgconf += cairo-drm-xr.pc
-ifeq ($(CAIRO_HAS_DRM_XR_FUNCTIONS),1)
-enabled_cairo_pkgconf += cairo-drm-xr.pc
-endif
-
 unsupported_cairo_headers += $(cairo_gallium_headers)
 all_cairo_headers += $(cairo_gallium_headers)
 all_cairo_private += $(cairo_gallium_private)
diff --git a/src/cairo-drm-xr.h b/src/cairo-drm-xr.h
deleted file mode 100644
index d135924..0000000
--- a/src/cairo-drm-xr.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Intel Coropration
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- */
-
-#ifndef CAIRO_DRM_XR_H
-#define CAIRO_DRM_XR_H
-
-#include "cairo.h"
-
-#if CAIRO_HAS_DRM_XR_FUNCTIONS
-
-CAIRO_BEGIN_DECLS
-
-typedef struct _xr_screen xr_screen_t;
-
-cairo_public xr_screen_t *
-cairo_drm_xr_enable (ScreenPtr screen, int fd);
-
-cairo_public void
-cairo_drm_xr_pixmap_link_bo (xr_screen_t *xr,
-			     PixmapPtr pixmap,
-			     uint32_t name,
-			     cairo_format_t format,
-			     int width,
-			     int height,
-			     int stride);
-
-cairo_public void
-cairo_drm_xr_pixmap_unlink_bo (xr_screen_t *xr,
-			       PixmapPtr pixmap);
-
-CAIRO_END_DECLS
-
-#else  /* CAIRO_HAS_DRM_XR_FUNCTIOSN */
-# error Cairo was not compiled with support for the DRM Xr DDX functions
-#endif /* CAIRO_HAS_DRM_XR_FUNCTIOSN */
-
-#endif /* CAIRO_DRM_XR_H */
diff --git a/src/drm/cairo-drm-xr.c b/src/drm/cairo-drm-xr.c
deleted file mode 100644
index 49d1728..0000000
--- a/src/drm/cairo-drm-xr.c
+++ /dev/null
@@ -1,2378 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2010 Intel Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Intel Corporation
- *
- * Contributor(s):
- *	Chris Wilson <chris at chris-wilson.co.uk>
- */
-
-/*
- * Implement an X Acceleration Architecture using the cairo-drm
- * backends.
- */
-
-#include "cairoint.h"
-#include "cairo-drm-private.h"
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#else
-#include <xorg-server.h>
-#endif
-
-#include "xf86.h"
-#include "gcstruct.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "windowstr.h"
-#include "picturestr.h"
-#include "mi.h"
-#include "fb.h"
-#ifdef MITSHM
-#include <X11/extensions/shm.h>
-#endif
-#ifdef RENDER
-#include "fbpict.h"
-#include "glyphstr.h"
-#endif
-
-#include "cairo-drm-xr.h"
-
-struct _xr_screen {
-    cairo_device_t *device;
-
-    CreateGCProcPtr SavedCreateGC;
-    CloseScreenProcPtr SavedCloseScreen;
-    GetImageProcPtr SavedGetImage;
-    GetSpansProcPtr SavedGetSpans;
-    CreatePixmapProcPtr SavedCreatePixmap;
-    DestroyPixmapProcPtr SavedDestroyPixmap;
-    CopyWindowProcPtr SavedCopyWindow;
-    ChangeWindowAttributesProcPtr SavedChangeWindowAttributes;
-    BitmapToRegionProcPtr SavedBitmapToRegion;
-
-#ifdef RENDER
-    CompositeProcPtr SavedComposite;
-    GlyphsProcPtr SavedGlyphs;
-    CompositeRectsProcPtr SavedCompositeRects;
-    TrapezoidsProcPtr SavedTrapezoids;
-    TrianglesProcPtr SavedTriangles;
-    TriStripProcPtr SavedTriStrip;
-    TriFanProcPtr SavedTriFan;
-    AddTrianglesProcPtr SavedAddTriangles;
-    AddTrapsProcPtr SavedAddTraps;
-
-    RealizeGlyphProcPtr SavedRealizeGlyph;
-    UnrealizeGlyphProcPtr SavedUnrealizeGlyph;
-#endif
-};
-
-struct xr_access_gc {
-    cairo_surface_t *stipple;
-    cairo_surface_t *tile;
-};
-
-struct xr_access_window {
-    cairo_surface_t *background;
-    cairo_surface_t *border;
-};
-
-static int xr_screen_index;
-static int xr_pixmap_index;
-
-static inline xr_screen_t *
-xr_get_screen (ScreenPtr screen)
-{
-    return dixLookupPrivate (&screen->devPrivates, &xr_screen_index);
-}
-
-static inline PixmapPtr
-xr_drawable_get_pixmap (DrawablePtr drawable)
-{
-    if (drawable->type == DRAWABLE_WINDOW)
-	return drawable->pScreen->GetWindowPixmap ((WindowPtr) drawable);
-    else
-	return (PixmapPtr) drawable;
-}
-
-static inline cairo_drm_surface_t *
-xr_pixmap_get_drm_surface (PixmapPtr pixmap)
-{
-    return dixLookupPrivate (&pixmap->devPrivates, &xr_pixmap_index);
-}
-
-static cairo_drm_surface_t *
-xr_drawable_get_drm_surface (DrawablePtr drawable)
-{
-    return xr_pixmap_get_drm_surface (xr_drawable_get_pixmap (drawable));
-}
-
-static cairo_format_t
-xr_format_for_depth (int depth)
-{
-    switch (depth) {
-    case 1:
-	return CAIRO_FORMAT_A1;
-    case 8:
-	return CAIRO_FORMAT_A8;
-    case 16:
-	return CAIRO_FORMAT_RGB16_565;
-    case 24:
-	return CAIRO_FORMAT_RGB24;
-    default:
-    case 32:
-	return CAIRO_FORMAT_ARGB32;
-    }
-}
-
-static cairo_surface_t *
-xr_pixmap_get_surface (PixmapPtr pixmap)
-{
-    cairo_drm_surface_t *drm;
-
-    drm = xr_pixmap_get_drm_surface (pixmap);
-    if (drm != NULL)
-	return cairo_surface_reference (&drm->base);
-
-    return cairo_image_surface_create_for_data (pixmap->devPrivate.ptr,
-						xr_format_for_depth (pixmap->drawable.depth),
-						pixmap->drawable.width,
-						pixmap->drawable.height,
-						pixmap->devKind);
-}
-
-static cairo_surface_t *
-xr_drawable_get_surface (DrawablePtr drawable)
-{
-    return xr_pixmap_get_surface (xr_drawable_get_pixmap (drawable));
-}
-
-static cairo_bool_t
-xr_prepare_access (DrawablePtr drawable,
-		   cairo_surface_t **image)
-{
-    PixmapPtr pixmap;
-    cairo_drm_surface_t *drm;
-
-    *image = NULL;
-
-    pixmap = xr_drawable_get_pixmap (drawable);
-    drm = xr_pixmap_get_drm_surface (pixmap);
-    if (drm == NULL)
-	return TRUE;
-
-    *image = cairo_drm_surface_map_to_image (&drm->base);
-    if ((*image)->status)
-	return FALSE;
-
-    pixmap->devPrivate.ptr =
-	((cairo_image_surface_t *) *image)->data;
-
-    return TRUE;
-}
-
-static void
-xr_finish_access (DrawablePtr drawable,
-		  cairo_surface_t *image)
-{
-    if (image != NULL) {
-	cairo_drm_surface_unmap (&xr_drawable_get_drm_surface (drawable)->base,
-				 image);
-    }
-}
-
-static cairo_bool_t
-xr_prepare_access_gc (GCPtr gc,
-		      struct xr_access_gc *local)
-{
-    local->stipple = NULL;
-    local->tile = NULL;
-
-    if (gc->stipple) {
-	if (! xr_prepare_access (&gc->stipple->drawable, &local->stipple))
-	    return FALSE;
-    }
-
-    if (gc->fillStyle == FillTiled) {
-	if (! xr_prepare_access (&gc->tile.pixmap->drawable,
-				  &local->tile))
-	{
-	    if (local->stipple) {
-		xr_finish_access (&gc->stipple->drawable,
-				   local->stipple);
-	    }
-
-	    return FALSE;
-	}
-    }
-
-    return TRUE;
-}
-
-static void
-xr_finish_access_gc (GCPtr gc,
-		     struct xr_access_gc *local)
-{
-    if (local->tile) {
-	xr_finish_access(&gc->tile.pixmap->drawable,
-			  local->tile);
-    }
-
-    if (local->stipple) {
-	xr_finish_access(&gc->stipple->drawable,
-			  local->stipple);
-    }
-}
-
-static void
-xr_fill_spans (DrawablePtr drawable,
-	       GCPtr gc,
-	       int nspans,
-	       DDXPointPtr ppt,
-	       int *pwidth,
-	       int fSorted)
-{
-    cairo_surface_t *image;
-    struct xr_access_gc access_gc;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	if (xr_prepare_access_gc (gc, &access_gc)) {
-	    fbFillSpans (drawable, gc,
-			 nspans, ppt, pwidth,
-			 fSorted);
-	    xr_finish_access_gc(gc, &access_gc);
-	}
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_set_spans (DrawablePtr drawable,
-	      GCPtr gc,
-	      char *psrc,
-	      DDXPointPtr ppt,
-	      int *pwidth,
-	      int nspans,
-	      int fSorted)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbSetSpans (drawable, gc, psrc, ppt, pwidth, nspans, fSorted);
-	xr_finish_access (drawable, image);
-    }
-}
-
-#define XR_PM_IS_SOLID(_pDrawable, _pm) \
-	(((_pm) & FbFullMask((_pDrawable)->depth)) == \
-	 FbFullMask((_pDrawable)->depth))
-
-static cairo_clip_t *
-xr_gc_get_clip (GCPtr gc, int xoff, int yoff)
-{
-    return NULL;
-}
-
-static cairo_bool_t
-xr_do_put_image (DrawablePtr drawable,
-		 GCPtr gc,
-		 int depth,
-		 int x, int y,
-		 int width, int height,
-		 int format,
-		 char *bits, int src_stride)
-{
-    cairo_surface_t *surface;
-    cairo_clip_t *clip;
-    cairo_surface_t *image;
-    cairo_surface_pattern_t pattern;
-    cairo_status_t status;
-    cairo_path_fixed_t path;
-    cairo_fixed_t x1, y1, x2, y2;
-
-    if (format != ZPixmap || drawable->bitsPerPixel < 8)
-	return FALSE;
-
-    if (! XR_PM_IS_SOLID (drawable, gc->planemask) || gc->alu != GXcopy)
-	return FALSE;
-
-    clip = xr_gc_get_clip (gc, drawable->x, drawable->y);
-    x1 = _cairo_fixed_from_int (x + drawable->x);
-    y1 = _cairo_fixed_from_int (y + drawable->y);
-    x2 = x1 + _cairo_fixed_from_int (width);
-    y2 = y1 + _cairo_fixed_from_int (height);
-    _cairo_path_fixed_init (&path);
-    if (_cairo_path_fixed_move_to (&path, x1, y1) ||
-	_cairo_path_fixed_line_to (&path, x2, y1) ||
-	_cairo_path_fixed_line_to (&path, x2, y2) ||
-	_cairo_path_fixed_line_to (&path, x1, y2) ||
-	_cairo_path_fixed_close_path (&path))
-    {
-	goto err_path;
-    }
-
-    image = cairo_image_surface_create_for_data ((uint8_t *) bits,
-						 xr_format_for_depth (depth),
-						 width, height, src_stride);
-    _cairo_pattern_init_for_surface (&pattern, image);
-    cairo_surface_destroy (image);
-    pattern.base.filter = CAIRO_FILTER_NEAREST;
-    cairo_matrix_init_translate (&pattern.base.matrix,
-				 -x - drawable->x,
-				 -y - drawable->x);
-
-    surface = xr_drawable_get_surface (drawable);
-    status = _cairo_surface_fill (surface,
-				  CAIRO_OPERATOR_SOURCE,
-				  &pattern.base,
-				  &path,
-				  CAIRO_FILL_RULE_WINDING,
-				  CAIRO_ANTIALIAS_DEFAULT,
-				  CAIRO_GSTATE_TOLERANCE_DEFAULT,
-				  clip);
-    cairo_surface_destroy (surface);
-    _cairo_pattern_fini (&pattern.base);
-err_path:
-    _cairo_path_fixed_fini (&path);
-
-    (void) status;
-    return TRUE;
-}
-
-static void
-xr_put_image(DrawablePtr drawable,
-	      GCPtr gc, int depth,
-	      int x, int y,
-	      int w, int h,
-	      int leftPad,
-	      int format,
-	      char *bits)
-{
-    if (! xr_do_put_image (drawable,
-			   gc,
-			   depth,
-			   x, y, w, h,
-			   format,
-			   bits,
-			   PixmapBytePad (w, drawable->depth)))
-    {
-	cairo_surface_t *image;
-
-	//ErrorF ("fallback: %s\n", __FUNCTION__);
-	if (xr_prepare_access (drawable, &image)) {
-	    fbPutImage (drawable, gc, depth,
-			x, y, w, h,
-			leftPad, format, bits);
-	    xr_finish_access (drawable, image);
-	}
-    }
-}
-
-static void
-xr_pattern_init_for_drawable (cairo_surface_pattern_t *pattern,
-			      DrawablePtr drawable)
-{
-    cairo_surface_t *surface;
-
-    surface = xr_drawable_get_surface (drawable);
-    _cairo_pattern_init_for_surface (pattern, surface);
-    cairo_surface_destroy (surface);
-
-    pattern->base.filter = CAIRO_FILTER_NEAREST;
-    pattern->base.extend = CAIRO_EXTEND_NONE;
-    cairo_matrix_init_translate (&pattern->base.matrix,
-				 drawable->x,
-				 drawable->y);
-}
-
-static RegionPtr
-xr_copy_area (DrawablePtr src,
-	      DrawablePtr dst,
-	      GCPtr gc,
-	      int src_x, int src_y,
-	      int width, int height,
-	      int dst_x, int dst_y)
-{
-    cairo_surface_pattern_t pattern;
-    cairo_clip_t *clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-    cairo_path_fixed_t path;
-    cairo_fixed_t x1, x2, y1, y2;
-
-    xr_pattern_init_for_drawable (&pattern, src);
-    cairo_matrix_translate (&pattern.base.matrix,
-			    src->x + src_x - dst_x - dst->x,
-			    src->y + src_y - dst_y - dst->y);
-
-    clip = xr_gc_get_clip (gc, dst->x, dst->y);
-    surface = xr_drawable_get_surface (dst);
-
-    x1 = _cairo_fixed_from_int (dst_x + dst->x);
-    y1 = _cairo_fixed_from_int (dst_y + dst->y);
-    x2 = x1 + _cairo_fixed_from_int (width);
-    y2 = y1 + _cairo_fixed_from_int (height);
-    _cairo_path_fixed_init (&path);
-    if (_cairo_path_fixed_move_to (&path, x1, y1) ||
-	_cairo_path_fixed_line_to (&path, x2, y1) ||
-	_cairo_path_fixed_line_to (&path, x2, y2) ||
-	_cairo_path_fixed_line_to (&path, x1, y2) ||
-	_cairo_path_fixed_close_path (&path))
-    {
-	goto err_path;
-    }
-
-    status = _cairo_surface_fill (surface,
-				  CAIRO_OPERATOR_SOURCE,
-				  &pattern.base,
-				  &path,
-				  CAIRO_FILL_RULE_WINDING,
-				  CAIRO_ANTIALIAS_DEFAULT,
-				  CAIRO_GSTATE_TOLERANCE_DEFAULT,
-				  clip);
-    (void) status;
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-    _cairo_pattern_fini (&pattern.base);
-    cairo_surface_destroy (surface);
-
-    return miGetCompositeClip (gc);
-}
-
-static RegionPtr
-xr_copy_plane (DrawablePtr src,
-	       DrawablePtr dst,
-	       GCPtr gc,
-	       int src_x, int src_y,
-	       int w, int h,
-	       int dst_x, int dst_y,
-	       unsigned long bitPlane)
-{
-    RegionPtr ret = NULL;
-    cairo_surface_t *src_image, *dst_image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (dst, &dst_image)) {
-	if (xr_prepare_access (src, &src_image)) {
-	    ret = fbCopyPlane (src, dst, gc,
-			       src_x, src_y,
-			       w, h,
-			       dst_x, dst_y,
-			       bitPlane);
-	    xr_finish_access (src, src_image);
-	}
-	xr_finish_access (dst, dst_image);
-    }
-    return ret;
-}
-
-static void
-xr_poly_point (DrawablePtr drawable,
-	       GCPtr gc,
-	       int mode,
-	       int npt,
-	       DDXPointPtr ppt)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbPolyPoint (drawable, gc, mode, npt, ppt);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_line (DrawablePtr drawable,
-	      GCPtr gc,
-	      int mode,
-	      int npt,
-	      DDXPointPtr ppt)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbPolyLine (drawable, gc, mode, npt, ppt);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_segment (DrawablePtr drawable,
-		 GCPtr gc,
-		 int nseg,
-		 xSegment *pSeg)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbPolySegment (drawable, gc, nseg, pSeg);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_rectangle (DrawablePtr drawable,
-		    GCPtr gc,
-		    int nrect,
-		    xRectangle *pRects)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbPolyRectangle (drawable, gc, nrect, pRects);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_arc (DrawablePtr drawable,
-	     GCPtr gc,
-	     int narcs,
-	     xArc *pArcs)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbPolyArc (drawable, gc, narcs, pArcs);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_fill (DrawablePtr drawable,
-	      GCPtr gc,
-	      int shape,
-	      int mode,
-	      int count,
-	      DDXPointPtr pPts)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbFillPolygon (drawable, gc, shape, mode, count, pPts);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_fill_rect_fallback (DrawablePtr drawable,
-			    GCPtr gc,
-			    int nrect,
-			    xRectangle *prect)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	miPolyFillRect (drawable, gc, nrect, prect);
-	xr_finish_access (drawable, image);
-    }
-}
-
-
-static void
-xr_poly_fill_rect (DrawablePtr drawable,
-		   GCPtr gc,
-		   int nrect,
-		   xRectangle *rect)
-{
-    cairo_clip_t *clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-    int n;
-
-    if (gc->alu != GXcopy && gc->alu != GXclear) {
-	xr_poly_fill_rect_fallback (drawable, gc, nrect, rect);
-	return;
-    }
-
-    if (gc->fillStyle != FillSolid &&
-	!(gc->tileIsPixel && gc->fillStyle == FillTiled))
-    {
-	xr_poly_fill_rect_fallback (drawable, gc, nrect, rect);
-	return;
-    }
-
-    surface = xr_drawable_get_surface (drawable);
-    clip = xr_gc_get_clip (gc, drawable->x, drawable->y);
-    if (clip == NULL && nrect == 1 &&
-	rect->x <= 0 &&
-	rect->y <= 0 &&
-	rect->width >= drawable->width &&
-	rect->height >= drawable->height &&
-	(gc->alu == GXclear || (gc->fgPixel & 0x00ffffff) == 0))
-    {
-	status = _cairo_surface_paint (surface,
-				       CAIRO_OPERATOR_CLEAR,
-				       &_cairo_pattern_clear.base,
-				       NULL);
-    }
-    else
-    {
-	cairo_path_fixed_t path;
-	cairo_fixed_t x_off, y_off;
-	cairo_solid_pattern_t pattern;
-	cairo_color_t color;
-
-	x_off = _cairo_fixed_from_int (drawable->x);
-	y_off = _cairo_fixed_from_int (drawable->y);
-	_cairo_path_fixed_init (&path);
-	for (n = 0; n < nrect; n++) {
-	    cairo_fixed_t x1 = x_off + _cairo_fixed_from_int (rect[n].x);
-	    cairo_fixed_t x2 = x1 + _cairo_fixed_from_int (rect[n].width);
-	    cairo_fixed_t y1 = y_off + _cairo_fixed_from_int (rect[n].y);
-	    cairo_fixed_t y2 = y1 + _cairo_fixed_from_int (rect[n].height);
-
-	    if (_cairo_path_fixed_move_to (&path, x1, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y2) ||
-		_cairo_path_fixed_line_to (&path, x1, y2) ||
-		_cairo_path_fixed_close_path (&path))
-	    {
-		goto err_path;
-	    }
-	}
-
-	_cairo_color_init_rgba (&color,
-				((gc->fgPixel & 0x00ff0000) >> 16) / 255.,
-				((gc->fgPixel & 0x0000ff00) >>  8) / 255.,
-				((gc->fgPixel & 0x000000ff) >>  0) / 255.,
-				1.0);
-	_cairo_pattern_init_solid (&pattern, &color, CAIRO_CONTENT_COLOR);
-
-	status = _cairo_surface_fill (surface,
-				      gc->alu == GXcopy ? CAIRO_OPERATOR_SOURCE : CAIRO_OPERATOR_CLEAR,
-				      &pattern.base,
-				      &path,
-				      CAIRO_FILL_RULE_WINDING,
-				      1.,
-				      CAIRO_ANTIALIAS_DEFAULT,
-				      clip);
-err_path:
-	_cairo_path_fixed_fini (&path);
-    }
-
-    cairo_surface_destroy (surface);
-    (void) status;
-}
-
-static void
-xr_poly_fill_arc (DrawablePtr drawable,
-		  GCPtr gc,
-		  int narc,
-		  xArc *arc)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	miPolyFillArc (drawable, gc, narc, arc);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_image_glyph_blt (DrawablePtr drawable, GCPtr gc,
-			  int x, int y, unsigned int nglyph,
-			  CharInfoPtr * ppci, pointer pglyphBase)
-{
-    cairo_surface_t *image;
-    struct xr_access_gc local_gc;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	if (xr_prepare_access_gc (gc, &local_gc)) {
-	    fbImageGlyphBlt (drawable, gc,
-			     x, y,
-			     nglyph,
-			     ppci,
-			     pglyphBase);
-	    xr_finish_access_gc (gc, &local_gc);
-	}
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_poly_glyph_blt (DrawablePtr drawable,
-		   GCPtr gc,
-		   int x, int y,
-		   unsigned int nglyph,
-		   CharInfoPtr *ppci,
-		   pointer pglyphBase)
-{
-    cairo_surface_t *image;
-    struct xr_access_gc local_gc;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	if (xr_prepare_access_gc (gc, &local_gc)) {
-	    fbPolyGlyphBlt (drawable, gc,
-			    x, y,
-			    nglyph,
-			    ppci,
-			    pglyphBase);
-	    xr_finish_access_gc (gc, &local_gc);
-	}
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_push_pixels (GCPtr gc,
-		PixmapPtr src,
-		DrawablePtr dst,
-		int w, int h, int x, int y)
-{
-    cairo_surface_t *src_image, *dst_image;
-    struct xr_access_gc local_gc;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (dst, &dst_image)) {
-	if (xr_prepare_access (&src->drawable, &src_image)) {
-	    if (xr_prepare_access_gc (gc, &local_gc)) {
-		fbPushPixels (gc, src, dst,
-			     w, h, x, y);
-		xr_finish_access_gc (gc, &local_gc);
-	    }
-	    xr_finish_access (&src->drawable, src_image);
-	}
-	xr_finish_access (dst, dst_image);
-    }
-}
-
-static void
-xr_validate_gc (GCPtr gc,
-		unsigned long changes,
-		DrawablePtr drawable)
-{
-    static const GCOps xr_ops = {
-	xr_fill_spans,
-	xr_set_spans,
-	xr_put_image,
-	xr_copy_area,
-	xr_copy_plane,
-	xr_poly_point,
-	xr_poly_line,
-	xr_poly_segment,
-	xr_poly_rectangle,
-	xr_poly_arc,
-	xr_poly_fill,
-	xr_poly_fill_rect,
-	xr_poly_fill_arc,
-	miPolyText8,
-	miPolyText16,
-	miImageText8,
-	miImageText16,
-	xr_image_glyph_blt,
-	xr_poly_glyph_blt,
-	xr_push_pixels,
-    };
-
-    /* fbValidateGC will do direct access to pixmaps if the tiling has
-     * changed.  Preempt fbValidateGC by doing its work and masking the
-     * change out, so that we can do the prepare/finish access.
-     */
-#ifdef FB_24_32BIT
-    if (changes & GCTile && fbGetRotatedPixmap (gc)) {
-	gc->pScreen->DestroyPixmap (fbGetRotatedPixmap (gc));
-	fbGetRotatedPixmap (gc) = 0;
-    }
-
-    if (gc->fillStyle == FillTiled) {
-	PixmapPtr old;
-
-	old = gc->tile.pixmap;
-	if (old->drawable.bitsPerPixel != drawable->bitsPerPixel) {
-	    PixmapPtr new = fbGetRotatedPixmap (gc);
-	    if (new == NULL ||
-		new->drawable.bitsPerPixel != drawable->bitsPerPixel)
-	    {
-		cairo_surface_t *image;
-
-		if (new)
-		    gc->pScreen->DestroyPixmap (new);
-
-		/* fb24_32ReformatTile will do direct access
-		 * of a newly-allocated pixmap.  This isn't a
-		 * problem yet, since we don't put pixmaps in
-		 * FB until at least one accelerated UXA op.
-		 */
-		if (xr_prepare_access (&old->drawable, &image)) {
-		    new = fb24_32ReformatTile (old,
-					       drawable->bitsPerPixel);
-		    xr_finish_access (&old->drawable, image);
-		}
-	    }
-
-	    if (new) {
-		fbGetRotatedPixmap (gc) = old;
-		gc->tile.pixmap = new;
-		changes |= GCTile;
-	    }
-	}
-    }
-#endif
-
-    if (changes & GCTile) {
-	if (! gc->tileIsPixel &&
-	    FbEvenTile (gc->tile.pixmap->drawable.width *
-			drawable->bitsPerPixel))
-	{
-	    cairo_surface_t *image;
-
-	    if (xr_prepare_access (&gc->tile.pixmap->drawable,
-				    &image))
-	    {
-		fbPadPixmap(gc->tile.pixmap);
-		xr_finish_access(&gc->tile.pixmap->drawable, image);
-	    }
-	}
-
-	/* Mask out the GCTile change notification, now that we've
-	 * done FB's job for it.
-	 */
-	changes &= ~GCTile;
-    }
-
-    if (changes & GCStipple && gc->stipple) {
-	cairo_surface_t *image;
-
-	/* We can't inline stipple handling like we do for GCTile
-	 * because it sets fbgc privates.
-	 */
-	if (xr_prepare_access (&gc->stipple->drawable, &image)) {
-	    fbValidateGC (gc, changes, drawable);
-	    xr_finish_access (&gc->stipple->drawable, image);
-	}
-    } else {
-	fbValidateGC(gc, changes, drawable);
-    }
-
-    gc->ops = (GCOps *) & xr_ops;
-}
-
-static void
-xr_change_gc (GCPtr gc, unsigned long mask)
-{
-}
-
-static void
-xr_copy_gc (GCPtr src, unsigned long changes, GCPtr dst)
-{
-}
-
-static void
-xr_destroy_gc (GCPtr gc)
-{
-    miDestroyGC (gc);
-}
-
-static void
-xr_destroy_clip (GCPtr gc)
-{
-    miDestroyClip (gc);
-}
-
-static void
-xr_change_clip (GCPtr gc, int type, pointer value, int nrects)
-{
-    xr_destroy_clip (gc);
-
-    miChangeClip (gc, type, value, nrects);
-}
-
-static void
-xr_copy_clip (GCPtr dst, GCPtr src)
-{
-    miCopyClip (dst, src);
-}
-
-static int xr_create_gc (GCPtr gc)
-{
-    static GCFuncs funcs = {
-	xr_validate_gc,
-	xr_change_gc,
-	xr_copy_gc,
-	xr_destroy_gc,
-	xr_change_clip,
-	xr_destroy_clip,
-	xr_copy_clip,
-    };
-
-    if (! fbCreateGC (gc))
-	return FALSE;
-
-    gc->funcs = &funcs;
-    return TRUE;
-}
-
-static void
-xr_get_image (DrawablePtr drawable,
-	      int x, int y, int w, int h,
-	      unsigned int format, unsigned long planeMask,
-	      char *d)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbGetImage (drawable, x, y, w, h, format, planeMask, d);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_get_spans (DrawablePtr drawable,
-	      int wMax,
-	      DDXPointPtr ppt,
-	      int *pwidth,
-	      int nspans,
-	      char *pdstStart)
-{
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (drawable, &image)) {
-	fbGetSpans (drawable, wMax, ppt, pwidth, nspans, pdstStart);
-	xr_finish_access (drawable, image);
-    }
-}
-
-static void
-xr_copy_window (WindowPtr win,
-		DDXPointRec origin,
-		RegionPtr src_region)
-{
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    RegionRec dst_region;
-    PixmapPtr pixmap;
-    int dx, dy;
-
-    dx = origin.x - win->drawable.x;
-    dy = origin.y - win->drawable.y;
-    REGION_TRANSLATE (win->drawable.pScreen, src_region, -dx, -dy);
-
-    REGION_INIT (win->drawable.pScreen, &dst_region, NullBox, 0);
-
-    REGION_INTERSECT (win->drawable.pScreen,
-		      &dst_region, &win->borderClip,
-		     src_region);
-    pixmap = win->drawable.pScreen->GetWindowPixmap (win);
-#ifdef COMPOSITE
-    if (pixmap->screen_x || pixmap->screen_y)
-	REGION_TRANSLATE (win->drawable.pScreen, &dst_region,
-			  -pixmap->screen_x, -pixmap->screen_y);
-#endif
-
-    miCopyRegion (&pixmap->drawable, &pixmap->drawable,
-		  NULL, &dst_region, dx, dy,
-		  xr_copy_n_to_n, 0, NULL);
-
-    REGION_UNINIT (win->drawable.pScreen, &dst_region);
-#endif
-}
-
-static cairo_bool_t
-xr_prepare_access_window (WindowPtr win,
-			  struct xr_access_window *local)
-{
-    local->background = NULL;
-    local->border = NULL;
-
-    if (win->backgroundState == BackgroundPixmap) {
-	if (! xr_prepare_access (&win->background.pixmap->drawable,
-				 &local->background))
-	{
-	    return FALSE;
-	}
-    }
-
-    if (win->borderIsPixel == FALSE) {
-	if (! xr_prepare_access (&win->border.pixmap->drawable,
-				 &local->border))
-	{
-	    if (local->background) {
-		xr_finish_access (&win->background.pixmap->drawable,
-				  local->background);
-	    }
-	    return FALSE;
-	}
-    }
-    return TRUE;
-}
-
-static void
-xr_finish_access_window (WindowPtr win,
-			 struct xr_access_window *local)
-{
-    if (local->background) {
-	xr_finish_access (&win->background.pixmap->drawable,
-			  local->background);
-    }
-
-    if (local->border) {
-	xr_finish_access (&win->border.pixmap->drawable,
-			  local->border);
-    }
-}
-
-static Bool
-xr_change_window_attributes (WindowPtr win,
-			     unsigned long mask)
-{
-    Bool ret = FALSE;
-    struct xr_access_window local;
-
-    if (xr_prepare_access_window (win, &local)) {
-	ret = fbChangeWindowAttributes (win, mask);
-	xr_finish_access_window (win, &local);
-    }
-
-    return ret;
-}
-
-static RegionPtr
-xr_bitmap_to_region (PixmapPtr pPix)
-{
-    RegionPtr ret = NULL;
-    cairo_surface_t *image;
-
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-    if (xr_prepare_access (&pPix->drawable, &image)) {
-	ret = fbPixmapToRegion (pPix);
-	xr_finish_access (&pPix->drawable, image);
-    }
-
-    return ret;
-}
-
-static void
-_color_from_pixel (cairo_color_t *color, uint32_t pixel)
-{
-    color->alpha_short = (pixel & 0xff000000 >> 24);
-    color->alpha_short |= color->alpha_short << 8;
-
-    if (color->alpha_short == 0) {
-	color->red_short = color->green_short = color->blue_short = 0;
-	color->alpha = color->red = color->green = color->blue = 0.;
-	return;
-    }
-
-    color->red_short = (pixel & 0x00ff0000 >> 16);
-    color->red_short |= color->red_short << 8;
-
-    color->green_short = (pixel & 0x0000ff00 >> 8);
-    color->green_short |= color->green_short << 8;
-
-    color->blue_short = (pixel & 0x000000ff >> 0);
-    color->blue_short |= color->blue_short << 8;
-
-    color->alpha = color->alpha_short / (double) 0xffff;
-    color->red = color->red_short / (double) 0xffff / color->alpha;
-    color->green = color->green_short / (double) 0xffff / color->alpha;
-    color->blue = color->blue_short / (double) 0xffff / color->alpha;
-}
-
-static uint32_t
-_pixmap_first_pixel (PixmapPtr pixmap)
-{
-    cairo_surface_t *image;
-    uint32_t pixel;
-    void *fb;
-
-    if (! xr_prepare_access (&pixmap->drawable, &image))
-	return 0;
-
-    fb = pixmap->devPrivate.ptr;
-    switch (pixmap->drawable.bitsPerPixel) {
-    case 32:
-	pixel = *(uint32_t *) fb;
-	break;
-    case 16:
-	pixel = *(uint16_t *) fb;
-	break;
-    default:
-	pixel = *(CARD8 *) fb;
-	break;
-    }
-    xr_finish_access (&pixmap->drawable, image);
-
-    return pixel;
-}
-
-static cairo_bool_t
-_rgba_from_pixel (uint32_t pixel,
-		  uint16_t *red,
-		  uint16_t *green,
-		  uint16_t *blue,
-		  uint16_t *alpha,
-		  uint32_t format)
-{
-    int rbits, bbits, gbits, abits;
-    int rshift, bshift, gshift, ashift;
-
-    rbits = PICT_FORMAT_R(format);
-    gbits = PICT_FORMAT_G(format);
-    bbits = PICT_FORMAT_B(format);
-    abits = PICT_FORMAT_A(format);
-
-    if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
-	rshift = gshift = bshift = ashift = 0;
-    } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
-	bshift = 0;
-	gshift = bbits;
-	rshift = gshift + gbits;
-	ashift = rshift + rbits;
-    } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) {
-	rshift = 0;
-	gshift = rbits;
-	bshift = gshift + gbits;
-	ashift = bshift + bbits;
-    } else {
-	return FALSE;
-    }
-
-    if (rbits) {
-	*red = ((pixel >> rshift) & ((1 << rbits) - 1)) << (16 - rbits);
-	while (rbits < 16) {
-	    *red |= *red >> rbits;
-	    rbits <<= 1;
-	}
-    } else
-	*red = 0;
-
-    if (gbits) {
-	*green = ((pixel >> gshift) & ((1 << gbits) - 1)) << (16 - gbits);
-	while (gbits < 16) {
-	    *green |= *green >> gbits;
-	    gbits <<= 1;
-	}
-    } else
-	*green = 0;
-
-    if (bbits) {
-	*blue = ((pixel >> bshift) & ((1 << bbits) - 1)) << (16 - bbits);
-	while (bbits < 16) {
-	    *blue |= *blue >> bbits;
-	    bbits <<= 1;
-	}
-    } else
-	*blue = 0;
-
-    if (abits) {
-	*alpha =
-	    ((pixel >> ashift) & ((1 << abits) - 1)) << (16 - abits);
-	while (abits < 16) {
-	    *alpha |= *alpha >> abits;
-	    abits <<= 1;
-	}
-    } else
-	*alpha = 0xffff;
-
-    return TRUE;
-}
-
-static cairo_bool_t
-_color_from_pixmap (PixmapPtr	 pixmap,
-		    uint32_t	 src_format,
-		    cairo_color_t  *color)
-{
-    uint32_t pixel = _pixmap_first_pixel(pixmap);
-    if (! _rgba_from_pixel (pixel,
-			    &color->red_short,
-			    &color->green_short,
-			    &color->blue_short,
-			    &color->alpha_short,
-			    src_format))
-    {
-	return FALSE;
-    }
-
-    if (color->alpha_short == 0) {
-	color->red_short = color->green_short = color->blue_short = 0;
-	color->alpha = color->red = color->green = color->blue = 0.;
-	return TRUE;
-    }
-
-    color->alpha = color->alpha_short / (double) 0xffff;
-    color->red = color->red_short / (double) 0xffff / color->alpha;
-    color->green = color->green_short / (double) 0xffff / color->alpha;
-    color->blue = color->blue_short / (double) 0xffff / color->alpha;
-    return TRUE;
-}
-
-static cairo_bool_t
-xr_pattern_init_for_picture (cairo_pattern_union_t *pattern,
-			     PicturePtr picture)
-{
-    cairo_color_t color;
-
-    if (picture->pSourcePict) {
-	SourcePict *source = picture->pSourcePict;
-	switch (source->type) {
-	case SourcePictTypeSolidFill:
-	    _color_from_pixel (&color, source->solidFill.color);
-	    _cairo_pattern_init_solid (&pattern->solid,
-				       &color,
-				       CAIRO_CONTENT_COLOR_ALPHA);
-	    break;
-	default:
-	    return FALSE;
-	}
-    } else if (picture->pDrawable) {
-	cairo_surface_t *surface;
-
-	if (picture->alphaMap)
-	    return FALSE;
-
-	if (picture->pDrawable->width == 1 &&
-	    picture->pDrawable->height == 1 &&
-	    picture->repeat == 1)
-	{
-	    if (! _color_from_pixmap ((PixmapPtr) picture->pDrawable,
-				      picture->format,
-				      &color))
-		goto use_surface;
-
-	    _cairo_pattern_init_solid (&pattern->solid,
-				       &color,
-				       CAIRO_CONTENT_COLOR_ALPHA);
-	}
-	else
-	{
-use_surface:
-	    surface = xr_drawable_get_surface (picture->pDrawable);
-	    _cairo_pattern_init_for_surface (&pattern->surface,
-					     surface);
-	    cairo_surface_destroy (surface);
-	}
-    } else {
-	return FALSE;
-    }
-
-    if (! picture->repeat) {
-	pattern->base.extend = CAIRO_EXTEND_NONE;
-    } else switch (picture->repeatType) {
-    case RepeatNormal:
-	pattern->base.extend = CAIRO_EXTEND_REPEAT;
-	break;
-    case RepeatPad:
-	pattern->base.extend = CAIRO_EXTEND_PAD;
-	break;
-    case RepeatReflect:
-	pattern->base.extend = CAIRO_EXTEND_REFLECT;
-	break;
-    default:
-	goto fail;
-    }
-
-    switch (picture->filter) {
-    case PictFilterNearest:
-	pattern->base.filter = CAIRO_FILTER_NEAREST;
-	break;
-    case PictFilterBilinear:
-	pattern->base.filter = CAIRO_FILTER_BILINEAR;
-	break;
-    case PictFilterFast:
-	pattern->base.filter = CAIRO_FILTER_FAST;
-	break;
-    case PictFilterGood:
-	pattern->base.filter = CAIRO_FILTER_GOOD;
-	break;
-    case PictFilterBest:
-	pattern->base.filter = CAIRO_FILTER_BEST;
-	break;
-    default:
-	goto fail;
-    }
-
-    return TRUE;
-
-fail:
-    _cairo_pattern_fini (&pattern->base);
-    return FALSE;
-}
-
-static cairo_bool_t
-_render_operator (CARD8 render_op, cairo_operator_t *op)
-{
-    switch (render_op) {
-    case PictOpClear: *op = CAIRO_OPERATOR_CLEAR; break;
-    case PictOpSrc: *op = CAIRO_OPERATOR_SOURCE; break;
-    case PictOpOver: *op = CAIRO_OPERATOR_OVER; break;
-    case PictOpIn: *op = CAIRO_OPERATOR_IN; break;
-    case PictOpOut: *op = CAIRO_OPERATOR_OUT; break;
-    case PictOpAtop: *op = CAIRO_OPERATOR_ATOP; break;
-    case PictOpDst: *op = CAIRO_OPERATOR_DEST; break;
-    case PictOpOverReverse: *op = CAIRO_OPERATOR_DEST_OVER; break;
-    case PictOpInReverse: *op = CAIRO_OPERATOR_DEST_IN; break;
-    case PictOpOutReverse: *op = CAIRO_OPERATOR_DEST_OUT; break;
-    case PictOpAtopReverse: *op = CAIRO_OPERATOR_DEST_ATOP; break;
-    case PictOpXor: *op = CAIRO_OPERATOR_XOR; break;
-    case PictOpAdd: *op = CAIRO_OPERATOR_ADD; break;
-    case PictOpSaturate: *op = CAIRO_OPERATOR_SATURATE; break;
-    case PictOpMultiply: *op = CAIRO_OPERATOR_MULTIPLY; break;
-    case PictOpScreen: *op = CAIRO_OPERATOR_SCREEN; break;
-    case PictOpOverlay: *op = CAIRO_OPERATOR_OVERLAY; break;
-    case PictOpDarken: *op = CAIRO_OPERATOR_DARKEN; break;
-    case PictOpLighten: *op = CAIRO_OPERATOR_LIGHTEN; break;
-    case PictOpColorDodge: *op = CAIRO_OPERATOR_COLOR_DODGE; break;
-    case PictOpColorBurn: *op = CAIRO_OPERATOR_COLOR_BURN; break;
-    case PictOpHardLight: *op = CAIRO_OPERATOR_HARD_LIGHT; break;
-    case PictOpSoftLight: *op = CAIRO_OPERATOR_SOFT_LIGHT; break;
-    case PictOpDifference: *op = CAIRO_OPERATOR_DIFFERENCE; break;
-    case PictOpExclusion: *op = CAIRO_OPERATOR_EXCLUSION; break;
-    case PictOpHSLHue: *op = CAIRO_OPERATOR_HSL_HUE; break;
-    case PictOpHSLSaturation: *op = CAIRO_OPERATOR_HSL_SATURATION; break;
-    case PictOpHSLColor: *op = CAIRO_OPERATOR_HSL_COLOR; break;
-    case PictOpHSLLuminosity: *op = CAIRO_OPERATOR_HSL_LUMINOSITY; break;
-
-    default: return FALSE;
-    }
-
-    return TRUE;
-}
-
-static void
-xr_picture_get_clip (PicturePtr picture,
-		     cairo_clip_t *clip)
-{
-    cairo_status_t status;
-
-    _cairo_clip_init (clip);
-
-    if (picture->pCompositeClip) {
-	cairo_path_fixed_t path;
-	BoxPtr pbox;
-	int nbox;
-
-	nbox = REGION_NUM_RECTS (picture->pCompositeClip);
-	pbox = REGION_RECTS (picture->pCompositeClip);
-	_cairo_path_fixed_init (&path);
-	while (nbox--) {
-	    if (_cairo_path_fixed_move_to (&path,
-					   _cairo_fixed_from_int (pbox->x1),
-					   _cairo_fixed_from_int (pbox->y1)) ||
-		_cairo_path_fixed_line_to (&path,
-					   _cairo_fixed_from_int (pbox->x2),
-					   _cairo_fixed_from_int (pbox->y1)) ||
-		_cairo_path_fixed_line_to (&path,
-					   _cairo_fixed_from_int (pbox->x2),
-					   _cairo_fixed_from_int (pbox->y2)) ||
-		_cairo_path_fixed_line_to (&path,
-					   _cairo_fixed_from_int (pbox->x1),
-					   _cairo_fixed_from_int (pbox->y2)) ||
-		_cairo_path_fixed_close_path (&path))
-	    {
-		goto err_path;
-	    }
-	}
-
-	status = _cairo_clip_clip (clip,
-				   &path,
-				   CAIRO_FILL_RULE_WINDING,
-				   1.0,
-				   CAIRO_ANTIALIAS_DEFAULT);
-
-err_path:
-	_cairo_path_fixed_fini (&path);
-    }
-
-    (void) status;
-}
-
-static void
-xr_composite (CARD8 render_op,
-	      PicturePtr pSrc,
-	      PicturePtr pMask,
-	      PicturePtr pDst,
-	      INT16 xSrc, INT16 ySrc,
-	      INT16 xMask, INT16 yMask,
-	      INT16 xDst, INT16 yDst,
-	      CARD16 width, CARD16 height)
-{
-    cairo_pattern_union_t source, mask;
-    cairo_operator_t op;
-    cairo_surface_t *surface;
-    cairo_clip_t clip;
-    cairo_rectangle_int_t rect;
-    cairo_bool_t mask_is_clipped = FALSE, source_is_clipped = FALSE;
-    cairo_status_t status;
-
-    if (! _render_operator (render_op, &op))
-	goto fallback;
-
-    if (! xr_pattern_init_for_picture (&source, pSrc))
-	goto fallback;
-
-    cairo_matrix_translate (&source.base.matrix,
-			    xSrc - xDst, ySrc - yDst);
-
-    if (pMask) {
-	if (! xr_pattern_init_for_picture (&mask, pMask)) {
-	    _cairo_pattern_fini (&source.base);
-	    goto fallback;
-	}
-
-	cairo_matrix_translate (&mask.base.matrix,
-				xMask - xDst, yMask - yDst);
-    }
-
-    xr_picture_get_clip (pDst, &clip);
-    rect.x = xDst;
-    rect.y = yDst;
-    rect.width  = width;
-    rect.height = height;
-    status = _cairo_clip_rectangle (&clip, &rect);
-
-#if 0
-    {
-	cairo_clip_t clip_source;
-
-	xr_picture_get_clip (pSrc, &clip_source);
-	if (clip_source.path != NULL) {
-	    _cairo_clip_apply_clip (&clip, &clip_source);
-	    source_is_clipped = TRUE;
-	}
-	_cairo_clip_fini (&clip_source);
-    }
-    if (pMask) {
-	cairo_clip_t clip_mask;
-
-	xr_picture_get_clip (pMask, &clip_mask);
-	if (clip_mask.path != NULL) {
-	    _cairo_clip_apply_clip (&clip, &clip_mask);
-	    mask_is_clipped = TRUE;
-	}
-	_cairo_clip_fini (&clip_mask);
-    }
-#endif
-
-    surface = xr_drawable_get_surface (pDst->pDrawable);
-    if (! clip.all_clipped) {
-	if (pMask) {
-	    status = _cairo_surface_mask (surface, op,
-					  &source.base,
-					  &mask.base,
-					  &clip);
-	} else {
-	    status = _cairo_surface_paint (surface, op,
-					   &source.base,
-					   &clip);
-	}
-    }
-
-#if 0
-    if (source_is_clipped) {
-	/* clear areas in dst where source was clipped */
-	cairo_surface_t *surface;
-	cairo_clip_t clip_source;
-
-	if (pMask) {
-	    cairo_clip_t clip_mask;
-
-	    xr_picture_get_clip (pMask, &clip_mask);
-	    if (clip_mask.path != NULL) {
-		_cairo_clip_apply_clip (&local_clip, &clip_mask);
-		mask_is_clipped = TRUE;
-	    }
-	    _cairo_clip_fini (&clip_mask);
-	}
-
-	xr_picture_get_inverse_clip (pSrc, &clip_source);
-	_cairo_clip_apply_clip (&clip_source, &clip);
-
-	if (pMask) {
-	    status = _cairo_surface_mask (surface,
-					  CAIRO_OPERATOR_CLEAR,
-					  &_cairo_pattern_clear.base,
-					  &mask.base,
-					  &clip_source);
-	} else {
-	    status = _cairo_surface_paint (surface,
-					  CAIRO_OPERATOR_CLEAR,
-					  &_cairo_pattern_clear.base,
-					  &clip_source);
-	}
-	_cairo_clip_fini (&clip_source);
-    }
-
-    if (mask_is_clipped && ! _cairo_operator_bounded_by_mask (op)) {
-	/* clear areas in dst where mask was clipped */
-	cairo_surface_t *surface;
-	cairo_clip_t clip_mask;
-
-	xr_picture_get_inverse_clip (pMask, &clip_mask);
-	_cairo_clip_apply_clip (&clip, &clip_mask);
-	_cairo_clip_fini (&clip_mask);
-
-	status = _cairo_surface_paint (surface,
-				       CAIRO_OPERATOR_CLEAR,
-				       &_cairo_pattern_clear.base,
-				       &clip);
-    }
-#endif
-
-    cairo_surface_destroy (surface);
-    _cairo_clip_fini (&clip);
-
-    if (pMask)
-	_cairo_pattern_fini (&mask.base);
-    _cairo_pattern_fini (&source.base);
-
-    return;
-
-fallback:
-    {
-	cairo_surface_t *dst_image, *src_image, *mask_image;
-	//ErrorF ("fallback: %s\n", __FUNCTION__);
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		if (pMask == NULL || pMask->pDrawable == NULL ||
-		    xr_prepare_access (pMask->pDrawable, &mask_image))
-		{
-		    fbComposite (op, pSrc, pMask, pDst,
-				 xSrc, ySrc,
-				 xMask, yMask,
-				 xDst, yDst,
-				 width, height);
-		    if (pMask && pMask->pDrawable)
-			xr_finish_access (pMask->pDrawable, mask_image);
-		}
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-}
-
-static void
-xr_glyphs (CARD8 op,
-	   PicturePtr pSrc,
-	   PicturePtr pDst,
-	   PictFormatPtr maskFormat,
-	   INT16 xSrc, INT16 ySrc,
-	   int nlist,
-	   GlyphListPtr list,
-	   GlyphPtr *glyphs)
-{
-}
-
-static cairo_bool_t
-xr_do_fill (cairo_operator_t op,
-	    PicturePtr pSrc,
-	    PicturePtr pDst,
-	    int		src_x,
-	    int		src_y,
-	    cairo_path_fixed_t *path)
-{
-    cairo_pattern_union_t source;
-    cairo_clip_t clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-
-    if (! xr_pattern_init_for_picture (&source, pSrc))
-	return FALSE;
-
-    cairo_matrix_translate (&source.base.matrix, src_x, src_y);
-
-    surface = xr_drawable_get_surface (pDst->pDrawable);
-    xr_picture_get_clip (pDst, &clip);
-    status = _cairo_surface_fill (surface, op, &source.base, path,
-				  CAIRO_FILL_RULE_WINDING,
-				  pDst->polyEdge == PolyEdgeSharp ? CAIRO_ANTIALIAS_NONE : CAIRO_ANTIALIAS_DEFAULT,
-				  CAIRO_GSTATE_TOLERANCE_DEFAULT,
-				  clip.path ? &clip : NULL);
-    _cairo_clip_fini (&clip);
-    cairo_surface_destroy (surface);
-    _cairo_pattern_fini (&source.base);
-
-    return TRUE;
-}
-
-static void
-xr_composite_rects (CARD8		 render_op,
-		    PicturePtr		 picture,
-		    xRenderColor	*xColor,
-		    int			 nrect,
-		    xRectangle		*rect)
-{
-    cairo_operator_t op;
-    cairo_clip_t clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-
-    if (! _render_operator (render_op, &op))
-	goto fallback;
-
-    surface = xr_drawable_get_surface (picture->pDrawable);
-    xr_picture_get_clip (picture, &clip);
-    if (clip.path == NULL && nrect == 1 &&
-	rect->x <= 0 &&
-	rect->y <= 0 &&
-	rect->width >= picture->pDrawable->width &&
-	rect->height >= picture->pDrawable->height &&
-	(op == CAIRO_OPERATOR_CLEAR || (op == CAIRO_OPERATOR_SOURCE && xColor->alpha <= 0x00ff)))
-    {
-	status = _cairo_surface_paint (surface,
-				       CAIRO_OPERATOR_CLEAR,
-				       &_cairo_pattern_clear.base,
-				       NULL);
-    }
-    else
-    {
-	cairo_path_fixed_t path;
-	cairo_fixed_t x_off, y_off;
-	cairo_solid_pattern_t pattern;
-	cairo_color_t color;
-	int n;
-
-	x_off = _cairo_fixed_from_int (picture->pDrawable->x);
-	y_off = _cairo_fixed_from_int (picture->pDrawable->y);
-	_cairo_path_fixed_init (&path);
-	for (n = 0; n < nrect; n++) {
-	    cairo_fixed_t x1 = x_off + _cairo_fixed_from_int (rect[n].x);
-	    cairo_fixed_t x2 = x1 + _cairo_fixed_from_int (rect[n].width);
-	    cairo_fixed_t y1 = y_off + _cairo_fixed_from_int (rect[n].y);
-	    cairo_fixed_t y2 = y1 + _cairo_fixed_from_int (rect[n].height);
-
-	    if (_cairo_path_fixed_move_to (&path, x1, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y2) ||
-		_cairo_path_fixed_line_to (&path, x1, y2) ||
-		_cairo_path_fixed_close_path (&path))
-	    {
-		goto err_path;
-	    }
-	}
-
-	color.red_short   = xColor->red;
-	color.green_short = xColor->green;
-	color.blue_short  = xColor->blue;
-	color.alpha_short = xColor->alpha;
-	if (color.alpha_short <= 0x00ff) {
-	    color.red_short = color.green_short = color.blue_short = 0;
-	    color.alpha = color.red = color.green = color.blue = 0.;
-	} else {
-	    color.alpha = color.alpha_short / (double) 0xffff;
-	    color.red   = color.red_short / (double) 0xffff / color.alpha;
-	    color.green = color.green_short / (double) 0xffff / color.alpha;
-	    color.blue  = color.blue_short / (double) 0xffff / color.alpha;
-	}
-	_cairo_pattern_init_solid (&pattern, &color, CAIRO_CONTENT_COLOR);
-
-	status = _cairo_surface_fill (surface, op,
-				      &pattern.base,
-				      &path,
-				      CAIRO_FILL_RULE_WINDING,
-				      1.,
-				      CAIRO_ANTIALIAS_DEFAULT,
-				      clip.path ? &clip : NULL);
-err_path:
-	_cairo_path_fixed_fini (&path);
-    }
-
-    cairo_surface_destroy (surface);
-    _cairo_clip_fini (&clip);
-
-    (void) status;
-    return;
-
-fallback:
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    {
-	cairo_surface_t *dst_image, *src_image;
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		fbTrapezoids (op, pSrc, pDst,
-			      maskFormat,
-			      xSrc, ySrc,
-			      ntrap, traps);
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-#endif
-    return;
-}
-
-static void
-xr_trapezoids (CARD8	    render_op,
-	       PicturePtr   pSrc,
-	       PicturePtr   pDst,
-	       PictFormatPtr maskFormat,
-	       INT16	    xSrc,
-	       INT16	    ySrc,
-	       int	    ntrap,
-	       xTrapezoid   *traps)
-{
-    cairo_path_fixed_t path;
-    cairo_operator_t op;
-    int src_x, src_y;
-
-    if (! _render_operator (render_op, &op))
-	goto fallback;
-
-    src_x = xSrc - (traps->left.p1.x >> 16);
-    src_y = ySrc - (traps->left.p1.y >> 16);
-
-    _cairo_path_fixed_init (&path);
-    while (ntrap--) {
-	if (traps->bottom > traps->top) {
-	    cairo_fixed_t x1, x2;
-	    cairo_fixed_t y1, y2;
-
-	    if (traps->left.p1.y != traps->top) {
-		double x;
-
-		x = _cairo_fixed_16_16_to_double (traps->left.p1.x) +
-		    _cairo_fixed_16_16_to_double (traps->left.p1.x - traps->left.p2.x) *
-		    _cairo_fixed_16_16_to_double (traps->top - traps->left.p2.y) /
-		    _cairo_fixed_16_16_to_double (traps->left.p1.y - traps->left.p2.y);
-
-		x1 = _cairo_fixed_from_double (x);
-	    } else {
-		x1 = _cairo_fixed_from_16_16 (traps->left.p1.x);
-	    }
-
-	    if (traps->right.p1.y != traps->top) {
-		double x;
-
-		x = _cairo_fixed_16_16_to_double (traps->right.p1.x) +
-		    _cairo_fixed_16_16_to_double (traps->right.p1.x - traps->right.p2.x) *
-		    _cairo_fixed_16_16_to_double (traps->top - traps->right.p2.y) /
-		    _cairo_fixed_16_16_to_double (traps->right.p1.y - traps->right.p2.y);
-
-		x2 = _cairo_fixed_from_double (x);
-	    } else {
-		x2 = _cairo_fixed_from_16_16 (traps->left.p2.x);
-	    }
-
-	    y1 = _cairo_fixed_from_16_16 (traps->top);
-	    y2 = _cairo_fixed_from_16_16 (traps->bottom);
-
-	    if (_cairo_path_fixed_move_to (&path, x1, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y1) ||
-		_cairo_path_fixed_line_to (&path, x2, y2) ||
-		_cairo_path_fixed_line_to (&path, x1, y2) ||
-		_cairo_path_fixed_close_path (&path))
-	    {
-		goto err_path;
-	    }
-	}
-
-	traps++;
-    }
-
-    if (! xr_do_fill (op, pSrc, pDst, src_x, src_y, &path)) {
-	_cairo_path_fixed_fini (&path);
-	goto fallback;
-    }
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-
-    return;
-
-fallback:
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    {
-	cairo_surface_t *dst_image, *src_image;
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		fbTrapezoids (op, pSrc, pDst,
-			      maskFormat,
-			      xSrc, ySrc,
-			      ntrap, traps);
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-#endif
-    return;
-}
-
-static void
-xr_triangles (CARD8	    render_op,
-	      PicturePtr	    pSrc,
-	      PicturePtr	    pDst,
-	      PictFormatPtr   maskFormat,
-	      INT16	    xSrc,
-	      INT16	    ySrc,
-	      int	     ntriangles,
-	      xTriangle	    *triangles)
-{
-    cairo_path_fixed_t path;
-    cairo_operator_t op;
-    int src_x, src_y;
-
-    if (! _render_operator (render_op, &op))
-	goto fallback;
-
-    src_x = xSrc - (triangles->p1.x >> 16);
-    src_y = ySrc - (triangles->p1.y >> 16);
-
-    _cairo_path_fixed_init (&path);
-    while (ntriangles--) {
-	if (_cairo_path_fixed_move_to (&path,
-				       _cairo_fixed_from_16_16 (triangles->p1.x),
-				       _cairo_fixed_from_16_16 (triangles->p1.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       _cairo_fixed_from_16_16 (triangles->p2.x),
-				       _cairo_fixed_from_16_16 (triangles->p2.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       _cairo_fixed_from_16_16 (triangles->p3.x),
-				       _cairo_fixed_from_16_16 (triangles->p3.y)) ||
-	    _cairo_path_fixed_close_path (&path))
-	{
-	    goto err_path;
-	}
-
-	triangles++;
-    }
-
-    if (! xr_do_fill (op, pSrc, pDst, src_x, src_y, &path)) {
-	_cairo_path_fixed_fini (&path);
-	goto fallback;
-    }
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-
-    return;
-
-fallback:
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    {
-	cairo_surface_t *dst_image, *src_image;
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		fbTriangles (op, pSrc, pDst,
-			     maskFormat,
-			     xSrc, ySrc,
-			     ntriangles, triangles);
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-#endif
-    return;
-}
-
-static void
-xr_tristrip (CARD8	    op,
-	     PicturePtr	    pSrc,
-	     PicturePtr	    pDst,
-	     PictFormatPtr    maskFormat,
-	     INT16	    xSrc,
-	     INT16	    ySrc,
-	     int		    npoints,
-	     xPointFixed	    *points)
-{
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    {
-	cairo_surface_t *dst_image, *src_image;
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		fbTriStrip (op, pSrc, pDst,
-			     maskFormat,
-			     xSrc, ySrc,
-			     npoints, points);
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-#endif
-}
-
-static void
-xr_trifan (CARD8		render_op,
-	   PicturePtr	pSrc,
-	   PicturePtr	pDst,
-	   PictFormatPtr	maskFormat,
-	   INT16		xSrc,
-	   INT16		ySrc,
-	   int		npoints,
-	   xPointFixed	*points)
-{
-    cairo_path_fixed_t path;
-    cairo_operator_t op;
-    int src_x, src_y;
-
-    if (! _render_operator (render_op, &op))
-	goto fallback;
-
-    src_x = xSrc - (points->x >> 16);
-    src_y = ySrc - (points->y >> 16);
-
-    _cairo_path_fixed_init (&path);
-    points++;
-    while (--npoints) {
-	if (_cairo_path_fixed_line_to (&path,
-				       _cairo_fixed_from_16_16 (points->x),
-				       _cairo_fixed_from_16_16 (points->y)))
-	{
-	    goto err_path;
-	}
-
-	points++;
-    }
-    if (_cairo_path_fixed_close_path (&path))
-	goto err_path;
-
-    if (! xr_do_fill (op, pSrc, pDst, src_x, src_y, &path)) {
-	_cairo_path_fixed_fini (&path);
-	goto fallback;
-    }
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-
-    return;
-
-fallback:
-    //ErrorF ("fallback: %s\n", __FUNCTION__);
-#if 0
-    {
-	cairo_surface_t *dst_image, *src_image;
-	if (xr_prepare_access (pDst->pDrawable, &dst_image)) {
-	    if (pSrc->pDrawable == NULL ||
-		xr_prepare_access (pSrc->pDrawable, &src_image))
-	    {
-		fbTriFan (op, pSrc, pDst,
-			     maskFormat,
-			     xSrc, ySrc,
-			     npoints, points);
-		if (pSrc->pDrawable)
-		    xr_finish_access (pSrc->pDrawable, src_image);
-	    }
-	    xr_finish_access (pDst->pDrawable, dst_image);
-	}
-    }
-#endif
-    return;
-}
-
-static void
-xr_add_triangles (PicturePtr picture,
-		  INT16 x_off, INT16 y_off,
-		  int ntriangle, xTriangle *triangles)
-{
-    cairo_path_fixed_t path;
-    cairo_clip_t clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-    int x, y;
-
-    x = _cairo_fixed_from_int (x_off);
-    y = _cairo_fixed_from_int (y_off);
-
-    _cairo_path_fixed_init (&path);
-    while (ntriangle--) {
-	if (_cairo_path_fixed_move_to (&path,
-				       x + _cairo_fixed_from_16_16 (triangles->p1.x),
-				       y + _cairo_fixed_from_16_16 (triangles->p1.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       x + _cairo_fixed_from_16_16 (triangles->p2.x),
-				       y + _cairo_fixed_from_16_16 (triangles->p2.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       x + _cairo_fixed_from_16_16 (triangles->p3.x),
-				       y + _cairo_fixed_from_16_16 (triangles->p3.y)) ||
-	    _cairo_path_fixed_close_path (&path))
-	{
-	    goto err_path;
-	}
-
-	triangles++;
-    }
-
-    surface = xr_drawable_get_surface (picture->pDrawable);
-    xr_picture_get_clip (picture, &clip);
-    status = _cairo_surface_fill (surface,
-				  CAIRO_OPERATOR_ADD,
-				  &_cairo_pattern_white.base,
-				  &path,
-				  CAIRO_FILL_RULE_WINDING,
-				  picture->polyEdge == PolyEdgeSharp ? CAIRO_ANTIALIAS_NONE : CAIRO_ANTIALIAS_DEFAULT,
-				  CAIRO_GSTATE_TOLERANCE_DEFAULT,
-				  clip.path ? &clip : NULL);
-    _cairo_clip_fini (&clip);
-    cairo_surface_destroy (surface);
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-}
-
-static void
-xr_add_traps (PicturePtr picture,
-	      INT16 x_off, INT16 y_off,
-	      int ntrap, xTrap * traps)
-{
-    cairo_path_fixed_t path;
-    cairo_clip_t clip;
-    cairo_surface_t *surface;
-    cairo_status_t status;
-    int x, y;
-
-    x = _cairo_fixed_from_int (x_off);
-    y = _cairo_fixed_from_int (y_off);
-
-    _cairo_path_fixed_init (&path);
-    while (ntrap--) {
-	if (_cairo_path_fixed_move_to (&path,
-				       x + _cairo_fixed_from_16_16 (traps->top.l),
-				       y + _cairo_fixed_from_16_16 (traps->top.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       x + _cairo_fixed_from_16_16 (traps->top.r),
-				       y + _cairo_fixed_from_16_16 (traps->top.y)) ||
-	    _cairo_path_fixed_line_to (&path,
-				       x + _cairo_fixed_from_16_16 (traps->bot.r),
-				       y + _cairo_fixed_from_16_16 (traps->bot.y)) ||
-	    _cairo_path_fixed_move_to (&path,
-				       x + _cairo_fixed_from_16_16 (traps->bot.l),
-				       y + _cairo_fixed_from_16_16 (traps->bot.y)) ||
-	    _cairo_path_fixed_close_path (&path))
-	{
-	    goto err_path;
-	}
-
-	traps++;
-    }
-
-    surface = xr_drawable_get_surface (picture->pDrawable);
-    xr_picture_get_clip (picture, &clip);
-    status = _cairo_surface_fill (surface,
-				  CAIRO_OPERATOR_ADD,
-				  &_cairo_pattern_white.base,
-				  &path,
-				  CAIRO_FILL_RULE_WINDING,
-				  picture->polyEdge == PolyEdgeSharp ? CAIRO_ANTIALIAS_NONE : CAIRO_ANTIALIAS_DEFAULT,
-				  CAIRO_GSTATE_TOLERANCE_DEFAULT,
-				  clip.path ? &clip : NULL);
-    _cairo_clip_fini (&clip);
-    cairo_surface_destroy (surface);
-
-err_path:
-    _cairo_path_fixed_fini (&path);
-}
-
-static Bool
-xr_realize_glyph (ScreenPtr screen, GlyphPtr glyph)
-{
-    return TRUE;
-}
-
-static void
-xr_unrealize_glyph (ScreenPtr screen, GlyphPtr glyph)
-{
-}
-
-static PixmapPtr
-xr_create_pixmap (ScreenPtr screen,
-		  int w, int h, int depth,
-		  unsigned usage)
-{
-    xr_screen_t *xr = xr_get_screen (screen);
-    PixmapPtr pixmap;
-
-    if (w > 32767 || h > 32767)
-	return NullPixmap;
-
-    if (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE)
-	return fbCreatePixmap (screen, w, h, depth, usage);
-
-    if (w && h) {
-	cairo_surface_t *surface;
-	cairo_format_t format;
-
-	format = xr_format_for_depth (depth);
-	surface = cairo_drm_surface_create (xr->device, format, w, h);
-	if (unlikely (surface->status))
-	    goto fallback;
-
-	pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
-	screen->ModifyPixmapHeader (pixmap, w, h, 0, 0,
-				    cairo_drm_surface_get_stride (surface),
-				    NULL);
-	dixSetPrivate (&pixmap->devPrivates, &xr_pixmap_index, surface);
-    } else {
-fallback:
-	pixmap = fbCreatePixmap (screen, w, h, depth, usage);
-    }
-
-    return pixmap;
-}
-
-static Bool
-xr_destroy_pixmap (PixmapPtr pixmap)
-{
-	if (pixmap->refcnt == 1)
-	    cairo_surface_destroy (&xr_pixmap_get_drm_surface (pixmap)->base);
-
-	fbDestroyPixmap(pixmap);
-	return TRUE;
-}
-
-static Bool
-xr_close_screen (int i, ScreenPtr screen)
-{
-    xr_screen_t *xr = xr_get_screen(screen);
-
-    screen->CreateGC = xr->SavedCreateGC;
-    screen->CloseScreen = xr->SavedCloseScreen;
-    screen->GetImage = xr->SavedGetImage;
-    screen->GetSpans = xr->SavedGetSpans;
-    screen->CreatePixmap = xr->SavedCreatePixmap;
-    screen->DestroyPixmap = xr->SavedDestroyPixmap;
-    screen->CopyWindow = xr->SavedCopyWindow;
-    screen->ChangeWindowAttributes =
-	xr->SavedChangeWindowAttributes;
-    screen->BitmapToRegion = xr->SavedBitmapToRegion;
-#ifdef RENDER
-    {
-	PictureScreenPtr ps = GetPictureScreenIfSet(screen);
-	if (ps) {
-	    ps->Composite = xr->SavedComposite;
-	    ps->Glyphs = xr->SavedGlyphs;
-	    ps->CompositeRects = xr->SavedCompositeRects;
-	    ps->Trapezoids = xr->SavedTrapezoids;
-	    ps->Triangles = xr->SavedTriangles;
-	    ps->TriStrip = xr->SavedTriStrip;
-	    ps->TriFan = xr->SavedTriFan;
-	    ps->AddTriangles = xr->SavedAddTriangles;
-	    ps->AddTraps = xr->SavedAddTraps;
-	    ps->RealizeGlyph = xr->SavedRealizeGlyph;
-	    ps->UnrealizeGlyph = xr->SavedUnrealizeGlyph;
-	}
-    }
-#endif
-
-    cairo_device_destroy (xr->device);
-    xfree (xr);
-
-    return screen->CloseScreen (i, screen);
-}
-
-static void
-xr_block_handler (void *data, OSTimePtr timeout, void *last_select_mask)
-{
-    xr_screen_t *xr = data;
-
-    cairo_device_flush (xr->device);
-    cairo_drm_device_throttle (xr->device);
-}
-
-static void
-xr_wakeup_handler (void *data, int result, void *last_select_mask)
-{
-}
-
-xr_screen_t *
-cairo_drm_xr_enable (ScreenPtr screen, int fd)
-{
-    xr_screen_t *xr;
-    cairo_device_t *device;
-
-    device = cairo_drm_device_get_for_fd (fd);
-    if (device == NULL)
-	return NULL;
-
-    xr = malloc (sizeof (*xr));
-    if (unlikely (xr == NULL))
-	goto cleanup_device;
-
-    xr->device = device;
-    dixSetPrivate (&screen->devPrivates,
-		   &xr_screen_index,
-		   xr);
-
-    if (! dixRequestPrivate(&xr_pixmap_index, 0))
-	goto cleanup_driver;
-
-    if (! RegisterBlockAndWakeupHandlers (xr_block_handler,
-					  xr_wakeup_handler,
-					  xr))
-    {
-	goto cleanup_driver;
-    }
-
-    /* wrap the screen interfaces */
-    xr->SavedCloseScreen = screen->CloseScreen;
-    screen->CloseScreen = xr_close_screen;
-
-    xr->SavedCreateGC = screen->CreateGC;
-    screen->CreateGC = xr_create_gc;
-
-    xr->SavedGetImage = screen->GetImage;
-    screen->GetImage = xr_get_image;
-
-    xr->SavedGetSpans = screen->GetSpans;
-    screen->GetSpans = xr_get_spans;
-
-    xr->SavedCopyWindow = screen->CopyWindow;
-    screen->CopyWindow = xr_copy_window;
-
-    xr->SavedChangeWindowAttributes =
-	screen->ChangeWindowAttributes;
-    screen->ChangeWindowAttributes = xr_change_window_attributes;
-
-    xr->SavedBitmapToRegion = screen->BitmapToRegion;
-    screen->BitmapToRegion = xr_bitmap_to_region;
-
-#ifdef RENDER
-    {
-	PictureScreenPtr ps = GetPictureScreenIfSet(screen);
-	if (ps) {
-	    xr->SavedComposite = ps->Composite;
-	    ps->Composite = xr_composite;
-
-	    xr->SavedGlyphs = ps->Glyphs;
-	    ps->Glyphs = xr_glyphs;
-
-	    xr->SavedCompositeRects = ps->CompositeRects;
-	    ps->CompositeRects = xr_composite_rects;
-
-	    xr->SavedTrapezoids = ps->Trapezoids;
-	    ps->Trapezoids = xr_trapezoids;
-
-	    xr->SavedTriangles = ps->Triangles;
-	    ps->Triangles = xr_triangles;
-
-	    xr->SavedTriStrip = ps->TriStrip;
-	    ps->TriStrip = xr_tristrip;
-
-	    xr->SavedTriFan = ps->TriFan;
-	    ps->TriFan = xr_trifan;
-
-	    xr->SavedAddTriangles = ps->AddTriangles;
-	    ps->AddTriangles = xr_add_triangles;
-
-	    xr->SavedAddTraps = ps->AddTraps;
-	    ps->AddTraps = xr_add_traps;
-
-	    xr->SavedRealizeGlyph = ps->RealizeGlyph;
-	    ps->RealizeGlyph = xr_realize_glyph;
-
-	    xr->SavedUnrealizeGlyph = ps->UnrealizeGlyph;
-	    ps->UnrealizeGlyph = xr_unrealize_glyph;
-	}
-    }
-#endif
-
-#ifdef MITSHM
-#if 0
-    /* Re-register with the MI funcs, which don't allow shared pixmaps.
-     * Shared pixmaps are almost always a performance loss for us, but this
-     * still allows for SHM PutImage.
-     */
-    {
-	static ShmFuncs xr_shm_funcs = { NULL, NULL };
-	ShmRegisterFuncs (screen, &xr_shm_funcs);
-    }
-#endif
-#endif
-
-    screen->CreatePixmap = xr_create_pixmap;
-    screen->DestroyPixmap = xr_destroy_pixmap;
-
-    LogMessage (X_INFO,
-		"XR(%d): Driver registered support.\n", screen->myNum);
-
-    return xr;
-
-cleanup_driver:
-    free (xr);
-cleanup_device:
-    cairo_device_destroy (device);
-    return NULL;
-}
-
-void
-cairo_drm_xr_pixmap_link_bo (xr_screen_t *xr,
-			     PixmapPtr pixmap,
-			     uint32_t name,
-			     cairo_format_t format,
-			     int width,
-			     int height,
-			     int stride)
-{
-    cairo_surface_t *surface;
-
-    cairo_surface_destroy (dixLookupPrivate (&pixmap->devPrivates,
-					     &xr_pixmap_index));
-
-    surface = cairo_drm_surface_create_for_name (xr->device, name, format,
-						 width, height, stride);
-    dixSetPrivate (&pixmap->devPrivates, &xr_pixmap_index, surface);
-}
-
-void
-cairo_drm_xr_pixmap_unlink_bo (xr_screen_t *xr,
-			       PixmapPtr pixmap)
-{
-    cairo_surface_destroy (dixLookupPrivate (&pixmap->devPrivates,
-					     &xr_pixmap_index));
-
-    dixSetPrivate (&pixmap->devPrivates, &xr_pixmap_index, NULL);
-}


More information about the cairo-commit mailing list