[cairo-commit] 29 commits - boilerplate/cairo-boilerplate-beos.cpp boilerplate/cairo-boilerplate-beos-private.h boilerplate/cairo-boilerplate.c boilerplate/cairo-boilerplate-directfb.c boilerplate/cairo-boilerplate-directfb-private.h boilerplate/cairo-boilerplate-glitz.c boilerplate/cairo-boilerplate-glitz-private.h boilerplate/cairo-boilerplate.h boilerplate/cairo-boilerplate-pdf.c boilerplate/cairo-boilerplate-pdf-private.h boilerplate/cairo-boilerplate-ps.c boilerplate/cairo-boilerplate-ps-private.h boilerplate/cairo-boilerplate-quartz.c boilerplate/cairo-boilerplate-quartz-private.h boilerplate/cairo-boilerplate-svg.c boilerplate/cairo-boilerplate-svg-private.h boilerplate/cairo-boilerplate-test-surfaces.c boilerplate/cairo-boilerplate-test-surfaces-private.h boilerplate/cairo-boilerplate-win32.c boilerplate/cairo-boilerplate-win32-private.h boilerplate/cairo-boilerplate-xcb.c boilerplate/cairo-boilerplate-xcb-private.h boilerplate/cairo-boilerplate-xlib.c boilerplate/cairo-boilerplate-xlib-private.h boilerplate/cairo-quartz-boilerplate.c boilerplate/cairo-quartz-boilerplate-private.h boilerplate/cairo-test-beos.cpp boilerplate/cairo-test-beos.h boilerplate/cairo-test-directfb.c boilerplate/cairo-test-directfb.h boilerplate/Makefile.am boilerplate/xmalloc.c boilerplate/xmalloc.h src/cairo-directfb-surface.c test/cairo-test.c test/cairo-test.h

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Apr 19 21:52:07 PDT 2007


 boilerplate/Makefile.am                               |   55 
 boilerplate/cairo-boilerplate-beos-private.h          |   34 
 boilerplate/cairo-boilerplate-beos.cpp                |   58 
 boilerplate/cairo-boilerplate-directfb-private.h      |   23 
 boilerplate/cairo-boilerplate-directfb.c              |   50 
 boilerplate/cairo-boilerplate-glitz-private.h         |   73 
 boilerplate/cairo-boilerplate-glitz.c                 |  477 +++++
 boilerplate/cairo-boilerplate-pdf-private.h           |   23 
 boilerplate/cairo-boilerplate-pdf.c                   |  134 +
 boilerplate/cairo-boilerplate-ps-private.h            |   23 
 boilerplate/cairo-boilerplate-ps.c                    |  138 +
 boilerplate/cairo-boilerplate-quartz-private.h        |    8 
 boilerplate/cairo-boilerplate-quartz.c                |   25 
 boilerplate/cairo-boilerplate-svg-private.h           |   23 
 boilerplate/cairo-boilerplate-svg.c                   |  129 +
 boilerplate/cairo-boilerplate-test-surfaces-private.h |   63 
 boilerplate/cairo-boilerplate-test-surfaces.c         |  159 +
 boilerplate/cairo-boilerplate-win32-private.h         |   21 
 boilerplate/cairo-boilerplate-win32.c                 |   30 
 boilerplate/cairo-boilerplate-xcb-private.h           |   23 
 boilerplate/cairo-boilerplate-xcb.c                   |  115 +
 boilerplate/cairo-boilerplate-xlib-private.h          |   23 
 boilerplate/cairo-boilerplate-xlib.c                  |  196 ++
 boilerplate/cairo-boilerplate.c                       | 1532 +-----------------
 boilerplate/cairo-boilerplate.h                       |   40 
 boilerplate/cairo-test-beos.h                         |   34 
 boilerplate/cairo-test-directfb.h                     |   23 
 boilerplate/xmalloc.c                                 |   50 
 boilerplate/xmalloc.h                                 |    9 
 src/cairo-directfb-surface.c                          |    2 
 test/cairo-test.c                                     |   68 
 test/cairo-test.h                                     |    2 
 32 files changed, 2047 insertions(+), 1616 deletions(-)

