[cairo-commit] 2 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-agl.c boilerplate/cairo-boilerplate-glitz-glx.c boilerplate/cairo-boilerplate-glitz-private.h boilerplate/cairo-boilerplate-glitz-wgl.c 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-qt.cpp boilerplate/cairo-boilerplate-qt-private.h boilerplate/cairo-boilerplate-quartz.c boilerplate/cairo-boilerplate-quartz-private.h boilerplate/cairo-boilerplate-script.c boilerplate/cairo-boilerplate-script-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-printing.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/.gitignore boilerplate/make-cairo-boilerplate-constructors.c boilerplate/Makefile.am boilerplate/Makefile.sources src/Makefile.sources src/test-meta-surface.c src/test-meta-surface.h test/make-cairo-test-constructors.c util/cairo-trace

Chris Wilson ickle at kemper.freedesktop.org
Sat Jul 4 14:03:35 PDT 2009


 boilerplate/.gitignore                                |    2 
 boilerplate/Makefile.am                               |   12 
 boilerplate/Makefile.sources                          |   27 
 boilerplate/cairo-boilerplate-beos-private.h          |   40 -
 boilerplate/cairo-boilerplate-beos.cpp                |   48 +
 boilerplate/cairo-boilerplate-directfb-private.h      |   26 
 boilerplate/cairo-boilerplate-directfb.c              |   29 
 boilerplate/cairo-boilerplate-glitz-agl.c             |   31 
 boilerplate/cairo-boilerplate-glitz-glx.c             |   31 
 boilerplate/cairo-boilerplate-glitz-private.h         |   88 --
 boilerplate/cairo-boilerplate-glitz-wgl.c             |   32 
 boilerplate/cairo-boilerplate-pdf-private.h           |   60 -
 boilerplate/cairo-boilerplate-pdf.c                   |   48 -
 boilerplate/cairo-boilerplate-ps-private.h            |   71 -
 boilerplate/cairo-boilerplate-ps.c                    |   73 +-
 boilerplate/cairo-boilerplate-qt-private.h            |   60 -
 boilerplate/cairo-boilerplate-qt.cpp                  |   29 
 boilerplate/cairo-boilerplate-quartz-private.h        |   44 -
 boilerplate/cairo-boilerplate-quartz.c                |   29 
 boilerplate/cairo-boilerplate-script-private.h        |   57 -
 boilerplate/cairo-boilerplate-script.c                |   28 
 boilerplate/cairo-boilerplate-svg-private.h           |   72 --
 boilerplate/cairo-boilerplate-svg.c                   |   70 +
 boilerplate/cairo-boilerplate-test-surfaces-private.h |   99 --
 boilerplate/cairo-boilerplate-test-surfaces.c         |  109 ++-
 boilerplate/cairo-boilerplate-win32-printing.c        |   43 -
 boilerplate/cairo-boilerplate-win32-private.h         |   65 -
 boilerplate/cairo-boilerplate-win32.c                 |   28 
 boilerplate/cairo-boilerplate-xcb-private.h           |   47 -
 boilerplate/cairo-boilerplate-xcb.c                   |   28 
 boilerplate/cairo-boilerplate-xlib-private.h          |   71 -
 boilerplate/cairo-boilerplate-xlib.c                  |  207 +++--
 boilerplate/cairo-boilerplate.c                       |  646 ++----------------
 boilerplate/cairo-boilerplate.h                       |    3 
 boilerplate/make-cairo-boilerplate-constructors.c     |  156 ++++
 src/Makefile.sources                                  |    2 
 src/test-meta-surface.c                               |  358 ---------
 src/test-meta-surface.h                               |   50 -
 test/make-cairo-test-constructors.c                   |   28 
 util/cairo-trace/trace.c                              |   49 -
 40 files changed, 978 insertions(+), 2018 deletions(-)

New commits:
commit ee8c50f2d6f1dba41f829c715b7bc59b5eeda50d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 4 22:00:09 2009 +0100

    Remove the defunct test-meta surface
    
    Replace the internal test-meta surface will the freshly exported,
    real meta-surface.

diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index 844991c..849627f 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -30,7 +30,6 @@
 
 #include <test-fallback-surface.h>
 #include <test-fallback16-surface.h>
-#include <test-meta-surface.h>
 #include <test-paginated-surface.h>
 #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,3)
 #include <test-null-surface.h>
@@ -69,21 +68,6 @@ _cairo_boilerplate_test_fallback16_create_surface (const char			 *name,
 }
 
 static cairo_surface_t *
-_cairo_boilerplate_test_meta_create_surface (const char			 *name,
-					     cairo_content_t		  content,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     void			**closure)
-{
-    *closure = NULL;
-    return _cairo_test_meta_surface_create (content, width, height);
-}
-
-static cairo_surface_t *
 _cairo_boilerplate_test_null_create_surface (const char			 *name,
 					     cairo_content_t		  content,
 					     double			  width,
@@ -297,28 +281,6 @@ static const cairo_boilerplate_target_t targets[] = {
 	cairo_surface_write_to_png
     },
     {
-	"test-meta", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_meta_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	NULL, NULL,
-	FALSE, TRUE
-    },
-    {
-	"test-meta", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
-	CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_test_meta_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	NULL, NULL,
-	FALSE, TRUE
-    },
-    {
 	"test-paginated", "image", NULL, NULL,
 	CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
 	CAIRO_CONTENT_COLOR_ALPHA, 0,
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index dfca1db..ea88c69 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -125,6 +125,21 @@ _cairo_boilerplate_image_create_surface (const char			 *name,
     return cairo_image_surface_create (format, ceil (width), ceil (height));
 }
 
+static cairo_surface_t *
+_cairo_boilerplate_meta_create_surface (const char	     *name,
+					cairo_content_t	      content,
+					double		      width,
+					double		      height,
+					double		      max_width,
+					double		      max_height,
+					cairo_boilerplate_mode_t mode,
+					int		      id,
+					void		    **closure)
+{
+    *closure = NULL;
+    return cairo_meta_surface_create (content, width, height);
+}
+
 cairo_surface_t *
 _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
 				      int page,
@@ -255,6 +270,26 @@ static const cairo_boilerplate_target_t builtin_targets[] = {
 	_cairo_boilerplate_get_image_surface,
 	cairo_surface_write_to_png
     },
+    {
+	"meta", "image", NULL, NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_meta_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	NULL, NULL,
+	FALSE, TRUE
+    },
+    {
+	"meta", "image", NULL, NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_meta_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	NULL, NULL,
+	FALSE, TRUE
+    },
 };
 CAIRO_BOILERPLATE (builtin, builtin_targets)
 
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 5648f25..ef4e1c8 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -192,14 +192,12 @@ cairo_ft_sources = cairo-ft-font.c
 cairo_test_surfaces_private = \
 	test-fallback-surface.h \
 	test-fallback16-surface.h \
-	test-meta-surface.h \
 	test-null-surface.h \
 	test-paginated-surface.h \
 	$(NULL)
 cairo_test_surfaces_sources = \
 	test-fallback-surface.c \
 	test-fallback16-surface.c \
-	test-meta-surface.c \
 	test-null-surface.c \
 	test-paginated-surface.c \
 	$(NULL)
diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c
deleted file mode 100644
index 80e56f3..0000000
--- a/src/test-meta-surface.c
+++ /dev/null
@@ -1,358 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- *	Carl Worth <cworth at cworth.org>
- */
-
-/* This isn't a "real" surface, but just something to be used by the
- * test suite to help exercise the meta-surface paths in cairo.
- *
- * The defining feature of this backend is that it uses a meta surface
- * to record all operations, and then replays everything to an image
- * surface.
- *
- * It's possible that this code might serve as a good starting point
- * for someone working on bringing up a new meta-surface-based
- * backend.
- */
-
-#include "cairoint.h"
-
-#include "test-meta-surface.h"
-
-#include "cairo-meta-surface-private.h"
-
-typedef struct _test_meta_surface {
-    cairo_surface_t base;
-
-    /* This is a cairo_meta_surface to record all operations. */
-    cairo_surface_t *meta;
-    int width, height;
-
-    /* And this is a cairo_image_surface to hold the final result. */
-    cairo_surface_t *image;
-
-    cairo_bool_t image_reflects_meta;
-} test_meta_surface_t;
-
-static cairo_int_status_t
-_test_meta_surface_show_page (void *abstract_surface);
-
-slim_hidden_proto (_cairo_test_meta_surface_create);
-
-static cairo_surface_t *
-_test_meta_surface_create_similar (void *abstract_surface,
-				   cairo_content_t content,
-				   int width, int height)
-{
-    return _cairo_test_meta_surface_create (content, width, height);
-}
-
-static cairo_status_t
-_test_meta_surface_finish (void *abstract_surface)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    cairo_surface_destroy (surface->meta);
-    cairo_surface_destroy (surface->image);
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_status_t
-_test_meta_surface_acquire_source_image (void		  *abstract_surface,
-					 cairo_image_surface_t	**image_out,
-					 void			**image_extra)
-{
-    test_meta_surface_t *surface = abstract_surface;
-    cairo_status_t status;
-
-    if (! surface->image_reflects_meta) {
-	status = _test_meta_surface_show_page (abstract_surface);
-	if (status)
-	    return status;
-    }
-
-    return _cairo_surface_acquire_source_image (surface->image,
-						image_out, image_extra);
-}
-
-static void
-_test_meta_surface_release_source_image (void			*abstract_surface,
-					 cairo_image_surface_t	*image,
-					 void			*image_extra)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    _cairo_surface_release_source_image (surface->image,
-					 image, image_extra);
-}
-
-static cairo_int_status_t
-_test_meta_surface_show_page (void *abstract_surface)
-{
-    test_meta_surface_t *surface = abstract_surface;
-    cairo_status_t status;
-
-    if (surface->image_reflects_meta)
-	return CAIRO_STATUS_SUCCESS;
-
-    if (surface->image == NULL) {
-	surface->image =
-	    _cairo_image_surface_create_with_content (surface->base.content,
-						      surface->width,
-						      surface->height);
-	status = surface->image->status;
-	if (status)
-	    return status;
-    }
-
-    status = cairo_meta_surface_replay (surface->meta, surface->image);
-    if (status)
-	return status;
-
-    surface->image_reflects_meta = TRUE;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
-_test_meta_surface_intersect_clip_path (void			*abstract_surface,
-					cairo_path_fixed_t	*path,
-					cairo_fill_rule_t	 fill_rule,
-					double			 tolerance,
-					cairo_antialias_t	 antialias)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    return _cairo_surface_intersect_clip_path (surface->meta,
-					       path, fill_rule,
-					       tolerance, antialias);
-}
-
-static cairo_int_status_t
-_test_meta_surface_get_extents (void			*abstract_surface,
-				cairo_rectangle_int_t	*rectangle)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    rectangle->x = 0;
-    rectangle->y = 0;
-    rectangle->width  = surface->width;
-    rectangle->height = surface->height;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
-static cairo_int_status_t
-_test_meta_surface_paint (void			*abstract_surface,
-			  cairo_operator_t	 op,
-			  const cairo_pattern_t	*source,
-			  cairo_rectangle_int_t *extents)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    surface->image_reflects_meta = FALSE;
-
-    return _cairo_surface_paint (surface->meta, op, source, extents);
-}
-
-static cairo_int_status_t
-_test_meta_surface_mask (void			*abstract_surface,
-			 cairo_operator_t	 op,
-			 const cairo_pattern_t	*source,
-			 const cairo_pattern_t	*mask,
-			 cairo_rectangle_int_t  *extents)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    surface->image_reflects_meta = FALSE;
-
-    return _cairo_surface_mask (surface->meta, op, source, mask, extents);
-}
-
-static cairo_int_status_t
-_test_meta_surface_stroke (void				*abstract_surface,
-			   cairo_operator_t		 op,
-			   const cairo_pattern_t	*source,
-			   cairo_path_fixed_t		*path,
-			   cairo_stroke_style_t		*style,
-			   cairo_matrix_t		*ctm,
-			   cairo_matrix_t		*ctm_inverse,
-			   double			 tolerance,
-			   cairo_antialias_t		 antialias,
-			   cairo_rectangle_int_t	*extents)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    surface->image_reflects_meta = FALSE;
-
-    return _cairo_surface_stroke (surface->meta, op, source,
-				  path, style,
-				  ctm, ctm_inverse,
-				  tolerance, antialias, extents);
-}
-
-static cairo_int_status_t
-_test_meta_surface_fill (void			*abstract_surface,
-			 cairo_operator_t	 op,
-			 const cairo_pattern_t	*source,
-			 cairo_path_fixed_t	*path,
-			 cairo_fill_rule_t	 fill_rule,
-			 double			 tolerance,
-			 cairo_antialias_t	 antialias,
-			 cairo_rectangle_int_t  *extents)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    surface->image_reflects_meta = FALSE;
-
-    return _cairo_surface_fill (surface->meta, op, source,
-				path, fill_rule,
-				tolerance, antialias, extents);
-}
-
-static cairo_bool_t
-_test_meta_surface_has_show_text_glyphs (void *abstract_surface)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    return cairo_surface_has_show_text_glyphs (surface->meta);
-}
-
-static cairo_int_status_t
-_test_meta_surface_show_text_glyphs (void		    *abstract_surface,
-				     cairo_operator_t	     op,
-				     const cairo_pattern_t  *source,
-				     const char		    *utf8,
-				     int		     utf8_len,
-				     cairo_glyph_t	    *glyphs,
-				     int		     num_glyphs,
-				     const cairo_text_cluster_t *clusters,
-				     int		     num_clusters,
-				     cairo_text_cluster_flags_t cluster_flags,
-				     cairo_scaled_font_t    *scaled_font,
-				     cairo_rectangle_int_t  *extents)
-{
-    test_meta_surface_t *surface = abstract_surface;
-
-    surface->image_reflects_meta = FALSE;
-
-    return _cairo_surface_show_text_glyphs (surface->meta, op, source,
-					    utf8, utf8_len,
-					    glyphs, num_glyphs,
-					    clusters, num_clusters, cluster_flags,
-					    scaled_font, extents);
-}
-
-
-static cairo_surface_t *
-_test_meta_surface_snapshot (void *abstract_other)
-{
-    test_meta_surface_t *other = abstract_other;
-
-    return _cairo_surface_snapshot (other->meta);
-}
-
-static const cairo_surface_backend_t test_meta_surface_backend = {
-    CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
-    _test_meta_surface_create_similar,
-    _test_meta_surface_finish,
-    _test_meta_surface_acquire_source_image,
-    _test_meta_surface_release_source_image,
-    NULL, /* acquire_dest_image */
-    NULL, /* release_dest_image */
-    NULL, /* clone_similar */
-    NULL, /* composite */
-    NULL, /* fill_rectangles */
-    NULL, /* composite_trapezoids */
-    NULL, /* create_span_renderer */
-    NULL, /* check_span_renderer */
-    NULL, /* copy_page */
-    _test_meta_surface_show_page,
-    NULL, /* set_clip_region */
-    _test_meta_surface_intersect_clip_path,
-    _test_meta_surface_get_extents,
-    NULL, /* old_show_glyphs */
-    NULL, /* get_font_options */
-    NULL, /* flush */
-    NULL, /* mark_dirty_rectangle */
-    NULL, /* scaled_font_fini */
-    NULL, /* scaled_glyph_fini */
-    _test_meta_surface_paint,
-    _test_meta_surface_mask,
-    _test_meta_surface_stroke,
-    _test_meta_surface_fill,
-    NULL, /* show_glyphs */
-    _test_meta_surface_snapshot,
-    NULL, /* is_similar */
-    NULL, /* reset */
-    NULL, /* fill_stroke */
-    NULL, /* create_solid_pattern_surface */
-    NULL, /* can_repaint_solid_pattern_surface */
-    _test_meta_surface_has_show_text_glyphs,
-    _test_meta_surface_show_text_glyphs
-};
-
-cairo_surface_t *
-_cairo_test_meta_surface_create (cairo_content_t	content,
-			         int			width,
-			         int			height)
-{
-    test_meta_surface_t *surface;
-    cairo_status_t status;
-
-    surface = malloc (sizeof (test_meta_surface_t));
-    if (unlikely (surface == NULL))
-	return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
-
-    _cairo_surface_init (&surface->base, &test_meta_surface_backend,
-			 content);
-
-    surface->meta = cairo_meta_surface_create (content, width, height);
-    status = cairo_surface_status (surface->meta);
-    if (status)
-	goto FAIL;
-
-    surface->width = width;
-    surface->height = height;
-
-    surface->image_reflects_meta = FALSE;
-    surface->image = NULL;
-
-    return &surface->base;
-
-  FAIL:
-    free (surface);
-    return _cairo_surface_create_in_error (status);
-}
-slim_hidden_def (_cairo_test_meta_surface_create);
diff --git a/src/test-meta-surface.h b/src/test-meta-surface.h
deleted file mode 100644
index 4cd27d8..0000000
--- a/src/test-meta-surface.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* cairo - a vector graphics library with display and print output
- *
- * Copyright © 2005 Red Hat, Inc
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Red Hat, Inc.
- *
- * Contributor(s):
- *	Carl Worth <cworth at cworth.org>
- */
-
-#ifndef TEST_META_SURFACE_H
-#define TEST_META_SURFACE_H
-
-#include "cairo.h"
-
-CAIRO_BEGIN_DECLS
-
-cairo_surface_t *
-_cairo_test_meta_surface_create (cairo_content_t	content,
-			         int			width,
-                                 int			height);
-
-CAIRO_END_DECLS
-
-#endif /* TEST_META_SURFACE_H */
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index e910d9e..b29b57f 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -4264,30 +4264,25 @@ _cairo_test_paginated_surface_create_for_data (unsigned char	*data,
     return ret;
 }
 
