summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-04 21:43:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-04 21:43:27 +0100
commit88cb69b10c66751f687c3745c8e9861b105de3a2 (patch)
tree3887fc1f4f4cf61b9111b62f6e85af0b72534782
parent8a10ab1c04298d6c22ae8aabec5d762141a8e98f (diff)
[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.
-rw-r--r--boilerplate/.gitignore2
-rw-r--r--boilerplate/Makefile.am12
-rw-r--r--boilerplate/Makefile.sources27
-rw-r--r--boilerplate/cairo-boilerplate-beos-private.h40
-rw-r--r--boilerplate/cairo-boilerplate-beos.cpp48
-rw-r--r--boilerplate/cairo-boilerplate-directfb-private.h26
-rw-r--r--boilerplate/cairo-boilerplate-directfb.c29
-rw-r--r--boilerplate/cairo-boilerplate-glitz-agl.c31
-rw-r--r--boilerplate/cairo-boilerplate-glitz-glx.c31
-rw-r--r--boilerplate/cairo-boilerplate-glitz-private.h88
-rw-r--r--boilerplate/cairo-boilerplate-glitz-wgl.c32
-rw-r--r--boilerplate/cairo-boilerplate-pdf-private.h60
-rw-r--r--boilerplate/cairo-boilerplate-pdf.c48
-rw-r--r--boilerplate/cairo-boilerplate-ps-private.h71
-rw-r--r--boilerplate/cairo-boilerplate-ps.c73
-rw-r--r--boilerplate/cairo-boilerplate-qt-private.h60
-rw-r--r--boilerplate/cairo-boilerplate-qt.cpp29
-rw-r--r--boilerplate/cairo-boilerplate-quartz-private.h44
-rw-r--r--boilerplate/cairo-boilerplate-quartz.c29
-rw-r--r--boilerplate/cairo-boilerplate-script-private.h57
-rw-r--r--boilerplate/cairo-boilerplate-script.c28
-rw-r--r--boilerplate/cairo-boilerplate-svg-private.h72
-rw-r--r--boilerplate/cairo-boilerplate-svg.c70
-rw-r--r--boilerplate/cairo-boilerplate-test-surfaces-private.h99
-rw-r--r--boilerplate/cairo-boilerplate-test-surfaces.c117
-rw-r--r--boilerplate/cairo-boilerplate-win32-printing.c43
-rw-r--r--boilerplate/cairo-boilerplate-win32-private.h65
-rw-r--r--boilerplate/cairo-boilerplate-win32.c28
-rw-r--r--boilerplate/cairo-boilerplate-xcb-private.h47
-rw-r--r--boilerplate/cairo-boilerplate-xcb.c28
-rw-r--r--boilerplate/cairo-boilerplate-xlib-private.h71
-rw-r--r--boilerplate/cairo-boilerplate-xlib.c207
-rw-r--r--boilerplate/cairo-boilerplate.c639
-rw-r--r--boilerplate/cairo-boilerplate.h3
-rw-r--r--boilerplate/make-cairo-boilerplate-constructors.c156
-rw-r--r--test/make-cairo-test-constructors.c28
36 files changed, 946 insertions, 1592 deletions
diff --git a/boilerplate/.gitignore b/boilerplate/.gitignore
index a19a6f94..251508c3 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 239af569..523453a4 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 1cccedad..f81781fb 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 4505d738..00000000
--- 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 f5276276..5596ac16 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 a34edcba..00000000
--- 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 ea7a8ad9..f7be0307 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 03d0423b..61c43520 100644
--- a/boilerplate/cairo-boilerplate-glitz-agl.c
+++ b/boilerplate/cairo-boilerplate-glitz-agl.c
@@ -24,8 +24,7 @@
* Author: Carl D. Worth <cworth@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 a1981ebf..6dfdb7fe 100644
--- a/boilerplate/cairo-boilerplate-glitz-glx.c
+++ b/boilerplate/cairo-boilerplate-glitz-glx.c
@@ -24,8 +24,7 @@
* Author: Carl D. Worth <cworth@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 62904c7c..00000000
--- 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@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 9cd11b60..3aeefdda 100644
--- a/boilerplate/cairo-boilerplate-glitz-wgl.c
+++ b/boilerplate/cairo-boilerplate-glitz-wgl.c
@@ -24,8 +24,7 @@
* Author: Carl D. Worth <cworth@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 f4affe76..00000000
--- 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@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 3ac380c2..166ba1c9 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -24,18 +24,12 @@
* Author: Carl D. Worth <cworth@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 7bcce1c0..00000000
--- 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@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 2fb03e89..0fdd0cfa 100644
--- a/boilerplate/cairo-boilerplate-ps.c
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -24,18 +24,13 @@
* Author: Carl D. Worth <cworth@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 917d63b4..00000000
--- 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 addcb12e..5d8d3f93 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 ccf8a9ac..00000000
--- 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@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 0b5b49d5..4c623581 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -24,12 +24,11 @@
* Author: Carl D. Worth <cworth@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 ad01d629..00000000
--- 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@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 3d78078c..24a5843a 100644
--- a/boilerplate/cairo-boilerplate-script.c
+++ b/boilerplate/cairo-boilerplate-script.c
@@ -24,12 +24,11 @@
* Author: Chris Wilson <chris@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 5a64eaf0..00000000
--- 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@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 407214c7..9d03b203 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -24,8 +24,7 @@
* Author: Carl D. Worth <cworth@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 57bf62dd..00000000
--- 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@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 255472c6..844991c9 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 7a6dafc9..541401a0 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 b09b9f7f..00000000
--- 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@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 83bc7c29..420989b2 100644
--- a/boilerplate/cairo-boilerplate-win32.c
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -24,12 +24,11 @@
* Author: Carl D. Worth <cworth@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 969b7614..00000000
--- 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@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 23e1b5ad..63c20e8a 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -24,20 +24,18 @@
* Author: Carl D. Worth <cworth@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 e4f24ce1..00000000
--- 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@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 f40f9271..3c996cd2 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -24,9 +24,8 @@
* Author: Carl D. Worth <cworth@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 f3e574c0..dfca1dbf 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 626ee2eb..aaa196c5 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 00000000..33068663
--- /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 1a8bd553..e19de372 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 ("}");