New commits:
diff-tree abcd929c57459f95e93504e0ef07b012b497a363 (from 97624dc488b41eb83d70b2c44a595daa5d833e7f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:50:48 2007 -0400

    [boilerplate] Add cairo_boilerplate_format_from_content

diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
index d6df7fa..3b23aed 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -39,14 +39,7 @@ _cairo_boilerplate_quartz_create_surface
 {
     cairo_format_t format;
 
-    switch (content) {
-	case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
-	case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
-	case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
-	default:
-	    assert (0); /* not reached */
-	    return NULL;
-    }
+    format = cairo_boilerplate_format_from_content (content);
 
     *closure = NULL;
 
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index ab202d5..93ca5e7 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -128,18 +128,7 @@ _cairo_boilerplate_test_paginated_surfac
 
     tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
 
-    switch (tpc->content) {
-    case CAIRO_CONTENT_COLOR:
-	format = CAIRO_FORMAT_RGB24;
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	format = CAIRO_FORMAT_ARGB32;
-	break;
-    case CAIRO_CONTENT_ALPHA:
-    default:
-	assert (0); /* not reached */
-	return CAIRO_STATUS_NO_MEMORY;
-    }
+    format = cairo_boilerplate_format_from_content (tpc->content);
 
     image = cairo_image_surface_create_for_data (tpc->data,
 						 format,
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
index 3b95378..cd15873 100644
--- a/boilerplate/cairo-boilerplate-win32.c
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -39,13 +39,9 @@ _cairo_boilerplate_win32_create_surface 
 {
     cairo_format_t format;
 
-    if (content == CAIRO_CONTENT_COLOR)
-        format = CAIRO_FORMAT_RGB24;
-    else if (content == CAIRO_CONTENT_COLOR_ALPHA)
-        format = CAIRO_FORMAT_ARGB32;
-    else
-        return NULL;
+    format = cairo_boilerplate_format_from_content (content);
 
     *closure = NULL;
+
     return cairo_win32_surface_create_with_dib (format, width, height);
 }
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6165d7e..1f49e82 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -100,6 +100,24 @@ cairo_boilerplate_content_name (cairo_co
     }
 }
 
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content)
+{
+    cairo_format_t format;
+
+    switch (content) {
+	case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
+	case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
+	case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
+	default:
+	    assert (0); /* not reached */
+	    format = (cairo_format_t) -1;
+	    break;
+    }
+
+    return format;
+}
+
 static cairo_surface_t *
 _cairo_boilerplate_image_create_surface (const char			 *name,
 					 cairo_content_t		  content,
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index aa23e1c..9f0fc56 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -94,6 +94,9 @@
 const char *
 cairo_boilerplate_content_name (cairo_content_t content);
 
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content);
+
 typedef enum {
     CAIRO_BOILERPLATE_MODE_TEST,
     CAIRO_BOILERPLATE_MODE_PERF
diff-tree 97624dc488b41eb83d70b2c44a595daa5d833e7f (from 2e709321d858a048731eeaaca4a13a96de739e3f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:45:42 2007 -0400

    [boilerplate] Strip test-surfaces boilerplate into cairo-boilerplate-test-surfaces*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index b588a20..b541af3 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -56,6 +56,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
 endif
 
+if CAIRO_HAS_TEST_SURFACES
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-test-surfaces.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-test-surfaces-private.h
+endif
+
 if CAIRO_HAS_WIN32_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32-private.h
diff --git a/boilerplate/cairo-boilerplate-test-surfaces-private.h b/boilerplate/cairo-boilerplate-test-surfaces-private.h
new file mode 100644
index 0000000..1b82226
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-test-surfaces-private.h
@@ -0,0 +1,63 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_TEST_SURFACES_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_TEST_SURFACES_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_test_fallback_create_surface (const char			 *name,
+						 cairo_content_t		  content,
+						 int				  width,
+						 int				  height,
+						 cairo_boilerplate_mode_t	  mode,
+						 void				**closure);
+
+
+cairo_surface_t *
+_cairo_boilerplate_test_meta_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure);
+
+
+cairo_surface_t *
+_cairo_boilerplate_test_paginated_create_surface (const char			 *name,
+						  cairo_content_t		  content,
+						  int				  width,
+						  int				  height,
+						  cairo_boilerplate_mode_t	  mode,
+						  void				**closure);
+
+cairo_status_t
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
+						        const char	*filename);
+
+void
+_cairo_boilerplate_test_paginated_cleanup (void *closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
new file mode 100644
index 0000000..ab202d5
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -0,0 +1,170 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-test-surfaces-private.h"
+
+#include <test-fallback-surface.h>
+#include <test-meta-surface.h>
+#include <test-paginated-surface.h>
+
+#include <assert.h>
+
+cairo_surface_t *
+_cairo_boilerplate_test_fallback_create_surface (const char			 *name,
+						 cairo_content_t		  content,
+						 int				  width,
+						 int				  height,
+						 cairo_boilerplate_mode_t	  mode,
+						 void				**closure)
+{
+    *closure = NULL;
+    return _cairo_test_fallback_surface_create (content, width, height);
+}
+
+cairo_surface_t *
+_cairo_boilerplate_test_meta_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure)
+{
+    *closure = NULL;
+    return _cairo_test_meta_surface_create (content, width, height);
+}
+
+static const cairo_user_data_key_t test_paginated_closure_key;
+
+typedef struct {
+    unsigned char *data;
+    cairo_content_t content;
+    int width;
+    int height;
+    int stride;
+} test_paginated_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_test_paginated_create_surface (const char			 *name,
+						  cairo_content_t		  content,
+						  int				  width,
+						  int				  height,
+						  cairo_boilerplate_mode_t	  mode,
+						  void				**closure)
+{
+    test_paginated_closure_t *tpc;
+    cairo_surface_t *surface;
+
+    *closure = tpc = xmalloc (sizeof (test_paginated_closure_t));
+
+    tpc->content = content;
+    tpc->width = width;
+    tpc->height = height;
+    tpc->stride = width * 4;
+
+    tpc->data = xcalloc (tpc->stride * height, 1);
+
+    surface = _cairo_test_paginated_surface_create_for_data (tpc->data,
+						       tpc->content,
+						       tpc->width,
+						       tpc->height,
+						       tpc->stride);
+
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &test_paginated_closure_key,
+					     tpc, NULL);
+
+    return surface;
+}
+
+/* The only reason we go through all these machinations to write a PNG
+ * image is to _really ensure_ that the data actually landed in our
+ * buffer through the paginated surface to the test_paginated_surface.
+ *
+ * If we didn't implement this function then the default
+ * cairo_surface_write_to_png would result in the paginated_surface's
+ * acquire_source_image function replaying the meta-surface to an
+ * intermediate image surface. And in that case the
+ * test_paginated_surface would not be involved and wouldn't be
+ * tested.
+ */
+cairo_status_t
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
+						        const char	*filename)
+{
+    cairo_surface_t *image;
+    cairo_format_t format;
+    test_paginated_closure_t *tpc;
+    cairo_status_t status;
+
+    /* show page first.  the automatic show_page is too late for us */
+    /* XXX use cairo_surface_show_page() when that's added */
+    cairo_t *cr = cairo_create (surface);
+    cairo_show_page (cr);
+    cairo_destroy (cr);
+
+    tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
+
+    switch (tpc->content) {
+    case CAIRO_CONTENT_COLOR:
+	format = CAIRO_FORMAT_RGB24;
+	break;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	format = CAIRO_FORMAT_ARGB32;
+	break;
+    case CAIRO_CONTENT_ALPHA:
+    default:
+	assert (0); /* not reached */
+	return CAIRO_STATUS_NO_MEMORY;
+    }
+
+    image = cairo_image_surface_create_for_data (tpc->data,
+						 format,
+						 tpc->width,
+						 tpc->height,
+						 tpc->stride);
+
+    status = cairo_surface_write_to_png (image, filename);
+    if (status) {
+	CAIRO_BOILERPLATE_LOG ("Error writing %s: %s. Exiting\n",
+			       filename,
+			       cairo_status_to_string (status));
+	exit (1);
+    }
+
+    cairo_surface_destroy (image);
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_test_paginated_cleanup (void *closure)
+{
+    test_paginated_closure_t *tpc = closure;
+
+    free (tpc->data);
+    free (tpc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 57e8312..6165d7e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -47,6 +47,9 @@
 #if CAIRO_HAS_SVG_SURFACE
 #include "cairo-boilerplate-svg-private.h"
 #endif
+#ifdef CAIRO_HAS_TEST_SURFACES
+#include "cairo-boilerplate-test-surfaces-private.h"
+#endif
 #if CAIRO_HAS_WIN32_SURFACE
 #include "cairo-boilerplate-win32-private.h"
 #endif
@@ -120,149 +123,6 @@ _cairo_boilerplate_image_create_surface 
     return cairo_image_surface_create (format, width, height);
 }
 
-#ifdef CAIRO_HAS_TEST_SURFACES
-
-#include <test-fallback-surface.h>
-#include <test-meta-surface.h>
-#include <test-paginated-surface.h>
-
-static cairo_surface_t *
-_cairo_boilerplate_test_fallback_create_surface (const char			 *name,
-						 cairo_content_t		  content,
-						 int				  width,
-						 int				  height,
-						 cairo_boilerplate_mode_t	  mode,
-						 void				**closure)
-{
-    *closure = NULL;
-    return _cairo_test_fallback_surface_create (content, width, height);
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_test_meta_create_surface (const char			 *name,
-					     cairo_content_t		  content,
-					     int			  width,
-					     int			  height,
-					     cairo_boilerplate_mode_t	  mode,
-					     void			**closure)
-{
-    *closure = NULL;
-    return _cairo_test_meta_surface_create (content, width, height);
-}
-
-static const cairo_user_data_key_t test_paginated_closure_key;
-
-typedef struct {
-    unsigned char *data;
-    cairo_content_t content;
-    int width;
-    int height;
-    int stride;
-} test_paginated_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_test_paginated_create_surface (const char			 *name,
-						  cairo_content_t		  content,
-						  int				  width,
-						  int				  height,
-						  cairo_boilerplate_mode_t	  mode,
-						  void				**closure)
-{
-    test_paginated_closure_t *tpc;
-    cairo_surface_t *surface;
-
-    *closure = tpc = xmalloc (sizeof (test_paginated_closure_t));
-
-    tpc->content = content;
-    tpc->width = width;
-    tpc->height = height;
-    tpc->stride = width * 4;
-
-    tpc->data = xcalloc (tpc->stride * height, 1);
-
-    surface = _cairo_test_paginated_surface_create_for_data (tpc->data,
-						       tpc->content,
-						       tpc->width,
-						       tpc->height,
-						       tpc->stride);
-
-    cairo_boilerplate_surface_set_user_data (surface,
-					     &test_paginated_closure_key,
-					     tpc, NULL);
-
-    return surface;
-}
-
-/* The only reason we go through all these machinations to write a PNG
- * image is to _really ensure_ that the data actually landed in our
- * buffer through the paginated surface to the test_paginated_surface.
- *
- * If we didn't implement this function then the default
- * cairo_surface_write_to_png would result in the paginated_surface's
- * acquire_source_image function replaying the meta-surface to an
- * intermediate image surface. And in that case the
- * test_paginated_surface would not be involved and wouldn't be
- * tested.
- */
-static cairo_status_t
-_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
-						        const char	*filename)
-{
-    cairo_surface_t *image;
-    cairo_format_t format;
-    test_paginated_closure_t *tpc;
-    cairo_status_t status;
-
-    /* show page first.  the automatic show_page is too late for us */
-    /* XXX use cairo_surface_show_page() when that's added */
-    cairo_t *cr = cairo_create (surface);
-    cairo_show_page (cr);
-    cairo_destroy (cr);
-
-    tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
-
-    switch (tpc->content) {
-    case CAIRO_CONTENT_COLOR:
-	format = CAIRO_FORMAT_RGB24;
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	format = CAIRO_FORMAT_ARGB32;
-	break;
-    case CAIRO_CONTENT_ALPHA:
-    default:
-	assert (0); /* not reached */
-	return CAIRO_STATUS_NO_MEMORY;
-    }
-
-    image = cairo_image_surface_create_for_data (tpc->data,
-						 format,
-						 tpc->width,
-						 tpc->height,
-						 tpc->stride);
-
-    status = cairo_surface_write_to_png (image, filename);
-    if (status) {
-	CAIRO_BOILERPLATE_LOG ("Error writing %s: %s. Exiting\n",
-			       filename,
-			       cairo_status_to_string (status));
-	exit (1);
-    }
-
-    cairo_surface_destroy (image);
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_test_paginated_cleanup (void *closure)
-{
-    test_paginated_closure_t *tpc = closure;
-
-    free (tpc->data);
-    free (tpc);
-}
-
-#endif
 
 static cairo_boilerplate_target_t targets[] =
 {
diff-tree 2e709321d858a048731eeaaca4a13a96de739e3f (from 5331445c12756293a915420a26ab5553fc7db3fc)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:34:51 2007 -0400

    [boilerplate] Move xasprintf to xmalloc.c

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6df0c8f..57e8312 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -57,9 +57,7 @@
 #include "cairo-boilerplate-xlib-private.h"
 #endif
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
 #include <ctype.h>
 #include <assert.h>
 
@@ -558,46 +556,3 @@ cairo_boilerplate_surface_set_user_data 
 	exit (1);
     }
 }
-
-void
-xasprintf (char **strp, const char *fmt, ...)
-{
-#ifdef HAVE_VASPRINTF
-    va_list va;
-    int ret;
-
-    va_start (va, fmt);
-    ret = vasprintf (strp, fmt, va);
-    va_end (va);
-
-    if (ret < 0) {
-	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
-	exit (1);
-    }
-#else /* !HAVE_VASNPRINTF */
-#define BUF_SIZE 1024
-    va_list va;
-    char buffer[BUF_SIZE];
-    int ret;
-
-    va_start (va, fmt);
-    ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
-    va_end (va);
-
-    if (ret < 0) {
-	CAIRO_BOILERPLATE_LOG ("Failure in vsnprintf\n");
-	exit (1);
-    }
-
-    if (strlen (buffer) == sizeof(buffer) - 1) {
-	CAIRO_BOILERPLATE_LOG ("Overflowed fixed buffer\n");
-	exit (1);
-    }
-
-    *strp = strdup (buffer);
-    if (!*strp) {
-	CAIRO_BOILERPLATE_LOG ("Out of memory\n");
-	exit (1);
-    }
-#endif /* !HAVE_VASNPRINTF */
-}
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 5b4c217..aa23e1c 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -67,18 +67,16 @@
 #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
 #endif
 
-#include "xmalloc.h"
-
 #ifndef CAIRO_BOILERPLATE_LOG
 #define CAIRO_BOILERPLATE_LOG(...) fprintf(stderr, __VA_ARGS__)
 #endif
 
-/* A fake format we use for the flattened ARGB output of the PS and
- * PDF surfaces. */
-#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
-
-const char *
-cairo_boilerplate_content_name (cairo_content_t content);
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
+	__attribute__((__format__(__printf__, fmt_index, va_index)))
+#else
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)
+#endif
 
 #ifndef FALSE
 #define FALSE 0
@@ -88,6 +86,14 @@ cairo_boilerplate_content_name (cairo_co
 #define TRUE 1
 #endif
 
+
+/* A fake format we use for the flattened ARGB output of the PS and
+ * PDF surfaces. */
+#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
+
+const char *
+cairo_boilerplate_content_name (cairo_content_t content);
+
 typedef enum {
     CAIRO_BOILERPLATE_MODE_TEST,
     CAIRO_BOILERPLATE_MODE_PERF
@@ -130,20 +136,12 @@ cairo_boilerplate_get_targets (int *num_
 void
 cairo_boilerplate_free_targets (cairo_boilerplate_target_t **targets);
 
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
-	__attribute__((__format__(__printf__, fmt_index, va_index)))
-#else
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
-#endif
-
 void
 cairo_boilerplate_surface_set_user_data (cairo_surface_t		*surface,
 					 const cairo_user_data_key_t	*key,
 					 void				*user_data,
 					 cairo_destroy_func_t		 destroy);
 
-void
-xasprintf (char **strp, const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3);
+#include "xmalloc.h"
 
 #endif
diff --git a/boilerplate/xmalloc.c b/boilerplate/xmalloc.c
index 8da0568..ddd5ccc 100644
--- a/boilerplate/xmalloc.c
+++ b/boilerplate/xmalloc.c
@@ -23,12 +23,13 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include <stdio.h>
-#include <stdlib.h>
-
 #include "cairo-boilerplate.h"
 #include "xmalloc.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
 void *
 xmalloc (size_t size)
 {
@@ -68,3 +69,46 @@ xrealloc (void *buf, size_t size)
 
     return buf;
 }
+
+void
+xasprintf (char **strp, const char *fmt, ...)
+{
+#ifdef HAVE_VASPRINTF
+    va_list va;
+    int ret;
+
+    va_start (va, fmt);
+    ret = vasprintf (strp, fmt, va);
+    va_end (va);
+
+    if (ret < 0) {
+	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
+	exit (1);
+    }
+#else /* !HAVE_VASNPRINTF */
+#define BUF_SIZE 1024
+    va_list va;
+    char buffer[BUF_SIZE];
+    int ret;
+
+    va_start (va, fmt);
+    ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
+    va_end (va);
+
+    if (ret < 0) {
+	CAIRO_BOILERPLATE_LOG ("Failure in vsnprintf\n");
+	exit (1);
+    }
+
+    if (strlen (buffer) == sizeof(buffer) - 1) {
+	CAIRO_BOILERPLATE_LOG ("Overflowed fixed buffer\n");
+	exit (1);
+    }
+
+    *strp = strdup (buffer);
+    if (!*strp) {
+	CAIRO_BOILERPLATE_LOG ("Out of memory\n");
+	exit (1);
+    }
+#endif /* !HAVE_VASNPRINTF */
+}
diff --git a/boilerplate/xmalloc.h b/boilerplate/xmalloc.h
index 1f0fadf..b0e891f 100644
--- a/boilerplate/xmalloc.h
+++ b/boilerplate/xmalloc.h
@@ -26,15 +26,22 @@
 #ifndef _XMALLOC_H_
 #define _XMALLOC_H_
 
-#include <stdlib.h>
+#include "cairo-boilerplate.h"
 
+#define xmalloc cairo_boilerplate_xmalloc
 void *
 xmalloc (size_t size);
 
+#define xcalloc cairo_boilerplate_xcalloc
 void *
 xcalloc (size_t nmemb, size_t size);
 
+#define xrealloc cairo_boilerplate_recalloc
 void *
 xrealloc (void *buf, size_t size);
 
+#define xasprintf cairo_boilerplate_xasprintf
+void
+xasprintf (char **strp, const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(2, 3);
+
 #endif
diff --git a/test/cairo-test.h b/test/cairo-test.h
index d3612ba..d7ed3a7 100755
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -118,7 +118,7 @@ cairo_test_fini (void);
 
 /* Print a message to the log file, ala printf. */
 void
-cairo_test_log (const char *fmt, ...) CAIRO_PRINTF_FORMAT(1, 2);
+cairo_test_log (const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(1, 2);
 
 /* Helper functions that take care of finding source images even when
  * building in a non-srcdir manner, (ie. the tests will be run in a
diff-tree 5331445c12756293a915420a26ab5553fc7db3fc (from 56e916d40cf2a5f061347254657592f7bfc90d02)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:26:17 2007 -0400

    [boilerplate] Cleanup includes in cairo-boilerplate-beos.cpp

diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp
index 1815d63..2a84d1b 100644
--- a/boilerplate/cairo-boilerplate-beos.cpp
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -38,14 +38,6 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-// Part of this code was originally part of
-// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
-
-#include <Application.h>
-#include <Window.h>
-#include <View.h>
-#include <Bitmap.h>
-
 // BeOS's C++ compiler does not support varargs in macros
 // So, define CAIRO_BOILERPLATE_LOG here
 #define CAIRO_BOILERPLATE_LOG cairo_beos_boilerplate_log
@@ -53,9 +45,17 @@
 extern "C" {
 #include "cairo-boilerplate.h"
 }
-
 #include "cairo-boilerplate-beos-private.h"
-#include "cairo-beos.h"
+
+#include <cairo-beos.h>
+
+// Part of this code was originally part of
+// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
+
+#include <Application.h>
+#include <Window.h>
+#include <View.h>
+#include <Bitmap.h>
 
 static int cairo_beos_boilerplate_log(const char* format, ...) {
     va_list args;
diff-tree 56e916d40cf2a5f061347254657592f7bfc90d02 (from 06718b0da642d39b7b4dbfc009f08acb24e5e802)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:25:44 2007 -0400

    [boilerplate] Fix typos in cairo-boilerplate-glitz.c

diff --git a/boilerplate/cairo-boilerplate-glitz.c b/boilerplate/cairo-boilerplate-glitz.c
index 15fa97c..9ef7115 100644
--- a/boilerplate/cairo-boilerplate-glitz.c
+++ b/boilerplate/cairo-boilerplate-glitz.c
@@ -25,7 +25,7 @@
  */
 
 #include "cairo-boilerplate.h"
-#include "cairo-boilerplate-xlib-private.h"
+#include "cairo-boilerplate-glitz-private.h"
 
 #include <cairo-glitz.h>
 
@@ -47,7 +47,7 @@ typedef struct _glitz_glx_target_closure
     Window          win;
 } glitz_glx_target_closure_t;
 
-glitz_surface_t *
+static glitz_surface_t *
 _cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t		 formatname,
 						      int				 width,
 						      int				 height,
diff-tree 06718b0da642d39b7b4dbfc009f08acb24e5e802 (from 99737a60cb8cae1643b84782768e8c6d50ac7d0a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:15:19 2007 -0400

    [boilerplate] Remove leftover call to cairo_test_log

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 1e39818..6df0c8f 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -571,7 +571,7 @@ xasprintf (char **strp, const char *fmt,
     va_end (va);
 
     if (ret < 0) {
-	cairo_test_log ("Out of memory\n");
+	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
 	exit (1);
     }
 #else /* !HAVE_VASNPRINTF */
diff-tree 99737a60cb8cae1643b84782768e8c6d50ac7d0a (from 4b569f13d758015f33ad258a70ad4f472da771ed)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:13:25 2007 -0400

    [boilerplate] Clean up includes and remove unnecessary ones

diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c
index 1e903dc..894672d 100644
--- a/boilerplate/cairo-boilerplate-directfb.c
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -9,13 +9,14 @@ make check
 
 */
 
-#include <stdio.h>
-#include <stdlib.h>
 #include "cairo-boilerplate.h"
-#include <directfb.h>
-#include "cairo-directfb.h"
 #include "cairo-boilerplate-directfb-private.h"
 
+#include <cairo-directfb.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
 /* macro for a safe call to DirectFB functions */
 #define DFBCHECK(x...) \
 {                                                                \
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 0b1dec0..13f9ef8 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -27,7 +27,7 @@
 #include "cairo-boilerplate.h"
 #include "cairo-boilerplate-pdf-private.h"
 
-#include "cairo-pdf.h"
+#include <cairo-pdf.h>
 
 cairo_user_data_key_t pdf_closure_key;
 
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index 8193031..cc344c9 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -27,7 +27,7 @@
 #include "cairo-boilerplate.h"
 #include "cairo-boilerplate-svg-private.h"
 
-#include "cairo-svg.h"
+#include <cairo-svg.h>
 
 cairo_user_data_key_t	svg_closure_key;
 
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index 2cc88cd..1a74d18 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -27,7 +27,7 @@
 #include "cairo-boilerplate.h"
 #include "cairo-boilerplate-xcb-private.h"
 
-#include "cairo-xcb-xrender.h"
+#include <cairo-xcb-xrender.h>
 
 #include <xcb/xcb_renderutil.h>
 
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index e1d4bb2..1e39818 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -26,24 +26,6 @@
 
 #include "cairo-boilerplate.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <setjmp.h>
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#include <assert.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-#include <string.h>
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
-
 #if CAIRO_HAS_BEOS_SURFACE
 #include "cairo-boilerplate-beos-private.h"
 #endif
@@ -75,6 +57,12 @@
 #include "cairo-boilerplate-xlib-private.h"
 #endif
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <assert.h>
+
 /* This is copied from cairoint.h. That makes it painful to keep in
  * sync, but the slim stuff makes cairoint.h "hard" to include when
  * not actually building the cairo library itself. Fortunately, since
@@ -136,9 +124,9 @@ _cairo_boilerplate_image_create_surface 
 
 #ifdef CAIRO_HAS_TEST_SURFACES
 
-#include "test-fallback-surface.h"
-#include "test-meta-surface.h"
-#include "test-paginated-surface.h"
+#include <test-fallback-surface.h>
+#include <test-meta-surface.h>
+#include <test-paginated-surface.h>
 
 static cairo_surface_t *
 _cairo_boilerplate_test_fallback_create_surface (const char			 *name,
diff-tree 4b569f13d758015f33ad258a70ad4f472da771ed (from 0a03d66fffe7388d8fb4ffdb7bb5501a214c6342)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Apr 20 00:08:44 2007 -0400

    [boilerplate] Strip win32 boilerplate into cairo-boilerplate-win32*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 4b0e899..b588a20 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -56,6 +56,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
 endif
 
+if CAIRO_HAS_WIN32_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32-private.h
+endif
+
 if CAIRO_HAS_XCB_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb-private.h
diff --git a/boilerplate/cairo-boilerplate-win32-private.h b/boilerplate/cairo-boilerplate-win32-private.h
new file mode 100644
index 0000000..7a6b0c1
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-win32-private.h
@@ -0,0 +1,38 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_WIN32_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_WIN32_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_win32_create_surface (const char			 *name,
+					 cairo_content_t		  content,
+					 int				  width,
+					 int				  height,
+					 cairo_boilerplate_mode_t	  mode,
+					 void				**closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
new file mode 100644
index 0000000..3b95378
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -0,0 +1,51 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-win32-private.h"
+
+#include <cairo-win32.h>
+
+cairo_surface_t *
+_cairo_boilerplate_win32_create_surface (const char			 *name,
+					 cairo_content_t		  content,
+					 int				  width,
+					 int				  height,
+					 cairo_boilerplate_mode_t	  mode,
+					 void				**closure)
+{
+    cairo_format_t format;
+
+    if (content == CAIRO_CONTENT_COLOR)
+        format = CAIRO_FORMAT_RGB24;
+    else if (content == CAIRO_CONTENT_COLOR_ALPHA)
+        format = CAIRO_FORMAT_ARGB32;
+    else
+        return NULL;
+
+    *closure = NULL;
+    return cairo_win32_surface_create_with_dib (format, width, height);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 5b7b432..e1d4bb2 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -65,12 +65,15 @@
 #if CAIRO_HAS_SVG_SURFACE
 #include "cairo-boilerplate-svg-private.h"
 #endif
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
-#include "cairo-boilerplate-xlib-private.h"
+#if CAIRO_HAS_WIN32_SURFACE
+#include "cairo-boilerplate-win32-private.h"
 #endif
 #if CAIRO_HAS_XCB_SURFACE
 #include "cairo-boilerplate-xcb-private.h"
 #endif
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+#include "cairo-boilerplate-xlib-private.h"
+#endif
 
 /* This is copied from cairoint.h. That makes it painful to keep in
  * sync, but the slim stuff makes cairoint.h "hard" to include when
@@ -275,30 +278,6 @@ _cairo_boilerplate_test_paginated_cleanu
 
 #endif
 
-#if CAIRO_HAS_WIN32_SURFACE
-#include "cairo-win32.h"
-static cairo_surface_t *
-_cairo_boilerplate_win32_create_surface (const char			 *name,
-					 cairo_content_t		  content,
-					 int				  width,
-					 int				  height,
-					 cairo_boilerplate_mode_t	  mode,
-					 void				**closure)
-{
-    cairo_format_t format;
-
-    if (content == CAIRO_CONTENT_COLOR)
-        format = CAIRO_FORMAT_RGB24;
-    else if (content == CAIRO_CONTENT_COLOR_ALPHA)
-        format = CAIRO_FORMAT_ARGB32;
-    else
-        return NULL;
-
-    *closure = NULL;
-    return cairo_win32_surface_create_with_dib (format, width, height);
-}
-#endif
-
 static cairo_boilerplate_target_t targets[] =
 {
     /* I'm uncompromising about leaving the image backend as 0
diff-tree 0a03d66fffe7388d8fb4ffdb7bb5501a214c6342 (from 5ee882d3941a9df61d539e056933564a758a6bbc)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 23:58:51 2007 -0400

    [boilerplate] Rename create_win32_surface to _cairo_boilerplate_win32_create_surface

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 04b765c..5b7b432 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -275,18 +275,15 @@ _cairo_boilerplate_test_paginated_cleanu
 
 #endif
 
-/* Testing the win32 surface isn't interesting, since for
- * ARGB images it just chains to the image backend
- */
 #if CAIRO_HAS_WIN32_SURFACE
 #include "cairo-win32.h"
 static cairo_surface_t *
-create_win32_surface (const char		 *name,
-		      cairo_content_t		  content,
-		      int			  width,
-		      int			  height,
-		      cairo_boilerplate_mode_t	  mode,
-		      void			**closure)
+_cairo_boilerplate_win32_create_surface (const char			 *name,
+					 cairo_content_t		  content,
+					 int				  width,
+					 int				  height,
+					 cairo_boilerplate_mode_t	  mode,
+					 void				**closure)
 {
     cairo_format_t format;
 
@@ -385,10 +382,13 @@ static cairo_boilerplate_target_t target
 #endif
 #if CAIRO_HAS_WIN32_SURFACE
     { "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
-      create_win32_surface,
+      _cairo_boilerplate_win32_create_surface,
       cairo_surface_write_to_png },
+    /* Testing the win32 surface isn't interesting, since for
+     * ARGB images it just chains to the image backend
+     */
     { "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
-      create_win32_surface,
+      _cairo_boilerplate_win32_create_surface,
       cairo_surface_write_to_png },
 #endif
 #if CAIRO_HAS_XCB_SURFACE
diff-tree 5ee882d3941a9df61d539e056933564a758a6bbc (from a684fd80e750bea5661262e29a59c4f8c4d9cee3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 23:53:34 2007 -0400

    [boilerplate] Remove empty cleanup_win32

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 7b8a41e..04b765c 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -300,11 +300,6 @@ create_win32_surface (const char		 *name
     *closure = NULL;
     return cairo_win32_surface_create_with_dib (format, width, height);
 }
-
-static void
-cleanup_win32 (void *closure)
-{
-}
 #endif
 
 static cairo_boilerplate_target_t targets[] =
@@ -391,12 +386,10 @@ static cairo_boilerplate_target_t target
 #if CAIRO_HAS_WIN32_SURFACE
     { "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
       create_win32_surface,
-      cairo_surface_write_to_png,
-      cleanup_win32 },
+      cairo_surface_write_to_png },
     { "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
       create_win32_surface,
-      cairo_surface_write_to_png,
-      cleanup_win32 },
+      cairo_surface_write_to_png },
 #endif
 #if CAIRO_HAS_XCB_SURFACE
     /* Acceleration architectures may make the results differ by a
diff-tree a684fd80e750bea5661262e29a59c4f8c4d9cee3 (from 23e6abc3fc01e3d722adfc48cd1df9c8db73adc1)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 23:36:00 2007 -0400

    [directfb] Silence compiler warning

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index f6e1c01..4a62846 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -333,7 +333,7 @@ _directfb_acquire_surface (cairo_directf
     cairo_format_t            cairo_format;
     cairo_format = surface->format;    
         
-    if (surface->format == -1) {
+    if (surface->format == (cairo_format_t) -1) {
         if( intrest_rec ) {
             source_rect.x = intrest_rec->x;
             source_rect.y = intrest_rec->y;
diff-tree 23e6abc3fc01e3d722adfc48cd1df9c8db73adc1 (from 7d576a376706aad427915b4872429f5605104886)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:40:52 2007 -0400

    [boilerplate] Strip glitz boilerplate into cairo-boilerplate-glitz*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 1e85c40..4b0e899 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,23 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
 endif
 
+if CAIRO_HAS_GLITZ_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-glitz.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-glitz-private.h
+if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS)
+endif
+endif
+
 if CAIRO_HAS_PDF_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf-private.h
@@ -49,19 +66,6 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
 endif
 
-if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS)
-endif
-
 # We're using _GNU_SOURCE to get the prototype for asprintf. This may
 # not be the most portable approach, but it is pragmatic and I'm
 # willing to do something cleaner as soon as it causes someone a
diff --git a/boilerplate/cairo-boilerplate-glitz-private.h b/boilerplate/cairo-boilerplate-glitz-private.h
new file mode 100644
index 0000000..e2b27fd
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-glitz-private.h
@@ -0,0 +1,73 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_GLITZ_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_GLITZ_PRIVATE_H_
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure);
+
+void
+_cairo_boilerplate_glitz_glx_cleanup (void *closure);
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure);
+
+void
+_cairo_boilerplate_glitz_agl_cleanup (void *closure);
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure);
+
+void
+_cairo_boilerplate_glitz_wgl_cleanup (void *closure);
+#endif
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-glitz.c b/boilerplate/cairo-boilerplate-glitz.c
new file mode 100644
index 0000000..15fa97c
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-glitz.c
@@ -0,0 +1,477 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-xlib-private.h"
+
+#include <cairo-glitz.h>
+
+static const cairo_user_data_key_t glitz_closure_key;
+
+typedef struct _glitz_target_closure_base {
+    int width;
+    int height;
+    cairo_content_t content;
+} glitz_target_closure_base_t;
+
+#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+#include <glitz-glx.h>
+
+typedef struct _glitz_glx_target_closure {
+    glitz_target_closure_base_t base;
+    Display        *dpy;
+    int             scr;
+    Window          win;
+} glitz_glx_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t		 formatname,
+						      int				 width,
+						      int				 height,
+						      glitz_glx_target_closure_t	*closure)
+{
+    Display                 * dpy = closure->dpy;
+    int                       scr = closure->scr;
+    glitz_drawable_format_t   templ;
+    glitz_drawable_format_t * dformat = NULL;
+    unsigned long             mask;
+    glitz_drawable_t        * drawable = NULL;
+    glitz_format_t          * format;
+    glitz_surface_t         * sr;
+
+    XSizeHints                xsh;
+    XSetWindowAttributes      xswa;
+    XVisualInfo             * vinfo;
+
+    memset(&templ, 0, sizeof(templ));
+    templ.color.red_size = 8;
+    templ.color.green_size = 8;
+    templ.color.blue_size = 8;
+    templ.color.alpha_size = 8;
+    templ.color.fourcc = GLITZ_FOURCC_RGB;
+    templ.samples = 1;
+
+    glitz_glx_init (NULL);
+
+    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+	GLITZ_FORMAT_BLUE_SIZE_MASK;
+    if (formatname == GLITZ_STANDARD_ARGB32)
+	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+    /* Try for a pbuffer first */
+    if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
+	dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
+
+    if (dformat) {
+	closure->win = None;
+
+	drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
+						      width, height);
+	if (!drawable)
+	    goto FAIL;
+    } else {
+	/* No pbuffer, try window */
+	dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
+
+	if (!dformat)
+	    goto FAIL;
+
+	vinfo = glitz_glx_get_visual_info_from_format(dpy,
+						      DefaultScreen(dpy),
+						      dformat);
+
+	if (!vinfo)
+	    goto FAIL;
+
+	xsh.flags = PSize;
+	xsh.x = 0;
+	xsh.y = 0;
+	xsh.width = width;
+	xsh.height = height;
+
+	xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
+					 vinfo->visual, AllocNone);
+	closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
+				      xsh.x, xsh.y, xsh.width, xsh.height,
+				      0, vinfo->depth, CopyFromParent,
+				      vinfo->visual, CWColormap, &xswa);
+	XFree (vinfo);
+
+	drawable =
+	    glitz_glx_create_drawable_for_window (dpy, scr,
+						  dformat, closure->win,
+						  width, height);
+
+	if (!drawable)
+	    goto DESTROY_WINDOW;
+    }
+
+    format = glitz_find_standard_format (drawable, formatname);
+    if (!format)
+	goto DESTROY_DRAWABLE;
+
+    sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
+    if (!sr)
+	goto DESTROY_DRAWABLE;
+
+    if (closure->win == None || dformat->doublebuffer) {
+	glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
+    } else {
+	XMapWindow (closure->dpy, closure->win);
+	glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+    }
+
+    glitz_drawable_destroy (drawable);
+
+    return sr;
+ DESTROY_DRAWABLE:
+    glitz_drawable_destroy (drawable);
+ DESTROY_WINDOW:
+    if (closure->win)
+	XDestroyWindow (dpy, closure->win);
+ FAIL:
+    return NULL;
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
+					     cairo_content_t 		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure)
+{
+    glitz_glx_target_closure_t *gxtc;
+    glitz_surface_t  * glitz_surface;
+    cairo_surface_t  * surface;
+
+    *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));
+
+    if (width == 0)
+	width = 1;
+    if (height == 0)
+	height = 1;
+
+    gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
+    if (!gxtc->dpy) {
+	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+	goto FAIL;
+    }
+
+    XSynchronize (gxtc->dpy, 1);
+
+    gxtc->scr = DefaultScreen(gxtc->dpy);
+
+    switch (content) {
+    case CAIRO_CONTENT_COLOR:
+	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, gxtc);
+	break;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, gxtc);
+	break;
+    case CAIRO_CONTENT_ALPHA:
+    default:
+	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
+	goto FAIL_CLOSE_DISPLAY;
+    }
+    if (!glitz_surface) {
+	CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
+	goto FAIL_CLOSE_DISPLAY;
+    }
+
+    surface = cairo_glitz_surface_create (glitz_surface);
+
+    gxtc->base.width = width;
+    gxtc->base.height = height;
+    gxtc->base.content = content;
+    cairo_surface_set_user_data (surface, &glitz_closure_key,
+				 gxtc, NULL);
+
+    return surface;
+
+ FAIL_CLOSE_DISPLAY:
+    XCloseDisplay (gxtc->dpy);
+ FAIL:
+    return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_glx_cleanup (void *closure)
+{
+    glitz_glx_target_closure_t *gxtc = closure;
+
+    glitz_glx_fini ();
+
+    if (gxtc->win)
+	XDestroyWindow (gxtc->dpy, gxtc->win);
+
+    XCloseDisplay (gxtc->dpy);
+
+    free (gxtc);
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_GLX_SURFACE */
+
+#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+#include <glitz-agl.h>
+
+typedef struct _glitz_agl_target_closure {
+    glitz_target_closure_base_t base;
+} glitz_agl_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t		 formatname,
+						      int				 width,
+						      int				 height,
+						      glitz_agl_target_closure_t	*closure)
+{
+    glitz_drawable_format_t *dformat;
+    glitz_drawable_format_t templ;
+    glitz_drawable_t *gdraw;
+    glitz_format_t *format;
+    glitz_surface_t *sr = NULL;
+    unsigned long mask;
+
+    memset(&templ, 0, sizeof(templ));
+    templ.color.red_size = 8;
+    templ.color.green_size = 8;
+    templ.color.blue_size = 8;
+    templ.color.alpha_size = 8;
+    templ.color.fourcc = GLITZ_FOURCC_RGB;
+    templ.samples = 1;
+
+    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+	GLITZ_FORMAT_BLUE_SIZE_MASK;
+    if (formatname == GLITZ_STANDARD_ARGB32)
+	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+    dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
+    if (!dformat) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+	goto FAIL;
+    }
+
+    gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
+    if (!gdraw) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+	goto FAIL;
+    }
+
+    format = glitz_find_standard_format (gdraw, formatname);
+    if (!format) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+	goto DESTROY_DRAWABLE;
+    }
+
+    sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
+    if (!sr) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+	goto DESTROY_DRAWABLE;
+    }
+
+    glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+ DESTROY_DRAWABLE:
+    glitz_drawable_destroy (gdraw);
+
+ FAIL:
+    return sr; /* will be NULL unless we create it and attach */
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface (const char			 *name,
+					     cairo_content_t 		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure)
+{
+    glitz_surface_t *glitz_surface;
+    cairo_surface_t *surface;
+    glitz_agl_target_closure_t *aglc;
+
+    glitz_agl_init ();
+
+    *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t));
+
+    switch (content) {
+    case CAIRO_CONTENT_COLOR:
+	glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
+	break;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
+	break;
+    default:
+	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
+	goto FAIL;
+    }
+
+    if (!glitz_surface)
+	goto FAIL;
+
+    surface = cairo_glitz_surface_create (glitz_surface);
+
+    aglc->base.width = width;
+    aglc->base.height = height;
+    aglc->base.content = content;
+    cairo_surface_set_user_data (surface, &glitz_closure_key, aglc, NULL);
+
+    return surface;
+
+ FAIL:
+    return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_agl_cleanup (void *closure)
+{
+    free (closure);
+    glitz_agl_fini ();
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_AGL_SURFACE */
+
+#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+#include <glitz-wgl.h>
+
+typedef struct _glitz_wgl_target_closure {
+    glitz_target_closure_base_t base;
+} glitz_wgl_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t		 formatname,
+						      int				 width,
+						      int				 height,
+						      glitz_wgl_target_closure_t	*closure)
+{
+    glitz_drawable_format_t *dformat;
+    glitz_drawable_format_t templ;
+    glitz_drawable_t *gdraw;
+    glitz_format_t *format;
+    glitz_surface_t *sr = NULL;
+    unsigned long mask;
+
+    memset(&templ, 0, sizeof(templ));
+    templ.color.red_size = 8;
+    templ.color.green_size = 8;
+    templ.color.blue_size = 8;
+    templ.color.alpha_size = 8;
+    templ.color.fourcc = GLITZ_FOURCC_RGB;
+    templ.samples = 1;
+
+    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+	GLITZ_FORMAT_BLUE_SIZE_MASK;
+    if (formatname == GLITZ_STANDARD_ARGB32)
+	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+    dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
+    if (!dformat) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+	goto FAIL;
+    }
+
+    gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
+    if (!gdraw) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+	goto FAIL;
+    }
+
+    format = glitz_find_standard_format (gdraw, formatname);
+    if (!format) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+	goto DESTROY_DRAWABLE;
+    }
+
+    sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
+    if (!sr) {
+	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+	goto DESTROY_DRAWABLE;
+    }
+
+    glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+ DESTROY_DRAWABLE:
+    glitz_drawable_destroy (gdraw);
+
+ FAIL:
+    return sr; /* will be NULL unless we create it and attach */
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
+					     cairo_content_t		  content,
+					     int			  width,
+					     int			  height,
+					     cairo_boilerplate_mode_t	  mode,
+					     void			**closure)
+{
+    glitz_surface_t *glitz_surface;
+    cairo_surface_t *surface;
+    glitz_wgl_target_closure_t *wglc;
+
+    glitz_wgl_init (NULL);
+
+    *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));
+
+    switch (content) {
+    case CAIRO_CONTENT_COLOR:
+	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
+	break;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
+	break;
+    default:
+	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
+	goto FAIL;
+    }
+
+    if (!glitz_surface)
+	goto FAIL;
+
+    surface = cairo_glitz_surface_create (glitz_surface);
+
+    wglc->base.width = width;
+    wglc->base.height = height;
+    wglc->base.content = content;
+    cairo_surface_set_user_data (surface, &glitz_closure_key, wglc, NULL);
+
+    return surface;
+
+ FAIL:
+    return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_wgl_cleanup (void *closure)
+{
+    free (closure);
+    glitz_wgl_fini ();
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_WGL_SURFACE */
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 245d942..7b8a41e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -50,6 +50,9 @@
 #if CAIRO_HAS_DIRECTFB_SURFACE
 #include "cairo-boilerplate-directfb-private.h"
 #endif
+#if CAIRO_HAS_GLITZ_SURFACE
+#include "cairo-boilerplate-glitz-private.h"
+#endif
 #if CAIRO_HAS_PDF_SURFACE
 #include "cairo-boilerplate-pdf-private.h"
 #endif
@@ -272,459 +275,6 @@ _cairo_boilerplate_test_paginated_cleanu
 
 #endif
 
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-#include <glitz.h>
-#include <cairo-glitz.h>
-
-static const cairo_user_data_key_t glitz_closure_key;
-
-typedef struct _glitz_target_closure_base {
-    int width;
-    int height;
-    cairo_content_t content;
-} glitz_target_closure_base_t;
-
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-#include <glitz-glx.h>
-
-typedef struct _glitz_glx_target_closure {
-    glitz_target_closure_base_t base;
-    Display        *dpy;
-    int             scr;
-    Window          win;
-} glitz_glx_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_glx_create_surface (glitz_format_name_t	 formatname,
-					     int			 width,
-					     int			 height,
-					     glitz_glx_target_closure_t	*closure)
-{
-    Display                 * dpy = closure->dpy;
-    int                       scr = closure->scr;
-    glitz_drawable_format_t   templ;
-    glitz_drawable_format_t * dformat = NULL;
-    unsigned long             mask;
-    glitz_drawable_t        * drawable = NULL;
-    glitz_format_t          * format;
-    glitz_surface_t         * sr;
-
-    XSizeHints                xsh;
-    XSetWindowAttributes      xswa;
-    XVisualInfo             * vinfo;
-
-    memset(&templ, 0, sizeof(templ));
-    templ.color.red_size = 8;
-    templ.color.green_size = 8;
-    templ.color.blue_size = 8;
-    templ.color.alpha_size = 8;
-    templ.color.fourcc = GLITZ_FOURCC_RGB;
-    templ.samples = 1;
-
-    glitz_glx_init (NULL);
-
-    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
-	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
-	GLITZ_FORMAT_BLUE_SIZE_MASK;
-    if (formatname == GLITZ_STANDARD_ARGB32)
-	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
-    /* Try for a pbuffer first */
-    if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
-	dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
-
-    if (dformat) {
-	closure->win = None;
-
-	drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
-						      width, height);
-	if (!drawable)
-	    goto FAIL;
-    } else {
-	/* No pbuffer, try window */
-	dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
-
-	if (!dformat)
-	    goto FAIL;
-
-	vinfo = glitz_glx_get_visual_info_from_format(dpy,
-						      DefaultScreen(dpy),
-						      dformat);
-
-	if (!vinfo)
-	    goto FAIL;
-
-	xsh.flags = PSize;
-	xsh.x = 0;
-	xsh.y = 0;
-	xsh.width = width;
-	xsh.height = height;
-
-	xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
-					 vinfo->visual, AllocNone);
-	closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
-				      xsh.x, xsh.y, xsh.width, xsh.height,
-				      0, vinfo->depth, CopyFromParent,
-				      vinfo->visual, CWColormap, &xswa);
-	XFree (vinfo);
-
-	drawable =
-	    glitz_glx_create_drawable_for_window (dpy, scr,
-						  dformat, closure->win,
-						  width, height);
-
-	if (!drawable)
-	    goto DESTROY_WINDOW;
-    }
-
-    format = glitz_find_standard_format (drawable, formatname);
-    if (!format)
-	goto DESTROY_DRAWABLE;
-
-    sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
-    if (!sr)
-	goto DESTROY_DRAWABLE;
-
-    if (closure->win == None || dformat->doublebuffer) {
-	glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
-    } else {
-	XMapWindow (closure->dpy, closure->win);
-	glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-    }
-
-    glitz_drawable_destroy (drawable);
-
-    return sr;
- DESTROY_DRAWABLE:
-    glitz_drawable_destroy (drawable);
- DESTROY_WINDOW:
-    if (closure->win)
-	XDestroyWindow (dpy, closure->win);
- FAIL:
-    return NULL;
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_glx_create_surface (const char			 *name,
-						   cairo_content_t 		  content,
-						   int				  width,
-						   int				  height,
-						   cairo_boilerplate_mode_t	  mode,
-						   void				**closure)
-{
-    glitz_glx_target_closure_t *gxtc;
-    glitz_surface_t  * glitz_surface;
-    cairo_surface_t  * surface;
-
-    *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));
-
-    if (width == 0)
-	width = 1;
-    if (height == 0)
-	height = 1;
-
-    gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
-    if (!gxtc->dpy) {
-	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
-	goto FAIL;
-    }
-
-    XSynchronize (gxtc->dpy, 1);
-
-    gxtc->scr = DefaultScreen(gxtc->dpy);
-
-    switch (content) {
-    case CAIRO_CONTENT_COLOR:
-	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_RGB24, width, height, gxtc);
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_ARGB32, width, height, gxtc);
-	break;
-    case CAIRO_CONTENT_ALPHA:
-    default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
-	goto FAIL_CLOSE_DISPLAY;
-    }
-    if (!glitz_surface) {
-	CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
-	goto FAIL_CLOSE_DISPLAY;
-    }
-
-    surface = cairo_glitz_surface_create (glitz_surface);
-
-    gxtc->base.width = width;
-    gxtc->base.height = height;
-    gxtc->base.content = content;
-    cairo_surface_set_user_data (surface, &glitz_closure_key,
-				 gxtc, NULL);
-
-    return surface;
-
- FAIL_CLOSE_DISPLAY:
-    XCloseDisplay (gxtc->dpy);
- FAIL:
-    return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_glx_cleanup (void *closure)
-{
-    glitz_glx_target_closure_t *gxtc = closure;
-
-    glitz_glx_fini ();
-
-    if (gxtc->win)
-	XDestroyWindow (gxtc->dpy, gxtc->win);
-
-    XCloseDisplay (gxtc->dpy);
-
-    free (gxtc);
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_GLX_SURFACE */
-
-#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-#include <glitz-agl.h>
-
-typedef struct _glitz_agl_target_closure {
-    glitz_target_closure_base_t base;
-} glitz_agl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_agl_create_surface (glitz_format_name_t	 formatname,
-					     int			 width,
-					     int			 height,
-					     glitz_agl_target_closure_t	*closure)
-{
-    glitz_drawable_format_t *dformat;
-    glitz_drawable_format_t templ;
-    glitz_drawable_t *gdraw;
-    glitz_format_t *format;
-    glitz_surface_t *sr = NULL;
-    unsigned long mask;
-
-    memset(&templ, 0, sizeof(templ));
-    templ.color.red_size = 8;
-    templ.color.green_size = 8;
-    templ.color.blue_size = 8;
-    templ.color.alpha_size = 8;
-    templ.color.fourcc = GLITZ_FOURCC_RGB;
-    templ.samples = 1;
-
-    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
-	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
-	GLITZ_FORMAT_BLUE_SIZE_MASK;
-    if (formatname == GLITZ_STANDARD_ARGB32)
-	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
-    dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
-    if (!dformat) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
-	goto FAIL;
-    }
-
-    gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
-    if (!gdraw) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
-	goto FAIL;
-    }
-
-    format = glitz_find_standard_format (gdraw, formatname);
-    if (!format) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
-	goto DESTROY_DRAWABLE;
-    }
-
-    sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
-    if (!sr) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
-	goto DESTROY_DRAWABLE;
-    }
-
-    glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
-    glitz_drawable_destroy (gdraw);
-
- FAIL:
-    return sr; /* will be NULL unless we create it and attach */
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_agl_create_surface (const char			 *name,
-						   cairo_content_t 		  content,
-						   int				  width,
-						   int				  height,
-						   cairo_boilerplate_mode_t	  mode,
-						   void				**closure)
-{
-    glitz_surface_t *glitz_surface;
-    cairo_surface_t *surface;
-    glitz_agl_target_closure_t *aglc;
-
-    glitz_agl_init ();
-
-    *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t));
-
-    switch (content) {
-    case CAIRO_CONTENT_COLOR:
-	glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
-	break;
-    default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
-	goto FAIL;
-    }
-
-    if (!glitz_surface)
-	goto FAIL;
-
-    surface = cairo_glitz_surface_create (glitz_surface);
-
-    aglc->base.width = width;
-    aglc->base.height = height;
-    aglc->base.content = content;
-    cairo_surface_set_user_data (surface, &glitz_closure_key, aglc, NULL);
-
-    return surface;
-
- FAIL:
-    return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_agl_cleanup (void *closure)
-{
-    free (closure);
-    glitz_agl_fini ();
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_AGL_SURFACE */
-
-#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-#include <glitz-wgl.h>
-
-typedef struct _glitz_wgl_target_closure {
-    glitz_target_closure_base_t base;
-} glitz_wgl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_wgl_create_surface (glitz_format_name_t	 formatname,
-					     int			 width,
-					     int			 height,
-					     glitz_wgl_target_closure_t	*closure)
-{
-    glitz_drawable_format_t *dformat;
-    glitz_drawable_format_t templ;
-    glitz_drawable_t *gdraw;
-    glitz_format_t *format;
-    glitz_surface_t *sr = NULL;
-    unsigned long mask;
-
-    memset(&templ, 0, sizeof(templ));
-    templ.color.red_size = 8;
-    templ.color.green_size = 8;
-    templ.color.blue_size = 8;
-    templ.color.alpha_size = 8;
-    templ.color.fourcc = GLITZ_FOURCC_RGB;
-    templ.samples = 1;
-
-    mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
-	GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
-	GLITZ_FORMAT_BLUE_SIZE_MASK;
-    if (formatname == GLITZ_STANDARD_ARGB32)
-	mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
-    dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
-    if (!dformat) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
-	goto FAIL;
-    }
-
-    gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
-    if (!gdraw) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
-	goto FAIL;
-    }
-
-    format = glitz_find_standard_format (gdraw, formatname);
-    if (!format) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
-	goto DESTROY_DRAWABLE;
-    }
-
-    sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
-    if (!sr) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
-	goto DESTROY_DRAWABLE;
-    }
-
-    glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
-    glitz_drawable_destroy (gdraw);
-
- FAIL:
-    return sr; /* will be NULL unless we create it and attach */
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_wgl_create_surface (const char			 *name,
-						   cairo_content_t		  content,
-						   int				  width,
-						   int				  height,
-						   cairo_boilerplate_mode_t	  mode,
-						   void				**closure)
-{
-    glitz_surface_t *glitz_surface;
-    cairo_surface_t *surface;
-    glitz_wgl_target_closure_t *wglc;
-
-    glitz_wgl_init (NULL);
-
-    *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));
-
-    switch (content) {
-    case CAIRO_CONTENT_COLOR:
-	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
-	break;
-    default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
-	goto FAIL;
-    }
-
-    if (!glitz_surface)
-	goto FAIL;
-
-    surface = cairo_glitz_surface_create (glitz_surface);
-
-    wglc->base.width = width;
-    wglc->base.height = height;
-    wglc->base.content = content;
-    cairo_surface_set_user_data (surface, &glitz_closure_key, wglc, NULL);
-
-    return surface;
-
- FAIL:
-    return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_wgl_cleanup (void *closure)
-{
-    free (closure);
-    glitz_wgl_fini ();
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_WGL_SURFACE */
-
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
-
 /* Testing the win32 surface isn't interesting, since for
  * ARGB images it just chains to the image backend
  */
@@ -799,33 +349,33 @@ static cairo_boilerplate_target_t target
 #ifdef CAIRO_HAS_GLITZ_SURFACE
 #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
     { "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
-      _cairo_boilerplate_cairo_glitz_glx_create_surface,
+      _cairo_boilerplate_glitz_glx_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_glx_cleanup },
+      _cairo_boilerplate_glitz_glx_cleanup },
     { "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-      _cairo_boilerplate_cairo_glitz_glx_create_surface,
+      _cairo_boilerplate_glitz_glx_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_glx_cleanup },
+      _cairo_boilerplate_glitz_glx_cleanup },
 #endif
 #if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
     { "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
-      _cairo_boilerplate_cairo_glitz_agl_create_surface,
+      _cairo_boilerplate_glitz_agl_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_agl_cleanup },
+      _cairo_boilerplate_glitz_agl_cleanup },
     { "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-      _cairo_boilerplate_cairo_glitz_agl_create_surface,
+      _cairo_boilerplate_glitz_agl_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_agl_cleanup },
+      _cairo_boilerplate_glitz_agl_cleanup },
 #endif
 #if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
     { "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
-      _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+      _cairo_boilerplate_glitz_wgl_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_wgl_cleanup },
+      _cairo_boilerplate_glitz_wgl_cleanup },
     { "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-      _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+      _cairo_boilerplate_glitz_wgl_create_surface,
       cairo_surface_write_to_png,
-      _cairo_boilerplate_cairo_glitz_wgl_cleanup },
+      _cairo_boilerplate_glitz_wgl_cleanup },
 #endif
 #endif /* CAIRO_HAS_GLITZ_SURFACE */
 #if CAIRO_HAS_QUARTZ_SURFACE