-#include <test-meta-surface.h>
+
+#include <test-null-surface.h>
 cairo_surface_t *
-_cairo_test_meta_surface_create (cairo_content_t	content,
-				 int			width,
-				 int			height)
+_cairo_test_null_surface_create (cairo_content_t	content)
 {
     cairo_surface_t *ret;
     long surface_id;
 
-    ret = DLCALL (_cairo_test_meta_surface_create, content, width, height);
+    ret = DLCALL (_cairo_test_null_surface_create, content);
     surface_id = _create_surface_id (ret);
 
     _emit_line_info ();
     if (_write_lock ()) {
 	_trace_printf ("dict\n"
-		       "  /type /test-meta set\n"
+		       "  /type /test-null set\n"
 		       "  /content //%s set\n"
-		       "  /width %d set\n"
-		       "  /height %d set\n"
 		       "  surface dup /s%ld exch def\n",
 		       _content_to_string (content),
-		       width, height,
 		       surface_id);
-	_surface_object_set_size (ret, width, height);
 	_get_object (SURFACE, ret)->defined = true;
 	_push_operand (SURFACE, ret);
 	_write_unlock ();
@@ -4295,25 +4290,31 @@ _cairo_test_meta_surface_create (cairo_content_t	content,
 
     return ret;
 }
+#endif
 
-#include <test-null-surface.h>
 cairo_surface_t *
-_cairo_test_null_surface_create (cairo_content_t	content)
+cairo_meta_surface_create (cairo_content_t content,
+			   double width,
+			   double height)
 {
     cairo_surface_t *ret;
     long surface_id;
 
-    ret = DLCALL (_cairo_test_null_surface_create, content);
+    ret = DLCALL (cairo_meta_surface_create, content, width, height);
     surface_id = _create_surface_id (ret);
 
     _emit_line_info ();
     if (_write_lock ()) {
 	_trace_printf ("dict\n"
-		       "  /type /test-null set\n"
+		       "  /type /meta set\n"
 		       "  /content //%s set\n"
+		       "  /width %f set\n"
+		       "  /height %f set\n"
 		       "  surface dup /s%ld exch def\n",
 		       _content_to_string (content),
+		       width, height,
 		       surface_id);
+	_surface_object_set_size (ret, width, height);
 	_get_object (SURFACE, ret)->defined = true;
 	_push_operand (SURFACE, ret);
 	_write_unlock ();
@@ -4321,4 +4322,22 @@ _cairo_test_null_surface_create (cairo_content_t	content)
 
     return ret;
 }
-#endif
+
+cairo_status_t
+cairo_meta_surface_replay (cairo_surface_t *meta, cairo_surface_t *target)
+{
+    cairo_status_t
+
+    ret = DLCALL (cairo_meta_surface_replay, meta, target);
+
+    _emit_line_info ();
+    if (_write_lock ()) {
+
+	_emit_surface (target);
+	_emit_surface (meta);
+	_trace_printf ("replay");
+	_consume_operand ();
+    }
+
+    return ret;
+}
commit 88cb69b10c66751f687c3745c8e9861b105de3a2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jul 4 21:43:27 2009 +0100

    [boilerpate] Move target definition to backends.
    
    By moving the backend target definition out of the massive amlagamated
    block in cairo-boilerplate.c and into each of the
    cairo-boilerplate-backend.c, we make it much easier to add new targets as
    the information need only be entered in a single file and not scattered
    across three. However, updating the target interface means trawling across
    all the files -- except given that I found it difficult maintaining the
    single massive array I do not see this as an increase in the maintenance
    burden.

diff --git a/boilerplate/.gitignore b/boilerplate/.gitignore
index a19a6f9..251508c 100644
--- a/boilerplate/.gitignore
+++ b/boilerplate/.gitignore
@@ -19,3 +19,5 @@ Makefile.am.features
 *~
 .*.sw?
 check-link
+cairo-boilerplate-constructors.c
+cairo-boilerplate-constructors
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 239af56..523453a 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -20,6 +20,7 @@ libcairoboilerplate_la_SOURCES = \
 	$(enabled_cairo_boilerplate_headers) \
 	$(enabled_cairo_boilerplate_private) \
 	$(enabled_cairo_boilerplate_sources) \
+	cairo-boilerplate-constructors.c \
 	$(NULL)
 libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la
 
@@ -47,6 +48,17 @@ endif
 
 libcairoboilerplate_la_LIBADD += $(CAIROBOILERPLATE_LIBS)
 
+make-cairo-boilerplate-constructors$(EXEEXT): make-cairo-boilerplate-constructors.c
+	$(CC) -o $@ make-cairo-boilerplate-constructors.c
+
+cairo-boilerplate-constructors.c: Makefile $(enabled_cairo_boilerplate_sources) make-cairo-boilerplate-constructors$(EXEEXT)
+	(cd $(srcdir) && ./make-cairo-boilerplate-constructors$(EXEEXT) $(enabled_cairo_boilerplate_sources)) > $@
+
+BUILT_SOURCES += cairo-boilerplate-constructors.c
+EXTRA_DIST += $(BUILT_SOURCES)
+CLEANFILES += $(BUILT_SOURCES)
+CLEANFILES += make-cairo-boilerplate-constructors
+
 test: check
 
 if CROSS_COMPILING
diff --git a/boilerplate/Makefile.sources b/boilerplate/Makefile.sources
index 1ccceda..f81781f 100644
--- a/boilerplate/Makefile.sources
+++ b/boilerplate/Makefile.sources
@@ -15,49 +15,28 @@ cairo_boilerplate_sources = \
 	cairo-boilerplate-system.c \
 	cairo-boilerplate.c \
 	$(NULL)
+cairo_boilerplate_private = \
+	cairo-boilerplate-private.h \
+	$(NULL)
 
 # automake is stupid enough to always use c++ linker if we enable the
 # following lines, even if beos surface is not enabled.  Disable it for now.
-cairo_boilerplate_beos_private = cairo-boilerplate-beos-private.h
 #libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
 
-cairo_boilerplate_directfb_private = cairo-boilerplate-directfb-private.h
 cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c
-
-cairo_boilerplate_glitz_private = cairo-boilerplate-glitz-private.h
 cairo_boilerplate_glitz_sources = \
 	cairo-boilerplate-glitz-agl.c \
 	cairo-boilerplate-glitz-glx.c \
 	cairo-boilerplate-glitz-wgl.c \
 	$(NULL)
-
-cairo_boilerplate_pdf_private = cairo-boilerplate-pdf-private.h
 cairo_boilerplate_pdf_sources = cairo-boilerplate-pdf.c
-
-cairo_boilerplate_ps_private = cairo-boilerplate-ps-private.h
 cairo_boilerplate_ps_sources = cairo-boilerplate-ps.c
-
-cairo_boilerplate_qt_private = cairo-boilerplate-qt-private.h
 cairo_boilerplate_qt_sources = cairo-boilerplate-qt.cpp
-
-cairo_boilerplate_quartz_private = cairo-boilerplate-quartz-private.h
 cairo_boilerplate_quartz_sources = cairo-boilerplate-quartz.c
-
-cairo_boilerplate_script_private = cairo-boilerplate-script-private.h
 cairo_boilerplate_script_sources = cairo-boilerplate-script.c
-
-cairo_boilerplate_svg_private = cairo-boilerplate-svg-private.h
 cairo_boilerplate_svg_sources = cairo-boilerplate-svg.c
-
-cairo_boilerplate_test_surfaces_private = cairo-boilerplate-test-surfaces-private.h
 cairo_boilerplate_test_surfaces_sources = cairo-boilerplate-test-surfaces.c
-
-cairo_boilerplate_win32_private = cairo-boilerplate-win32-private.h
 cairo_boilerplate_win32_sources = cairo-boilerplate-win32.c cairo-boilerplate-win32-printing.c
-
-cairo_boilerplate_xcb_private = cairo-boilerplate-xcb-private.h
 cairo_boilerplate_xcb_sources = cairo-boilerplate-xcb.c
-
 cairo_boilerplate_xlib_headers = cairo-boilerplate-xlib.h
-cairo_boilerplate_xlib_private = cairo-boilerplate-xlib-private.h
 cairo_boilerplate_xlib_sources = cairo-boilerplate-xlib.c
diff --git a/boilerplate/cairo-boilerplate-beos-private.h b/boilerplate/cairo-boilerplate-beos-private.h
deleted file mode 100644
index 4505d73..0000000
--- a/boilerplate/cairo-boilerplate-beos-private.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef _CAIRO_BOILERPLATE_BEOS_PRIVATE_H_
-#define _CAIRO_BOILERPLATE_BEOS_PRIVATE_H_
-
-/* Two functions: One for a real window, one for a bitmap */
-
-#include <cairo.h>
-
-CAIRO_BEGIN_DECLS
-
-extern cairo_surface_t *
-_cairo_boilerplate_beos_create_surface (const char              *name,
-					cairo_content_t          content,
-					double                      width,
-					double                      height,
-					double                      max_width,
-					double                      max_height,
-					cairo_boilerplate_mode_t mode,
-					int                      id,
-					void                   **closure);
-
-extern void
-_cairo_boilerplate_beos_cleanup (void* closure);
-
-extern cairo_surface_t *
-_cairo_boilerplate_beos_create_surface_for_bitmap (const char              *name,
-						   cairo_content_t          content,
-						   double                      width,
-						   double                      height,
-						   double                      max_width,
-						   double                      max_height,
-						   cairo_boilerplate_mode_t mode,
-						   int                      id,
-						   void                   **closure);
-
-extern void
-_cairo_boilerplate_beos_cleanup_bitmap (void* closure);
-
-CAIRO_END_DECLS
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp
index f527627..5596ac1 100644
--- a/boilerplate/cairo-boilerplate-beos.cpp
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -38,11 +38,7 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-extern "C" {
 #include "cairo-boilerplate.h"
-}
-#include "cairo-boilerplate-beos-private.h"
-
 #include <cairo-beos.h>
 
 // Part of this code was originally part of
@@ -161,15 +157,14 @@ AppRunner::~AppRunner()
 // Make sure that the BApplication is initialized
 static AppRunner sAppRunner;
 
-struct beos_boilerplate_closure
-{
+struct beos_boilerplate_closure {
     BView* view;
     BBitmap* bitmap;
     BWindow* window;
 };
 
 // Test a real window
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_beos_create_surface (const char			 *name,
 					cairo_content_t			  content,
 					double				  width,
@@ -192,7 +187,7 @@ _cairo_boilerplate_beos_create_surface (const char			 *name,
     return cairo_beos_surface_create(wnd->View());
 }
 
-void
+static void
 _cairo_boilerplate_beos_cleanup (void* closure)
 {
     beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
@@ -204,7 +199,7 @@ _cairo_boilerplate_beos_cleanup (void* closure)
 }
 
 // Test a bitmap
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_beos_create_surface_for_bitmap (const char			 *name,
 						   cairo_content_t		  content,
 						   double				  width,
@@ -228,7 +223,7 @@ _cairo_boilerplate_beos_create_surface_for_bitmap (const char			 *name,
     return cairo_beos_surface_create_for_bitmap(view, bmp);
 }
 
-void
+static void
 _cairo_boilerplate_beos_cleanup_bitmap (void* closure)
 {
     beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
@@ -242,4 +237,37 @@ _cairo_boilerplate_beos_cleanup_bitmap (void* closure)
     delete bclosure;
 }
 
+static const cairo_boilerplate_target_t targets[] = {
+    /* BeOS sometimes produces a slightly different image. Perhaps this
+     * is related to the fact that it doesn't use premultiplied alpha...
+     * Just ignore the small difference. */
+    {
+	"beos", "beos", NULL, NULL,
+	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_beos_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_beos_cleanup
+    },
+    {
+	"beos-bitmap", "beos", NULL, NULL,
+	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_beos_create_surface_for_bitmap,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_beos_cleanup_bitmap
+    },
+    {
+	"beos-bitmap", "beos", NULL, NULL,
+	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	_cairo_boilerplate_beos_create_surface_for_bitmap,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_beos_cleanup_bitmap
+    },
+};
+CAIRO_BOILERPLATE (beos, targets)
 
diff --git a/boilerplate/cairo-boilerplate-directfb-private.h b/boilerplate/cairo-boilerplate-directfb-private.h
deleted file mode 100644
index a34edcb..0000000
--- a/boilerplate/cairo-boilerplate-directfb-private.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef CAIRO_TEST_DIRECTFB_H_
-#define CAIRO_TEST_DIRECTFB_H_
-
-/* Two functions: One for a real window, one for a bitmap */
-
-#include <cairo.h>
-
-CAIRO_BEGIN_DECLS
-
-extern cairo_surface_t *
-_cairo_boilerplate_directfb_create_surface (const char			 *name,
-					    cairo_content_t		  content,
-					    double				  width,
-					    double				  height,
-					    double				  max_width,
-					    double				  max_height,
-					    cairo_boilerplate_mode_t	  mode,
-					    int                           id,
-					    void			**closure);
-
-extern void
-_cairo_boilerplate_directfb_cleanup (void* closure);
-
-CAIRO_END_DECLS
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c
index ea7a8ad..f7be030 100644
--- a/boilerplate/cairo-boilerplate-directfb.c
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -9,8 +9,7 @@ make check
 
 */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-directfb-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-directfb.h>
 
@@ -37,7 +36,7 @@ typedef struct _DFBInfo {
     IDirectFBSurface       *surface;
 } DFBInfo;
 
-void
+static void
 _cairo_boilerplate_directfb_cleanup (void *closure)
 {
     DFBInfo *info = (DFBInfo *) closure;
@@ -168,7 +167,7 @@ ERROR:
     return NULL;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_directfb_create_surface (const char			 *name,
 					    cairo_content_t		  content,
 					    double				  width,
@@ -207,3 +206,25 @@ _cairo_boilerplate_directfb_create_surface (const char			 *name,
     else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
 	return _cairo_boilerplate_directfb_window_create_surface (info, content, width, height);
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"directfb", "directfb", NULL, NULL,
+	CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_directfb_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_directfb_cleanup
+    },
+    {
+	"directfb-bitmap", "directfb", NULL, NULL,
+	CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_directfb_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_directfb_cleanup
+    },
+};
+CAIRO_BOILERPLATE (directfb, targets);
diff --git a/boilerplate/cairo-boilerplate-glitz-agl.c b/boilerplate/cairo-boilerplate-glitz-agl.c
index 03d0423..61c4352 100644
--- a/boilerplate/cairo-boilerplate-glitz-agl.c
+++ b/boilerplate/cairo-boilerplate-glitz-agl.c
@@ -24,8 +24,7 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-glitz-private.h"
+#include "cairo-boilerplate-private.h"
 
 #if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
 #include <cairo-glitz.h>
@@ -98,7 +97,7 @@ _cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t		 form
     return NULL;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_glitz_agl_create_surface (const char			 *name,
 					     cairo_content_t 		  content,
 					     double			  width,
@@ -156,7 +155,7 @@ _cairo_boilerplate_glitz_agl_create_surface (const char			 *name,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_glitz_agl_cleanup (void *closure)
 {
     free (closure);
@@ -164,3 +163,27 @@ _cairo_boilerplate_glitz_agl_cleanup (void *closure)
 }
 
 #endif
+
+static const cairo_boilerplate_target_t targets[] = {
+#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+    {
+	"glitz-agl", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_glitz_agl_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_agl_cleanup
+    },
+    {
+	"glitz-agl", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_glitz_agl_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_agl_cleanup
+    },
+#endif
+};
+CAIRO_BOILERPLATE (glitz_agl, targets)
diff --git a/boilerplate/cairo-boilerplate-glitz-glx.c b/boilerplate/cairo-boilerplate-glitz-glx.c
index a1981eb..6dfdb7f 100644
--- a/boilerplate/cairo-boilerplate-glitz-glx.c
+++ b/boilerplate/cairo-boilerplate-glitz-glx.c
@@ -24,8 +24,7 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-glitz-private.h"
+#include "cairo-boilerplate-private.h"
 
 #if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
 #include <cairo-glitz.h>
@@ -151,7 +150,7 @@ _cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t		 form
     return NULL;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
 					     cairo_content_t		  content,
 					     double			  width,
@@ -226,7 +225,7 @@ _cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_glitz_glx_cleanup (void *closure)
 {
     glitz_glx_target_closure_t *gxtc = closure;
@@ -242,3 +241,27 @@ _cairo_boilerplate_glitz_glx_cleanup (void *closure)
 }
 
 #endif
+
+static const cairo_boilerplate_target_t targets[] = {
+#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+    {
+	"glitz-glx", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_glitz_glx_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_glx_cleanup
+    },
+    {
+	"glitz-glx", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_glitz_glx_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_glx_cleanup
+    },
+#endif
+};
+CAIRO_BOILERPLATE (glitz_glx, targets)
diff --git a/boilerplate/cairo-boilerplate-glitz-private.h b/boilerplate/cairo-boilerplate-glitz-private.h
deleted file mode 100644
index 62904c7..0000000
--- a/boilerplate/cairo-boilerplate-glitz-private.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- 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
-
-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
-cairo_surface_t *
-_cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
-					     cairo_content_t		  content,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     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,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     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,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     void			**closure);
-
-void
-_cairo_boilerplate_glitz_wgl_cleanup (void *closure);
-#endif
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-glitz-wgl.c b/boilerplate/cairo-boilerplate-glitz-wgl.c
index 9cd11b6..3aeefdd 100644
--- a/boilerplate/cairo-boilerplate-glitz-wgl.c
+++ b/boilerplate/cairo-boilerplate-glitz-wgl.c
@@ -24,8 +24,7 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-glitz-private.h"
+#include "cairo-boilerplate-private.h"
 
 #if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
 #include <cairo-glitz.h>
@@ -37,7 +36,7 @@ typedef struct _glitz_wgl_target_closure {
     glitz_target_closure_base_t base;
 } glitz_wgl_target_closure_t;
 
-glitz_surface_t *
+static glitz_surface_t *
 _cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t		 formatname,
 						      int				 width,
 						      int				 height,
@@ -97,7 +96,7 @@ _cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t		 form
     return sr; /* will be NULL unless we create it and attach */
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
 					     cairo_content_t		  content,
 					     double			  width,
@@ -154,11 +153,34 @@ _cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_glitz_wgl_cleanup (void *closure)
 {
     free (closure);
     glitz_wgl_fini ();
 }
+#endif
 
+static const cairo_boilerplate_target_t targets[] = {
+#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+    {
+	"glitz-wgl", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_glitz_wgl_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_wgl_cleanup
+    },
+    {
+	"glitz-wgl", "glitz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_glitz_wgl_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_glitz_wgl_cleanup
+    },
 #endif
+};
+CAIRO_BOILERPLATE (glitz_wgl, targets)
diff --git a/boilerplate/cairo-boilerplate-pdf-private.h b/boilerplate/cairo-boilerplate-pdf-private.h
deleted file mode 100644
index f4affe7..0000000
--- a/boilerplate/cairo-boilerplate-pdf-private.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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,
-				       double			  width,
-				       double			  height,
-				       double			  max_width,
-				       double			  max_height,
-				       cairo_boilerplate_mode_t	  mode,
-				       int                        id,
-				       void			**closure);
-
-void
-_cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
-	                                unsigned int flags);
-
-cairo_status_t
-_cairo_boilerplate_pdf_finish_surface (cairo_surface_t		*surface);
-
-cairo_status_t
-_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename);
-
-cairo_surface_t *
-_cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
-					  int page,
-					  int width,
-					  int height);
-
-void
-_cairo_boilerplate_pdf_cleanup (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 3ac380c..166ba1c 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -24,18 +24,12 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-pdf-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-pdf.h>
 #include <cairo-pdf-surface-private.h>
 #include <cairo-paginated-surface-private.h>
 
-#if HAVE_SIGNAL_H
-#include <stdlib.h>
-#include <signal.h>
-#endif
-
 static const cairo_user_data_key_t pdf_closure_key;
 
 typedef struct _pdf_target_closure
@@ -48,7 +42,7 @@ typedef struct _pdf_target_closure
 
 #define ARRAY_LENGTH(__array) ((int) (sizeof (__array) / sizeof (__array[0])))
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_pdf_create_surface (const char		 *name,
 				       cairo_content_t		  content,
 				       double			  width,
@@ -107,7 +101,7 @@ _cairo_boilerplate_pdf_create_surface (const char		 *name,
     return surface;
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_pdf_finish_surface (cairo_surface_t		*surface)
 {
     pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface,
@@ -151,7 +145,7 @@ _cairo_boilerplate_pdf_finish_surface (cairo_surface_t		*surface)
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_status_t
+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);
@@ -181,7 +175,7 @@ _cairo_boilerplate_pdf_convert_to_image (cairo_surface_t *surface, int page)
     return cairo_boilerplate_convert_to_image (ptc->filename, page+1);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
 					  int page,
 					  int width,
@@ -199,7 +193,7 @@ _cairo_boilerplate_pdf_get_image_surface (cairo_surface_t *surface,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_pdf_cleanup (void *closure)
 {
     pdf_target_closure_t *ptc = closure;
@@ -209,8 +203,7 @@ _cairo_boilerplate_pdf_cleanup (void *closure)
     free (ptc);
 }
 
-
-void
+static void
 _cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
 	                                unsigned int flags)
 {
@@ -227,3 +220,30 @@ _cairo_boilerplate_pdf_force_fallbacks (cairo_surface_t *abstract_surface,
     surface = (cairo_pdf_surface_t*) paginated->target;
     surface->force_fallbacks = TRUE;
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"pdf", "pdf", ".pdf", NULL,
+	CAIRO_SURFACE_TYPE_PDF,
+	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
+	_cairo_boilerplate_pdf_create_surface,
+	_cairo_boilerplate_pdf_force_fallbacks,
+	_cairo_boilerplate_pdf_finish_surface,
+	_cairo_boilerplate_pdf_get_image_surface,
+	_cairo_boilerplate_pdf_surface_write_to_png,
+	_cairo_boilerplate_pdf_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"pdf", "pdf", ".pdf", NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_pdf_create_surface,
+	_cairo_boilerplate_pdf_force_fallbacks,
+	_cairo_boilerplate_pdf_finish_surface,
+	_cairo_boilerplate_pdf_get_image_surface,
+	_cairo_boilerplate_pdf_surface_write_to_png,
+	_cairo_boilerplate_pdf_cleanup,
+	NULL, TRUE, TRUE
+    },
+};
+CAIRO_BOILERPLATE (pdf, targets)
diff --git a/boilerplate/cairo-boilerplate-ps-private.h b/boilerplate/cairo-boilerplate-ps-private.h
deleted file mode 100644
index 7bcce1c..0000000
--- a/boilerplate/cairo-boilerplate-ps-private.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- 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_ps2_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       double			  width,
-				       double			  height,
-				       double			  max_width,
-				       double			  max_height,
-				       cairo_boilerplate_mode_t	  mode,
-				       int                        id,
-				       void			**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_ps3_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       double			  width,
-				       double			  height,
-				       double			  max_width,
-				       double			  max_height,
-				       cairo_boilerplate_mode_t	  mode,
-				       int                        id,
-				       void			**closure);
-
-void
-_cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface,
-	                               unsigned int flags);
-
-void
-_cairo_boilerplate_ps_cleanup (void *closure);
-
-cairo_status_t
-_cairo_boilerplate_ps_finish_surface (cairo_surface_t		*surface);
-
-cairo_status_t
-_cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char *filename);
-
-cairo_surface_t *
-_cairo_boilerplate_ps_get_image_surface (cairo_surface_t *surface,
-					 int page,
-					 int width,
-					 int height);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
index 2fb03e8..0fdd0cf 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -24,18 +24,13 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-ps-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-ps.h>
+
 #include <cairo-ps-surface-private.h>
 #include <cairo-paginated-surface-private.h>
 
-#if HAVE_SIGNAL_H
-#include <stdlib.h>
-#include <signal.h>
-#endif
-
 static const cairo_user_data_key_t ps_closure_key;
 
 typedef struct _ps_target_closure {
@@ -127,7 +122,7 @@ _cairo_boilerplate_ps_create_surface (const char		 *name,
     return surface;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_ps2_create_surface (const char		 *name,
 				       cairo_content_t		  content,
 				       double			  width,
@@ -146,7 +141,7 @@ _cairo_boilerplate_ps2_create_surface (const char		 *name,
 						 closure);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_ps3_create_surface (const char		 *name,
 				       cairo_content_t		  content,
 				       double			  width,
@@ -165,7 +160,7 @@ _cairo_boilerplate_ps3_create_surface (const char		 *name,
 						 closure);
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_ps_finish_surface (cairo_surface_t		*surface)
 {
     ps_target_closure_t *ptc = cairo_surface_get_user_data (surface,
@@ -209,7 +204,7 @@ _cairo_boilerplate_ps_finish_surface (cairo_surface_t		*surface)
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char *filename)
 {
     ps_target_closure_t *ptc = cairo_surface_get_user_data (surface,
@@ -232,7 +227,7 @@ _cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_ps_get_image_surface (cairo_surface_t *surface,
 					 int page,
 					 int width,
@@ -266,7 +261,7 @@ _cairo_boilerplate_ps_get_image_surface (cairo_surface_t *surface,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_ps_cleanup (void *closure)
 {
     ps_target_closure_t *ptc = closure;
@@ -276,7 +271,7 @@ _cairo_boilerplate_ps_cleanup (void *closure)
     free (ptc);
 }
 
-void
+static void
 _cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface,
 	                               unsigned int flags)
 {
@@ -293,3 +288,53 @@ _cairo_boilerplate_ps_force_fallbacks (cairo_surface_t *abstract_surface,
     surface = (cairo_ps_surface_t*) paginated->target;
     surface->force_fallbacks = TRUE;
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"ps2", "ps", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_PS,
+	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
+	_cairo_boilerplate_ps2_create_surface,
+	_cairo_boilerplate_ps_force_fallbacks,
+	_cairo_boilerplate_ps_finish_surface,
+	_cairo_boilerplate_ps_get_image_surface,
+	_cairo_boilerplate_ps_surface_write_to_png,
+	_cairo_boilerplate_ps_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"ps2", "ps", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_ps2_create_surface,
+	_cairo_boilerplate_ps_force_fallbacks,
+	_cairo_boilerplate_ps_finish_surface,
+	_cairo_boilerplate_ps_get_image_surface,
+	_cairo_boilerplate_ps_surface_write_to_png,
+	_cairo_boilerplate_ps_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"ps3", "ps", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_PS,
+	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
+	_cairo_boilerplate_ps3_create_surface,
+	_cairo_boilerplate_ps_force_fallbacks,
+	_cairo_boilerplate_ps_finish_surface,
+	_cairo_boilerplate_ps_get_image_surface,
+	_cairo_boilerplate_ps_surface_write_to_png,
+	_cairo_boilerplate_ps_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"ps3", "ps", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_ps3_create_surface,
+	_cairo_boilerplate_ps_force_fallbacks,
+	_cairo_boilerplate_ps_finish_surface,
+	_cairo_boilerplate_ps_get_image_surface,
+	_cairo_boilerplate_ps_surface_write_to_png,
+	_cairo_boilerplate_ps_cleanup,
+	NULL, TRUE, TRUE
+    },
+};
+CAIRO_BOILERPLATE (ps, targets)
diff --git a/boilerplate/cairo-boilerplate-qt-private.h b/boilerplate/cairo-boilerplate-qt-private.h
deleted file mode 100644
index 917d63b..0000000
--- a/boilerplate/cairo-boilerplate-qt-private.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Cairo - a vector graphics library with display and print output
- *
- * Copyright © 2009 Chris Wilson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is Chris Wilson.
- */
-
-#ifndef CAIRO_BOILERPLATE_QT_PRIVATE_H
-#define CAIRO_BOILERPLATE_QT_PRIVATE_H
-
-#include <cairo.h>
-
-CAIRO_BEGIN_DECLS
-
-extern cairo_surface_t *
-_cairo_boilerplate_qt_create_surface (const char			 *name,
-				      cairo_content_t			  content,
-				      double				  width,
-				      double				  height,
-				      double				  max_width,
-				      double				  max_height,
-				      cairo_boilerplate_mode_t	  mode,
-				      int                           id,
-				      void			**closure);
-
-extern void
-_cairo_boilerplate_qt_cleanup (void* closure);
-
-extern void
-_cairo_boilerplate_qt_synchronize (void *closure);
-
-CAIRO_END_DECLS
-
-#endif /* CAIRO_BOILERPLATE_QT_PRIVATE_H */
-
diff --git a/boilerplate/cairo-boilerplate-qt.cpp b/boilerplate/cairo-boilerplate-qt.cpp
index addcb12..5d8d3f9 100644
--- a/boilerplate/cairo-boilerplate-qt.cpp
+++ b/boilerplate/cairo-boilerplate-qt.cpp
@@ -31,7 +31,6 @@
  */
 
 #include "cairo-boilerplate.h"
-#include "cairo-boilerplate-qt-private.h"
 
 #include <cairo-qt.h>
 
@@ -43,7 +42,7 @@ typedef struct _qt_closure {
     QApplication *app;
 } qt_closure_t;
 
-void
+static void
 _cairo_boilerplate_qt_cleanup (void *closure)
 {
     qt_closure_t *qtc = (qt_closure_t *) closure;
@@ -53,7 +52,7 @@ _cairo_boilerplate_qt_cleanup (void *closure)
     free (qtc);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_qt_create_surface (const char		 *name,
 				      cairo_content_t		  content,
 				      double			  width,
@@ -81,10 +80,32 @@ _cairo_boilerplate_qt_create_surface (const char		 *name,
     return cairo_qt_surface_create_with_qpixmap (content, width, height);
 }
 
-void
+static void
 _cairo_boilerplate_qt_synchronize (void *closure)
 {
     qt_closure_t *qtc = (qt_closure_t *) closure;
 
     qtc->app->flush (); /* not sure if this is sufficient */
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"qt", "qt", NULL, NULL,
+	CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_qt_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_qt_cleanup
+    },
+    {
+	"qt", "qt", NULL, NULL,
+	CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_qt_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_qt_cleanup
+    },
+};
+CAIRO_BOILERPLATE (qt, targets)
diff --git a/boilerplate/cairo-boilerplate-quartz-private.h b/boilerplate/cairo-boilerplate-quartz-private.h
deleted file mode 100644
index ccf8a9a..0000000
--- a/boilerplate/cairo-boilerplate-quartz-private.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/*
- * Copyright © 2004,2007 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_QUARTZ_PRIVATE_H_
-#define _CAIRO_BOILERPLATE_QUARTZ_PRIVATE_H_
-
-cairo_surface_t *
-_cairo_boilerplate_quartz_create_surface (const char		   *name,
-					  cairo_content_t	    content,
-					  double			    width,
-					  double			    height,
-					  double			    max_width,
-					  double			    max_height,
-					  cairo_boilerplate_mode_t  mode,
-					  int                       id,
-					  void			  **closure);
-
-void
-_cairo_boilerplate_quartz_cleanup (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
index 0b5b49d..4c62358 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -24,12 +24,11 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-quartz-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-quartz.h>
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_quartz_create_surface (const char			 *name,
 					  cairo_content_t		  content,
 					  double				  width,
@@ -49,8 +48,22 @@ _cairo_boilerplate_quartz_create_surface (const char			 *name,
     return cairo_quartz_surface_create (format, width, height);
 }
 
-void
-_cairo_boilerplate_quartz_cleanup (void *closure)
-{
-    /* nothing */
-}
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"quartz", "quartz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_quartz_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+    },
+    {
+	"quartz", "quartz", NULL, NULL,
+	CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_quartz_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+    },
+};
+CAIRO_BOILERPLATE (quartz, targets)
diff --git a/boilerplate/cairo-boilerplate-script-private.h b/boilerplate/cairo-boilerplate-script-private.h
deleted file mode 100644
index ad01d62..0000000
--- a/boilerplate/cairo-boilerplate-script-private.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/*
- * Copyright © 2008 Chris Wilson
- *
- * 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: Chris Wilson <chris at chris-wilson.co.uk>
- */
-
-#ifndef _CAIRO_BOILERPLATE_SCRIPT_PRIVATE_H_
-#define _CAIRO_BOILERPLATE_SCRIPT_PRIVATE_H_
-
-cairo_surface_t *
-_cairo_boilerplate_script_create_surface (const char		 *name,
-				       cairo_content_t		  content,
-				       double			  width,
-				       double			  height,
-				       double			  max_width,
-				       double			  max_height,
-				       cairo_boilerplate_mode_t	  mode,
-				       int                        id,
-				       void			**closure);
-
-cairo_status_t
-_cairo_boilerplate_script_finish_surface (cairo_surface_t *surface);
-
-cairo_status_t
-_cairo_boilerplate_script_surface_write_to_png (cairo_surface_t *surface,
-						const char *filename);
-
-cairo_surface_t *
-_cairo_boilerplate_script_get_image_surface (cairo_surface_t *surface,
-					     int page,
-					     int width,
-					     int height);
-
-void
-_cairo_boilerplate_script_cleanup (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-script.c b/boilerplate/cairo-boilerplate-script.c
index 3d78078..24a5843 100644
--- a/boilerplate/cairo-boilerplate-script.c
+++ b/boilerplate/cairo-boilerplate-script.c
@@ -24,12 +24,11 @@
  * Author: Chris Wilson <chris at chris-wilson.co.uk>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-script-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include "cairo-script.h"
 
-cairo_user_data_key_t script_closure_key;
+static cairo_user_data_key_t script_closure_key;
 
 typedef struct _script_target_closure {
     char		*filename;
@@ -37,7 +36,7 @@ typedef struct _script_target_closure {
     double		 height;
 } script_target_closure_t;
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_script_create_surface (const char		 *name,
 					  cairo_content_t	  content,
 					  double			  width,
@@ -75,14 +74,14 @@ _cairo_boilerplate_script_create_surface (const char		 *name,
     return surface;
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_script_finish_surface (cairo_surface_t		*surface)
 {
     cairo_surface_finish (surface);
     return cairo_surface_status (surface);
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_script_surface_write_to_png (cairo_surface_t *surface,
 						const char *filename)
 {
@@ -98,7 +97,7 @@ _cairo_boilerplate_script_convert_to_image (cairo_surface_t *surface,
     return cairo_boilerplate_convert_to_image (ptc->filename, page);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_script_get_image_surface (cairo_surface_t *surface,
 					     int page,
 					     int width,
@@ -116,10 +115,23 @@ _cairo_boilerplate_script_get_image_surface (cairo_surface_t *surface,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_script_cleanup (void *closure)
 {
     script_target_closure_t *ptc = closure;
     free (ptc->filename);
     free (ptc);
 }
+
+static const cairo_boilerplate_target_t target[] = {{
+    "script", "script", ".cs", NULL,
+    CAIRO_SURFACE_TYPE_SCRIPT, CAIRO_CONTENT_COLOR_ALPHA, 0,
+    _cairo_boilerplate_script_create_surface,
+    NULL,
+    _cairo_boilerplate_script_finish_surface,
+    _cairo_boilerplate_script_get_image_surface,
+    _cairo_boilerplate_script_surface_write_to_png,
+    _cairo_boilerplate_script_cleanup,
+    NULL, FALSE
+}};
+CAIRO_BOILERPLATE (script, target)
diff --git a/boilerplate/cairo-boilerplate-svg-private.h b/boilerplate/cairo-boilerplate-svg-private.h
deleted file mode 100644
index 5a64eaf..0000000
--- a/boilerplate/cairo-boilerplate-svg-private.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- 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_svg11_create_surface (const char		 *name,
-					 cairo_content_t          content,
-					 double			  width,
-					 double			  height,
-					 double			  max_width,
-					 double			  max_height,
-					 cairo_boilerplate_mode_t mode,
-					 int                      id,
-					 void			**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_svg12_create_surface (const char		 *name,
-					 cairo_content_t	  content,
-					 double			  width,
-					 double			  height,
-					 double			  max_width,
-					 double			  max_height,
-					 cairo_boilerplate_mode_t mode,
-					 int                      id,
-					 void			**closure);
-
-void
-_cairo_boilerplate_svg_force_fallbacks (cairo_surface_t *surface,
-	                                unsigned int flags);
-
-
-cairo_status_t
-_cairo_boilerplate_svg_finish_surface (cairo_surface_t		*surface);
-
-cairo_status_t
-_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename);
-
-cairo_surface_t *
-_cairo_boilerplate_svg_get_image_surface (cairo_surface_t *surface,
-					  int page,
-					  int width,
-					  int height);
-
-void
-_cairo_boilerplate_svg_cleanup (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index 407214c..9d03b20 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -24,8 +24,7 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-svg-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-svg.h>
 #include <cairo-svg-surface-private.h>
@@ -100,7 +99,7 @@ _cairo_boilerplate_svg_create_surface (const char		 *name,
     return surface;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_svg11_create_surface (const char		 *name,
 					 cairo_content_t	  content,
 					 double			  width,
@@ -120,7 +119,7 @@ _cairo_boilerplate_svg11_create_surface (const char		 *name,
 						  closure);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_svg12_create_surface (const char		 *name,
 					 cairo_content_t	  content,
 					 double			  width,
@@ -139,7 +138,7 @@ _cairo_boilerplate_svg12_create_surface (const char		 *name,
 						  closure);
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_svg_finish_surface (cairo_surface_t		*surface)
 {
     svg_target_closure_t *ptc = cairo_surface_get_user_data (surface,
@@ -183,7 +182,7 @@ _cairo_boilerplate_svg_finish_surface (cairo_surface_t		*surface)
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_status_t
+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,
@@ -214,7 +213,7 @@ _cairo_boilerplate_svg_convert_to_image (cairo_surface_t *surface)
     return cairo_boilerplate_convert_to_image (ptc->filename, 0);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_svg_get_image_surface (cairo_surface_t *surface,
 					  int page,
 					  int width,
@@ -235,7 +234,7 @@ _cairo_boilerplate_svg_get_image_surface (cairo_surface_t *surface,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_svg_cleanup (void *closure)
 {
     svg_target_closure_t *ptc = closure;
@@ -245,7 +244,7 @@ _cairo_boilerplate_svg_cleanup (void *closure)
     free (ptc);
 }
 
-void
+static void
 _cairo_boilerplate_svg_force_fallbacks (cairo_surface_t *abstract_surface,
 	                                unsigned int flags)
 {
@@ -262,3 +261,56 @@ _cairo_boilerplate_svg_force_fallbacks (cairo_surface_t *abstract_surface,
     surface = (cairo_svg_surface_t*) paginated->target;
     surface->force_fallbacks = TRUE;
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    /* It seems we should be able to round-trip SVG content perfectly
+     * through librsvg and cairo, but for some mysterious reason, some
+     * systems get an error of 1 for some pixels on some of the text
+     * tests. XXX: I'd still like to chase these down at some point.
+     * For now just set the svg error tolerance to 1. */
+    {
+	"svg11", "svg", NULL, NULL,
+	CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	_cairo_boilerplate_svg11_create_surface,
+	_cairo_boilerplate_svg_force_fallbacks,
+	_cairo_boilerplate_svg_finish_surface,
+	_cairo_boilerplate_svg_get_image_surface,
+	_cairo_boilerplate_svg_surface_write_to_png,
+	_cairo_boilerplate_svg_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"svg11", "svg", NULL, NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_svg11_create_surface,
+	_cairo_boilerplate_svg_force_fallbacks,
+	_cairo_boilerplate_svg_finish_surface,
+	_cairo_boilerplate_svg_get_image_surface,
+	_cairo_boilerplate_svg_surface_write_to_png,
+	_cairo_boilerplate_svg_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"svg12", "svg", NULL, NULL,
+	CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	_cairo_boilerplate_svg12_create_surface,
+	_cairo_boilerplate_svg_force_fallbacks,
+	_cairo_boilerplate_svg_finish_surface,
+	_cairo_boilerplate_svg_get_image_surface,
+	_cairo_boilerplate_svg_surface_write_to_png,
+	_cairo_boilerplate_svg_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"svg12", "svg", NULL, NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_svg12_create_surface,
+	_cairo_boilerplate_svg_force_fallbacks,
+	_cairo_boilerplate_svg_finish_surface,
+	_cairo_boilerplate_svg_get_image_surface,
+	_cairo_boilerplate_svg_surface_write_to_png,
+	_cairo_boilerplate_svg_cleanup,
+	NULL, TRUE, TRUE
+    },
+};
+CAIRO_BOILERPLATE (svg, targets)
diff --git a/boilerplate/cairo-boilerplate-test-surfaces-private.h b/boilerplate/cairo-boilerplate-test-surfaces-private.h
deleted file mode 100644
index 57bf62d..0000000
--- a/boilerplate/cairo-boilerplate-test-surfaces-private.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- 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,
-						 double				  width,
-						 double				  height,
-						 double				  max_width,
-						 double				  max_height,
-						 cairo_boilerplate_mode_t	  mode,
-						 int                              id,
-						 void				**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_test_fallback16_create_surface (const char			 *name,
-						 cairo_content_t		  content,
-						 double				  width,
-						 double				  height,
-						 double				  max_width,
-						 double				  max_height,
-						 cairo_boilerplate_mode_t	  mode,
-						 int                              id,
-						 void				**closure);
-
-
-cairo_surface_t *
-_cairo_boilerplate_test_meta_create_surface (const char			 *name,
-					     cairo_content_t		  content,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     void			**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_test_null_create_surface (const char			 *name,
-					     cairo_content_t		  content,
-					     double			  width,
-					     double			  height,
-					     double			  max_width,
-					     double			  max_height,
-					     cairo_boilerplate_mode_t	  mode,
-					     int                          id,
-					     void			**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_test_paginated_create_surface (const char			 *name,
-						  cairo_content_t		  content,
-						  double				  width,
-						  double				  height,
-						  double				  max_width,
-						  double				  max_height,
-						  cairo_boilerplate_mode_t	  mode,
-						  int                             id,
-						  void				**closure);
-
-cairo_status_t
-_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
-						        const char	*filename);
-
-cairo_surface_t *
-_cairo_boilerplate_test_paginated_get_image_surface (cairo_surface_t *surface,
-						     int page,
-						     int width,
-						     int height);
-
-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
index 255472c..844991c 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -26,8 +26,7 @@
 
 #include "../cairo-version.h"
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-test-surfaces-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <test-fallback-surface.h>
 #include <test-fallback16-surface.h>
@@ -37,9 +36,9 @@
 #include <test-null-surface.h>
 #endif
 
-#include <assert.h>
+#include <cairo-types-private.h>
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_fallback_create_surface (const char			 *name,
 						 cairo_content_t		  content,
 						 double				  width,
@@ -54,7 +53,7 @@ _cairo_boilerplate_test_fallback_create_surface (const char			 *name,
     return _cairo_test_fallback_surface_create (content, width, height);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_fallback16_create_surface (const char			 *name,
 						   cairo_content_t		  content,
 						   double				  width,
@@ -69,7 +68,7 @@ _cairo_boilerplate_test_fallback16_create_surface (const char			 *name,
     return _cairo_test_fallback16_surface_create (content, width, height);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_meta_create_surface (const char			 *name,
 					     cairo_content_t		  content,
 					     double			  width,
@@ -84,7 +83,7 @@ _cairo_boilerplate_test_meta_create_surface (const char			 *name,
     return _cairo_test_meta_surface_create (content, width, height);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_null_create_surface (const char			 *name,
 					     cairo_content_t		  content,
 					     double			  width,
@@ -113,7 +112,7 @@ typedef struct {
     int stride;
 } test_paginated_closure_t;
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_paginated_create_surface (const char			 *name,
 						  cairo_content_t		  content,
 						  double				  width,
@@ -173,7 +172,7 @@ _cairo_boilerplate_test_paginated_create_surface (const char			 *name,
  * test_paginated_surface would not be involved and wouldn't be
  * tested.
  */
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface,
 						        const char	*filename)
 {
@@ -204,7 +203,7 @@ _cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t	*surface
     return status;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_test_paginated_get_image_surface (cairo_surface_t *surface,
 						     int page,
 						     int width,
@@ -251,7 +250,7 @@ _cairo_boilerplate_test_paginated_get_image_surface (cairo_surface_t *surface,
     }
 }
 
-void
+static void
 _cairo_boilerplate_test_paginated_cleanup (void *closure)
 {
     test_paginated_closure_t *tpc = closure;
@@ -259,3 +258,99 @@ _cairo_boilerplate_test_paginated_cleanup (void *closure)
     free (tpc->data);
     free (tpc);
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"test-fallback", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
+	CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_test_fallback_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png
+    },
+    {
+	"test-fallback", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
+	CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_test_fallback_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png
+    },
+    {
+	"test-fallback16", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
+	CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_test_fallback16_create_surface,
+	NULL, NULL,
+	NULL, /* _cairo_boilerplate_get_image_surface, */
+	cairo_surface_write_to_png
+    },
+    {
+	"test-fallback16", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
+	CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_test_fallback16_create_surface,
+	NULL, NULL,
+	NULL, /* _cairo_boilerplate_get_image_surface, */
+	cairo_surface_write_to_png
+    },
+    {
+	"test-meta", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
+	CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_test_meta_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	NULL, NULL,
+	FALSE, TRUE
+    },
+    {
+	"test-meta", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
+	CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_test_meta_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	NULL, NULL,
+	FALSE, TRUE
+    },
+    {
+	"test-paginated", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
+	CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_test_paginated_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_test_paginated_get_image_surface,
+	_cairo_boilerplate_test_paginated_surface_write_to_png,
+	_cairo_boilerplate_test_paginated_cleanup,
+	NULL,
+	FALSE, TRUE,
+    },
+    {
+	"test-paginated", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
+	CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_test_paginated_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_test_paginated_get_image_surface,
+	_cairo_boilerplate_test_paginated_surface_write_to_png,
+	_cairo_boilerplate_test_paginated_cleanup,
+	NULL,
+	FALSE, TRUE
+    },
+    {
+	"null", "image", NULL, NULL,
+	CAIRO_INTERNAL_SURFACE_TYPE_NULL,
+	CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_test_null_create_surface,
+	NULL, NULL,
+	NULL, NULL, NULL,
+	NULL,
+	TRUE, FALSE
+    },
+};
+CAIRO_BOILERPLATE (test, targets)
diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c
index 7a6dafc..541401a 100644
--- a/boilerplate/cairo-boilerplate-win32-printing.c
+++ b/boilerplate/cairo-boilerplate-win32-printing.c
@@ -34,8 +34,7 @@
 # define _WIN32_WINNT 0x0500
 #endif
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-win32-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-win32.h>
 #include <cairo-win32-private.h>
@@ -59,10 +58,9 @@
 # define FEATURESETTING_PSLEVEL 0x0002
 #endif
 
-cairo_user_data_key_t win32_closure_key;
+static cairo_user_data_key_t win32_closure_key;
 
-typedef struct _win32_target_closure
-{
+typedef struct _win32_target_closure {
     char *filename;
     int width;
     int height;
@@ -161,7 +159,7 @@ create_printer_dc (win32_target_closure_t *ptc)
     ptc->bottom_margin = 72.0*(page_height - printable_height - top_margin)/y_dpi;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_win32_printing_create_surface (const char              *name,
 						  cairo_content_t          content,
 						  double                      width,
@@ -233,7 +231,7 @@ _cairo_boilerplate_win32_printing_create_surface (const char              *name,
     return surface;
 }
 
-cairo_status_t
+static cairo_status_t
 _cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface, const char *filename)
 {
     win32_target_closure_t *ptc = cairo_surface_get_user_data (surface, &win32_closure_key);
@@ -300,7 +298,7 @@ _cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface
     return CAIRO_STATUS_SUCCESS;
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_win32_printing_get_image_surface (cairo_surface_t *surface,
 						     int page,
 						     int width,
@@ -331,7 +329,7 @@ _cairo_boilerplate_win32_printing_get_image_surface (cairo_surface_t *surface,
     return surface;
 }
 
-void
+static void
 _cairo_boilerplate_win32_printing_cleanup (void *closure)
 {
     win32_target_closure_t *ptc = closure;
@@ -342,3 +340,30 @@ _cairo_boilerplate_win32_printing_cleanup (void *closure)
     free (ptc);
     DeleteDC (ptc->dc);
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+#if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE
+    {
+	"win32-printing", "win32", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_WIN32_PRINTING,
+	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
+	_cairo_boilerplate_win32_printing_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_win32_printing_get_image_surface,
+	_cairo_boilerplate_win32_printing_surface_write_to_png,
+	_cairo_boilerplate_win32_printing_cleanup,
+	NULL, TRUE, TRUE
+    },
+    {
+	"win32-printing", "win32", ".ps", NULL,
+	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_win32_printing_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_win32_printing_get_image_surface,
+	_cairo_boilerplate_win32_printing_surface_write_to_png,
+	_cairo_boilerplate_win32_printing_cleanup,
+	NULL, TRUE, TRUE
+    },
+#endif
+};
+CAIRO_BOILERPLATE (win32_printing, targets)
diff --git a/boilerplate/cairo-boilerplate-win32-private.h b/boilerplate/cairo-boilerplate-win32-private.h
deleted file mode 100644
index b09b9f7..0000000
--- a/boilerplate/cairo-boilerplate-win32-private.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- 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,
-					 double				  width,
-					 double				  height,
-					 double				  max_width,
-					 double				  max_height,
-					 cairo_boilerplate_mode_t	  mode,
-					 int                              id,
-					 void				**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_win32_printing_create_surface (const char		  *name,
-						  cairo_content_t	   content,
-						  double			   width,
-						  double			   height,
-						  double			   max_width,
-						  double			   max_height,
-						  cairo_boilerplate_mode_t mode,
-						  int			   id,
-						  void			 **closure);
-
-void
-_cairo_boilerplate_win32_printing_cleanup (void *closure);
-
-cairo_status_t
-_cairo_boilerplate_win32_printing_surface_write_to_png (cairo_surface_t *surface,
-							const char      *filename);
-
-cairo_surface_t *
-_cairo_boilerplate_win32_printing_get_image_surface (cairo_surface_t *surface,
-						     int page,
-						     int width,
-						     int height);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
index 83bc7c2..420989b 100644
--- a/boilerplate/cairo-boilerplate-win32.c
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -24,12 +24,11 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-win32-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-win32.h>
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_win32_create_surface (const char			 *name,
 					 cairo_content_t		  content,
 					 double				  width,
@@ -48,3 +47,26 @@ _cairo_boilerplate_win32_create_surface (const char			 *name,
 
     return cairo_win32_surface_create_with_dib (format, width, height);
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    {
+	"win32", "win32", NULL, NULL,
+	CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
+	_cairo_boilerplate_win32_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_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", "win32", NULL, NULL,
+	CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
+	_cairo_boilerplate_win32_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png
+    },
+};
+CAIRO_BOILERPLATE (win32, targets)
diff --git a/boilerplate/cairo-boilerplate-xcb-private.h b/boilerplate/cairo-boilerplate-xcb-private.h
deleted file mode 100644
index 969b761..0000000
--- a/boilerplate/cairo-boilerplate-xcb-private.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- 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,
-				       double			  width,
-				       double			  height,
-				       double			  max_width,
-				       double			  max_height,
-				       cairo_boilerplate_mode_t	  mode,
-				       int                        id,
-				       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
index 23e1b5a..63c20e8 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -24,20 +24,18 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-xcb-private.h"
+#include "cairo-boilerplate-private.h"
 
 #include <cairo-xcb-xrender.h>
 
 #include <xcb/xcb_renderutil.h>
 
-typedef struct _xcb_target_closure
-{
+typedef struct _xcb_target_closure {
     xcb_connection_t *c;
     xcb_pixmap_t pixmap;
 } xcb_target_closure_t;
 
-void
+static void
 _cairo_boilerplate_xcb_synchronize (void *closure)
 {
     xcb_target_closure_t *xtc = closure;
@@ -47,7 +45,7 @@ _cairo_boilerplate_xcb_synchronize (void *closure)
 		0));
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_xcb_create_surface (const char		 *name,
 				       cairo_content_t		  content,
 				       double			  width,
@@ -105,7 +103,7 @@ _cairo_boilerplate_xcb_create_surface (const char		 *name,
 							 width, height);
 }
 
-void
+static void
 _cairo_boilerplate_xcb_cleanup (void *closure)
 {
     xcb_target_closure_t *xtc = closure;
@@ -114,3 +112,19 @@ _cairo_boilerplate_xcb_cleanup (void *closure)
     xcb_disconnect (xtc->c);
     free (xtc);
 }
+
+static const cairo_boilerplate_target_t targets[] = {
+    /* Acceleration architectures may make the results differ by a
+     * bit, so we set the error tolerance to 1. */
+    {
+	"xcb", "xcb", NULL, NULL,
+	CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	_cairo_boilerplate_xcb_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_xcb_cleanup,
+	_cairo_boilerplate_xcb_synchronize
+    },
+};
+CAIRO_BOILERPLATE (xcb, targets)
diff --git a/boilerplate/cairo-boilerplate-xlib-private.h b/boilerplate/cairo-boilerplate-xlib-private.h
deleted file mode 100644
index e4f24ce..0000000
--- a/boilerplate/cairo-boilerplate-xlib-private.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- 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_XLIB_PRIVATE_H_
-#define _CAIRO_BOILERPLATE_XLIB_PRIVATE_H_
-
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
-cairo_surface_t *
-_cairo_boilerplate_xlib_create_surface (const char		  *name,
-					cairo_content_t		   content,
-					double			   width,
-					double			   height,
-					double			   max_width,
-					double			   max_height,
-					cairo_boilerplate_mode_t   mode,
-					int                        id,
-					void			 **closure);
-#endif
-
-cairo_surface_t *
-_cairo_boilerplate_xlib_reference_create_surface (const char			 *name,
-						 cairo_content_t		  content,
-						 double				  width,
-						 double				  height,
-						 double				  max_width,
-						 double				  max_height,
-						 cairo_boilerplate_mode_t	  mode,
-						 int				  id,
-						 void				**closure);
-
-cairo_surface_t *
-_cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
-						 cairo_content_t		  content,
-						 double				  width,
-						 double				  height,
-						 double				  max_width,
-						 double				  max_height,
-						 cairo_boilerplate_mode_t	  mode,
-						 int				  id,
-						 void				**closure);
-
-void
-_cairo_boilerplate_xlib_cleanup (void *closure);
-
-void
-_cairo_boilerplate_xlib_synchronize (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index f40f927..3c996cd 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -24,9 +24,8 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
-#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-private.h"
 #include "cairo-boilerplate-xlib.h"
-#include "cairo-boilerplate-xlib-private.h"
 
 #include <cairo-xlib.h>
 #if CAIRO_HAS_XLIB_XRENDER_SURFACE
@@ -36,14 +35,28 @@
 
 #include <X11/Xutil.h> /* for XDestroyImage */
 
-typedef struct _xlib_target_closure
-{
+typedef struct _xlib_target_closure {
     Display *dpy;
     Drawable drawable;
     cairo_bool_t drawable_is_pixmap;
 } xlib_target_closure_t;
 
-void
+static void
+_cairo_boilerplate_xlib_cleanup (void *closure)
+{
+    xlib_target_closure_t *xtc = closure;
+
+    if (xtc->drawable) {
+	if (xtc->drawable_is_pixmap)
+	    XFreePixmap (xtc->dpy, xtc->drawable);
+	else
+	    XDestroyWindow (xtc->dpy, xtc->drawable);
+    }
+    XCloseDisplay (xtc->dpy);
+    free (xtc);
+}
+
+static void
 _cairo_boilerplate_xlib_synchronize (void *closure)
 {
     xlib_target_closure_t *xtc = closure;
@@ -185,7 +198,7 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
 							  width, height);
 }
 
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_xlib_create_surface (const char			 *name,
 					cairo_content_t			  content,
 					double				  width,
@@ -228,60 +241,24 @@ _cairo_boilerplate_xlib_create_surface (const char			 *name,
     return surface;
 }
 
-cairo_surface_t *
-_cairo_boilerplate_xlib_reference_create_surface (const char			 *name,
-						  cairo_content_t			  content,
-						  double				  width,
-						  double				  height,
-						  double				  max_width,
-						  double				  max_height,
-						  cairo_boilerplate_mode_t	  mode,
-						  int                               id,
-						  void				**closure)
+cairo_status_t
+cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface)
 {
-    xlib_target_closure_t *xtc;
-    Display *dpy;
-    cairo_surface_t *surface;
-    const char *display;
-
-    display = getenv ("CAIRO_REFERENCE_DISPLAY");
-    if (display == NULL) {
-	return _cairo_boilerplate_xlib_fallback_create_surface (name, content,
-								width, height,
-								max_width,
-								max_height,
-								mode, id,
-								closure);
-    }
-
-    *closure = xtc = xcalloc (1, sizeof (xlib_target_closure_t));
-
-    width = ceil (width);
-    if (width < 1)
-	width = 1;
-
-    height = ceil (height);
-    if (height < 1)
-	height = 1;
+    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t*) abstract_surface;
 
-    xtc->dpy = dpy = XOpenDisplay (display);
-    if (xtc->dpy == NULL) {
-	free (xtc);
-	CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", display));
-	return NULL;
-    }
+    if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_XLIB)
+	return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
 
-    if (mode == CAIRO_BOILERPLATE_MODE_TEST)
-	surface = _cairo_boilerplate_xlib_test_create_surface (dpy, content, width, height, xtc);
-    else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
-	surface = _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc);
+    surface->render_major = surface->render_minor = -1;
+    surface->xrender_format = NULL;
 
-    if (surface == NULL || cairo_surface_status (surface))
-	_cairo_boilerplate_xlib_cleanup (xtc);
+    /* The content type is forced by _xrender_format_to_content() during
+     * non-Render surface creation, so repeat the procedure here. */
+    surface->base.content = CAIRO_CONTENT_COLOR;
 
-    return surface;
+    return CAIRO_STATUS_SUCCESS;
 }
-#endif
+
 
 /* The xlib-fallback target differs from the xlib target in two ways:
  *
@@ -292,7 +269,7 @@ _cairo_boilerplate_xlib_reference_create_surface (const char			 *name,
  * This provides testing of the non-Render fallback paths we have in
  * cairo-xlib-surface.c
  */
-cairo_surface_t *
+static cairo_surface_t *
 _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
 						 cairo_content_t		  content,
 						 double				  width,
@@ -389,35 +366,109 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
     return surface;
 }
 
-void
-_cairo_boilerplate_xlib_cleanup (void *closure)
+static cairo_surface_t *
+_cairo_boilerplate_xlib_reference_create_surface (const char			 *name,
+						  cairo_content_t			  content,
+						  double				  width,
+						  double				  height,
+						  double				  max_width,
+						  double				  max_height,
+						  cairo_boilerplate_mode_t	  mode,
+						  int                               id,
+						  void				**closure)
 {
-    xlib_target_closure_t *xtc = closure;
+    xlib_target_closure_t *xtc;
+    Display *dpy;
+    cairo_surface_t *surface;
+    const char *display;
 
-    if (xtc->drawable) {
-	if (xtc->drawable_is_pixmap)
-	    XFreePixmap (xtc->dpy, xtc->drawable);
-	else
-	    XDestroyWindow (xtc->dpy, xtc->drawable);
+    display = getenv ("CAIRO_REFERENCE_DISPLAY");
+    if (display == NULL) {
+	return _cairo_boilerplate_xlib_fallback_create_surface (name, content,
+								width, height,
+								max_width,
+								max_height,
+								mode, id,
+								closure);
     }
-    XCloseDisplay (xtc->dpy);
-    free (xtc);
-}
 
-cairo_status_t
-cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface)
-{
-    cairo_xlib_surface_t *surface = (cairo_xlib_surface_t*) abstract_surface;
+    *closure = xtc = xcalloc (1, sizeof (xlib_target_closure_t));
 
-    if (cairo_surface_get_type (abstract_surface) != CAIRO_SURFACE_TYPE_XLIB)
-	return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
+    width = ceil (width);
+    if (width < 1)
+	width = 1;
 
-    surface->render_major = surface->render_minor = -1;
-    surface->xrender_format = NULL;
+    height = ceil (height);
+    if (height < 1)
+	height = 1;
 
-    /* The content type is forced by _xrender_format_to_content() during
-     * non-Render surface creation, so repeat the procedure here. */
-    surface->base.content = CAIRO_CONTENT_COLOR;
+    xtc->dpy = dpy = XOpenDisplay (display);
+    if (xtc->dpy == NULL) {
+	free (xtc);
+	CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", display));
+	return NULL;
+    }
 
-    return CAIRO_STATUS_SUCCESS;
+    if (mode == CAIRO_BOILERPLATE_MODE_TEST)
+	surface = _cairo_boilerplate_xlib_test_create_surface (dpy, content, width, height, xtc);
+    else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
+	surface = _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc);
+
+    if (surface == NULL || cairo_surface_status (surface))
+	_cairo_boilerplate_xlib_cleanup (xtc);
+
+    return surface;
 }
+#endif
+
+static const cairo_boilerplate_target_t targets[] = {
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+    /* Acceleration architectures may make the results differ by a
+     * bit, so we set the error tolerance to 1. */
+    {
+	"xlib", "xlib", NULL, "xlib-reference",
+	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 1,
+	_cairo_boilerplate_xlib_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_xlib_cleanup,
+	_cairo_boilerplate_xlib_synchronize
+    },
+    {
+	"xlib", "xlib", NULL, "xlib-reference",
+	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_xlib_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_xlib_cleanup,
+	_cairo_boilerplate_xlib_synchronize
+    },
+    {
+	"xlib-reference", "xlib", NULL, NULL,
+	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_xlib_reference_create_surface,
+	NULL, NULL,
+	NULL, /* get_image */
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_xlib_cleanup,
+	_cairo_boilerplate_xlib_synchronize
+    },
+#endif
+#if CAIRO_HAS_XLIB_SURFACE
+    /* This is a fallback surface which uses xlib fallbacks instead of
+     * the Render extension. */
+    {
+	"xlib-fallback", "xlib", NULL, NULL,
+	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
+	_cairo_boilerplate_xlib_fallback_create_surface,
+	NULL, NULL,
+	_cairo_boilerplate_get_image_surface,
+	cairo_surface_write_to_png,
+	_cairo_boilerplate_xlib_cleanup,
+	_cairo_boilerplate_xlib_synchronize
+    },
+#endif
+};
+CAIRO_BOILERPLATE (xlib, targets)
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index f3e574c..dfca1db 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -26,49 +26,9 @@
 
 #define CAIRO_VERSION_H 1
 
-#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-private.h"
 #include "cairo-boilerplate-scaled-font.h"
 
-#if CAIRO_HAS_BEOS_SURFACE
-#include "cairo-boilerplate-beos-private.h"
-#endif
-#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
-#if CAIRO_HAS_PS_SURFACE
-#include "cairo-boilerplate-ps-private.h"
-#endif
-#if CAIRO_HAS_QT_SURFACE
-#include "cairo-boilerplate-qt-private.h"
-#endif
-#if CAIRO_HAS_QUARTZ_SURFACE
-#include "cairo-boilerplate-quartz-private.h"
-#endif
-#if CAIRO_HAS_SCRIPT_SURFACE
-#include "cairo-boilerplate-script-private.h"
-#endif
-#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
-#if CAIRO_HAS_XCB_SURFACE
-#include "cairo-boilerplate-xcb-private.h"
-#endif
-#if CAIRO_HAS_XLIB_SURFACE
-#include "cairo-boilerplate-xlib-private.h"
-#endif
-
 #include <cairo-types-private.h>
 #include <cairo-scaled-font-private.h>
 
@@ -275,8 +235,7 @@ cairo_boilerplate_get_image_surface_from_png (const char *filename,
     return surface;
 }
 
-static const cairo_boilerplate_target_t targets[] =
-{
+static const cairo_boilerplate_target_t builtin_targets[] = {
     /* I'm uncompromising about leaving the image backend as 0
      * for tolerance. There shouldn't ever be anything that is out of
      * our control here. */
@@ -296,499 +255,28 @@ static const cairo_boilerplate_target_t targets[] =
 	_cairo_boilerplate_get_image_surface,
 	cairo_surface_write_to_png
     },
-#ifdef CAIRO_HAS_TEST_SURFACES
-    {
-	"test-fallback", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_fallback_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png
-    },
-    {
-	"test-fallback", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
-	CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_test_fallback_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png
-    },
-    {
-	"test-fallback16", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_fallback16_create_surface,
-	NULL, NULL,
-	NULL, /* _cairo_boilerplate_get_image_surface, */
-	cairo_surface_write_to_png
-    },
-    {
-	"test-fallback16", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
-	CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_test_fallback16_create_surface,
-	NULL, NULL,
-	NULL, /* _cairo_boilerplate_get_image_surface, */
-	cairo_surface_write_to_png
-    },
-    {
-	"test-meta", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_meta_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	NULL, NULL,
-	FALSE, TRUE
-    },
-    {
-	"test-meta", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
-	CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_test_meta_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	NULL, NULL,
-	FALSE, TRUE
-    },
-    {
-	"test-paginated", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_paginated_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_test_paginated_get_image_surface,
-	_cairo_boilerplate_test_paginated_surface_write_to_png,
-	_cairo_boilerplate_test_paginated_cleanup,
-	NULL,
-	FALSE, TRUE,
-    },
-    {
-	"test-paginated", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
-	CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_test_paginated_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_test_paginated_get_image_surface,
-	_cairo_boilerplate_test_paginated_surface_write_to_png,
-	_cairo_boilerplate_test_paginated_cleanup,
-	NULL,
-	FALSE, TRUE
-    },
-    {
-	"null", "image", NULL, NULL,
-	CAIRO_INTERNAL_SURFACE_TYPE_NULL,
-	CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_test_null_create_surface,
-	NULL, NULL,
-	NULL, NULL, NULL,
-	NULL,
-	TRUE, FALSE
-    },
-#endif
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-    {
-	"glitz-glx", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_glitz_glx_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_glx_cleanup
-    },
-    {
-	"glitz-glx", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_glitz_glx_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_glx_cleanup
-    },
-#endif
-#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-    {
-	"glitz-agl", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_glitz_agl_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_agl_cleanup
-    },
-    {
-	"glitz-agl", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_glitz_agl_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_agl_cleanup
-    },
-#endif
-#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-    {
-	"glitz-wgl", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_glitz_wgl_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_wgl_cleanup
-    },
-    {
-	"glitz-wgl", "glitz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_glitz_wgl_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_glitz_wgl_cleanup
-    },
-#endif
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
-#if CAIRO_HAS_QT_SURFACE
-    {
-	"qt", "qt", NULL, NULL,
-	CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_qt_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_qt_cleanup
-    },
-    {
-	"qt", "qt", NULL, NULL,
-	CAIRO_SURFACE_TYPE_QT, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_qt_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_qt_cleanup
-    },
-#endif
-#if CAIRO_HAS_QUARTZ_SURFACE
-    {
-	"quartz", "quartz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_quartz_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_quartz_cleanup
-    },
-    {
-	"quartz", "quartz", NULL, NULL,
-	CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_quartz_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_quartz_cleanup
-    },
-#endif
-#if CAIRO_HAS_WIN32_SURFACE
-    {
-	"win32", "win32", NULL, NULL,
-	CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_win32_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_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", "win32", NULL, NULL,
-	CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_win32_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png
-    },
-#if CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE
-    {
-	"win32-printing", "win32", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_WIN32_PRINTING,
-	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
-	_cairo_boilerplate_win32_printing_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_win32_printing_get_image_surface,
-	_cairo_boilerplate_win32_printing_surface_write_to_png,
-	_cairo_boilerplate_win32_printing_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"win32-printing", "win32", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_win32_printing_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_win32_printing_get_image_surface,
-	_cairo_boilerplate_win32_printing_surface_write_to_png,
-	_cairo_boilerplate_win32_printing_cleanup,
-	NULL, TRUE, TRUE
-    },
-#endif
-#endif
-#if CAIRO_HAS_XCB_SURFACE
-    /* Acceleration architectures may make the results differ by a
-     * bit, so we set the error tolerance to 1. */
-    {
-	"xcb", "xcb", NULL, NULL,
-	CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA, 1,
-	_cairo_boilerplate_xcb_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_xcb_cleanup,
-	_cairo_boilerplate_xcb_synchronize
-    },
-#endif
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
-    /* Acceleration architectures may make the results differ by a
-     * bit, so we set the error tolerance to 1. */
-    {
-	"xlib", "xlib", NULL, "xlib-reference",
-	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 1,
-	_cairo_boilerplate_xlib_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_xlib_cleanup,
-	_cairo_boilerplate_xlib_synchronize
-    },
-    {
-	"xlib", "xlib", NULL, "xlib-reference",
-	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_xlib_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_xlib_cleanup,
-	_cairo_boilerplate_xlib_synchronize
-    },
-    {
-	"xlib-reference", "xlib", NULL, NULL,
-	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_xlib_reference_create_surface,
-	NULL, NULL,
-	NULL, /* get_image */
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_xlib_cleanup,
-	_cairo_boilerplate_xlib_synchronize
-    },
-#endif
-#if CAIRO_HAS_XLIB_SURFACE
-    /* This is a fallback surface which uses xlib fallbacks instead of
-     * the Render extension. */
-    {
-	"xlib-fallback", "xlib", NULL, NULL,
-	CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_xlib_fallback_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_xlib_cleanup,
-	_cairo_boilerplate_xlib_synchronize
-    },
-#endif
-#if CAIRO_HAS_PS_SURFACE && CAIRO_CAN_TEST_PS_SURFACE
-    {
-	"ps2", "ps", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_PS,
-	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
-	_cairo_boilerplate_ps2_create_surface,
-	_cairo_boilerplate_ps_force_fallbacks,
-	_cairo_boilerplate_ps_finish_surface,
-	_cairo_boilerplate_ps_get_image_surface,
-	_cairo_boilerplate_ps_surface_write_to_png,
-	_cairo_boilerplate_ps_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"ps2", "ps", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_ps2_create_surface,
-	_cairo_boilerplate_ps_force_fallbacks,
-	_cairo_boilerplate_ps_finish_surface,
-	_cairo_boilerplate_ps_get_image_surface,
-	_cairo_boilerplate_ps_surface_write_to_png,
-	_cairo_boilerplate_ps_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"ps3", "ps", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_PS,
-	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
-	_cairo_boilerplate_ps3_create_surface,
-	_cairo_boilerplate_ps_force_fallbacks,
-	_cairo_boilerplate_ps_finish_surface,
-	_cairo_boilerplate_ps_get_image_surface,
-	_cairo_boilerplate_ps_surface_write_to_png,
-	_cairo_boilerplate_ps_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"ps3", "ps", ".ps", NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_ps3_create_surface,
-	_cairo_boilerplate_ps_force_fallbacks,
-	_cairo_boilerplate_ps_finish_surface,
-	_cairo_boilerplate_ps_get_image_surface,
-	_cairo_boilerplate_ps_surface_write_to_png,
-	_cairo_boilerplate_ps_cleanup,
-	NULL, TRUE, TRUE
-    },
-#endif
-#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
-    {
-	"pdf", "pdf", ".pdf", NULL,
-	CAIRO_SURFACE_TYPE_PDF,
-	CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
-	_cairo_boilerplate_pdf_create_surface,
-	_cairo_boilerplate_pdf_force_fallbacks,
-	_cairo_boilerplate_pdf_finish_surface,
-	_cairo_boilerplate_pdf_get_image_surface,
-	_cairo_boilerplate_pdf_surface_write_to_png,
-	_cairo_boilerplate_pdf_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"pdf", "pdf", ".pdf", NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_pdf_create_surface,
-	_cairo_boilerplate_pdf_force_fallbacks,
-	_cairo_boilerplate_pdf_finish_surface,
-	_cairo_boilerplate_pdf_get_image_surface,
-	_cairo_boilerplate_pdf_surface_write_to_png,
-	_cairo_boilerplate_pdf_cleanup,
-	NULL, TRUE, TRUE
-    },
-#endif
-#if CAIRO_HAS_SCRIPT_SURFACE
-    {
-	"script", "script", ".cs", NULL,
-	CAIRO_SURFACE_TYPE_SCRIPT, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_script_create_surface,
-	NULL,
-	_cairo_boilerplate_script_finish_surface,
-	_cairo_boilerplate_script_get_image_surface,
-	_cairo_boilerplate_script_surface_write_to_png,
-	_cairo_boilerplate_script_cleanup,
-	NULL, FALSE
-    },
-#endif
-#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
-    /* It seems we should be able to round-trip SVG content perfectly
-     * through librsvg and cairo, but for some mysterious reason, some
-     * systems get an error of 1 for some pixels on some of the text
-     * tests. XXX: I'd still like to chase these down at some point.
-     * For now just set the svg error tolerance to 1. */
-    {
-	"svg11", "svg", NULL, NULL,
-	CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
-	_cairo_boilerplate_svg11_create_surface,
-	_cairo_boilerplate_svg_force_fallbacks,
-	_cairo_boilerplate_svg_finish_surface,
-	_cairo_boilerplate_svg_get_image_surface,
-	_cairo_boilerplate_svg_surface_write_to_png,
-	_cairo_boilerplate_svg_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"svg11", "svg", NULL, NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_svg11_create_surface,
-	_cairo_boilerplate_svg_force_fallbacks,
-	_cairo_boilerplate_svg_finish_surface,
-	_cairo_boilerplate_svg_get_image_surface,
-	_cairo_boilerplate_svg_surface_write_to_png,
-	_cairo_boilerplate_svg_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"svg12", "svg", NULL, NULL,
-	CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
-	_cairo_boilerplate_svg12_create_surface,
-	_cairo_boilerplate_svg_force_fallbacks,
-	_cairo_boilerplate_svg_finish_surface,
-	_cairo_boilerplate_svg_get_image_surface,
-	_cairo_boilerplate_svg_surface_write_to_png,
-	_cairo_boilerplate_svg_cleanup,
-	NULL, TRUE, TRUE
-    },
-    {
-	"svg12", "svg", NULL, NULL,
-	CAIRO_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_svg12_create_surface,
-	_cairo_boilerplate_svg_force_fallbacks,
-	_cairo_boilerplate_svg_finish_surface,
-	_cairo_boilerplate_svg_get_image_surface,
-	_cairo_boilerplate_svg_surface_write_to_png,
-	_cairo_boilerplate_svg_cleanup,
-	NULL, TRUE, TRUE
-    },
-#endif
-#if CAIRO_HAS_BEOS_SURFACE
-    /* BeOS sometimes produces a slightly different image. Perhaps this
-     * is related to the fact that it doesn't use premultiplied alpha...
-     * Just ignore the small difference. */
-    {
-	"beos", "beos", NULL, NULL,
-	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_beos_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_beos_cleanup
-    },
-    {
-	"beos-bitmap", "beos", NULL, NULL,
-	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
-	_cairo_boilerplate_beos_create_surface_for_bitmap,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_beos_cleanup_bitmap
-    },
-    {
-	"beos-bitmap", "beos", NULL, NULL,
-	CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1,
-	_cairo_boilerplate_beos_create_surface_for_bitmap,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_beos_cleanup_bitmap
-    },
-#endif
-
-#if CAIRO_HAS_DIRECTFB_SURFACE
-    {
-	"directfb", "directfb", NULL, NULL,
-	CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
-	_cairo_boilerplate_directfb_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_directfb_cleanup
-    },
-    {
-	"directfb-bitmap", "directfb", NULL, NULL,
-	CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0,
-	_cairo_boilerplate_directfb_create_surface,
-	NULL, NULL,
-	_cairo_boilerplate_get_image_surface,
-	cairo_surface_write_to_png,
-	_cairo_boilerplate_directfb_cleanup
-    },
-#endif
 };
+CAIRO_BOILERPLATE (builtin, builtin_targets)
+
+static struct cairo_boilerplate_target_list {
+    struct cairo_boilerplate_target_list *next;
+    const cairo_boilerplate_target_t *target;
+} *cairo_boilerplate_targets;
+
+void
+_cairo_boilerplate_register_backend (const cairo_boilerplate_target_t *targets,
+				     unsigned int count)
+{
+    targets += count;
+    while (count--) {
+	struct cairo_boilerplate_target_list *list;
+
+	list = xmalloc (sizeof (*list));
+	list->next = cairo_boilerplate_targets;
+	list->target = --targets;
+	cairo_boilerplate_targets = list;
+    }
+}
 
 const cairo_boilerplate_target_t **
 cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets)
@@ -797,6 +285,10 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
     cairo_bool_t limited_targets = FALSE;
     const char *tname;
     const cairo_boilerplate_target_t **targets_to_test;
+    struct cairo_boilerplate_target_list *list;
+
+    if (cairo_boilerplate_targets == NULL)
+	_cairo_boilerplate_register_all ();
 
     if ((tname = getenv ("CAIRO_TEST_TARGET")) != NULL && *tname) {
 	/* check the list of targets specified by the user */
@@ -816,29 +308,40 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
 		continue;
 	    }
 
-	    for (i = 0; i < sizeof (targets) / sizeof (targets[0]); i++) {
-		if (0 == strncmp (targets[i].name, tname, end - tname) &&
-		    !isalnum (targets[i].name[end - tname])) {
+	    for (list = cairo_boilerplate_targets;
+		 list != NULL;
+		 list = list->next)
+	    {
+		const cairo_boilerplate_target_t *target = list->target;
+		if (0 == strncmp (target->name, tname, end - tname) &&
+		    !isalnum (target->name[end - tname])) {
 		    /* realloc isn't exactly the best thing here, but meh. */
 		    targets_to_test = xrealloc (targets_to_test, sizeof(cairo_boilerplate_target_t *) * (num_targets+1));
-		    targets_to_test[num_targets++] = &targets[i];
+		    targets_to_test[num_targets++] = target;
 		    found = 1;
 		}
 	    }
 
 	    if (!found) {
+		const char *last_name = NULL;
+
 		fprintf (stderr, "Cannot find target '%.*s'.\n",
 			 (int)(end - tname), tname);
 		fprintf (stderr, "Known targets:");
-		for (i = 0; i < sizeof (targets) / sizeof (targets[0]); i++) {
-		    if (i != 0) {
-			if (strcmp (targets[i].name, targets[i-1].name) == 0) {
+		for (list = cairo_boilerplate_targets;
+		     list != NULL;
+		     list = list->next)
+		{
+		    const cairo_boilerplate_target_t *target = list->target;
+		    if (last_name != NULL) {
+			if (strcmp (target->name, last_name) == 0) {
 			    /* filter out repeats that differ in content */
 			    continue;
 			}
 			fprintf (stderr, ",");
 		    }
-		    fprintf (stderr, " %s", targets[i].name);
+		    fprintf (stderr, " %s", target->name);
+		    last_name = target->name;
 		}
 		fprintf (stderr, "\n");
 		exit(-1);
@@ -850,10 +353,18 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
 	}
     } else {
 	/* check all compiled in targets */
-	num_targets = sizeof (targets) / sizeof (targets[0]);
+	num_targets = 0;
+	for (list = cairo_boilerplate_targets; list != NULL; list = list->next)
+	    num_targets++;
+
 	targets_to_test = xmalloc (sizeof(cairo_boilerplate_target_t*) * num_targets);
-	for (i = 0; i < num_targets; i++) {
-	    targets_to_test[i] = &targets[i];
+	num_targets = 0;
+	for (list = cairo_boilerplate_targets;
+	     list != NULL;
+	     list = list->next)
+	{
+	    const cairo_boilerplate_target_t *target = list->target;
+	    targets_to_test[num_targets++] = target;
 	}
     }
 
@@ -899,14 +410,17 @@ cairo_boilerplate_get_targets (int *pnum_targets, cairo_bool_t *plimited_targets
 const cairo_boilerplate_target_t *
 cairo_boilerplate_get_image_target (cairo_content_t content)
 {
-    int num_targets, i;
+    struct cairo_boilerplate_target_list *list;
+
+    if (cairo_boilerplate_targets == NULL)
+	_cairo_boilerplate_register_all ();
 
-    num_targets = sizeof (targets) / sizeof (targets[0]);
-    for (i = 0; i < num_targets; i++) {
-	if (targets[i].expected_type == CAIRO_SURFACE_TYPE_IMAGE &&
-	    targets[i].content == content)
+    for (list = cairo_boilerplate_targets; list != NULL; list = list->next) {
+	const cairo_boilerplate_target_t *target = list->target;
+	if (target->expected_type == CAIRO_SURFACE_TYPE_IMAGE &&
+	    target->content == content)
 	{
-	    return &targets[i];
+	    return target;
 	}
     }
 
@@ -917,23 +431,26 @@ const cairo_boilerplate_target_t *
 cairo_boilerplate_get_target_by_name (const char *name,
 				      cairo_content_t content)
 {
-    int num_targets, i;
+    struct cairo_boilerplate_target_list *list;
 
-    num_targets = sizeof (targets) / sizeof (targets[0]);
+    if (cairo_boilerplate_targets == NULL)
+	_cairo_boilerplate_register_all ();
 
     /* first return an exact match */
-    for (i = 0; i < num_targets; i++) {
-	if (strcmp (targets[i].name, name) == 0 &&
-	    targets[i].content == content)
+    for (list = cairo_boilerplate_targets; list != NULL; list = list->next) {
+	const cairo_boilerplate_target_t *target = list->target;
+	if (strcmp (target->name, name) == 0 &&
+	    target->content == content)
 	{
-	    return &targets[i];
+	    return target;
 	}
     }
 
     /* otherwise just return a match that may differ in content */
-    for (i = 0; i < num_targets; i++) {
-	if (strcmp (targets[i].name, name) == 0)
-	    return &targets[i];
+    for (list = cairo_boilerplate_targets; list != NULL; list = list->next) {
+	const cairo_boilerplate_target_t *target = list->target;
+	if (strcmp (target->name, name) == 0)
+	    return target;
     }
 
     return NULL;
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 626ee2e..aaa196c 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -147,8 +147,7 @@ typedef void
 typedef void
 (*cairo_boilerplate_wait_t) (void *closure);
 
-typedef struct _cairo_boilerplate_target
-{
+typedef struct _cairo_boilerplate_target {
     const char					*name;
     const char					*basename;
     const char					*file_extension;
diff --git a/boilerplate/make-cairo-boilerplate-constructors.c b/boilerplate/make-cairo-boilerplate-constructors.c
new file mode 100644
index 0000000..3306866
--- /dev/null
+++ b/boilerplate/make-cairo-boilerplate-constructors.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2009 Joonas Pihlaja
+ * Copyright © 2009 Chris Wilson
+ *
+ * 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 the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS 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.
+ */
+/* Usage:
+ *   ./make-cairo-boilerplate-constructors [sources.c...] >cairo-boilerplate-constructors.c
+ *
+ * Parses invocations of the CAIRO_BOILERPLATE macro from the source files
+ * given on the command line, gathers names of targets, and outputs a C
+ * file with one function _cairo_boilerplate_register_targets() which
+ * calls the functions _register_<target>() in reverse order.
+ */
+
+/* Keep this file ANSI compliant without any special needs. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define NAME "make-cairo-boilerplate-constructors.c"
+
+static struct name {
+    struct name *next;
+    char         name[1];
+} *head;
+
+static void *
+xmalloc (size_t n)
+{
+    void *bytes = malloc(n);
+    if (!bytes) {
+        fprintf (stderr, "Out of memory\n");
+        exit(2);
+    }
+    return bytes;
+}
+
+static void
+add_name (const char *name)
+{
+    struct name *node;
+    int len;
+
+    len = strlen (name);
+    node = xmalloc (sizeof (struct name) + len);
+    memcpy (node->name, name, len + 1);
+
+    node->next = head;
+    head = node;
+}
+
+static int
+scan_file (const char   *filename,
+           FILE         *fp)
+{
+    int line_num = 0;
+    char linebuf[1024];
+    int fail = 0;
+
+    while (fgets (linebuf, sizeof (linebuf)-1, fp)) {
+        char *macro;
+        char *name;
+        size_t length;
+
+        line_num++;
+        linebuf[sizeof (linebuf)-1] = 0;
+
+        macro = strstr (linebuf, "CAIRO_BOILERPLATE");
+        if (!macro)
+            continue;
+        macro += strlen ("CAIRO_BOILERPLATE");
+
+        length = strspn (macro, " (");
+        if (length == 0)
+            continue;
+        name = macro + length;
+
+        length = strspn (name,
+                         "_"
+                         "abcdefghijklmnopqrstuvwxyz"
+                         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                         "0123456789");
+        name[length] = 0;
+
+        if (length == 0) {
+            fprintf (stderr, "%s:%d: CAIRO_BOILERPLATE invocation "
+                     "can't be parsed by " NAME"\n",
+                     filename, line_num);
+            fail = 1;
+            continue;
+        }
+
+        add_name (name);
+    }
+
+    return fail;
+}
+
+int
+main (int argc, char **argv)
+{
+    int i;
+    int fail = 0;
+    struct name *node;
+
+    for (i=1; i<argc; i++) {
+        FILE *fp = fopen (argv[i], "r");
+        if (fp) {
+            fail |= scan_file (argv[i], fp);
+            fclose (fp);
+        }
+    }
+    if (fail)
+        exit(1);
+
+    puts ("/* WARNING: Autogenerated file - see " NAME "! */");
+    puts ("");
+    puts ("#include \"cairo-boilerplate-private.h\"");
+    puts ("");
+
+    for (node = head; node; node = node->next) {
+        printf ("extern void _register_%s (void);\n",
+               node->name);
+    }
+    puts("");
+
+    puts ("void _cairo_boilerplate_register_all (void);");
+    puts("");
+
+    puts ("void");
+    puts ("_cairo_boilerplate_register_all (void)");
+    puts ("{");
+    for (node = head; node; node = node->next) {
+        printf ("    _register_%s ();\n", node->name);
+    }
+    puts ("}");
+
+    return 0;
+}
diff --git a/test/make-cairo-test-constructors.c b/test/make-cairo-test-constructors.c
index 1a8bd55..e19de37 100644
--- a/test/make-cairo-test-constructors.c
+++ b/test/make-cairo-test-constructors.c
@@ -27,17 +27,18 @@
  * file with one function _cairo_test_runner_register_tests() which
  * calls the functions _register_<testname>() in reverse order.
  */
+
 /* Keep this file ANSI compliant without any special needs. */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-struct name {
-    struct name *next;
-    char        *name;
-};
+#define NAME "make-cairo-test-constructors.c"
 
-static struct name *head = NULL;
+static struct name {
+    struct name *next;
+    char         name[1];
+} *head;
 
 static void *
 xmalloc (size_t n)
@@ -53,10 +54,12 @@ xmalloc (size_t n)
 static void
 add_name (const char *name)
 {
-    struct name *node = xmalloc (sizeof (struct name));
+    struct name *node;
+    int len;
 
-    node->name = xmalloc (strlen(name)+1);
-    strcpy (node->name, name);
+    len = strlen (name);
+    node = xmalloc (sizeof (struct name) + len);
+    memcpy (node->name, name, len + 1);
 
     node->next = head;
     head = node;
@@ -97,7 +100,7 @@ scan_file (const char   *filename,
 
         if (length == 0) {
             fprintf (stderr, "%s:%d: CAIRO_TEST invocation "
-                     "can't be parsed by make-cairo-test-constructors.c\n",
+                     "can't be parsed by " NAME "\n",
                      filename, line_num);
             fail = 1;
             continue;
@@ -126,14 +129,13 @@ main (int argc, char **argv)
     if (fail)
         exit(1);
 
-    puts ("/* WARNING: Autogenerated file - "
-          "see make-cairo-test-constructors.c! */");
+    puts ("/* WARNING: Autogenerated file - see " NAME "! */");
     puts ("");
     puts ("#include \"cairo-test-private.h\"");
     puts ("");
 
     for (node = head; node; node = node->next) {
-        printf("extern void _register_%s (void);\n",
+        printf ("extern void _register_%s (void);\n",
                node->name);
     }
     puts("");
@@ -145,7 +147,7 @@ main (int argc, char **argv)
     puts ("_cairo_test_runner_register_tests (void)");
     puts ("{");
     for (node = head; node; node = node->next) {
-        printf("    _register_%s ();\n", node->name);
+        printf ("    _register_%s ();\n", node->name);
     }
     puts ("}");
 


More information about the cairo-commit mailing list