diff-tree 7d576a376706aad427915b4872429f5605104886 (from 06b657ccf129f6f154c0db7886e5cca6191f93ca)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:25:28 2007 -0400

    [boilerplate] Minor indentation fix

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index b6174de..245d942 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -213,8 +213,8 @@ _cairo_boilerplate_test_paginated_create
  * tested.
  */
 static cairo_status_t
-_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
-			     const char	     *filename)
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
+						        const char	*filename)
 {
     cairo_surface_t *image;
     cairo_format_t format;
diff-tree 06b657ccf129f6f154c0db7886e5cca6191f93ca (from 65f636649d54348722354b2400c3a191309da0e1)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:20:38 2007 -0400

    [boilerplate] Strip xcb boilerplate into cairo-boilerplate-xcb*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 2968648..1e85c40 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -39,6 +39,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
 endif
 
+if CAIRO_HAS_XCB_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb-private.h
+endif
+
 if CAIRO_HAS_XLIB_XRENDER_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
diff --git a/boilerplate/cairo-boilerplate-xcb-private.h b/boilerplate/cairo-boilerplate-xcb-private.h
new file mode 100644
index 0000000..80717e9
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xcb-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_XCB_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_XCB_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_xcb_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure);
+
+void
+_cairo_boilerplate_xcb_cleanup (void *closure);
+
+void
+_cairo_boilerplate_xcb_synchronize (void *closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
new file mode 100644
index 0000000..2cc88cd
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -0,0 +1,115 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-xcb-private.h"
+
+#include "cairo-xcb-xrender.h"
+
+#include <xcb/xcb_renderutil.h>
+
+typedef struct _xcb_target_closure
+{
+    xcb_connection_t *c;
+    xcb_pixmap_t pixmap;
+} xcb_target_closure_t;
+
+void
+_cairo_boilerplate_xcb_synchronize (void *closure)
+{
+    xcb_target_closure_t *xtc = closure;
+    free (xcb_get_image_reply (xtc->c,
+		xcb_get_image (xtc->c, XCB_IMAGE_FORMAT_Z_PIXMAP,
+		    xtc->pixmap, 0, 0, 1, 1, /* AllPlanes */ ~0UL),
+		0));
+}
+
+cairo_surface_t *
+_cairo_boilerplate_xcb_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure)
+{
+    xcb_screen_t *root;
+    xcb_target_closure_t *xtc;
+    cairo_surface_t *surface;
+    xcb_connection_t *c;
+    xcb_render_pictforminfo_t *render_format;
+    xcb_pict_standard_t format;
+
+    *closure = xtc = xmalloc (sizeof (xcb_target_closure_t));
+
+    if (width == 0)
+	width = 1;
+    if (height == 0)
+	height = 1;
+
+    xtc->c = c = xcb_connect(NULL,NULL);
+    if (xcb_connection_has_error(c)) {
+	CAIRO_BOILERPLATE_LOG ("Failed to connect to X server through XCB\n");
+	return NULL;
+    }
+
+    root = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
+
+    xtc->pixmap = xcb_generate_id (c);
+    xcb_create_pixmap (c, 32, xtc->pixmap, root->root,
+			 width, height);
+
+    switch (content) {
+    case CAIRO_CONTENT_COLOR:
+	format = XCB_PICT_STANDARD_RGB_24;
+	break;
+    case CAIRO_CONTENT_COLOR_ALPHA:
+	format = XCB_PICT_STANDARD_ARGB_32;
+	break;
+    case CAIRO_CONTENT_ALPHA:  /* would be XCB_PICT_STANDARD_A_8 */
+    default:
+	CAIRO_BOILERPLATE_LOG ("Invalid content for XCB test: %d\n", content);
+	return NULL;
+    }
+
+    render_format = xcb_render_util_find_standard_format (xcb_render_util_query_formats (c), format);
+    if (render_format->id == 0)
+	return NULL;
+    surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->pixmap, root,
+							    render_format,
+							    width, height);
+
+    return surface;
+}
+
+void
+_cairo_boilerplate_xcb_cleanup (void *closure)
+{
+    xcb_target_closure_t *xtc = closure;
+
+    xcb_free_pixmap (xtc->c, xtc->pixmap);
+    xcb_disconnect (xtc->c);
+    free (xtc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6a8449e..b6174de 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -65,6 +65,9 @@
 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
 #include "cairo-boilerplate-xlib-private.h"
 #endif
+#if CAIRO_HAS_XCB_SURFACE
+#include "cairo-boilerplate-xcb-private.h"
+#endif
 
 /* This is copied from cairoint.h. That makes it painful to keep in
  * sync, but the slim stuff makes cairoint.h "hard" to include when
@@ -754,93 +757,6 @@ cleanup_win32 (void *closure)
 }
 #endif
 
-#if CAIRO_HAS_XCB_SURFACE
-#include "cairo-xcb-xrender.h"
-#include <xcb/xcb_renderutil.h>
-typedef struct _xcb_target_closure
-{
-    xcb_connection_t *c;
-    xcb_pixmap_t pixmap;
-} xcb_target_closure_t;
-
-static void
-_cairo_boilerplate_xcb_synchronize (void *closure)
-{
-    xcb_target_closure_t *xtc = closure;
-    free (xcb_get_image_reply (xtc->c,
-		xcb_get_image (xtc->c, XCB_IMAGE_FORMAT_Z_PIXMAP,
-		    xtc->pixmap, 0, 0, 1, 1, /* AllPlanes */ ~0UL),
-		0));
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_xcb_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       int			  width,
-				       int			  height,
-				       cairo_boilerplate_mode_t	  mode,
-				       void			**closure)
-{
-    xcb_screen_t *root;
-    xcb_target_closure_t *xtc;
-    cairo_surface_t *surface;
-    xcb_connection_t *c;
-    xcb_render_pictforminfo_t *render_format;
-    xcb_pict_standard_t format;
-
-    *closure = xtc = xmalloc (sizeof (xcb_target_closure_t));
-
-    if (width == 0)
-	width = 1;
-    if (height == 0)
-	height = 1;
-
-    xtc->c = c = xcb_connect(NULL,NULL);
-    if (xcb_connection_has_error(c)) {
-	CAIRO_BOILERPLATE_LOG ("Failed to connect to X server through XCB\n");
-	return NULL;
-    }
-
-    root = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
-
-    xtc->pixmap = xcb_generate_id (c);
-    xcb_create_pixmap (c, 32, xtc->pixmap, root->root,
-			 width, height);
-
-    switch (content) {
-    case CAIRO_CONTENT_COLOR:
-	format = XCB_PICT_STANDARD_RGB_24;
-	break;
-    case CAIRO_CONTENT_COLOR_ALPHA:
-	format = XCB_PICT_STANDARD_ARGB_32;
-	break;
-    case CAIRO_CONTENT_ALPHA:  /* would be XCB_PICT_STANDARD_A_8 */
-    default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for XCB test: %d\n", content);
-	return NULL;
-    }
-
-    render_format = xcb_render_util_find_standard_format (xcb_render_util_query_formats (c), format);
-    if (render_format->id == 0)
-	return NULL;
-    surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->pixmap, root,
-							    render_format,
-							    width, height);
-
-    return surface;
-}
-
-static void
-_cairo_boilerplate_xcb_cleanup (void *closure)
-{
-    xcb_target_closure_t *xtc = closure;
-
-    xcb_free_pixmap (xtc->c, xtc->pixmap);
-    xcb_disconnect (xtc->c);
-    free (xtc);
-}
-#endif
-
 static cairo_boilerplate_target_t targets[] =
 {
     /* I'm uncompromising about leaving the image backend as 0
diff-tree 65f636649d54348722354b2400c3a191309da0e1 (from 8c9960675b82978acbd5a85ef358c674c3407ee3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:13:08 2007 -0400

    [boilerplate] Strip svg boilerplate into cairo-boilerplate-svg*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 8d9b1b2..2968648 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -34,6 +34,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
 endif
 
+if CAIRO_HAS_SVG_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
+endif
+
 if CAIRO_HAS_XLIB_XRENDER_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
diff --git a/boilerplate/cairo-boilerplate-svg-private.h b/boilerplate/cairo-boilerplate-svg-private.h
new file mode 100644
index 0000000..ffc56c8
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-svg-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_SVG_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_SVG_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_svg_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure);
+
+void
+_cairo_boilerplate_svg_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
new file mode 100644
index 0000000..8193031
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -0,0 +1,129 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-svg-private.h"
+
+#include "cairo-svg.h"
+
+cairo_user_data_key_t	svg_closure_key;
+
+typedef struct _svg_target_closure
+{
+    char    *filename;
+    int	    width, height;
+    cairo_surface_t	*target;
+} svg_target_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_svg_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure)
+{
+    svg_target_closure_t *ptc;
+    cairo_surface_t *surface;
+
+    *closure = ptc = xmalloc (sizeof (svg_target_closure_t));
+
+    ptc->width = width;
+    ptc->height = height;
+
+    xasprintf (&ptc->filename, "%s-svg-%s-out.svg",
+	       name, cairo_boilerplate_content_name (content));
+
+    surface = cairo_svg_surface_create (ptc->filename, width, height);
+    if (cairo_surface_status (surface)) {
+	free (ptc->filename);
+	free (ptc);
+	return NULL;
+    }
+    cairo_surface_set_fallback_resolution (surface, 72., 72.);
+
+    if (content == CAIRO_CONTENT_COLOR) {
+	ptc->target = surface;
+	surface = cairo_surface_create_similar (ptc->target,
+						CAIRO_CONTENT_COLOR,
+						width, height);
+    } else {
+	ptc->target = NULL;
+    }
+
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &svg_closure_key,
+					     ptc, NULL);
+
+    return surface;
+}
+
+cairo_status_t
+_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+{
+    svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
+    char    command[4096];
+
+    /* Both surface and ptc->target were originally created at the
+     * same dimensions. We want a 1:1 copy here, so we first clear any
+     * device offset on surface.
+     *
+     * In a more realistic use case of device offsets, the target of
+     * this copying would be of a different size than the source, and
+     * the offset would be desirable during the copy operation. */
+    cairo_surface_set_device_offset (surface, 0, 0);
+
+    if (ptc->target) {
+	cairo_t *cr;
+	cr = cairo_create (ptc->target);
+	cairo_set_source_surface (cr, surface, 0, 0);
+	cairo_paint (cr);
+	cairo_show_page (cr);
+	cairo_destroy (cr);
+
+	cairo_surface_finish (surface);
+	surface = ptc->target;
+    }
+
+    cairo_surface_finish (surface);
+    sprintf (command, "./svg2png %s %s",
+	     ptc->filename, filename);
+
+    if (system (command) != 0)
+	return CAIRO_STATUS_WRITE_ERROR;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_svg_cleanup (void *closure)
+{
+    svg_target_closure_t *ptc = closure;
+    if (ptc->target)
+	cairo_surface_destroy (ptc->target);
+    free (ptc->filename);
+    free (ptc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 42552f4..6a8449e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -59,6 +59,9 @@
 #if CAIRO_HAS_QUARTZ_SURFACE
 #include "cairo-boilerplate-quartz-private.h"
 #endif
+#if CAIRO_HAS_SVG_SURFACE
+#include "cairo-boilerplate-svg-private.h"
+#endif
 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
 #include "cairo-boilerplate-xlib-private.h"
 #endif
@@ -838,109 +841,6 @@ _cairo_boilerplate_xcb_cleanup (void *cl
 }
 #endif
 
-#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
-#include "cairo-svg.h"
-
-cairo_user_data_key_t	svg_closure_key;
-
-typedef struct _svg_target_closure
-{
-    char    *filename;
-    int	    width, height;
-    cairo_surface_t	*target;
-} svg_target_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_svg_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       int			  width,
-				       int			  height,
-				       cairo_boilerplate_mode_t	  mode,
-				       void			**closure)
-{
-    svg_target_closure_t *ptc;
-    cairo_surface_t *surface;
-
-    *closure = ptc = xmalloc (sizeof (svg_target_closure_t));
-
-    ptc->width = width;
-    ptc->height = height;
-
-    xasprintf (&ptc->filename, "%s-svg-%s-out.svg",
-	       name, cairo_boilerplate_content_name (content));
-
-    surface = cairo_svg_surface_create (ptc->filename, width, height);
-    if (cairo_surface_status (surface)) {
-	free (ptc->filename);
-	free (ptc);
-	return NULL;
-    }
-    cairo_surface_set_fallback_resolution (surface, 72., 72.);
-
-    if (content == CAIRO_CONTENT_COLOR) {
-	ptc->target = surface;
-	surface = cairo_surface_create_similar (ptc->target,
-						CAIRO_CONTENT_COLOR,
-						width, height);
-    } else {
-	ptc->target = NULL;
-    }
-
-    cairo_boilerplate_surface_set_user_data (surface,
-					     &svg_closure_key,
-					     ptc, NULL);
-
-    return surface;
-}
-
-static cairo_status_t
-_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
-{
-    svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
-    char    command[4096];
-
-    /* Both surface and ptc->target were originally created at the
-     * same dimensions. We want a 1:1 copy here, so we first clear any
-     * device offset on surface.
-     *
-     * In a more realistic use case of device offsets, the target of
-     * this copying would be of a different size than the source, and
-     * the offset would be desirable during the copy operation. */
-    cairo_surface_set_device_offset (surface, 0, 0);
-
-    if (ptc->target) {
-	cairo_t *cr;
-	cr = cairo_create (ptc->target);
-	cairo_set_source_surface (cr, surface, 0, 0);
-	cairo_paint (cr);
-	cairo_show_page (cr);
-	cairo_destroy (cr);
-
-	cairo_surface_finish (surface);
-	surface = ptc->target;
-    }
-
-    cairo_surface_finish (surface);
-    sprintf (command, "./svg2png %s %s",
-	     ptc->filename, filename);
-
-    if (system (command) != 0)
-	return CAIRO_STATUS_WRITE_ERROR;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_svg_cleanup (void *closure)
-{
-    svg_target_closure_t *ptc = closure;
-    if (ptc->target)
-	cairo_surface_destroy (ptc->target);
-    free (ptc->filename);
-    free (ptc);
-}
-#endif /* CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE */
-
 static cairo_boilerplate_target_t targets[] =
 {
     /* I'm uncompromising about leaving the image backend as 0
diff-tree 8c9960675b82978acbd5a85ef358c674c3407ee3 (from d9ce7de57514710f425bdee613edc4ea79ac0f0a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:10:09 2007 -0400

    [boilerplate] Strip pdf boilerplate into cairo-boilerplate-pdf*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 7753d7c..8d9b1b2 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
 endif
 
+if CAIRO_HAS_PDF_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf-private.h
+endif
+
 if CAIRO_HAS_PS_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps-private.h
diff --git a/boilerplate/cairo-boilerplate-pdf-private.h b/boilerplate/cairo-boilerplate-pdf-private.h
new file mode 100644
index 0000000..7ce181e
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-pdf-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_PDF_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_PDF_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_pdf_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure);
+
+void
+_cairo_boilerplate_pdf_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
new file mode 100644
index 0000000..0b1dec0
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -0,0 +1,134 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-pdf-private.h"
+
+#include "cairo-pdf.h"
+
+cairo_user_data_key_t pdf_closure_key;
+
+typedef struct _pdf_target_closure
+{
+    char		*filename;
+    int			 width;
+    int			 height;
+    cairo_surface_t	*target;
+} pdf_target_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_pdf_create_surface (const char		 *name,
+				       cairo_content_t		  content,
+				       int			  width,
+				       int			  height,
+				       cairo_boilerplate_mode_t	  mode,
+				       void			**closure)
+{
+    pdf_target_closure_t *ptc;
+    cairo_surface_t *surface;
+
+    /* Sanitize back to a real cairo_content_t value. */
+    if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
+	content = CAIRO_CONTENT_COLOR_ALPHA;
+
+    *closure = ptc = xmalloc (sizeof (pdf_target_closure_t));
+
+    ptc->width = width;
+    ptc->height = height;
+
+    xasprintf (&ptc->filename, "%s-pdf-%s-out.pdf",
+	       name, cairo_boilerplate_content_name (content));
+
+    surface = cairo_pdf_surface_create (ptc->filename, width, height);
+    if (cairo_surface_status (surface)) {
+	free (ptc->filename);
+	free (ptc);
+	return NULL;
+    }
+    cairo_surface_set_fallback_resolution (surface, 72., 72.);
+
+    if (content == CAIRO_CONTENT_COLOR) {
+	ptc->target = surface;
+	surface = cairo_surface_create_similar (ptc->target,
+						CAIRO_CONTENT_COLOR,
+						width, height);
+    } else {
+	ptc->target = NULL;
+    }
+
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &pdf_closure_key,
+					     ptc, NULL);
+
+    return surface;
+}
+
+cairo_status_t
+_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+{
+    pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
+    char    command[4096];
+
+    /* Both surface and ptc->target were originally created at the
+     * same dimensions. We want a 1:1 copy here, so we first clear any
+     * device offset on surface.
+     *
+     * In a more realistic use case of device offsets, the target of
+     * this copying would be of a different size than the source, and
+     * the offset would be desirable during the copy operation. */
+    cairo_surface_set_device_offset (surface, 0, 0);
+
+    if (ptc->target) {
+	cairo_t *cr;
+	cr = cairo_create (ptc->target);
+	cairo_set_source_surface (cr, surface, 0, 0);
+	cairo_paint (cr);
+	cairo_show_page (cr);
+	cairo_destroy (cr);
+
+	cairo_surface_finish (surface);
+	surface = ptc->target;
+    }
+
+    cairo_surface_finish (surface);
+    sprintf (command, "./pdf2png %s %s 1",
+	     ptc->filename, filename);
+
+    if (system (command) != 0)
+	return CAIRO_STATUS_WRITE_ERROR;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_pdf_cleanup (void *closure)
+{
+    pdf_target_closure_t *ptc = closure;
+    if (ptc->target)
+	cairo_surface_destroy (ptc->target);
+    free (ptc->filename);
+    free (ptc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 0dc7c19..42552f4 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -50,6 +50,9 @@
 #if CAIRO_HAS_DIRECTFB_SURFACE
 #include "cairo-boilerplate-directfb-private.h"
 #endif
+#if CAIRO_HAS_PDF_SURFACE
+#include "cairo-boilerplate-pdf-private.h"
+#endif
 #if CAIRO_HAS_PS_SURFACE
 #include "cairo-boilerplate-ps-private.h"
 #endif
@@ -835,114 +838,6 @@ _cairo_boilerplate_xcb_cleanup (void *cl
 }
 #endif
 
-#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
-#include "cairo-pdf.h"
-
-cairo_user_data_key_t pdf_closure_key;
-
-typedef struct _pdf_target_closure
-{
-    char		*filename;
-    int			 width;
-    int			 height;
-    cairo_surface_t	*target;
-} pdf_target_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_pdf_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       int			  width,
-				       int			  height,
-				       cairo_boilerplate_mode_t	  mode,
-				       void			**closure)
-{
-    pdf_target_closure_t *ptc;
-    cairo_surface_t *surface;
-
-    /* Sanitize back to a real cairo_content_t value. */
-    if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
-	content = CAIRO_CONTENT_COLOR_ALPHA;
-
-    *closure = ptc = xmalloc (sizeof (pdf_target_closure_t));
-
-    ptc->width = width;
-    ptc->height = height;
-
-    xasprintf (&ptc->filename, "%s-pdf-%s-out.pdf",
-	       name, cairo_boilerplate_content_name (content));
-
-    surface = cairo_pdf_surface_create (ptc->filename, width, height);
-    if (cairo_surface_status (surface)) {
-	free (ptc->filename);
-	free (ptc);
-	return NULL;
-    }
-    cairo_surface_set_fallback_resolution (surface, 72., 72.);
-
-    if (content == CAIRO_CONTENT_COLOR) {
-	ptc->target = surface;
-	surface = cairo_surface_create_similar (ptc->target,
-						CAIRO_CONTENT_COLOR,
-						width, height);
-    } else {
-	ptc->target = NULL;
-    }
-
-    cairo_boilerplate_surface_set_user_data (surface,
-					     &pdf_closure_key,
-					     ptc, NULL);
-
-    return surface;
-}
-
-static cairo_status_t
-_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
-{
-    pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
-    char    command[4096];
-
-    /* Both surface and ptc->target were originally created at the
-     * same dimensions. We want a 1:1 copy here, so we first clear any
-     * device offset on surface.
-     *
-     * In a more realistic use case of device offsets, the target of
-     * this copying would be of a different size than the source, and
-     * the offset would be desirable during the copy operation. */
-    cairo_surface_set_device_offset (surface, 0, 0);
-
-    if (ptc->target) {
-	cairo_t *cr;
-	cr = cairo_create (ptc->target);
-	cairo_set_source_surface (cr, surface, 0, 0);
-	cairo_paint (cr);
-	cairo_show_page (cr);
-	cairo_destroy (cr);
-
-	cairo_surface_finish (surface);
-	surface = ptc->target;
-    }
-
-    cairo_surface_finish (surface);
-    sprintf (command, "./pdf2png %s %s 1",
-	     ptc->filename, filename);
-
-    if (system (command) != 0)
-	return CAIRO_STATUS_WRITE_ERROR;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_pdf_cleanup (void *closure)
-{
-    pdf_target_closure_t *ptc = closure;
-    if (ptc->target)
-	cairo_surface_destroy (ptc->target);
-    free (ptc->filename);
-    free (ptc);
-}
-#endif /* CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE */
-
 #if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
 #include "cairo-svg.h"
 
diff-tree d9ce7de57514710f425bdee613edc4ea79ac0f0a (from df6b8ecc8963518c897648d82aab1aa090b4721a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 22:08:24 2007 -0400

    [boilerplate] Rename xcairo_surface_set_user_data to cairo_boilerplate_surface_set_user_data
    
    and make it public.

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 730b855..0dc7c19 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -119,24 +119,6 @@ _cairo_boilerplate_image_create_surface 
     return cairo_image_surface_create (format, width, height);
 }
 
-static void
-xcairo_surface_set_user_data (cairo_surface_t		 *surface,
-			      const cairo_user_data_key_t *key,
-			      void			 *user_data,
-			      cairo_destroy_func_t	 destroy)
-{
-    cairo_status_t status;
-
-    status = cairo_surface_set_user_data (surface,
-					  key, user_data,
-					  destroy);
-    if (status) {
-	CAIRO_BOILERPLATE_LOG ("Error: %s. Exiting\n",
-			       cairo_status_to_string (status));
-	exit (1);
-    }
-}
-
 #ifdef CAIRO_HAS_TEST_SURFACES
 
 #include "test-fallback-surface.h"
@@ -203,8 +185,9 @@ _cairo_boilerplate_test_paginated_create
 						       tpc->height,
 						       tpc->stride);
 
-    xcairo_surface_set_user_data (surface, &test_paginated_closure_key,
-				  tpc, NULL);
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &test_paginated_closure_key,
+					     tpc, NULL);
 
     return surface;
 }
@@ -905,7 +888,9 @@ _cairo_boilerplate_pdf_create_surface (c
 	ptc->target = NULL;
     }
 
-    xcairo_surface_set_user_data (surface, &pdf_closure_key, ptc, NULL);
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &pdf_closure_key,
+					     ptc, NULL);
 
     return surface;
 }
@@ -1006,7 +991,9 @@ _cairo_boilerplate_svg_create_surface (c
 	ptc->target = NULL;
     }
 
-    xcairo_surface_set_user_data (surface, &svg_closure_key, ptc, NULL);
+    cairo_boilerplate_surface_set_user_data (surface,
+					     &svg_closure_key,
+					     ptc, NULL);
 
     return surface;
 }
@@ -1333,6 +1320,23 @@ cairo_boilerplate_free_targets (cairo_bo
     free (targets);
 }
 
+void
+cairo_boilerplate_surface_set_user_data (cairo_surface_t		*surface,
+					 const cairo_user_data_key_t	*key,
+					 void				*user_data,
+					 cairo_destroy_func_t		 destroy)
+{
+    cairo_status_t status;
+
+    status = cairo_surface_set_user_data (surface,
+					  key, user_data,
+					  destroy);
+    if (status) {
+	CAIRO_BOILERPLATE_LOG ("Error: %s. Exiting\n",
+			       cairo_status_to_string (status));
+	exit (1);
+    }
+}
 
 void
 xasprintf (char **strp, const char *fmt, ...)
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 8d3c215..5b4c217 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -138,6 +138,12 @@ cairo_boilerplate_free_targets (cairo_bo
 #endif
 
 void
+cairo_boilerplate_surface_set_user_data (cairo_surface_t		*surface,
+					 const cairo_user_data_key_t	*key,
+					 void				*user_data,
+					 cairo_destroy_func_t		 destroy);
+
+void
 xasprintf (char **strp, const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3);
 
 #endif
diff-tree df6b8ecc8963518c897648d82aab1aa090b4721a (from 6461f0d120bf5fabd08b7621233229b223b3de89)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Apr 19 21:46:51 2007 -0400

    [boilerplate] Strip ps boilerplate into cairo-boilerplate-ps*

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index f84600c..7753d7c 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,11 @@ libcairoboilerplate_la_SOURCES += cairo-
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
 endif
 
+if CAIRO_HAS_PS_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps-private.h
+endif
+
 if CAIRO_HAS_QUARTZ_SURFACE
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz.c
 libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
diff --git a/boilerplate/cairo-boilerplate-ps-private.h b/boilerplate/cairo-boilerplate-ps-private.h
new file mode 100644
index 0000000..8d1faf1
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-ps-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_PS_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_PS_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_ps_create_surface (const char		 *name,
+				      cairo_content_t		  content,
+				      int			  width,
+				      int			  height,
+				      cairo_boilerplate_mode_t	  mode,
+				      void			**closure);
+
+void
+_cairo_boilerplate_ps_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
new file mode 100644
index 0000000..676d3e8
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -0,0 +1,138 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. make