[cairo-commit] 29 commits - boilerplate/cairo-boilerplate-beos.cpp
boilerplate/cairo-boilerplate-beos-private.h
boilerplate/cairo-boilerplate.c
boilerplate/cairo-boilerplate-directfb.c
boilerplate/cairo-boilerplate-directfb-private.h
boilerplate/cairo-boilerplate-glitz.c
boilerplate/cairo-boilerplate-glitz-private.h
boilerplate/cairo-boilerplate.h boilerplate/cairo-boilerplate-pdf.c
boilerplate/cairo-boilerplate-pdf-private.h
boilerplate/cairo-boilerplate-ps.c
boilerplate/cairo-boilerplate-ps-private.h
boilerplate/cairo-boilerplate-quartz.c
boilerplate/cairo-boilerplate-quartz-private.h
boilerplate/cairo-boilerplate-svg.c
boilerplate/cairo-boilerplate-svg-private.h
boilerplate/cairo-boilerplate-test-surfaces.c
boilerplate/cairo-boilerplate-test-surfaces-private.h
boilerplate/cairo-boilerplate-win32.c
boilerplate/cairo-boilerplate-win32-private.h
boilerplate/cairo-boilerplate-xcb.c
boilerplate/cairo-boilerplate-xcb-private.h
boilerplate/cairo-boilerplate-xlib.c
boilerplate/cairo-boilerplate-xlib-private.h
boilerplate/cairo-quartz-boilerplate.c
boilerplate/cairo-quartz-boilerplate-private.h
boilerplate/cairo-test-beos.cpp boilerplate/cairo-test-beos.h
boilerplate/cairo-test-directfb.c
boilerplate/cairo-test-directfb.h boilerplate/Makefile.am
boilerplate/xmalloc.c boilerplate/xmalloc.h
src/cairo-directfb-surface.c test/cairo-test.c test/cairo-test.h
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Apr 19 21:52:07 PDT 2007
boilerplate/Makefile.am | 55
boilerplate/cairo-boilerplate-beos-private.h | 34
boilerplate/cairo-boilerplate-beos.cpp | 58
boilerplate/cairo-boilerplate-directfb-private.h | 23
boilerplate/cairo-boilerplate-directfb.c | 50
boilerplate/cairo-boilerplate-glitz-private.h | 73
boilerplate/cairo-boilerplate-glitz.c | 477 +++++
boilerplate/cairo-boilerplate-pdf-private.h | 23
boilerplate/cairo-boilerplate-pdf.c | 134 +
boilerplate/cairo-boilerplate-ps-private.h | 23
boilerplate/cairo-boilerplate-ps.c | 138 +
boilerplate/cairo-boilerplate-quartz-private.h | 8
boilerplate/cairo-boilerplate-quartz.c | 25
boilerplate/cairo-boilerplate-svg-private.h | 23
boilerplate/cairo-boilerplate-svg.c | 129 +
boilerplate/cairo-boilerplate-test-surfaces-private.h | 63
boilerplate/cairo-boilerplate-test-surfaces.c | 159 +
boilerplate/cairo-boilerplate-win32-private.h | 21
boilerplate/cairo-boilerplate-win32.c | 30
boilerplate/cairo-boilerplate-xcb-private.h | 23
boilerplate/cairo-boilerplate-xcb.c | 115 +
boilerplate/cairo-boilerplate-xlib-private.h | 23
boilerplate/cairo-boilerplate-xlib.c | 196 ++
boilerplate/cairo-boilerplate.c | 1532 +-----------------
boilerplate/cairo-boilerplate.h | 40
boilerplate/cairo-test-beos.h | 34
boilerplate/cairo-test-directfb.h | 23
boilerplate/xmalloc.c | 50
boilerplate/xmalloc.h | 9
src/cairo-directfb-surface.c | 2
test/cairo-test.c | 68
test/cairo-test.h | 2
32 files changed, 2047 insertions(+), 1616 deletions(-)
New commits:
diff-tree abcd929c57459f95e93504e0ef07b012b497a363 (from 97624dc488b41eb83d70b2c44a595daa5d833e7f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:50:48 2007 -0400
[boilerplate] Add cairo_boilerplate_format_from_content
diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
index d6df7fa..3b23aed 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -39,14 +39,7 @@ _cairo_boilerplate_quartz_create_surface
{
cairo_format_t format;
- switch (content) {
- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
- default:
- assert (0); /* not reached */
- return NULL;
- }
+ format = cairo_boilerplate_format_from_content (content);
*closure = NULL;
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index ab202d5..93ca5e7 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -128,18 +128,7 @@ _cairo_boilerplate_test_paginated_surfac
tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
- switch (tpc->content) {
- case CAIRO_CONTENT_COLOR:
- format = CAIRO_FORMAT_RGB24;
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- format = CAIRO_FORMAT_ARGB32;
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- assert (0); /* not reached */
- return CAIRO_STATUS_NO_MEMORY;
- }
+ format = cairo_boilerplate_format_from_content (tpc->content);
image = cairo_image_surface_create_for_data (tpc->data,
format,
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
index 3b95378..cd15873 100644
--- a/boilerplate/cairo-boilerplate-win32.c
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -39,13 +39,9 @@ _cairo_boilerplate_win32_create_surface
{
cairo_format_t format;
- if (content == CAIRO_CONTENT_COLOR)
- format = CAIRO_FORMAT_RGB24;
- else if (content == CAIRO_CONTENT_COLOR_ALPHA)
- format = CAIRO_FORMAT_ARGB32;
- else
- return NULL;
+ format = cairo_boilerplate_format_from_content (content);
*closure = NULL;
+
return cairo_win32_surface_create_with_dib (format, width, height);
}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6165d7e..1f49e82 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -100,6 +100,24 @@ cairo_boilerplate_content_name (cairo_co
}
}
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content)
+{
+ cairo_format_t format;
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
+ case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
+ case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
+ default:
+ assert (0); /* not reached */
+ format = (cairo_format_t) -1;
+ break;
+ }
+
+ return format;
+}
+
static cairo_surface_t *
_cairo_boilerplate_image_create_surface (const char *name,
cairo_content_t content,
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index aa23e1c..9f0fc56 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -94,6 +94,9 @@
const char *
cairo_boilerplate_content_name (cairo_content_t content);
+cairo_format_t
+cairo_boilerplate_format_from_content (cairo_content_t content);
+
typedef enum {
CAIRO_BOILERPLATE_MODE_TEST,
CAIRO_BOILERPLATE_MODE_PERF
diff-tree 97624dc488b41eb83d70b2c44a595daa5d833e7f (from 2e709321d858a048731eeaaca4a13a96de739e3f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:45:42 2007 -0400
[boilerplate] Strip test-surfaces boilerplate into cairo-boilerplate-test-surfaces*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index b588a20..b541af3 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -56,6 +56,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
endif
+if CAIRO_HAS_TEST_SURFACES
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-test-surfaces.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-test-surfaces-private.h
+endif
+
if CAIRO_HAS_WIN32_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32-private.h
diff --git a/boilerplate/cairo-boilerplate-test-surfaces-private.h b/boilerplate/cairo-boilerplate-test-surfaces-private.h
new file mode 100644
index 0000000..1b82226
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-test-surfaces-private.h
@@ -0,0 +1,63 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_TEST_SURFACES_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_TEST_SURFACES_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_test_fallback_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+
+cairo_surface_t *
+_cairo_boilerplate_test_meta_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+
+cairo_surface_t *
+_cairo_boilerplate_test_paginated_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+cairo_status_t
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
+ const char *filename);
+
+void
+_cairo_boilerplate_test_paginated_cleanup (void *closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
new file mode 100644
index 0000000..ab202d5
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -0,0 +1,170 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-test-surfaces-private.h"
+
+#include <test-fallback-surface.h>
+#include <test-meta-surface.h>
+#include <test-paginated-surface.h>
+
+#include <assert.h>
+
+cairo_surface_t *
+_cairo_boilerplate_test_fallback_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ *closure = NULL;
+ return _cairo_test_fallback_surface_create (content, width, height);
+}
+
+cairo_surface_t *
+_cairo_boilerplate_test_meta_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ *closure = NULL;
+ return _cairo_test_meta_surface_create (content, width, height);
+}
+
+static const cairo_user_data_key_t test_paginated_closure_key;
+
+typedef struct {
+ unsigned char *data;
+ cairo_content_t content;
+ int width;
+ int height;
+ int stride;
+} test_paginated_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_test_paginated_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ test_paginated_closure_t *tpc;
+ cairo_surface_t *surface;
+
+ *closure = tpc = xmalloc (sizeof (test_paginated_closure_t));
+
+ tpc->content = content;
+ tpc->width = width;
+ tpc->height = height;
+ tpc->stride = width * 4;
+
+ tpc->data = xcalloc (tpc->stride * height, 1);
+
+ surface = _cairo_test_paginated_surface_create_for_data (tpc->data,
+ tpc->content,
+ tpc->width,
+ tpc->height,
+ tpc->stride);
+
+ cairo_boilerplate_surface_set_user_data (surface,
+ &test_paginated_closure_key,
+ tpc, NULL);
+
+ return surface;
+}
+
+/* The only reason we go through all these machinations to write a PNG
+ * image is to _really ensure_ that the data actually landed in our
+ * buffer through the paginated surface to the test_paginated_surface.
+ *
+ * If we didn't implement this function then the default
+ * cairo_surface_write_to_png would result in the paginated_surface's
+ * acquire_source_image function replaying the meta-surface to an
+ * intermediate image surface. And in that case the
+ * test_paginated_surface would not be involved and wouldn't be
+ * tested.
+ */
+cairo_status_t
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
+ const char *filename)
+{
+ cairo_surface_t *image;
+ cairo_format_t format;
+ test_paginated_closure_t *tpc;
+ cairo_status_t status;
+
+ /* show page first. the automatic show_page is too late for us */
+ /* XXX use cairo_surface_show_page() when that's added */
+ cairo_t *cr = cairo_create (surface);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
+ tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
+
+ switch (tpc->content) {
+ case CAIRO_CONTENT_COLOR:
+ format = CAIRO_FORMAT_RGB24;
+ break;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ format = CAIRO_FORMAT_ARGB32;
+ break;
+ case CAIRO_CONTENT_ALPHA:
+ default:
+ assert (0); /* not reached */
+ return CAIRO_STATUS_NO_MEMORY;
+ }
+
+ image = cairo_image_surface_create_for_data (tpc->data,
+ format,
+ tpc->width,
+ tpc->height,
+ tpc->stride);
+
+ status = cairo_surface_write_to_png (image, filename);
+ if (status) {
+ CAIRO_BOILERPLATE_LOG ("Error writing %s: %s. Exiting\n",
+ filename,
+ cairo_status_to_string (status));
+ exit (1);
+ }
+
+ cairo_surface_destroy (image);
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_test_paginated_cleanup (void *closure)
+{
+ test_paginated_closure_t *tpc = closure;
+
+ free (tpc->data);
+ free (tpc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 57e8312..6165d7e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -47,6 +47,9 @@
#if CAIRO_HAS_SVG_SURFACE
#include "cairo-boilerplate-svg-private.h"
#endif
+#ifdef CAIRO_HAS_TEST_SURFACES
+#include "cairo-boilerplate-test-surfaces-private.h"
+#endif
#if CAIRO_HAS_WIN32_SURFACE
#include "cairo-boilerplate-win32-private.h"
#endif
@@ -120,149 +123,6 @@ _cairo_boilerplate_image_create_surface
return cairo_image_surface_create (format, width, height);
}
-#ifdef CAIRO_HAS_TEST_SURFACES
-
-#include <test-fallback-surface.h>
-#include <test-meta-surface.h>
-#include <test-paginated-surface.h>
-
-static cairo_surface_t *
-_cairo_boilerplate_test_fallback_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- *closure = NULL;
- return _cairo_test_fallback_surface_create (content, width, height);
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_test_meta_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- *closure = NULL;
- return _cairo_test_meta_surface_create (content, width, height);
-}
-
-static const cairo_user_data_key_t test_paginated_closure_key;
-
-typedef struct {
- unsigned char *data;
- cairo_content_t content;
- int width;
- int height;
- int stride;
-} test_paginated_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_test_paginated_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- test_paginated_closure_t *tpc;
- cairo_surface_t *surface;
-
- *closure = tpc = xmalloc (sizeof (test_paginated_closure_t));
-
- tpc->content = content;
- tpc->width = width;
- tpc->height = height;
- tpc->stride = width * 4;
-
- tpc->data = xcalloc (tpc->stride * height, 1);
-
- surface = _cairo_test_paginated_surface_create_for_data (tpc->data,
- tpc->content,
- tpc->width,
- tpc->height,
- tpc->stride);
-
- cairo_boilerplate_surface_set_user_data (surface,
- &test_paginated_closure_key,
- tpc, NULL);
-
- return surface;
-}
-
-/* The only reason we go through all these machinations to write a PNG
- * image is to _really ensure_ that the data actually landed in our
- * buffer through the paginated surface to the test_paginated_surface.
- *
- * If we didn't implement this function then the default
- * cairo_surface_write_to_png would result in the paginated_surface's
- * acquire_source_image function replaying the meta-surface to an
- * intermediate image surface. And in that case the
- * test_paginated_surface would not be involved and wouldn't be
- * tested.
- */
-static cairo_status_t
-_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
- const char *filename)
-{
- cairo_surface_t *image;
- cairo_format_t format;
- test_paginated_closure_t *tpc;
- cairo_status_t status;
-
- /* show page first. the automatic show_page is too late for us */
- /* XXX use cairo_surface_show_page() when that's added */
- cairo_t *cr = cairo_create (surface);
- cairo_show_page (cr);
- cairo_destroy (cr);
-
- tpc = cairo_surface_get_user_data (surface, &test_paginated_closure_key);
-
- switch (tpc->content) {
- case CAIRO_CONTENT_COLOR:
- format = CAIRO_FORMAT_RGB24;
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- format = CAIRO_FORMAT_ARGB32;
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- assert (0); /* not reached */
- return CAIRO_STATUS_NO_MEMORY;
- }
-
- image = cairo_image_surface_create_for_data (tpc->data,
- format,
- tpc->width,
- tpc->height,
- tpc->stride);
-
- status = cairo_surface_write_to_png (image, filename);
- if (status) {
- CAIRO_BOILERPLATE_LOG ("Error writing %s: %s. Exiting\n",
- filename,
- cairo_status_to_string (status));
- exit (1);
- }
-
- cairo_surface_destroy (image);
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_test_paginated_cleanup (void *closure)
-{
- test_paginated_closure_t *tpc = closure;
-
- free (tpc->data);
- free (tpc);
-}
-
-#endif
static cairo_boilerplate_target_t targets[] =
{
diff-tree 2e709321d858a048731eeaaca4a13a96de739e3f (from 5331445c12756293a915420a26ab5553fc7db3fc)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:34:51 2007 -0400
[boilerplate] Move xasprintf to xmalloc.c
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6df0c8f..57e8312 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -57,9 +57,7 @@
#include "cairo-boilerplate-xlib-private.h"
#endif
-#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
#include <ctype.h>
#include <assert.h>
@@ -558,46 +556,3 @@ cairo_boilerplate_surface_set_user_data
exit (1);
}
}
-
-void
-xasprintf (char **strp, const char *fmt, ...)
-{
-#ifdef HAVE_VASPRINTF
- va_list va;
- int ret;
-
- va_start (va, fmt);
- ret = vasprintf (strp, fmt, va);
- va_end (va);
-
- if (ret < 0) {
- CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
- exit (1);
- }
-#else /* !HAVE_VASNPRINTF */
-#define BUF_SIZE 1024
- va_list va;
- char buffer[BUF_SIZE];
- int ret;
-
- va_start (va, fmt);
- ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
- va_end (va);
-
- if (ret < 0) {
- CAIRO_BOILERPLATE_LOG ("Failure in vsnprintf\n");
- exit (1);
- }
-
- if (strlen (buffer) == sizeof(buffer) - 1) {
- CAIRO_BOILERPLATE_LOG ("Overflowed fixed buffer\n");
- exit (1);
- }
-
- *strp = strdup (buffer);
- if (!*strp) {
- CAIRO_BOILERPLATE_LOG ("Out of memory\n");
- exit (1);
- }
-#endif /* !HAVE_VASNPRINTF */
-}
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 5b4c217..aa23e1c 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -67,18 +67,16 @@
#error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.)
#endif
-#include "xmalloc.h"
-
#ifndef CAIRO_BOILERPLATE_LOG
#define CAIRO_BOILERPLATE_LOG(...) fprintf(stderr, __VA_ARGS__)
#endif
-/* A fake format we use for the flattened ARGB output of the PS and
- * PDF surfaces. */
-#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
-
-const char *
-cairo_boilerplate_content_name (cairo_content_t content);
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
+ __attribute__((__format__(__printf__, fmt_index, va_index)))
+#else
+#define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index)
+#endif
#ifndef FALSE
#define FALSE 0
@@ -88,6 +86,14 @@ cairo_boilerplate_content_name (cairo_co
#define TRUE 1
#endif
+
+/* A fake format we use for the flattened ARGB output of the PS and
+ * PDF surfaces. */
+#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
+
+const char *
+cairo_boilerplate_content_name (cairo_content_t content);
+
typedef enum {
CAIRO_BOILERPLATE_MODE_TEST,
CAIRO_BOILERPLATE_MODE_PERF
@@ -130,20 +136,12 @@ cairo_boilerplate_get_targets (int *num_
void
cairo_boilerplate_free_targets (cairo_boilerplate_target_t **targets);
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index) \
- __attribute__((__format__(__printf__, fmt_index, va_index)))
-#else
-#define CAIRO_PRINTF_FORMAT(fmt_index, va_index)
-#endif
-
void
cairo_boilerplate_surface_set_user_data (cairo_surface_t *surface,
const cairo_user_data_key_t *key,
void *user_data,
cairo_destroy_func_t destroy);
-void
-xasprintf (char **strp, const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3);
+#include "xmalloc.h"
#endif
diff --git a/boilerplate/xmalloc.c b/boilerplate/xmalloc.c
index 8da0568..ddd5ccc 100644
--- a/boilerplate/xmalloc.c
+++ b/boilerplate/xmalloc.c
@@ -23,12 +23,13 @@
* Author: Carl D. Worth <cworth at cworth.org>
*/
-#include <stdio.h>
-#include <stdlib.h>
-
#include "cairo-boilerplate.h"
#include "xmalloc.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
void *
xmalloc (size_t size)
{
@@ -68,3 +69,46 @@ xrealloc (void *buf, size_t size)
return buf;
}
+
+void
+xasprintf (char **strp, const char *fmt, ...)
+{
+#ifdef HAVE_VASPRINTF
+ va_list va;
+ int ret;
+
+ va_start (va, fmt);
+ ret = vasprintf (strp, fmt, va);
+ va_end (va);
+
+ if (ret < 0) {
+ CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
+ exit (1);
+ }
+#else /* !HAVE_VASNPRINTF */
+#define BUF_SIZE 1024
+ va_list va;
+ char buffer[BUF_SIZE];
+ int ret;
+
+ va_start (va, fmt);
+ ret = vsnprintf (buffer, sizeof(buffer), fmt, va);
+ va_end (va);
+
+ if (ret < 0) {
+ CAIRO_BOILERPLATE_LOG ("Failure in vsnprintf\n");
+ exit (1);
+ }
+
+ if (strlen (buffer) == sizeof(buffer) - 1) {
+ CAIRO_BOILERPLATE_LOG ("Overflowed fixed buffer\n");
+ exit (1);
+ }
+
+ *strp = strdup (buffer);
+ if (!*strp) {
+ CAIRO_BOILERPLATE_LOG ("Out of memory\n");
+ exit (1);
+ }
+#endif /* !HAVE_VASNPRINTF */
+}
diff --git a/boilerplate/xmalloc.h b/boilerplate/xmalloc.h
index 1f0fadf..b0e891f 100644
--- a/boilerplate/xmalloc.h
+++ b/boilerplate/xmalloc.h
@@ -26,15 +26,22 @@
#ifndef _XMALLOC_H_
#define _XMALLOC_H_
-#include <stdlib.h>
+#include "cairo-boilerplate.h"
+#define xmalloc cairo_boilerplate_xmalloc
void *
xmalloc (size_t size);
+#define xcalloc cairo_boilerplate_xcalloc
void *
xcalloc (size_t nmemb, size_t size);
+#define xrealloc cairo_boilerplate_recalloc
void *
xrealloc (void *buf, size_t size);
+#define xasprintf cairo_boilerplate_xasprintf
+void
+xasprintf (char **strp, const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(2, 3);
+
#endif
diff --git a/test/cairo-test.h b/test/cairo-test.h
index d3612ba..d7ed3a7 100755
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -118,7 +118,7 @@ cairo_test_fini (void);
/* Print a message to the log file, ala printf. */
void
-cairo_test_log (const char *fmt, ...) CAIRO_PRINTF_FORMAT(1, 2);
+cairo_test_log (const char *fmt, ...) CAIRO_BOILERPLATE_PRINTF_FORMAT(1, 2);
/* Helper functions that take care of finding source images even when
* building in a non-srcdir manner, (ie. the tests will be run in a
diff-tree 5331445c12756293a915420a26ab5553fc7db3fc (from 56e916d40cf2a5f061347254657592f7bfc90d02)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:26:17 2007 -0400
[boilerplate] Cleanup includes in cairo-boilerplate-beos.cpp
diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp
index 1815d63..2a84d1b 100644
--- a/boilerplate/cairo-boilerplate-beos.cpp
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -38,14 +38,6 @@
*
* ***** END LICENSE BLOCK ***** */
-// Part of this code was originally part of
-// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
-
-#include <Application.h>
-#include <Window.h>
-#include <View.h>
-#include <Bitmap.h>
-
// BeOS's C++ compiler does not support varargs in macros
// So, define CAIRO_BOILERPLATE_LOG here
#define CAIRO_BOILERPLATE_LOG cairo_beos_boilerplate_log
@@ -53,9 +45,17 @@
extern "C" {
#include "cairo-boilerplate.h"
}
-
#include "cairo-boilerplate-beos-private.h"
-#include "cairo-beos.h"
+
+#include <cairo-beos.h>
+
+// Part of this code was originally part of
+// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
+
+#include <Application.h>
+#include <Window.h>
+#include <View.h>
+#include <Bitmap.h>
static int cairo_beos_boilerplate_log(const char* format, ...) {
va_list args;
diff-tree 56e916d40cf2a5f061347254657592f7bfc90d02 (from 06718b0da642d39b7b4dbfc009f08acb24e5e802)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:25:44 2007 -0400
[boilerplate] Fix typos in cairo-boilerplate-glitz.c
diff --git a/boilerplate/cairo-boilerplate-glitz.c b/boilerplate/cairo-boilerplate-glitz.c
index 15fa97c..9ef7115 100644
--- a/boilerplate/cairo-boilerplate-glitz.c
+++ b/boilerplate/cairo-boilerplate-glitz.c
@@ -25,7 +25,7 @@
*/
#include "cairo-boilerplate.h"
-#include "cairo-boilerplate-xlib-private.h"
+#include "cairo-boilerplate-glitz-private.h"
#include <cairo-glitz.h>
@@ -47,7 +47,7 @@ typedef struct _glitz_glx_target_closure
Window win;
} glitz_glx_target_closure_t;
-glitz_surface_t *
+static glitz_surface_t *
_cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t formatname,
int width,
int height,
diff-tree 06718b0da642d39b7b4dbfc009f08acb24e5e802 (from 99737a60cb8cae1643b84782768e8c6d50ac7d0a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:15:19 2007 -0400
[boilerplate] Remove leftover call to cairo_test_log
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 1e39818..6df0c8f 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -571,7 +571,7 @@ xasprintf (char **strp, const char *fmt,
va_end (va);
if (ret < 0) {
- cairo_test_log ("Out of memory\n");
+ CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
exit (1);
}
#else /* !HAVE_VASNPRINTF */
diff-tree 99737a60cb8cae1643b84782768e8c6d50ac7d0a (from 4b569f13d758015f33ad258a70ad4f472da771ed)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:13:25 2007 -0400
[boilerplate] Clean up includes and remove unnecessary ones
diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c
index 1e903dc..894672d 100644
--- a/boilerplate/cairo-boilerplate-directfb.c
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -9,13 +9,14 @@ make check
*/
-#include <stdio.h>
-#include <stdlib.h>
#include "cairo-boilerplate.h"
-#include <directfb.h>
-#include "cairo-directfb.h"
#include "cairo-boilerplate-directfb-private.h"
+#include <cairo-directfb.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
/* macro for a safe call to DirectFB functions */
#define DFBCHECK(x...) \
{ \
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
index 0b1dec0..13f9ef8 100644
--- a/boilerplate/cairo-boilerplate-pdf.c
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -27,7 +27,7 @@
#include "cairo-boilerplate.h"
#include "cairo-boilerplate-pdf-private.h"
-#include "cairo-pdf.h"
+#include <cairo-pdf.h>
cairo_user_data_key_t pdf_closure_key;
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
index 8193031..cc344c9 100644
--- a/boilerplate/cairo-boilerplate-svg.c
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -27,7 +27,7 @@
#include "cairo-boilerplate.h"
#include "cairo-boilerplate-svg-private.h"
-#include "cairo-svg.h"
+#include <cairo-svg.h>
cairo_user_data_key_t svg_closure_key;
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index 2cc88cd..1a74d18 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -27,7 +27,7 @@
#include "cairo-boilerplate.h"
#include "cairo-boilerplate-xcb-private.h"
-#include "cairo-xcb-xrender.h"
+#include <cairo-xcb-xrender.h>
#include <xcb/xcb_renderutil.h>
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index e1d4bb2..1e39818 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -26,24 +26,6 @@
#include "cairo-boilerplate.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <ctype.h>
-#include <setjmp.h>
-#ifdef HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-#include <assert.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <errno.h>
-#include <string.h>
-#if HAVE_FCFINI
-#include <fontconfig/fontconfig.h>
-#endif
-
#if CAIRO_HAS_BEOS_SURFACE
#include "cairo-boilerplate-beos-private.h"
#endif
@@ -75,6 +57,12 @@
#include "cairo-boilerplate-xlib-private.h"
#endif
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ctype.h>
+#include <assert.h>
+
/* This is copied from cairoint.h. That makes it painful to keep in
* sync, but the slim stuff makes cairoint.h "hard" to include when
* not actually building the cairo library itself. Fortunately, since
@@ -136,9 +124,9 @@ _cairo_boilerplate_image_create_surface
#ifdef CAIRO_HAS_TEST_SURFACES
-#include "test-fallback-surface.h"
-#include "test-meta-surface.h"
-#include "test-paginated-surface.h"
+#include <test-fallback-surface.h>
+#include <test-meta-surface.h>
+#include <test-paginated-surface.h>
static cairo_surface_t *
_cairo_boilerplate_test_fallback_create_surface (const char *name,
diff-tree 4b569f13d758015f33ad258a70ad4f472da771ed (from 0a03d66fffe7388d8fb4ffdb7bb5501a214c6342)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Apr 20 00:08:44 2007 -0400
[boilerplate] Strip win32 boilerplate into cairo-boilerplate-win32*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 4b0e899..b588a20 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -56,6 +56,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
endif
+if CAIRO_HAS_WIN32_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-win32-private.h
+endif
+
if CAIRO_HAS_XCB_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb-private.h
diff --git a/boilerplate/cairo-boilerplate-win32-private.h b/boilerplate/cairo-boilerplate-win32-private.h
new file mode 100644
index 0000000..7a6b0c1
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-win32-private.h
@@ -0,0 +1,38 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_WIN32_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_WIN32_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_win32_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-win32.c b/boilerplate/cairo-boilerplate-win32.c
new file mode 100644
index 0000000..3b95378
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-win32.c
@@ -0,0 +1,51 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-win32-private.h"
+
+#include <cairo-win32.h>
+
+cairo_surface_t *
+_cairo_boilerplate_win32_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ cairo_format_t format;
+
+ if (content == CAIRO_CONTENT_COLOR)
+ format = CAIRO_FORMAT_RGB24;
+ else if (content == CAIRO_CONTENT_COLOR_ALPHA)
+ format = CAIRO_FORMAT_ARGB32;
+ else
+ return NULL;
+
+ *closure = NULL;
+ return cairo_win32_surface_create_with_dib (format, width, height);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 5b7b432..e1d4bb2 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -65,12 +65,15 @@
#if CAIRO_HAS_SVG_SURFACE
#include "cairo-boilerplate-svg-private.h"
#endif
-#if CAIRO_HAS_XLIB_XRENDER_SURFACE
-#include "cairo-boilerplate-xlib-private.h"
+#if CAIRO_HAS_WIN32_SURFACE
+#include "cairo-boilerplate-win32-private.h"
#endif
#if CAIRO_HAS_XCB_SURFACE
#include "cairo-boilerplate-xcb-private.h"
#endif
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+#include "cairo-boilerplate-xlib-private.h"
+#endif
/* This is copied from cairoint.h. That makes it painful to keep in
* sync, but the slim stuff makes cairoint.h "hard" to include when
@@ -275,30 +278,6 @@ _cairo_boilerplate_test_paginated_cleanu
#endif
-#if CAIRO_HAS_WIN32_SURFACE
-#include "cairo-win32.h"
-static cairo_surface_t *
-_cairo_boilerplate_win32_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- cairo_format_t format;
-
- if (content == CAIRO_CONTENT_COLOR)
- format = CAIRO_FORMAT_RGB24;
- else if (content == CAIRO_CONTENT_COLOR_ALPHA)
- format = CAIRO_FORMAT_ARGB32;
- else
- return NULL;
-
- *closure = NULL;
- return cairo_win32_surface_create_with_dib (format, width, height);
-}
-#endif
-
static cairo_boilerplate_target_t targets[] =
{
/* I'm uncompromising about leaving the image backend as 0
diff-tree 0a03d66fffe7388d8fb4ffdb7bb5501a214c6342 (from 5ee882d3941a9df61d539e056933564a758a6bbc)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 23:58:51 2007 -0400
[boilerplate] Rename create_win32_surface to _cairo_boilerplate_win32_create_surface
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 04b765c..5b7b432 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -275,18 +275,15 @@ _cairo_boilerplate_test_paginated_cleanu
#endif
-/* Testing the win32 surface isn't interesting, since for
- * ARGB images it just chains to the image backend
- */
#if CAIRO_HAS_WIN32_SURFACE
#include "cairo-win32.h"
static cairo_surface_t *
-create_win32_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_win32_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
cairo_format_t format;
@@ -385,10 +382,13 @@ static cairo_boilerplate_target_t target
#endif
#if CAIRO_HAS_WIN32_SURFACE
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
- create_win32_surface,
+ _cairo_boilerplate_win32_create_surface,
cairo_surface_write_to_png },
+ /* Testing the win32 surface isn't interesting, since for
+ * ARGB images it just chains to the image backend
+ */
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_win32_surface,
+ _cairo_boilerplate_win32_create_surface,
cairo_surface_write_to_png },
#endif
#if CAIRO_HAS_XCB_SURFACE
diff-tree 5ee882d3941a9df61d539e056933564a758a6bbc (from a684fd80e750bea5661262e29a59c4f8c4d9cee3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 23:53:34 2007 -0400
[boilerplate] Remove empty cleanup_win32
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 7b8a41e..04b765c 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -300,11 +300,6 @@ create_win32_surface (const char *name
*closure = NULL;
return cairo_win32_surface_create_with_dib (format, width, height);
}
-
-static void
-cleanup_win32 (void *closure)
-{
-}
#endif
static cairo_boilerplate_target_t targets[] =
@@ -391,12 +386,10 @@ static cairo_boilerplate_target_t target
#if CAIRO_HAS_WIN32_SURFACE
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
create_win32_surface,
- cairo_surface_write_to_png,
- cleanup_win32 },
+ cairo_surface_write_to_png },
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
create_win32_surface,
- cairo_surface_write_to_png,
- cleanup_win32 },
+ cairo_surface_write_to_png },
#endif
#if CAIRO_HAS_XCB_SURFACE
/* Acceleration architectures may make the results differ by a
diff-tree a684fd80e750bea5661262e29a59c4f8c4d9cee3 (from 23e6abc3fc01e3d722adfc48cd1df9c8db73adc1)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 23:36:00 2007 -0400
[directfb] Silence compiler warning
diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index f6e1c01..4a62846 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -333,7 +333,7 @@ _directfb_acquire_surface (cairo_directf
cairo_format_t cairo_format;
cairo_format = surface->format;
- if (surface->format == -1) {
+ if (surface->format == (cairo_format_t) -1) {
if( intrest_rec ) {
source_rect.x = intrest_rec->x;
source_rect.y = intrest_rec->y;
diff-tree 23e6abc3fc01e3d722adfc48cd1df9c8db73adc1 (from 7d576a376706aad427915b4872429f5605104886)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:40:52 2007 -0400
[boilerplate] Strip glitz boilerplate into cairo-boilerplate-glitz*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 1e85c40..4b0e899 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,23 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
+if CAIRO_HAS_GLITZ_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-glitz.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-glitz-private.h
+if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS)
+endif
+if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS)
+endif
+endif
+
if CAIRO_HAS_PDF_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf-private.h
@@ -49,19 +66,6 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
endif
-if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_EGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_EGL_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_GLX_LIBS)
-endif
-if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-libcairoboilerplate_la_LIBADD += $(GLITZ_WGL_LIBS)
-endif
-
# We're using _GNU_SOURCE to get the prototype for asprintf. This may
# not be the most portable approach, but it is pragmatic and I'm
# willing to do something cleaner as soon as it causes someone a
diff --git a/boilerplate/cairo-boilerplate-glitz-private.h b/boilerplate/cairo-boilerplate-glitz-private.h
new file mode 100644
index 0000000..e2b27fd
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-glitz-private.h
@@ -0,0 +1,73 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_GLITZ_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_GLITZ_PRIVATE_H_
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_glitz_glx_cleanup (void *closure);
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_glitz_agl_cleanup (void *closure);
+#endif
+
+#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+cairo_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_glitz_wgl_cleanup (void *closure);
+#endif
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-glitz.c b/boilerplate/cairo-boilerplate-glitz.c
new file mode 100644
index 0000000..15fa97c
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-glitz.c
@@ -0,0 +1,477 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-xlib-private.h"
+
+#include <cairo-glitz.h>
+
+static const cairo_user_data_key_t glitz_closure_key;
+
+typedef struct _glitz_target_closure_base {
+ int width;
+ int height;
+ cairo_content_t content;
+} glitz_target_closure_base_t;
+
+#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
+#include <glitz-glx.h>
+
+typedef struct _glitz_glx_target_closure {
+ glitz_target_closure_base_t base;
+ Display *dpy;
+ int scr;
+ Window win;
+} glitz_glx_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface_internal (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_glx_target_closure_t *closure)
+{
+ Display * dpy = closure->dpy;
+ int scr = closure->scr;
+ glitz_drawable_format_t templ;
+ glitz_drawable_format_t * dformat = NULL;
+ unsigned long mask;
+ glitz_drawable_t * drawable = NULL;
+ glitz_format_t * format;
+ glitz_surface_t * sr;
+
+ XSizeHints xsh;
+ XSetWindowAttributes xswa;
+ XVisualInfo * vinfo;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.color.red_size = 8;
+ templ.color.green_size = 8;
+ templ.color.blue_size = 8;
+ templ.color.alpha_size = 8;
+ templ.color.fourcc = GLITZ_FOURCC_RGB;
+ templ.samples = 1;
+
+ glitz_glx_init (NULL);
+
+ mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+ GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+ GLITZ_FORMAT_BLUE_SIZE_MASK;
+ if (formatname == GLITZ_STANDARD_ARGB32)
+ mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+ /* Try for a pbuffer first */
+ if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
+ dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
+
+ if (dformat) {
+ closure->win = None;
+
+ drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
+ width, height);
+ if (!drawable)
+ goto FAIL;
+ } else {
+ /* No pbuffer, try window */
+ dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
+
+ if (!dformat)
+ goto FAIL;
+
+ vinfo = glitz_glx_get_visual_info_from_format(dpy,
+ DefaultScreen(dpy),
+ dformat);
+
+ if (!vinfo)
+ goto FAIL;
+
+ xsh.flags = PSize;
+ xsh.x = 0;
+ xsh.y = 0;
+ xsh.width = width;
+ xsh.height = height;
+
+ xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
+ vinfo->visual, AllocNone);
+ closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
+ xsh.x, xsh.y, xsh.width, xsh.height,
+ 0, vinfo->depth, CopyFromParent,
+ vinfo->visual, CWColormap, &xswa);
+ XFree (vinfo);
+
+ drawable =
+ glitz_glx_create_drawable_for_window (dpy, scr,
+ dformat, closure->win,
+ width, height);
+
+ if (!drawable)
+ goto DESTROY_WINDOW;
+ }
+
+ format = glitz_find_standard_format (drawable, formatname);
+ if (!format)
+ goto DESTROY_DRAWABLE;
+
+ sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
+ if (!sr)
+ goto DESTROY_DRAWABLE;
+
+ if (closure->win == None || dformat->doublebuffer) {
+ glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
+ } else {
+ XMapWindow (closure->dpy, closure->win);
+ glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+ }
+
+ glitz_drawable_destroy (drawable);
+
+ return sr;
+ DESTROY_DRAWABLE:
+ glitz_drawable_destroy (drawable);
+ DESTROY_WINDOW:
+ if (closure->win)
+ XDestroyWindow (dpy, closure->win);
+ FAIL:
+ return NULL;
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_glx_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ glitz_glx_target_closure_t *gxtc;
+ glitz_surface_t * glitz_surface;
+ cairo_surface_t * surface;
+
+ *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
+ if (!gxtc->dpy) {
+ CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+ goto FAIL;
+ }
+
+ XSynchronize (gxtc->dpy, 1);
+
+ gxtc->scr = DefaultScreen(gxtc->dpy);
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, gxtc);
+ break;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ glitz_surface = _cairo_boilerplate_glitz_glx_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, gxtc);
+ break;
+ case CAIRO_CONTENT_ALPHA:
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
+ goto FAIL_CLOSE_DISPLAY;
+ }
+ if (!glitz_surface) {
+ CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
+ goto FAIL_CLOSE_DISPLAY;
+ }
+
+ surface = cairo_glitz_surface_create (glitz_surface);
+
+ gxtc->base.width = width;
+ gxtc->base.height = height;
+ gxtc->base.content = content;
+ cairo_surface_set_user_data (surface, &glitz_closure_key,
+ gxtc, NULL);
+
+ return surface;
+
+ FAIL_CLOSE_DISPLAY:
+ XCloseDisplay (gxtc->dpy);
+ FAIL:
+ return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_glx_cleanup (void *closure)
+{
+ glitz_glx_target_closure_t *gxtc = closure;
+
+ glitz_glx_fini ();
+
+ if (gxtc->win)
+ XDestroyWindow (gxtc->dpy, gxtc->win);
+
+ XCloseDisplay (gxtc->dpy);
+
+ free (gxtc);
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_GLX_SURFACE */
+
+#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
+#include <glitz-agl.h>
+
+typedef struct _glitz_agl_target_closure {
+ glitz_target_closure_base_t base;
+} glitz_agl_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_agl_target_closure_t *closure)
+{
+ glitz_drawable_format_t *dformat;
+ glitz_drawable_format_t templ;
+ glitz_drawable_t *gdraw;
+ glitz_format_t *format;
+ glitz_surface_t *sr = NULL;
+ unsigned long mask;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.color.red_size = 8;
+ templ.color.green_size = 8;
+ templ.color.blue_size = 8;
+ templ.color.alpha_size = 8;
+ templ.color.fourcc = GLITZ_FOURCC_RGB;
+ templ.samples = 1;
+
+ mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+ GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+ GLITZ_FORMAT_BLUE_SIZE_MASK;
+ if (formatname == GLITZ_STANDARD_ARGB32)
+ mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+ dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
+ if (!dformat) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+ goto FAIL;
+ }
+
+ gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
+ if (!gdraw) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+ goto FAIL;
+ }
+
+ format = glitz_find_standard_format (gdraw, formatname);
+ if (!format) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+ goto DESTROY_DRAWABLE;
+ }
+
+ sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
+ if (!sr) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+ goto DESTROY_DRAWABLE;
+ }
+
+ glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+ DESTROY_DRAWABLE:
+ glitz_drawable_destroy (gdraw);
+
+ FAIL:
+ return sr; /* will be NULL unless we create it and attach */
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_agl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ glitz_surface_t *glitz_surface;
+ cairo_surface_t *surface;
+ glitz_agl_target_closure_t *aglc;
+
+ glitz_agl_init ();
+
+ *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t));
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
+ break;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ glitz_surface = _cairo_boilerplate_glitz_agl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
+ break;
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
+ goto FAIL;
+ }
+
+ if (!glitz_surface)
+ goto FAIL;
+
+ surface = cairo_glitz_surface_create (glitz_surface);
+
+ aglc->base.width = width;
+ aglc->base.height = height;
+ aglc->base.content = content;
+ cairo_surface_set_user_data (surface, &glitz_closure_key, aglc, NULL);
+
+ return surface;
+
+ FAIL:
+ return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_agl_cleanup (void *closure)
+{
+ free (closure);
+ glitz_agl_fini ();
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_AGL_SURFACE */
+
+#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
+#include <glitz-wgl.h>
+
+typedef struct _glitz_wgl_target_closure {
+ glitz_target_closure_base_t base;
+} glitz_wgl_target_closure_t;
+
+glitz_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_wgl_target_closure_t *closure)
+{
+ glitz_drawable_format_t *dformat;
+ glitz_drawable_format_t templ;
+ glitz_drawable_t *gdraw;
+ glitz_format_t *format;
+ glitz_surface_t *sr = NULL;
+ unsigned long mask;
+
+ memset(&templ, 0, sizeof(templ));
+ templ.color.red_size = 8;
+ templ.color.green_size = 8;
+ templ.color.blue_size = 8;
+ templ.color.alpha_size = 8;
+ templ.color.fourcc = GLITZ_FOURCC_RGB;
+ templ.samples = 1;
+
+ mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
+ GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
+ GLITZ_FORMAT_BLUE_SIZE_MASK;
+ if (formatname == GLITZ_STANDARD_ARGB32)
+ mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
+
+ dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
+ if (!dformat) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+ goto FAIL;
+ }
+
+ gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
+ if (!gdraw) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+ goto FAIL;
+ }
+
+ format = glitz_find_standard_format (gdraw, formatname);
+ if (!format) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+ goto DESTROY_DRAWABLE;
+ }
+
+ sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
+ if (!sr) {
+ CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+ goto DESTROY_DRAWABLE;
+ }
+
+ glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
+
+ DESTROY_DRAWABLE:
+ glitz_drawable_destroy (gdraw);
+
+ FAIL:
+ return sr; /* will be NULL unless we create it and attach */
+}
+
+cairo_surface_t *
+_cairo_boilerplate_glitz_wgl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ glitz_surface_t *glitz_surface;
+ cairo_surface_t *surface;
+ glitz_wgl_target_closure_t *wglc;
+
+ glitz_wgl_init (NULL);
+
+ *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_RGB24, width, height, NULL);
+ break;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
+ break;
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
+ goto FAIL;
+ }
+
+ if (!glitz_surface)
+ goto FAIL;
+
+ surface = cairo_glitz_surface_create (glitz_surface);
+
+ wglc->base.width = width;
+ wglc->base.height = height;
+ wglc->base.content = content;
+ cairo_surface_set_user_data (surface, &glitz_closure_key, wglc, NULL);
+
+ return surface;
+
+ FAIL:
+ return NULL;
+}
+
+void
+_cairo_boilerplate_glitz_wgl_cleanup (void *closure)
+{
+ free (closure);
+ glitz_wgl_fini ();
+}
+
+#endif /* CAIRO_CAN_TEST_GLITZ_WGL_SURFACE */
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 245d942..7b8a41e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -50,6 +50,9 @@
#if CAIRO_HAS_DIRECTFB_SURFACE
#include "cairo-boilerplate-directfb-private.h"
#endif
+#if CAIRO_HAS_GLITZ_SURFACE
+#include "cairo-boilerplate-glitz-private.h"
+#endif
#if CAIRO_HAS_PDF_SURFACE
#include "cairo-boilerplate-pdf-private.h"
#endif
@@ -272,459 +275,6 @@ _cairo_boilerplate_test_paginated_cleanu
#endif
-#ifdef CAIRO_HAS_GLITZ_SURFACE
-#include <glitz.h>
-#include <cairo-glitz.h>
-
-static const cairo_user_data_key_t glitz_closure_key;
-
-typedef struct _glitz_target_closure_base {
- int width;
- int height;
- cairo_content_t content;
-} glitz_target_closure_base_t;
-
-#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
-#include <glitz-glx.h>
-
-typedef struct _glitz_glx_target_closure {
- glitz_target_closure_base_t base;
- Display *dpy;
- int scr;
- Window win;
-} glitz_glx_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_glx_create_surface (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_glx_target_closure_t *closure)
-{
- Display * dpy = closure->dpy;
- int scr = closure->scr;
- glitz_drawable_format_t templ;
- glitz_drawable_format_t * dformat = NULL;
- unsigned long mask;
- glitz_drawable_t * drawable = NULL;
- glitz_format_t * format;
- glitz_surface_t * sr;
-
- XSizeHints xsh;
- XSetWindowAttributes xswa;
- XVisualInfo * vinfo;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- glitz_glx_init (NULL);
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- /* Try for a pbuffer first */
- if (!getenv("CAIRO_TEST_FORCE_GLITZ_WINDOW"))
- dformat = glitz_glx_find_pbuffer_format (dpy, scr, mask, &templ, 0);
-
- if (dformat) {
- closure->win = None;
-
- drawable = glitz_glx_create_pbuffer_drawable (dpy, scr, dformat,
- width, height);
- if (!drawable)
- goto FAIL;
- } else {
- /* No pbuffer, try window */
- dformat = glitz_glx_find_window_format (dpy, scr, mask, &templ, 0);
-
- if (!dformat)
- goto FAIL;
-
- vinfo = glitz_glx_get_visual_info_from_format(dpy,
- DefaultScreen(dpy),
- dformat);
-
- if (!vinfo)
- goto FAIL;
-
- xsh.flags = PSize;
- xsh.x = 0;
- xsh.y = 0;
- xsh.width = width;
- xsh.height = height;
-
- xswa.colormap = XCreateColormap (dpy, RootWindow(dpy, scr),
- vinfo->visual, AllocNone);
- closure->win = XCreateWindow (dpy, RootWindow(dpy, scr),
- xsh.x, xsh.y, xsh.width, xsh.height,
- 0, vinfo->depth, CopyFromParent,
- vinfo->visual, CWColormap, &xswa);
- XFree (vinfo);
-
- drawable =
- glitz_glx_create_drawable_for_window (dpy, scr,
- dformat, closure->win,
- width, height);
-
- if (!drawable)
- goto DESTROY_WINDOW;
- }
-
- format = glitz_find_standard_format (drawable, formatname);
- if (!format)
- goto DESTROY_DRAWABLE;
-
- sr = glitz_surface_create (drawable, format, width, height, 0, NULL);
- if (!sr)
- goto DESTROY_DRAWABLE;
-
- if (closure->win == None || dformat->doublebuffer) {
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_BACK_COLOR);
- } else {
- XMapWindow (closure->dpy, closure->win);
- glitz_surface_attach (sr, drawable, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
- }
-
- glitz_drawable_destroy (drawable);
-
- return sr;
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (drawable);
- DESTROY_WINDOW:
- if (closure->win)
- XDestroyWindow (dpy, closure->win);
- FAIL:
- return NULL;
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_glx_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- glitz_glx_target_closure_t *gxtc;
- glitz_surface_t * glitz_surface;
- cairo_surface_t * surface;
-
- *closure = gxtc = xmalloc (sizeof (glitz_glx_target_closure_t));
-
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
- if (!gxtc->dpy) {
- CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
- goto FAIL;
- }
-
- XSynchronize (gxtc->dpy, 1);
-
- gxtc->scr = DefaultScreen(gxtc->dpy);
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_RGB24, width, height, gxtc);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_ARGB32, width, height, gxtc);
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
- goto FAIL_CLOSE_DISPLAY;
- }
- if (!glitz_surface) {
- CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
- goto FAIL_CLOSE_DISPLAY;
- }
-
- surface = cairo_glitz_surface_create (glitz_surface);
-
- gxtc->base.width = width;
- gxtc->base.height = height;
- gxtc->base.content = content;
- cairo_surface_set_user_data (surface, &glitz_closure_key,
- gxtc, NULL);
-
- return surface;
-
- FAIL_CLOSE_DISPLAY:
- XCloseDisplay (gxtc->dpy);
- FAIL:
- return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_glx_cleanup (void *closure)
-{
- glitz_glx_target_closure_t *gxtc = closure;
-
- glitz_glx_fini ();
-
- if (gxtc->win)
- XDestroyWindow (gxtc->dpy, gxtc->win);
-
- XCloseDisplay (gxtc->dpy);
-
- free (gxtc);
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_GLX_SURFACE */
-
-#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
-#include <glitz-agl.h>
-
-typedef struct _glitz_agl_target_closure {
- glitz_target_closure_base_t base;
-} glitz_agl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_agl_create_surface (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_agl_target_closure_t *closure)
-{
- glitz_drawable_format_t *dformat;
- glitz_drawable_format_t templ;
- glitz_drawable_t *gdraw;
- glitz_format_t *format;
- glitz_surface_t *sr = NULL;
- unsigned long mask;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
- if (!dformat) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
- goto FAIL;
- }
-
- gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
- if (!gdraw) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
- goto FAIL;
- }
-
- format = glitz_find_standard_format (gdraw, formatname);
- if (!format) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
- goto DESTROY_DRAWABLE;
- }
-
- sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
- if (!sr) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
- goto DESTROY_DRAWABLE;
- }
-
- glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (gdraw);
-
- FAIL:
- return sr; /* will be NULL unless we create it and attach */
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_agl_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface;
- glitz_agl_target_closure_t *aglc;
-
- glitz_agl_init ();
-
- *closure = aglc = xmalloc (sizeof (glitz_agl_target_closure_t));
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
- break;
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
- goto FAIL;
- }
-
- if (!glitz_surface)
- goto FAIL;
-
- surface = cairo_glitz_surface_create (glitz_surface);
-
- aglc->base.width = width;
- aglc->base.height = height;
- aglc->base.content = content;
- cairo_surface_set_user_data (surface, &glitz_closure_key, aglc, NULL);
-
- return surface;
-
- FAIL:
- return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_agl_cleanup (void *closure)
-{
- free (closure);
- glitz_agl_fini ();
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_AGL_SURFACE */
-
-#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
-#include <glitz-wgl.h>
-
-typedef struct _glitz_wgl_target_closure {
- glitz_target_closure_base_t base;
-} glitz_wgl_target_closure_t;
-
-static glitz_surface_t *
-_cairo_boilerplate_glitz_wgl_create_surface (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_wgl_target_closure_t *closure)
-{
- glitz_drawable_format_t *dformat;
- glitz_drawable_format_t templ;
- glitz_drawable_t *gdraw;
- glitz_format_t *format;
- glitz_surface_t *sr = NULL;
- unsigned long mask;
-
- memset(&templ, 0, sizeof(templ));
- templ.color.red_size = 8;
- templ.color.green_size = 8;
- templ.color.blue_size = 8;
- templ.color.alpha_size = 8;
- templ.color.fourcc = GLITZ_FOURCC_RGB;
- templ.samples = 1;
-
- mask = GLITZ_FORMAT_SAMPLES_MASK | GLITZ_FORMAT_FOURCC_MASK |
- GLITZ_FORMAT_RED_SIZE_MASK | GLITZ_FORMAT_GREEN_SIZE_MASK |
- GLITZ_FORMAT_BLUE_SIZE_MASK;
- if (formatname == GLITZ_STANDARD_ARGB32)
- mask |= GLITZ_FORMAT_ALPHA_SIZE_MASK;
-
- dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
- if (!dformat) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
- goto FAIL;
- }
-
- gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
- if (!gdraw) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
- goto FAIL;
- }
-
- format = glitz_find_standard_format (gdraw, formatname);
- if (!format) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
- goto DESTROY_DRAWABLE;
- }
-
- sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
- if (!sr) {
- CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
- goto DESTROY_DRAWABLE;
- }
-
- glitz_surface_attach (sr, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
-
- DESTROY_DRAWABLE:
- glitz_drawable_destroy (gdraw);
-
- FAIL:
- return sr; /* will be NULL unless we create it and attach */
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_cairo_glitz_wgl_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- glitz_surface_t *glitz_surface;
- cairo_surface_t *surface;
- glitz_wgl_target_closure_t *wglc;
-
- glitz_wgl_init (NULL);
-
- *closure = wglc = xmalloc (sizeof (glitz_wgl_target_closure_t));
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
- break;
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
- goto FAIL;
- }
-
- if (!glitz_surface)
- goto FAIL;
-
- surface = cairo_glitz_surface_create (glitz_surface);
-
- wglc->base.width = width;
- wglc->base.height = height;
- wglc->base.content = content;
- cairo_surface_set_user_data (surface, &glitz_closure_key, wglc, NULL);
-
- return surface;
-
- FAIL:
- return NULL;
-}
-
-static void
-_cairo_boilerplate_cairo_glitz_wgl_cleanup (void *closure)
-{
- free (closure);
- glitz_wgl_fini ();
-}
-
-#endif /* CAIRO_CAN_TEST_GLITZ_WGL_SURFACE */
-
-#endif /* CAIRO_HAS_GLITZ_SURFACE */
-
/* Testing the win32 surface isn't interesting, since for
* ARGB images it just chains to the image backend
*/
@@ -799,33 +349,33 @@ static cairo_boilerplate_target_t target
#ifdef CAIRO_HAS_GLITZ_SURFACE
#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_boilerplate_cairo_glitz_glx_create_surface,
+ _cairo_boilerplate_glitz_glx_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_glx_cleanup },
+ _cairo_boilerplate_glitz_glx_cleanup },
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- _cairo_boilerplate_cairo_glitz_glx_create_surface,
+ _cairo_boilerplate_glitz_glx_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_glx_cleanup },
+ _cairo_boilerplate_glitz_glx_cleanup },
#endif
#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_boilerplate_cairo_glitz_agl_create_surface,
+ _cairo_boilerplate_glitz_agl_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_agl_cleanup },
+ _cairo_boilerplate_glitz_agl_cleanup },
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- _cairo_boilerplate_cairo_glitz_agl_create_surface,
+ _cairo_boilerplate_glitz_agl_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_agl_cleanup },
+ _cairo_boilerplate_glitz_agl_cleanup },
#endif
#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+ _cairo_boilerplate_glitz_wgl_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_wgl_cleanup },
+ _cairo_boilerplate_glitz_wgl_cleanup },
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+ _cairo_boilerplate_glitz_wgl_create_surface,
cairo_surface_write_to_png,
- _cairo_boilerplate_cairo_glitz_wgl_cleanup },
+ _cairo_boilerplate_glitz_wgl_cleanup },
#endif
#endif /* CAIRO_HAS_GLITZ_SURFACE */
#if CAIRO_HAS_QUARTZ_SURFACE
diff-tree 7d576a376706aad427915b4872429f5605104886 (from 06b657ccf129f6f154c0db7886e5cca6191f93ca)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:25:28 2007 -0400
[boilerplate] Minor indentation fix
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index b6174de..245d942 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -213,8 +213,8 @@ _cairo_boilerplate_test_paginated_create
* tested.
*/
static cairo_status_t
-_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
- const char *filename)
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
+ const char *filename)
{
cairo_surface_t *image;
cairo_format_t format;
diff-tree 06b657ccf129f6f154c0db7886e5cca6191f93ca (from 65f636649d54348722354b2400c3a191309da0e1)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:20:38 2007 -0400
[boilerplate] Strip xcb boilerplate into cairo-boilerplate-xcb*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 2968648..1e85c40 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -39,6 +39,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
endif
+if CAIRO_HAS_XCB_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xcb-private.h
+endif
+
if CAIRO_HAS_XLIB_XRENDER_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
diff --git a/boilerplate/cairo-boilerplate-xcb-private.h b/boilerplate/cairo-boilerplate-xcb-private.h
new file mode 100644
index 0000000..80717e9
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xcb-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_XCB_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_XCB_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_xcb_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_xcb_cleanup (void *closure);
+
+void
+_cairo_boilerplate_xcb_synchronize (void *closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
new file mode 100644
index 0000000..2cc88cd
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -0,0 +1,115 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-xcb-private.h"
+
+#include "cairo-xcb-xrender.h"
+
+#include <xcb/xcb_renderutil.h>
+
+typedef struct _xcb_target_closure
+{
+ xcb_connection_t *c;
+ xcb_pixmap_t pixmap;
+} xcb_target_closure_t;
+
+void
+_cairo_boilerplate_xcb_synchronize (void *closure)
+{
+ xcb_target_closure_t *xtc = closure;
+ free (xcb_get_image_reply (xtc->c,
+ xcb_get_image (xtc->c, XCB_IMAGE_FORMAT_Z_PIXMAP,
+ xtc->pixmap, 0, 0, 1, 1, /* AllPlanes */ ~0UL),
+ 0));
+}
+
+cairo_surface_t *
+_cairo_boilerplate_xcb_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ xcb_screen_t *root;
+ xcb_target_closure_t *xtc;
+ cairo_surface_t *surface;
+ xcb_connection_t *c;
+ xcb_render_pictforminfo_t *render_format;
+ xcb_pict_standard_t format;
+
+ *closure = xtc = xmalloc (sizeof (xcb_target_closure_t));
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ xtc->c = c = xcb_connect(NULL,NULL);
+ if (xcb_connection_has_error(c)) {
+ CAIRO_BOILERPLATE_LOG ("Failed to connect to X server through XCB\n");
+ return NULL;
+ }
+
+ root = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
+
+ xtc->pixmap = xcb_generate_id (c);
+ xcb_create_pixmap (c, 32, xtc->pixmap, root->root,
+ width, height);
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR:
+ format = XCB_PICT_STANDARD_RGB_24;
+ break;
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ format = XCB_PICT_STANDARD_ARGB_32;
+ break;
+ case CAIRO_CONTENT_ALPHA: /* would be XCB_PICT_STANDARD_A_8 */
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for XCB test: %d\n", content);
+ return NULL;
+ }
+
+ render_format = xcb_render_util_find_standard_format (xcb_render_util_query_formats (c), format);
+ if (render_format->id == 0)
+ return NULL;
+ surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->pixmap, root,
+ render_format,
+ width, height);
+
+ return surface;
+}
+
+void
+_cairo_boilerplate_xcb_cleanup (void *closure)
+{
+ xcb_target_closure_t *xtc = closure;
+
+ xcb_free_pixmap (xtc->c, xtc->pixmap);
+ xcb_disconnect (xtc->c);
+ free (xtc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 6a8449e..b6174de 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -65,6 +65,9 @@
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
#include "cairo-boilerplate-xlib-private.h"
#endif
+#if CAIRO_HAS_XCB_SURFACE
+#include "cairo-boilerplate-xcb-private.h"
+#endif
/* This is copied from cairoint.h. That makes it painful to keep in
* sync, but the slim stuff makes cairoint.h "hard" to include when
@@ -754,93 +757,6 @@ cleanup_win32 (void *closure)
}
#endif
-#if CAIRO_HAS_XCB_SURFACE
-#include "cairo-xcb-xrender.h"
-#include <xcb/xcb_renderutil.h>
-typedef struct _xcb_target_closure
-{
- xcb_connection_t *c;
- xcb_pixmap_t pixmap;
-} xcb_target_closure_t;
-
-static void
-_cairo_boilerplate_xcb_synchronize (void *closure)
-{
- xcb_target_closure_t *xtc = closure;
- free (xcb_get_image_reply (xtc->c,
- xcb_get_image (xtc->c, XCB_IMAGE_FORMAT_Z_PIXMAP,
- xtc->pixmap, 0, 0, 1, 1, /* AllPlanes */ ~0UL),
- 0));
-}
-
-static cairo_surface_t *
-_cairo_boilerplate_xcb_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- xcb_screen_t *root;
- xcb_target_closure_t *xtc;
- cairo_surface_t *surface;
- xcb_connection_t *c;
- xcb_render_pictforminfo_t *render_format;
- xcb_pict_standard_t format;
-
- *closure = xtc = xmalloc (sizeof (xcb_target_closure_t));
-
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- xtc->c = c = xcb_connect(NULL,NULL);
- if (xcb_connection_has_error(c)) {
- CAIRO_BOILERPLATE_LOG ("Failed to connect to X server through XCB\n");
- return NULL;
- }
-
- root = xcb_setup_roots_iterator(xcb_get_setup(c)).data;
-
- xtc->pixmap = xcb_generate_id (c);
- xcb_create_pixmap (c, 32, xtc->pixmap, root->root,
- width, height);
-
- switch (content) {
- case CAIRO_CONTENT_COLOR:
- format = XCB_PICT_STANDARD_RGB_24;
- break;
- case CAIRO_CONTENT_COLOR_ALPHA:
- format = XCB_PICT_STANDARD_ARGB_32;
- break;
- case CAIRO_CONTENT_ALPHA: /* would be XCB_PICT_STANDARD_A_8 */
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for XCB test: %d\n", content);
- return NULL;
- }
-
- render_format = xcb_render_util_find_standard_format (xcb_render_util_query_formats (c), format);
- if (render_format->id == 0)
- return NULL;
- surface = cairo_xcb_surface_create_with_xrender_format (c, xtc->pixmap, root,
- render_format,
- width, height);
-
- return surface;
-}
-
-static void
-_cairo_boilerplate_xcb_cleanup (void *closure)
-{
- xcb_target_closure_t *xtc = closure;
-
- xcb_free_pixmap (xtc->c, xtc->pixmap);
- xcb_disconnect (xtc->c);
- free (xtc);
-}
-#endif
-
static cairo_boilerplate_target_t targets[] =
{
/* I'm uncompromising about leaving the image backend as 0
diff-tree 65f636649d54348722354b2400c3a191309da0e1 (from 8c9960675b82978acbd5a85ef358c674c3407ee3)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:13:08 2007 -0400
[boilerplate] Strip svg boilerplate into cairo-boilerplate-svg*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 8d9b1b2..2968648 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -34,6 +34,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
endif
+if CAIRO_HAS_SVG_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-svg-private.h
+endif
+
if CAIRO_HAS_XLIB_XRENDER_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
diff --git a/boilerplate/cairo-boilerplate-svg-private.h b/boilerplate/cairo-boilerplate-svg-private.h
new file mode 100644
index 0000000..ffc56c8
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-svg-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_SVG_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_SVG_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_svg_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_svg_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-svg.c b/boilerplate/cairo-boilerplate-svg.c
new file mode 100644
index 0000000..8193031
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-svg.c
@@ -0,0 +1,129 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-svg-private.h"
+
+#include "cairo-svg.h"
+
+cairo_user_data_key_t svg_closure_key;
+
+typedef struct _svg_target_closure
+{
+ char *filename;
+ int width, height;
+ cairo_surface_t *target;
+} svg_target_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_svg_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ svg_target_closure_t *ptc;
+ cairo_surface_t *surface;
+
+ *closure = ptc = xmalloc (sizeof (svg_target_closure_t));
+
+ ptc->width = width;
+ ptc->height = height;
+
+ xasprintf (&ptc->filename, "%s-svg-%s-out.svg",
+ name, cairo_boilerplate_content_name (content));
+
+ surface = cairo_svg_surface_create (ptc->filename, width, height);
+ if (cairo_surface_status (surface)) {
+ free (ptc->filename);
+ free (ptc);
+ return NULL;
+ }
+ cairo_surface_set_fallback_resolution (surface, 72., 72.);
+
+ if (content == CAIRO_CONTENT_COLOR) {
+ ptc->target = surface;
+ surface = cairo_surface_create_similar (ptc->target,
+ CAIRO_CONTENT_COLOR,
+ width, height);
+ } else {
+ ptc->target = NULL;
+ }
+
+ cairo_boilerplate_surface_set_user_data (surface,
+ &svg_closure_key,
+ ptc, NULL);
+
+ return surface;
+}
+
+cairo_status_t
+_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+{
+ svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
+ char command[4096];
+
+ /* Both surface and ptc->target were originally created at the
+ * same dimensions. We want a 1:1 copy here, so we first clear any
+ * device offset on surface.
+ *
+ * In a more realistic use case of device offsets, the target of
+ * this copying would be of a different size than the source, and
+ * the offset would be desirable during the copy operation. */
+ cairo_surface_set_device_offset (surface, 0, 0);
+
+ if (ptc->target) {
+ cairo_t *cr;
+ cr = cairo_create (ptc->target);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
+ cairo_surface_finish (surface);
+ surface = ptc->target;
+ }
+
+ cairo_surface_finish (surface);
+ sprintf (command, "./svg2png %s %s",
+ ptc->filename, filename);
+
+ if (system (command) != 0)
+ return CAIRO_STATUS_WRITE_ERROR;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_svg_cleanup (void *closure)
+{
+ svg_target_closure_t *ptc = closure;
+ if (ptc->target)
+ cairo_surface_destroy (ptc->target);
+ free (ptc->filename);
+ free (ptc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 42552f4..6a8449e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -59,6 +59,9 @@
#if CAIRO_HAS_QUARTZ_SURFACE
#include "cairo-boilerplate-quartz-private.h"
#endif
+#if CAIRO_HAS_SVG_SURFACE
+#include "cairo-boilerplate-svg-private.h"
+#endif
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
#include "cairo-boilerplate-xlib-private.h"
#endif
@@ -838,109 +841,6 @@ _cairo_boilerplate_xcb_cleanup (void *cl
}
#endif
-#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
-#include "cairo-svg.h"
-
-cairo_user_data_key_t svg_closure_key;
-
-typedef struct _svg_target_closure
-{
- char *filename;
- int width, height;
- cairo_surface_t *target;
-} svg_target_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_svg_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- svg_target_closure_t *ptc;
- cairo_surface_t *surface;
-
- *closure = ptc = xmalloc (sizeof (svg_target_closure_t));
-
- ptc->width = width;
- ptc->height = height;
-
- xasprintf (&ptc->filename, "%s-svg-%s-out.svg",
- name, cairo_boilerplate_content_name (content));
-
- surface = cairo_svg_surface_create (ptc->filename, width, height);
- if (cairo_surface_status (surface)) {
- free (ptc->filename);
- free (ptc);
- return NULL;
- }
- cairo_surface_set_fallback_resolution (surface, 72., 72.);
-
- if (content == CAIRO_CONTENT_COLOR) {
- ptc->target = surface;
- surface = cairo_surface_create_similar (ptc->target,
- CAIRO_CONTENT_COLOR,
- width, height);
- } else {
- ptc->target = NULL;
- }
-
- cairo_boilerplate_surface_set_user_data (surface,
- &svg_closure_key,
- ptc, NULL);
-
- return surface;
-}
-
-static cairo_status_t
-_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
-{
- svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
- char command[4096];
-
- /* Both surface and ptc->target were originally created at the
- * same dimensions. We want a 1:1 copy here, so we first clear any
- * device offset on surface.
- *
- * In a more realistic use case of device offsets, the target of
- * this copying would be of a different size than the source, and
- * the offset would be desirable during the copy operation. */
- cairo_surface_set_device_offset (surface, 0, 0);
-
- if (ptc->target) {
- cairo_t *cr;
- cr = cairo_create (ptc->target);
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- cairo_show_page (cr);
- cairo_destroy (cr);
-
- cairo_surface_finish (surface);
- surface = ptc->target;
- }
-
- cairo_surface_finish (surface);
- sprintf (command, "./svg2png %s %s",
- ptc->filename, filename);
-
- if (system (command) != 0)
- return CAIRO_STATUS_WRITE_ERROR;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_svg_cleanup (void *closure)
-{
- svg_target_closure_t *ptc = closure;
- if (ptc->target)
- cairo_surface_destroy (ptc->target);
- free (ptc->filename);
- free (ptc);
-}
-#endif /* CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE */
-
static cairo_boilerplate_target_t targets[] =
{
/* I'm uncompromising about leaving the image backend as 0
diff-tree 8c9960675b82978acbd5a85ef358c674c3407ee3 (from d9ce7de57514710f425bdee613edc4ea79ac0f0a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:10:09 2007 -0400
[boilerplate] Strip pdf boilerplate into cairo-boilerplate-pdf*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 7753d7c..8d9b1b2 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
+if CAIRO_HAS_PDF_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-pdf-private.h
+endif
+
if CAIRO_HAS_PS_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps-private.h
diff --git a/boilerplate/cairo-boilerplate-pdf-private.h b/boilerplate/cairo-boilerplate-pdf-private.h
new file mode 100644
index 0000000..7ce181e
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-pdf-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_PDF_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_PDF_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_pdf_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_pdf_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-pdf.c b/boilerplate/cairo-boilerplate-pdf.c
new file mode 100644
index 0000000..0b1dec0
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-pdf.c
@@ -0,0 +1,134 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-pdf-private.h"
+
+#include "cairo-pdf.h"
+
+cairo_user_data_key_t pdf_closure_key;
+
+typedef struct _pdf_target_closure
+{
+ char *filename;
+ int width;
+ int height;
+ cairo_surface_t *target;
+} pdf_target_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_pdf_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ pdf_target_closure_t *ptc;
+ cairo_surface_t *surface;
+
+ /* Sanitize back to a real cairo_content_t value. */
+ if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
+ content = CAIRO_CONTENT_COLOR_ALPHA;
+
+ *closure = ptc = xmalloc (sizeof (pdf_target_closure_t));
+
+ ptc->width = width;
+ ptc->height = height;
+
+ xasprintf (&ptc->filename, "%s-pdf-%s-out.pdf",
+ name, cairo_boilerplate_content_name (content));
+
+ surface = cairo_pdf_surface_create (ptc->filename, width, height);
+ if (cairo_surface_status (surface)) {
+ free (ptc->filename);
+ free (ptc);
+ return NULL;
+ }
+ cairo_surface_set_fallback_resolution (surface, 72., 72.);
+
+ if (content == CAIRO_CONTENT_COLOR) {
+ ptc->target = surface;
+ surface = cairo_surface_create_similar (ptc->target,
+ CAIRO_CONTENT_COLOR,
+ width, height);
+ } else {
+ ptc->target = NULL;
+ }
+
+ cairo_boilerplate_surface_set_user_data (surface,
+ &pdf_closure_key,
+ ptc, NULL);
+
+ return surface;
+}
+
+cairo_status_t
+_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+{
+ pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
+ char command[4096];
+
+ /* Both surface and ptc->target were originally created at the
+ * same dimensions. We want a 1:1 copy here, so we first clear any
+ * device offset on surface.
+ *
+ * In a more realistic use case of device offsets, the target of
+ * this copying would be of a different size than the source, and
+ * the offset would be desirable during the copy operation. */
+ cairo_surface_set_device_offset (surface, 0, 0);
+
+ if (ptc->target) {
+ cairo_t *cr;
+ cr = cairo_create (ptc->target);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
+ cairo_surface_finish (surface);
+ surface = ptc->target;
+ }
+
+ cairo_surface_finish (surface);
+ sprintf (command, "./pdf2png %s %s 1",
+ ptc->filename, filename);
+
+ if (system (command) != 0)
+ return CAIRO_STATUS_WRITE_ERROR;
+
+ return CAIRO_STATUS_SUCCESS;
+}
+
+void
+_cairo_boilerplate_pdf_cleanup (void *closure)
+{
+ pdf_target_closure_t *ptc = closure;
+ if (ptc->target)
+ cairo_surface_destroy (ptc->target);
+ free (ptc->filename);
+ free (ptc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 0dc7c19..42552f4 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -50,6 +50,9 @@
#if CAIRO_HAS_DIRECTFB_SURFACE
#include "cairo-boilerplate-directfb-private.h"
#endif
+#if CAIRO_HAS_PDF_SURFACE
+#include "cairo-boilerplate-pdf-private.h"
+#endif
#if CAIRO_HAS_PS_SURFACE
#include "cairo-boilerplate-ps-private.h"
#endif
@@ -835,114 +838,6 @@ _cairo_boilerplate_xcb_cleanup (void *cl
}
#endif
-#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
-#include "cairo-pdf.h"
-
-cairo_user_data_key_t pdf_closure_key;
-
-typedef struct _pdf_target_closure
-{
- char *filename;
- int width;
- int height;
- cairo_surface_t *target;
-} pdf_target_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_pdf_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- pdf_target_closure_t *ptc;
- cairo_surface_t *surface;
-
- /* Sanitize back to a real cairo_content_t value. */
- if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
- content = CAIRO_CONTENT_COLOR_ALPHA;
-
- *closure = ptc = xmalloc (sizeof (pdf_target_closure_t));
-
- ptc->width = width;
- ptc->height = height;
-
- xasprintf (&ptc->filename, "%s-pdf-%s-out.pdf",
- name, cairo_boilerplate_content_name (content));
-
- surface = cairo_pdf_surface_create (ptc->filename, width, height);
- if (cairo_surface_status (surface)) {
- free (ptc->filename);
- free (ptc);
- return NULL;
- }
- cairo_surface_set_fallback_resolution (surface, 72., 72.);
-
- if (content == CAIRO_CONTENT_COLOR) {
- ptc->target = surface;
- surface = cairo_surface_create_similar (ptc->target,
- CAIRO_CONTENT_COLOR,
- width, height);
- } else {
- ptc->target = NULL;
- }
-
- cairo_boilerplate_surface_set_user_data (surface,
- &pdf_closure_key,
- ptc, NULL);
-
- return surface;
-}
-
-static cairo_status_t
-_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
-{
- pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
- char command[4096];
-
- /* Both surface and ptc->target were originally created at the
- * same dimensions. We want a 1:1 copy here, so we first clear any
- * device offset on surface.
- *
- * In a more realistic use case of device offsets, the target of
- * this copying would be of a different size than the source, and
- * the offset would be desirable during the copy operation. */
- cairo_surface_set_device_offset (surface, 0, 0);
-
- if (ptc->target) {
- cairo_t *cr;
- cr = cairo_create (ptc->target);
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- cairo_show_page (cr);
- cairo_destroy (cr);
-
- cairo_surface_finish (surface);
- surface = ptc->target;
- }
-
- cairo_surface_finish (surface);
- sprintf (command, "./pdf2png %s %s 1",
- ptc->filename, filename);
-
- if (system (command) != 0)
- return CAIRO_STATUS_WRITE_ERROR;
-
- return CAIRO_STATUS_SUCCESS;
-}
-
-static void
-_cairo_boilerplate_pdf_cleanup (void *closure)
-{
- pdf_target_closure_t *ptc = closure;
- if (ptc->target)
- cairo_surface_destroy (ptc->target);
- free (ptc->filename);
- free (ptc);
-}
-#endif /* CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE */
-
#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
#include "cairo-svg.h"
diff-tree d9ce7de57514710f425bdee613edc4ea79ac0f0a (from df6b8ecc8963518c897648d82aab1aa090b4721a)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 22:08:24 2007 -0400
[boilerplate] Rename xcairo_surface_set_user_data to cairo_boilerplate_surface_set_user_data
and make it public.
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 730b855..0dc7c19 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -119,24 +119,6 @@ _cairo_boilerplate_image_create_surface
return cairo_image_surface_create (format, width, height);
}
-static void
-xcairo_surface_set_user_data (cairo_surface_t *surface,
- const cairo_user_data_key_t *key,
- void *user_data,
- cairo_destroy_func_t destroy)
-{
- cairo_status_t status;
-
- status = cairo_surface_set_user_data (surface,
- key, user_data,
- destroy);
- if (status) {
- CAIRO_BOILERPLATE_LOG ("Error: %s. Exiting\n",
- cairo_status_to_string (status));
- exit (1);
- }
-}
-
#ifdef CAIRO_HAS_TEST_SURFACES
#include "test-fallback-surface.h"
@@ -203,8 +185,9 @@ _cairo_boilerplate_test_paginated_create
tpc->height,
tpc->stride);
- xcairo_surface_set_user_data (surface, &test_paginated_closure_key,
- tpc, NULL);
+ cairo_boilerplate_surface_set_user_data (surface,
+ &test_paginated_closure_key,
+ tpc, NULL);
return surface;
}
@@ -905,7 +888,9 @@ _cairo_boilerplate_pdf_create_surface (c
ptc->target = NULL;
}
- xcairo_surface_set_user_data (surface, &pdf_closure_key, ptc, NULL);
+ cairo_boilerplate_surface_set_user_data (surface,
+ &pdf_closure_key,
+ ptc, NULL);
return surface;
}
@@ -1006,7 +991,9 @@ _cairo_boilerplate_svg_create_surface (c
ptc->target = NULL;
}
- xcairo_surface_set_user_data (surface, &svg_closure_key, ptc, NULL);
+ cairo_boilerplate_surface_set_user_data (surface,
+ &svg_closure_key,
+ ptc, NULL);
return surface;
}
@@ -1333,6 +1320,23 @@ cairo_boilerplate_free_targets (cairo_bo
free (targets);
}
+void
+cairo_boilerplate_surface_set_user_data (cairo_surface_t *surface,
+ const cairo_user_data_key_t *key,
+ void *user_data,
+ cairo_destroy_func_t destroy)
+{
+ cairo_status_t status;
+
+ status = cairo_surface_set_user_data (surface,
+ key, user_data,
+ destroy);
+ if (status) {
+ CAIRO_BOILERPLATE_LOG ("Error: %s. Exiting\n",
+ cairo_status_to_string (status));
+ exit (1);
+ }
+}
void
xasprintf (char **strp, const char *fmt, ...)
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 8d3c215..5b4c217 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -138,6 +138,12 @@ cairo_boilerplate_free_targets (cairo_bo
#endif
void
+cairo_boilerplate_surface_set_user_data (cairo_surface_t *surface,
+ const cairo_user_data_key_t *key,
+ void *user_data,
+ cairo_destroy_func_t destroy);
+
+void
xasprintf (char **strp, const char *fmt, ...) CAIRO_PRINTF_FORMAT(2, 3);
#endif
diff-tree df6b8ecc8963518c897648d82aab1aa090b4721a (from 6461f0d120bf5fabd08b7621233229b223b3de89)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 21:46:51 2007 -0400
[boilerplate] Strip ps boilerplate into cairo-boilerplate-ps*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index f84600c..7753d7c 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -19,6 +19,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
+if CAIRO_HAS_PS_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-ps-private.h
+endif
+
if CAIRO_HAS_QUARTZ_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
diff --git a/boilerplate/cairo-boilerplate-ps-private.h b/boilerplate/cairo-boilerplate-ps-private.h
new file mode 100644
index 0000000..8d1faf1
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-ps-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_PS_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_PS_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_ps_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_ps_cleanup (void *closure);
+
+cairo_status_t
+_cairo_boilerplate_ps_surface_write_to_png (cairo_surface_t *surface, const char *filename);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-ps.c b/boilerplate/cairo-boilerplate-ps.c
new file mode 100644
index 0000000..676d3e8
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-ps.c
@@ -0,0 +1,138 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-ps-private.h"
+
+#include <cairo-ps.h>
+
+cairo_user_data_key_t ps_closure_key;
+
+typedef struct _ps_target_closure
+{
+ char *filename;
+ int width;
+ int height;
+ cairo_surface_t *target;
+} ps_target_closure_t;
+
+cairo_surface_t *
+_cairo_boilerplate_ps_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ ps_target_closure_t *ptc;
+ cairo_surface_t *surface;
+
+ /* Sanitize back to a real cairo_content_t value. */
+ if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
+ content = CAIRO_CONTENT_COLOR_ALPHA;
+
+ *closure = ptc = xmalloc (sizeof (ps_target_closure_t));
+
+ xasprintf (&ptc->filename, "%s-ps-%s-out.ps",
+ name, cairo_boilerplate_content_name (content));
+
+ ptc->width = width;
+ ptc->height = height;
+
+ surface = cairo_ps_surface_create (ptc->filename, width, height);
+ if (cairo_surface_status (surface)) {
+ free (ptc->filename);
+ free (ptc);
+ return NULL;
+ }
+ cairo_surface_set_fallback_resolution (surface, 72., 72.);
+
+ if (content == CAIRO_CONTENT_COLOR) {
+ ptc->target = surface;
+ surface = cairo_surface_create_similar (ptc->target,
+ CAIRO_CONTENT_COLOR,
+ width, height);
+ } else {
+ ptc->target = NULL;
+ }
+
+ if (cairo_surface_set_user_data (surface,
+ &ps_closure_key,
+ ptc,
+ NULL) != CAIRO_STATUS_SUCCESS) {
+ cairo_surface_destroy (surface);
+ free (ptc->filename);
+ free (ptc);
+ return NULL;
+ }
+
+ return surface;
+}
+
+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, &ps_closure_key);
+ char command[4096];
+
+ /* Both surface and ptc->target were originally created at the
+ * same dimensions. We want a 1:1 copy here, so we first clear any
+ * device offset on surface.
+ *
+ * In a more realistic use case of device offsets, the target of
+ * this copying would be of a different size than the source, and
+ * the offset would be desirable during the copy operation. */
+ cairo_surface_set_device_offset (surface, 0, 0);
+
+ if (ptc->target) {
+ cairo_t *cr;
+ cr = cairo_create (ptc->target);
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_paint (cr);
+ cairo_show_page (cr);
+ cairo_destroy (cr);
+
+ cairo_surface_finish (surface);
+ surface = ptc->target;
+ }
+
+ cairo_surface_finish (surface);
+ sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
+ ptc->width, ptc->height, filename, ptc->filename);
+ if (system (command) == 0)
+ return CAIRO_STATUS_SUCCESS;
+ return CAIRO_STATUS_WRITE_ERROR;
+}
+
+void
+_cairo_boilerplate_ps_cleanup (void *closure)
+{
+ ps_target_closure_t *ptc = closure;
+ if (ptc->target)
+ cairo_surface_destroy (ptc->target);
+ free (ptc->filename);
+ free (ptc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 674c531..730b855 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -50,6 +50,9 @@
#if CAIRO_HAS_DIRECTFB_SURFACE
#include "cairo-boilerplate-directfb-private.h"
#endif
+#if CAIRO_HAS_PS_SURFACE
+#include "cairo-boilerplate-ps-private.h"
+#endif
#if CAIRO_HAS_QUARTZ_SURFACE
#include "cairo-boilerplate-quartz-private.h"
#endif
@@ -849,118 +852,6 @@ _cairo_boilerplate_xcb_cleanup (void *cl
}
#endif
-#if CAIRO_HAS_PS_SURFACE
-#include "cairo-ps.h"
-
-cairo_user_data_key_t ps_closure_key;
-
-typedef struct _ps_target_closure
-{
- char *filename;
- int width;
- int height;
- cairo_surface_t *target;
-} ps_target_closure_t;
-
-static cairo_surface_t *
-_cairo_boilerplate_ps_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- ps_target_closure_t *ptc;
- cairo_surface_t *surface;
-
- /* Sanitize back to a real cairo_content_t value. */
- if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
- content = CAIRO_CONTENT_COLOR_ALPHA;
-
- *closure = ptc = xmalloc (sizeof (ps_target_closure_t));
-
- xasprintf (&ptc->filename, "%s-ps-%s-out.ps",
- name, cairo_boilerplate_content_name (content));
-
- ptc->width = width;
- ptc->height = height;
-
- surface = cairo_ps_surface_create (ptc->filename, width, height);
- if (cairo_surface_status (surface)) {
- free (ptc->filename);
- free (ptc);
- return NULL;
- }
- cairo_surface_set_fallback_resolution (surface, 72., 72.);
-
- if (content == CAIRO_CONTENT_COLOR) {
- ptc->target = surface;
- surface = cairo_surface_create_similar (ptc->target,
- CAIRO_CONTENT_COLOR,
- width, height);
- } else {
- ptc->target = NULL;
- }
-
- if (cairo_surface_set_user_data (surface,
- &ps_closure_key,
- ptc,
- NULL) != CAIRO_STATUS_SUCCESS) {
- cairo_surface_destroy (surface);
- free (ptc->filename);
- free (ptc);
- return NULL;
- }
-
- return surface;
-}
-
-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, &ps_closure_key);
- char command[4096];
-
- /* Both surface and ptc->target were originally created at the
- * same dimensions. We want a 1:1 copy here, so we first clear any
- * device offset on surface.
- *
- * In a more realistic use case of device offsets, the target of
- * this copying would be of a different size than the source, and
- * the offset would be desirable during the copy operation. */
- cairo_surface_set_device_offset (surface, 0, 0);
-
- if (ptc->target) {
- cairo_t *cr;
- cr = cairo_create (ptc->target);
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_paint (cr);
- cairo_show_page (cr);
- cairo_destroy (cr);
-
- cairo_surface_finish (surface);
- surface = ptc->target;
- }
-
- cairo_surface_finish (surface);
- sprintf (command, "gs -q -r72 -g%dx%d -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pngalpha -sOutputFile=%s %s",
- ptc->width, ptc->height, filename, ptc->filename);
- if (system (command) == 0)
- return CAIRO_STATUS_SUCCESS;
- return CAIRO_STATUS_WRITE_ERROR;
-}
-
-static void
-_cairo_boilerplate_ps_cleanup (void *closure)
-{
- ps_target_closure_t *ptc = closure;
- if (ptc->target)
- cairo_surface_destroy (ptc->target);
- free (ptc->filename);
- free (ptc);
-}
-#endif /* CAIRO_HAS_PS_SURFACE */
-
#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
#include "cairo-pdf.h"
diff-tree 6461f0d120bf5fabd08b7621233229b223b3de89 (from f2d6275352142df631e00e27456d7e6ceb83804c)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:45:10 2007 -0400
[boilerplate] Remove unused variables
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 791fa0f..674c531 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -872,7 +872,6 @@ _cairo_boilerplate_ps_create_surface (co
{
ps_target_closure_t *ptc;
cairo_surface_t *surface;
- int i;
/* Sanitize back to a real cairo_content_t value. */
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
@@ -985,7 +984,6 @@ _cairo_boilerplate_pdf_create_surface (c
{
pdf_target_closure_t *ptc;
cairo_surface_t *surface;
- int i;
/* Sanitize back to a real cairo_content_t value. */
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
@@ -1089,7 +1087,6 @@ _cairo_boilerplate_svg_create_surface (c
cairo_boilerplate_mode_t mode,
void **closure)
{
- int i;
svg_target_closure_t *ptc;
cairo_surface_t *surface;
diff-tree f2d6275352142df631e00e27456d7e6ceb83804c (from d5535c993b5cde5df29a7a29339aa500992128bf)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:41:34 2007 -0400
[boilerplate] Fix renaming typo
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index cd86fef..791fa0f 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -772,7 +772,7 @@ typedef struct _xcb_target_closure
} xcb_target_closure_t;
static void
-_cairo_boilerplate_xlib_synchronize (void *closure)
+_cairo_boilerplate_xcb_synchronize (void *closure)
{
xcb_target_closure_t *xtc = closure;
free (xcb_get_image_reply (xtc->c,
diff-tree d5535c993b5cde5df29a7a29339aa500992128bf (from d6dc4f978364d287367d239e5594c7ffe50a2571)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:36:14 2007 -0400
[boilerplate/test] Move vector_ignored_tests from boilerplate/ to test/
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 1eda4b8..cd86fef 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -72,22 +72,6 @@ typedef enum cairo_internal_surface_type
CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED
} cairo_internal_surface_type_t;
-static const char *vector_ignored_tests[] = {
- /* We can't match the results of tests that depend on
- * CAIRO_ANTIALIAS_NONE/SUBPIXEL for vector backends
- * (nor do we care). */
- "ft-text-antialias-none",
- "rectangle-rounding-error",
- "text-antialias-gray",
- "text-antialias-none",
- "text-antialias-subpixel",
- "unantialiased-shapes",
-
- /* Nor do we care about rendering anomalies in external renderers. */
- "fill-degenerate-sort-order",
- NULL
-};
-
const char *
cairo_boilerplate_content_name (cairo_content_t content)
{
@@ -890,10 +874,6 @@ _cairo_boilerplate_ps_create_surface (co
cairo_surface_t *surface;
int i;
- for (i = 0; vector_ignored_tests[i] != NULL; i++)
- if (strcmp (name, vector_ignored_tests[i]) == 0)
- return NULL;
-
/* Sanitize back to a real cairo_content_t value. */
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
content = CAIRO_CONTENT_COLOR_ALPHA;
@@ -1007,10 +987,6 @@ _cairo_boilerplate_pdf_create_surface (c
cairo_surface_t *surface;
int i;
- for (i = 0; vector_ignored_tests[i] != NULL; i++)
- if (strcmp (name, vector_ignored_tests[i]) == 0)
- return NULL;
-
/* Sanitize back to a real cairo_content_t value. */
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
content = CAIRO_CONTENT_COLOR_ALPHA;
@@ -1117,10 +1093,6 @@ _cairo_boilerplate_svg_create_surface (c
svg_target_closure_t *ptc;
cairo_surface_t *surface;
- for (i = 0; vector_ignored_tests[i] != NULL; i++)
- if (strcmp (name, vector_ignored_tests[i]) == 0)
- return NULL;
-
*closure = ptc = xmalloc (sizeof (svg_target_closure_t));
ptc->width = width;
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 1582d93..7bc5dd6 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -75,6 +75,22 @@ static const char *fail_face = "", *norm
#define NUM_DEVICE_OFFSETS 2
+static const char *vector_ignored_tests[] = {
+ /* We can't match the results of tests that depend on
+ * CAIRO_ANTIALIAS_NONE/SUBPIXEL for vector backends
+ * (nor do we care). */
+ "ft-text-antialias-none",
+ "rectangle-rounding-error",
+ "text-antialias-gray",
+ "text-antialias-none",
+ "text-antialias-subpixel",
+ "unantialiased-shapes",
+
+ /* Nor do we care about rendering anomalies in external renderers. */
+ "fill-degenerate-sort-order",
+ NULL
+};
+
/* Static data is messy, but we're coding for tests here, not a
* general-purpose library, and it keeps the tests cleaner to avoid a
* context object there, (though not a whole lot). */
@@ -194,10 +210,10 @@ cairo_test_for_target (cairo_test_t *
int dev_offset)
{
cairo_test_status_t status;
- cairo_surface_t *surface;
+ cairo_surface_t *surface = NULL;
cairo_t *cr;
char *png_name, *ref_name, *diff_name, *offset_str;
- cairo_test_status_t ret;
+ cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
cairo_content_t expected_content;
cairo_font_options_t *font_options;
const char *format;
@@ -221,22 +237,36 @@ cairo_test_for_target (cairo_test_t *
format,
offset_str, CAIRO_TEST_DIFF_SUFFIX);
- /* Run the actual drawing code. */
- if (test->width && test->height) {
- test->width += dev_offset;
- test->height += dev_offset;
- }
-
- surface = (target->create_surface) (test->name,
- target->content,
- test->width,
- test->height,
- CAIRO_BOILERPLATE_MODE_TEST,
- &target->closure);
-
- if (test->width && test->height) {
- test->width -= dev_offset;
- test->height -= dev_offset;;
+ if (target->is_vector) {
+ int i;
+
+ for (i = 0; vector_ignored_tests[i] != NULL; i++)
+ if (strcmp (test->name, vector_ignored_tests[i]) == 0) {
+ cairo_test_log ("Error: Skipping for vector target %s\n", target->name);
+ ret = CAIRO_TEST_UNTESTED;
+ goto UNWIND_STRINGS;
+ }
+ }
+
+ if (ret == CAIRO_TEST_SUCCESS) {
+ /* Run the actual drawing code. */
+
+ if (test->width && test->height) {
+ test->width += dev_offset;
+ test->height += dev_offset;
+ }
+
+ surface = (target->create_surface) (test->name,
+ target->content,
+ test->width,
+ test->height,
+ CAIRO_BOILERPLATE_MODE_TEST,
+ &target->closure);
+
+ if (test->width && test->height) {
+ test->width -= dev_offset;
+ test->height -= dev_offset;;
+ }
}
if (surface == NULL) {
@@ -342,8 +372,6 @@ cairo_test_for_target (cairo_test_t *
}
}
- ret = CAIRO_TEST_SUCCESS;
-
UNWIND_CAIRO:
cairo_destroy (cr);
UNWIND_SURFACE:
diff-tree d6dc4f978364d287367d239e5594c7ffe50a2571 (from 0b5e2dbaa84225452a0935f61d2348bce88a3e69)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:28:22 2007 -0400
[boilerplate] Add a boolean is_vector to boilerplate target type
This is used to move the skip-these-tests-for-vector code into
cairo-test which it belongs.
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 58c6f70..1eda4b8 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -1318,7 +1318,8 @@ static cairo_boilerplate_target_t target
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
_cairo_boilerplate_ps_create_surface,
_cairo_boilerplate_ps_surface_write_to_png,
- _cairo_boilerplate_ps_cleanup },
+ _cairo_boilerplate_ps_cleanup,
+ NULL, TRUE },
/* XXX: We expect type image here only due to a limitation in
* the current PS/meta-surface code. A PS surface is
@@ -1331,14 +1332,16 @@ static cairo_boilerplate_target_t target
{ "ps", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0,
_cairo_boilerplate_ps_create_surface,
_cairo_boilerplate_ps_surface_write_to_png,
- _cairo_boilerplate_ps_cleanup },
+ _cairo_boilerplate_ps_cleanup,
+ NULL, TRUE },
#endif
#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
{ "pdf", CAIRO_SURFACE_TYPE_PDF,
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
_cairo_boilerplate_pdf_create_surface,
_cairo_boilerplate_pdf_surface_write_to_png,
- _cairo_boilerplate_pdf_cleanup },
+ _cairo_boilerplate_pdf_cleanup,
+ NULL, TRUE },
/* XXX: We expect type image here only due to a limitation in
* the current PDF/meta-surface code. A PDF surface is
@@ -1351,7 +1354,8 @@ static cairo_boilerplate_target_t target
{ "pdf", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0,
_cairo_boilerplate_pdf_create_surface,
_cairo_boilerplate_pdf_surface_write_to_png,
- _cairo_boilerplate_pdf_cleanup },
+ _cairo_boilerplate_pdf_cleanup,
+ NULL, TRUE },
#endif
#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
/* It seems we should be able to round-trip SVG content perfrectly
@@ -1362,11 +1366,13 @@ static cairo_boilerplate_target_t target
{ "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
_cairo_boilerplate_svg_create_surface,
_cairo_boilerplate_svg_surface_write_to_png,
- _cairo_boilerplate_svg_cleanup },
+ _cairo_boilerplate_svg_cleanup,
+ NULL, TRUE },
{ "svg", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
_cairo_boilerplate_svg_create_surface,
_cairo_boilerplate_svg_surface_write_to_png,
- _cairo_boilerplate_svg_cleanup },
+ _cairo_boilerplate_svg_cleanup,
+ NULL, TRUE },
#endif
#if CAIRO_HAS_BEOS_SURFACE
/* BeOS sometimes produces a slightly different image. Perhaps this
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index c9e6ef0..8d3c215 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -120,6 +120,7 @@ typedef struct _cairo_boilerplate_target
cairo_boilerplate_write_to_png_t write_to_png;
cairo_boilerplate_cleanup_t cleanup;
cairo_boilerplate_wait_t synchronize;
+ cairo_bool_t is_vector;
void *closure;
} cairo_boilerplate_target_t;
diff-tree 0b5e2dbaa84225452a0935f61d2348bce88a3e69 (from be0320c4f8082a9274899959dc82297a04aa7800)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:23:55 2007 -0400
[boilerplate] Sort backend entries in Makefile.am alphabetically
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 2f02a26..f84600c 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -7,11 +7,6 @@ xmalloc.c \
xmalloc.h
libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LDADD)
-if CAIRO_HAS_QUARTZ_SURFACE
-libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz.c
-libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
-endif
-
if CAIRO_HAS_BEOS_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos-private.h
@@ -24,6 +19,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
+if CAIRO_HAS_QUARTZ_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
+endif
+
if CAIRO_HAS_XLIB_XRENDER_SURFACE
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
diff-tree be0320c4f8082a9274899959dc82297a04aa7800 (from 9b660a3d54940c68eb48f2afeca7e87e1d2bffa6)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 20:17:26 2007 -0400
[boilerplate] Properly namespace boilerplate methods
in preparation for ripping them into per-backend files.
diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp
index 2ebe297..1815d63 100644
--- a/boilerplate/cairo-boilerplate-beos.cpp
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -183,12 +183,12 @@ struct beos_boilerplate_closure
// Test a real window
cairo_surface_t *
-_cairo_boilerplate_beos_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_beos_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
float right = width ? width - 1 : 0;
float bottom = height ? height - 1 : 0;
@@ -218,12 +218,12 @@ _cairo_boilerplate_beos_cleanup (void* c
// Test a bitmap
cairo_surface_t *
-_cairo_boilerplate_beos_create_surface_for_bitmap (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_beos_create_surface_for_bitmap (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
BRect rect(0.0, 0.0, width - 1, height - 1);
color_space beosformat = (content == CAIRO_CONTENT_COLOR_ALPHA) ? B_RGBA32
diff --git a/boilerplate/cairo-boilerplate-directfb.c b/boilerplate/cairo-boilerplate-directfb.c
index 07fe17c..1e903dc 100644
--- a/boilerplate/cairo-boilerplate-directfb.c
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -59,10 +59,11 @@ static DFBInfo *init(void) {
}
static cairo_surface_t *
-create_directfb_window_surface (DFBInfo *info,
- cairo_content_t content,
- int width,
- int height) {
+_cairo_boilerplate_directfb_window_create_surface (DFBInfo *info,
+ cairo_content_t content,
+ int width,
+ int height)
+{
DFBWindowDescription desc;
int err;
desc.flags = ( DWDESC_POSX | DWDESC_POSY |
@@ -87,10 +88,11 @@ create_directfb_window_surface (DFBInfo
}
static cairo_surface_t *
-create_directfb_bitmap_surface (DFBInfo *info,
- cairo_content_t content,
- int width,
- int height) {
+_cairo_boilerplate_directfb_bitmap_create_surface (DFBInfo *info,
+ cairo_content_t content,
+ int width,
+ int height)
+{
int err;
DFBSurfaceDescription desc;
@@ -118,11 +120,12 @@ _cairo_boilerplate_directfb_cleanup (voi
cairo_surface_t *
_cairo_boilerplate_directfb_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure) {
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
DFBInfo* info= init();
*closure = info;
@@ -137,7 +140,7 @@ _cairo_boilerplate_directfb_create_surfa
height = 1;
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
- return create_directfb_bitmap_surface (info, content, width, height);
+ return _cairo_boilerplate_directfb_bitmap_create_surface (info, content, width, height);
else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
- return create_directfb_window_surface (info, content, width, height);
+ return _cairo_boilerplate_directfb_window_create_surface (info, content, width, height);
}
diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
index ccfd79f..d6df7fa 100644
--- a/boilerplate/cairo-boilerplate-quartz.c
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -30,12 +30,12 @@
#include <cairo-quartz.h>
cairo_surface_t *
-_cairo_boilerplate_quartz_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_quartz_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
cairo_format_t format;
diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index de3746c..302035d 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -60,11 +60,11 @@ _cairo_boilerplate_xlib_synchronize (voi
* For obvious reasons, we don't use XSynchronize.
*/
static cairo_surface_t *
-create_xlib_test_surface (Display *dpy,
- cairo_content_t content,
- int width,
- int height,
- xlib_target_closure_t *xtc)
+_cairo_boilerplate_xlib_test_create_surface (Display *dpy,
+ cairo_content_t content,
+ int width,
+ int height,
+ xlib_target_closure_t *xtc)
{
XRenderPictFormat *xrender_format;
@@ -109,11 +109,11 @@ create_xlib_test_surface (Display *dpy,
}
static cairo_surface_t *
-create_xlib_perf_surface (Display *dpy,
- cairo_content_t content,
- int width,
- int height,
- xlib_target_closure_t *xtc)
+_cairo_boilerplate_xlib_perf_create_surface (Display *dpy,
+ cairo_content_t content,
+ int width,
+ int height,
+ xlib_target_closure_t *xtc)
{
XSetWindowAttributes attr;
XRenderPictFormat *xrender_format;
@@ -177,9 +177,9 @@ _cairo_boilerplate_xlib_create_surface (
}
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
- return create_xlib_test_surface (dpy, content, width, height, xtc);
+ return _cairo_boilerplate_xlib_test_create_surface (dpy, content, width, height, xtc);
else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
- return create_xlib_perf_surface (dpy, content, width, height, xtc);
+ return _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc);
}
void
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 3e5f0dd..58c6f70 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -110,12 +110,12 @@ cairo_boilerplate_content_name (cairo_co
}
static cairo_surface_t *
-create_image_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_image_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
cairo_format_t format;
*closure = NULL;
@@ -157,24 +157,24 @@ xcairo_surface_set_user_data (cairo_surf
#include "test-paginated-surface.h"
static cairo_surface_t *
-create_test_fallback_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_test_fallback_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
*closure = NULL;
return _cairo_test_fallback_surface_create (content, width, height);
}
static cairo_surface_t *
-create_test_meta_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_test_meta_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
*closure = NULL;
return _cairo_test_meta_surface_create (content, width, height);
@@ -191,12 +191,12 @@ typedef struct {
} test_paginated_closure_t;
static cairo_surface_t *
-create_test_paginated_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_test_paginated_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
test_paginated_closure_t *tpc;
cairo_surface_t *surface;
@@ -234,7 +234,7 @@ create_test_paginated_surface (const cha
* tested.
*/
static cairo_status_t
-test_paginated_write_to_png (cairo_surface_t *surface,
+_cairo_boilerplate_test_paginated_surface_write_to_png (cairo_surface_t *surface,
const char *filename)
{
cairo_surface_t *image;
@@ -283,7 +283,7 @@ test_paginated_write_to_png (cairo_surfa
}
static void
-cleanup_test_paginated (void *closure)
+_cairo_boilerplate_test_paginated_cleanup (void *closure)
{
test_paginated_closure_t *tpc = closure;
@@ -316,10 +316,10 @@ typedef struct _glitz_glx_target_closure
} glitz_glx_target_closure_t;
static glitz_surface_t *
-create_glitz_glx_surface (glitz_format_name_t formatname,
- int width,
- int height,
- glitz_glx_target_closure_t *closure)
+_cairo_boilerplate_glitz_glx_create_surface (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_glx_target_closure_t *closure)
{
Display * dpy = closure->dpy;
int scr = closure->scr;
@@ -426,12 +426,12 @@ create_glitz_glx_surface (glitz_format_n
}
static cairo_surface_t *
-create_cairo_glitz_glx_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_cairo_glitz_glx_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
glitz_glx_target_closure_t *gxtc;
glitz_surface_t * glitz_surface;
@@ -456,10 +456,10 @@ create_cairo_glitz_glx_surface (const ch
switch (content) {
case CAIRO_CONTENT_COLOR:
- glitz_surface = create_glitz_glx_surface (GLITZ_STANDARD_RGB24, width, height, gxtc);
+ glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_RGB24, width, height, gxtc);
break;
case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = create_glitz_glx_surface (GLITZ_STANDARD_ARGB32, width, height, gxtc);
+ glitz_surface = _cairo_boilerplate_glitz_glx_create_surface (GLITZ_STANDARD_ARGB32, width, height, gxtc);
break;
case CAIRO_CONTENT_ALPHA:
default:
@@ -488,7 +488,7 @@ create_cairo_glitz_glx_surface (const ch
}
static void
-cleanup_cairo_glitz_glx (void *closure)
+_cairo_boilerplate_cairo_glitz_glx_cleanup (void *closure)
{
glitz_glx_target_closure_t *gxtc = closure;
@@ -512,9 +512,10 @@ typedef struct _glitz_agl_target_closure
} glitz_agl_target_closure_t;
static glitz_surface_t *
-create_glitz_agl_surface (glitz_format_name_t formatname,
- int width, int height,
- glitz_agl_target_closure_t *closure)
+_cairo_boilerplate_glitz_agl_create_surface (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_agl_target_closure_t *closure)
{
glitz_drawable_format_t *dformat;
glitz_drawable_format_t templ;
@@ -571,12 +572,12 @@ create_glitz_agl_surface (glitz_format_n
}
static cairo_surface_t *
-create_cairo_glitz_agl_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_cairo_glitz_agl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
glitz_surface_t *glitz_surface;
cairo_surface_t *surface;
@@ -588,10 +589,10 @@ create_cairo_glitz_agl_surface (const ch
switch (content) {
case CAIRO_CONTENT_COLOR:
- glitz_surface = create_glitz_agl_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
+ glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
break;
case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = create_glitz_agl_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
+ glitz_surface = _cairo_boilerplate_glitz_agl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
break;
default:
CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
@@ -615,7 +616,7 @@ create_cairo_glitz_agl_surface (const ch
}
static void
-cleanup_cairo_glitz_agl (void *closure)
+_cairo_boilerplate_cairo_glitz_agl_cleanup (void *closure)
{
free (closure);
glitz_agl_fini ();
@@ -631,9 +632,10 @@ typedef struct _glitz_wgl_target_closure
} glitz_wgl_target_closure_t;
static glitz_surface_t *
-create_glitz_wgl_surface (glitz_format_name_t formatname,
- int width, int height,
- glitz_wgl_target_closure_t *closure)
+_cairo_boilerplate_glitz_wgl_create_surface (glitz_format_name_t formatname,
+ int width,
+ int height,
+ glitz_wgl_target_closure_t *closure)
{
glitz_drawable_format_t *dformat;
glitz_drawable_format_t templ;
@@ -690,12 +692,12 @@ create_glitz_wgl_surface (glitz_format_n
}
static cairo_surface_t *
-create_cairo_glitz_wgl_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_cairo_glitz_wgl_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
glitz_surface_t *glitz_surface;
cairo_surface_t *surface;
@@ -707,10 +709,10 @@ create_cairo_glitz_wgl_surface (const ch
switch (content) {
case CAIRO_CONTENT_COLOR:
- glitz_surface = create_glitz_wgl_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
+ glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_RGB24, width, height, NULL);
break;
case CAIRO_CONTENT_COLOR_ALPHA:
- glitz_surface = create_glitz_wgl_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
+ glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface (GLITZ_STANDARD_ARGB32, width, height, NULL);
break;
default:
CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
@@ -734,7 +736,7 @@ create_cairo_glitz_wgl_surface (const ch
}
static void
-cleanup_cairo_glitz_wgl (void *closure)
+_cairo_boilerplate_cairo_glitz_wgl_cleanup (void *closure)
{
free (closure);
glitz_wgl_fini ();
@@ -786,7 +788,7 @@ typedef struct _xcb_target_closure
} xcb_target_closure_t;
static void
-boilerplate_xcb_synchronize (void *closure)
+_cairo_boilerplate_xlib_synchronize (void *closure)
{
xcb_target_closure_t *xtc = closure;
free (xcb_get_image_reply (xtc->c,
@@ -796,12 +798,12 @@ boilerplate_xcb_synchronize (void *closu
}
static cairo_surface_t *
-create_xcb_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_xcb_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
xcb_screen_t *root;
xcb_target_closure_t *xtc;
@@ -853,7 +855,7 @@ create_xcb_surface (const char *name,
}
static void
-cleanup_xcb (void *closure)
+_cairo_boilerplate_xcb_cleanup (void *closure)
{
xcb_target_closure_t *xtc = closure;
@@ -877,12 +879,12 @@ typedef struct _ps_target_closure
} ps_target_closure_t;
static cairo_surface_t *
-create_ps_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_ps_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
ps_target_closure_t *ptc;
cairo_surface_t *surface;
@@ -935,7 +937,7 @@ create_ps_surface (const char *name,
}
static cairo_status_t
-ps_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+_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, &ps_closure_key);
char command[4096];
@@ -970,7 +972,7 @@ ps_surface_write_to_png (cairo_surface_t
}
static void
-cleanup_ps (void *closure)
+_cairo_boilerplate_ps_cleanup (void *closure)
{
ps_target_closure_t *ptc = closure;
if (ptc->target)
@@ -994,12 +996,12 @@ typedef struct _pdf_target_closure
} pdf_target_closure_t;
static cairo_surface_t *
-create_pdf_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_pdf_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
pdf_target_closure_t *ptc;
cairo_surface_t *surface;
@@ -1044,7 +1046,7 @@ create_pdf_surface (const char *name,
}
static cairo_status_t
-pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+_cairo_boilerplate_pdf_surface_write_to_png (cairo_surface_t *surface, const char *filename)
{
pdf_target_closure_t *ptc = cairo_surface_get_user_data (surface, &pdf_closure_key);
char command[4096];
@@ -1081,7 +1083,7 @@ pdf_surface_write_to_png (cairo_surface_
}
static void
-cleanup_pdf (void *closure)
+_cairo_boilerplate_pdf_cleanup (void *closure)
{
pdf_target_closure_t *ptc = closure;
if (ptc->target)
@@ -1104,12 +1106,12 @@ typedef struct _svg_target_closure
} svg_target_closure_t;
static cairo_surface_t *
-create_svg_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
+_cairo_boilerplate_svg_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
{
int i;
svg_target_closure_t *ptc;
@@ -1150,7 +1152,7 @@ create_svg_surface (const char *name,
}
static cairo_status_t
-svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
+_cairo_boilerplate_svg_surface_write_to_png (cairo_surface_t *surface, const char *filename)
{
svg_target_closure_t *ptc = cairo_surface_get_user_data (surface, &svg_closure_key);
char command[4096];
@@ -1187,7 +1189,7 @@ svg_surface_write_to_png (cairo_surface_
}
static void
-cleanup_svg (void *closure)
+_cairo_boilerplate_svg_cleanup (void *closure)
{
svg_target_closure_t *ptc = closure;
if (ptc->target)
@@ -1203,121 +1205,153 @@ static cairo_boilerplate_target_t target
* for tolerance. There shouldn't ever be anything that is out of
* our control here. */
{ "image", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_image_surface, cairo_surface_write_to_png, NULL},
+ _cairo_boilerplate_image_create_surface,
+ cairo_surface_write_to_png },
{ "image", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0,
- create_image_surface, cairo_surface_write_to_png, NULL},
+ _cairo_boilerplate_image_create_surface,
+ cairo_surface_write_to_png },
#ifdef CAIRO_HAS_TEST_SURFACES
{ "test-fallback", CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_test_fallback_surface, cairo_surface_write_to_png, NULL },
+ _cairo_boilerplate_test_fallback_create_surface,
+ cairo_surface_write_to_png },
{ "test-fallback", CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
CAIRO_CONTENT_COLOR, 0,
- create_test_fallback_surface, cairo_surface_write_to_png, NULL },
+ _cairo_boilerplate_test_fallback_create_surface,
+ cairo_surface_write_to_png },
{ "test-meta", CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_test_meta_surface, cairo_surface_write_to_png, NULL },
+ _cairo_boilerplate_test_meta_create_surface,
+ cairo_surface_write_to_png },
{ "test-meta", CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
CAIRO_CONTENT_COLOR, 0,
- create_test_meta_surface, cairo_surface_write_to_png, NULL },
+ _cairo_boilerplate_test_meta_create_surface,
+ cairo_surface_write_to_png },
{ "test-paginated", CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_test_paginated_surface,
- test_paginated_write_to_png,
- cleanup_test_paginated },
+ _cairo_boilerplate_test_paginated_create_surface,
+ _cairo_boilerplate_test_paginated_surface_write_to_png,
+ _cairo_boilerplate_test_paginated_cleanup },
{ "test-paginated", CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
CAIRO_CONTENT_COLOR, 0,
- create_test_paginated_surface,
- test_paginated_write_to_png,
- cleanup_test_paginated },
+ _cairo_boilerplate_test_paginated_create_surface,
+ _cairo_boilerplate_test_paginated_surface_write_to_png,
+ _cairo_boilerplate_test_paginated_cleanup },
#endif
#ifdef CAIRO_HAS_GLITZ_SURFACE
#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_cairo_glitz_glx_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_glx },
+ _cairo_boilerplate_cairo_glitz_glx_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_glx_cleanup },
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- create_cairo_glitz_glx_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_glx },
+ _cairo_boilerplate_cairo_glitz_glx_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_glx_cleanup },
#endif
#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_cairo_glitz_agl_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_agl },
+ _cairo_boilerplate_cairo_glitz_agl_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_agl_cleanup },
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- create_cairo_glitz_agl_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_agl },
+ _cairo_boilerplate_cairo_glitz_agl_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_agl_cleanup },
#endif
#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_cairo_glitz_wgl_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_wgl },
+ _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_wgl_cleanup },
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR, 0,
- create_cairo_glitz_wgl_surface, cairo_surface_write_to_png,
- cleanup_cairo_glitz_wgl },
+ _cairo_boilerplate_cairo_glitz_wgl_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_cairo_glitz_wgl_cleanup },
#endif
#endif /* CAIRO_HAS_GLITZ_SURFACE */
#if CAIRO_HAS_QUARTZ_SURFACE
{ "quartz", CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_boilerplate_quartz_create_surface, cairo_surface_write_to_png,
+ _cairo_boilerplate_quartz_create_surface,
+ cairo_surface_write_to_png,
_cairo_boilerplate_quartz_cleanup },
{ "quartz", CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR, 0,
- _cairo_boilerplate_quartz_create_surface, cairo_surface_write_to_png,
+ _cairo_boilerplate_quartz_create_surface,
+ cairo_surface_write_to_png,
_cairo_boilerplate_quartz_cleanup },
#endif
#if CAIRO_HAS_WIN32_SURFACE
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
- create_win32_surface, cairo_surface_write_to_png, cleanup_win32 },
+ create_win32_surface,
+ cairo_surface_write_to_png,
+ cleanup_win32 },
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_win32_surface, cairo_surface_write_to_png, cleanup_win32 },
+ create_win32_surface,
+ cairo_surface_write_to_png,
+ cleanup_win32 },
#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", CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA, 1,
- create_xcb_surface, cairo_surface_write_to_png, cleanup_xcb,
- boilerplate_xcb_synchronize},
+ _cairo_boilerplate_xcb_create_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", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 1,
- _cairo_boilerplate_xlib_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_xlib_cleanup,
+ _cairo_boilerplate_xlib_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_xlib_cleanup,
_cairo_boilerplate_xlib_synchronize},
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
- _cairo_boilerplate_xlib_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_xlib_cleanup,
+ _cairo_boilerplate_xlib_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_xlib_cleanup,
_cairo_boilerplate_xlib_synchronize},
#endif
#if CAIRO_HAS_PS_SURFACE
{ "ps", CAIRO_SURFACE_TYPE_PS,
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
- create_ps_surface, ps_surface_write_to_png, cleanup_ps },
+ _cairo_boilerplate_ps_create_surface,
+ _cairo_boilerplate_ps_surface_write_to_png,
+ _cairo_boilerplate_ps_cleanup },
/* XXX: We expect type image here only due to a limitation in
* the current PS/meta-surface code. A PS surface is
* "naturally" COLOR_ALPHA, so the COLOR-only variant goes
- * through create_similar in create_ps_surface which results
+ * through create_similar in _cairo_boilerplate_ps_create_surface which results
* in the similar surface being used as a source. We do not yet
* have source support for PS/meta-surfaces, so the
* create_similar path for all paginated surfaces currently
* returns an image surface.*/
{ "ps", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0,
- create_ps_surface, ps_surface_write_to_png, cleanup_ps },
+ _cairo_boilerplate_ps_create_surface,
+ _cairo_boilerplate_ps_surface_write_to_png,
+ _cairo_boilerplate_ps_cleanup },
#endif
#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
{ "pdf", CAIRO_SURFACE_TYPE_PDF,
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,
- create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
+ _cairo_boilerplate_pdf_create_surface,
+ _cairo_boilerplate_pdf_surface_write_to_png,
+ _cairo_boilerplate_pdf_cleanup },
/* XXX: We expect type image here only due to a limitation in
* the current PDF/meta-surface code. A PDF surface is
* "naturally" COLOR_ALPHA, so the COLOR-only variant goes
- * through create_similar in create_pdf_surface which results
+ * through create_similar in _cairo_boilerplate_pdf_create_surface which results
* in the similar surface being used as a source. We do not yet
* have source support for PDF/meta-surfaces, so the
* create_similar path for all paginated surfaces currently
* returns an image surface.*/
{ "pdf", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR, 0,
- create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
+ _cairo_boilerplate_pdf_create_surface,
+ _cairo_boilerplate_pdf_surface_write_to_png,
+ _cairo_boilerplate_pdf_cleanup },
#endif
#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
/* It seems we should be able to round-trip SVG content perfrectly
@@ -1326,28 +1360,42 @@ static cairo_boilerplate_target_t target
* tests. XXX: I'd still like to chase these down at some point.
* For now just set the svg error tolerance to 1. */
{ "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA, 1,
- create_svg_surface, svg_surface_write_to_png, cleanup_svg },
+ _cairo_boilerplate_svg_create_surface,
+ _cairo_boilerplate_svg_surface_write_to_png,
+ _cairo_boilerplate_svg_cleanup },
{ "svg", CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 1,
- create_svg_surface, svg_surface_write_to_png, cleanup_svg },
+ _cairo_boilerplate_svg_create_surface,
+ _cairo_boilerplate_svg_surface_write_to_png,
+ _cairo_boilerplate_svg_cleanup },
#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", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
- _cairo_boilerplate_beos_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup},
+ _cairo_boilerplate_beos_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_beos_cleanup},
{ "beos-bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
- _cairo_boilerplate_beos_create_surface_for_bitmap, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup_bitmap},
+ _cairo_boilerplate_beos_create_surface_for_bitmap,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_beos_cleanup_bitmap},
{ "beos-bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1,
- _cairo_boilerplate_beos_create_surface_for_bitmap, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup_bitmap},
+ _cairo_boilerplate_beos_create_surface_for_bitmap,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_beos_cleanup_bitmap},
#endif
#if CAIRO_HAS_DIRECTFB_SURFACE
{ "directfb", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
- _cairo_boilerplate_directfb_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_directfb_cleanup},
+ _cairo_boilerplate_directfb_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_directfb_cleanup},
{ "directfb-bitmap", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_boilerplate_directfb_create_surface, cairo_surface_write_to_png,_cairo_boilerplate_directfb_cleanup},
+ _cairo_boilerplate_directfb_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_directfb_cleanup},
#endif
};
diff-tree 9b660a3d54940c68eb48f2afeca7e87e1d2bffa6 (from d945f6434643ac35f0e86352cfe3ccf021f568de)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 19:56:05 2007 -0400
[boilerplate] Strip xlib boilerplate into cairo-boilerplate-xlib*
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index f82b2e6..2f02a26 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -24,6 +24,11 @@ libcairoboilerplate_la_SOURCES += cairo-
libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
+if CAIRO_HAS_XLIB_XRENDER_SURFACE
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-xlib-private.h
+endif
+
if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
libcairoboilerplate_la_LIBADD += $(GLITZ_AGL_LIBS)
endif
diff --git a/boilerplate/cairo-boilerplate-xlib-private.h b/boilerplate/cairo-boilerplate-xlib-private.h
new file mode 100644
index 0000000..9757827
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xlib-private.h
@@ -0,0 +1,44 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_XLIB_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_XLIB_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_xlib_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ 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
new file mode 100644
index 0000000..de3746c
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -0,0 +1,196 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-xlib-private.h"
+
+#include <cairo-xlib-xrender.h>
+
+typedef struct _xlib_target_closure
+{
+ Display *dpy;
+ Drawable drawable;
+ cairo_bool_t drawable_is_pixmap;
+} xlib_target_closure_t;
+
+void
+_cairo_boilerplate_xlib_synchronize (void *closure)
+{
+ xlib_target_closure_t *xtc = closure;
+ XImage *ximage;
+
+ ximage = XGetImage (xtc->dpy, xtc->drawable,
+ 0, 0, 1, 1, AllPlanes, ZPixmap);
+ if (ximage != NULL)
+ XDestroyImage (ximage);
+}
+
+/* For the xlib backend we distinguish between TEST and PERF mode in a
+ * couple of ways.
+ *
+ * For TEST, we always test against pixmaps of depth 32 (for
+ * COLOR_ALPHA) or 24 (for COLOR) and we use XSynchronize to make it
+ * easier to debug problems.
+ *
+ * For PERF, we test against 32-bit pixmaps for COLOR_ALPHA, but for
+ * COLOR we test against _windows_ at the depth of the default visual.
+ * For obvious reasons, we don't use XSynchronize.
+ */
+static cairo_surface_t *
+create_xlib_test_surface (Display *dpy,
+ cairo_content_t content,
+ int width,
+ int height,
+ xlib_target_closure_t *xtc)
+{
+ XRenderPictFormat *xrender_format;
+
+ /* This kills performance, but it makes debugging much
+ * easier. That's why we have it here when in TEST mode, but not
+ * over in PERF mode. */
+ XSynchronize (xtc->dpy, 1);
+
+ /* XXX: Currently we don't do any xlib testing when the X server
+ * doesn't have the Render extension. We could do better here,
+ * (perhaps by converting the tests from ARGB32 to RGB24). One
+ * step better would be to always test the non-Render fallbacks
+ * for each test even if the server does have the Render
+ * extension. That would probably be through another
+ * cairo_boilerplate_target which would use an extended version of
+ * cairo_test_xlib_disable_render. */
+ switch (content) {
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ break;
+ case CAIRO_CONTENT_COLOR:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
+ break;
+ case CAIRO_CONTENT_ALPHA:
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
+ return NULL;
+ }
+ if (xrender_format == NULL) {
+ CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+ return NULL;
+ }
+
+ xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
+ width, height, xrender_format->depth);
+ xtc->drawable_is_pixmap = TRUE;
+
+ return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
+ DefaultScreenOfDisplay (dpy),
+ xrender_format,
+ width, height);
+}
+
+static cairo_surface_t *
+create_xlib_perf_surface (Display *dpy,
+ cairo_content_t content,
+ int width,
+ int height,
+ xlib_target_closure_t *xtc)
+{
+ XSetWindowAttributes attr;
+ XRenderPictFormat *xrender_format;
+ Visual *visual;
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR_ALPHA:
+ xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
+ xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
+ width, height, xrender_format->depth);
+ xtc->drawable_is_pixmap = TRUE;
+ break;
+ case CAIRO_CONTENT_COLOR:
+ visual = DefaultVisual (dpy, DefaultScreen (dpy));
+ xrender_format = XRenderFindVisualFormat (dpy, visual);
+ attr.override_redirect = True;
+ xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
+ width, height, 0, xrender_format->depth,
+ InputOutput, visual, CWOverrideRedirect, &attr);
+ XMapWindow (dpy, xtc->drawable);
+ xtc->drawable_is_pixmap = FALSE;
+ break;
+ case CAIRO_CONTENT_ALPHA:
+ default:
+ CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
+ return NULL;
+ }
+ if (xrender_format == NULL) {
+ CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+ return NULL;
+ }
+
+ return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
+ DefaultScreenOfDisplay (dpy),
+ xrender_format,
+ width, height);
+}
+
+cairo_surface_t *
+_cairo_boilerplate_xlib_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ xlib_target_closure_t *xtc;
+ Display *dpy;
+
+ *closure = xtc = xmalloc (sizeof (xlib_target_closure_t));
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ xtc->dpy = dpy = XOpenDisplay (NULL);
+ if (xtc->dpy == NULL) {
+ CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+ return NULL;
+ }
+
+ if (mode == CAIRO_BOILERPLATE_MODE_TEST)
+ return create_xlib_test_surface (dpy, content, width, height, xtc);
+ else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
+ return create_xlib_perf_surface (dpy, content, width, height, xtc);
+}
+
+void
+_cairo_boilerplate_xlib_cleanup (void *closure)
+{
+ xlib_target_closure_t *xtc = closure;
+
+ if (xtc->drawable_is_pixmap)
+ XFreePixmap (xtc->dpy, xtc->drawable);
+ else
+ XDestroyWindow (xtc->dpy, xtc->drawable);
+ XCloseDisplay (xtc->dpy);
+ free (xtc);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 66febfb..3e5f0dd 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -53,6 +53,9 @@
#if CAIRO_HAS_QUARTZ_SURFACE
#include "cairo-boilerplate-quartz-private.h"
#endif
+#if CAIRO_HAS_XLIB_XRENDER_SURFACE
+#include "cairo-boilerplate-xlib-private.h"
+#endif
/* This is copied from cairoint.h. That makes it painful to keep in
* sync, but the slim stuff makes cairoint.h "hard" to include when
@@ -860,175 +863,6 @@ cleanup_xcb (void *closure)
}
#endif
-#if CAIRO_HAS_XLIB_SURFACE
-#include "cairo-xlib-xrender.h"
-typedef struct _xlib_target_closure
-{
- Display *dpy;
- Drawable drawable;
- cairo_bool_t drawable_is_pixmap;
-} xlib_target_closure_t;
-
-static void
-boilerplate_xlib_synchronize (void *closure)
-{
- xlib_target_closure_t *xtc = closure;
- XImage *ximage;
-
- ximage = XGetImage (xtc->dpy, xtc->drawable,
- 0, 0, 1, 1, AllPlanes, ZPixmap);
- if (ximage != NULL)
- XDestroyImage (ximage);
-}
-
-/* For the xlib backend we distinguish between TEST and PERF mode in a
- * couple of ways.
- *
- * For TEST, we always test against pixmaps of depth 32 (for
- * COLOR_ALPHA) or 24 (for COLOR) and we use XSynchronize to make it
- * easier to debug problems.
- *
- * For PERF, we test against 32-bit pixmaps for COLOR_ALPHA, but for
- * COLOR we test against _windows_ at the depth of the default visual.
- * For obvious reasons, we don't use XSynchronize.
- */
-static cairo_surface_t *
-create_xlib_test_surface (Display *dpy,
- cairo_content_t content,
- int width,
- int height,
- xlib_target_closure_t *xtc)
-{
- XRenderPictFormat *xrender_format;
-
- /* This kills performance, but it makes debugging much
- * easier. That's why we have it here when in TEST mode, but not
- * over in PERF mode. */
- XSynchronize (xtc->dpy, 1);
-
- /* XXX: Currently we don't do any xlib testing when the X server
- * doesn't have the Render extension. We could do better here,
- * (perhaps by converting the tests from ARGB32 to RGB24). One
- * step better would be to always test the non-Render fallbacks
- * for each test even if the server does have the Render
- * extension. That would probably be through another
- * cairo_boilerplate_target which would use an extended version of
- * cairo_test_xlib_disable_render. */
- switch (content) {
- case CAIRO_CONTENT_COLOR_ALPHA:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
- break;
- case CAIRO_CONTENT_COLOR:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardRGB24);
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
- return NULL;
- }
- if (xrender_format == NULL) {
- CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
- return NULL;
- }
-
- xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
- width, height, xrender_format->depth);
- xtc->drawable_is_pixmap = TRUE;
-
- return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
- DefaultScreenOfDisplay (dpy),
- xrender_format,
- width, height);
-}
-
-static cairo_surface_t *
-create_xlib_perf_surface (Display *dpy,
- cairo_content_t content,
- int width,
- int height,
- xlib_target_closure_t *xtc)
-{
- XSetWindowAttributes attr;
- XRenderPictFormat *xrender_format;
- Visual *visual;
-
- switch (content) {
- case CAIRO_CONTENT_COLOR_ALPHA:
- xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
- xtc->drawable = XCreatePixmap (dpy, DefaultRootWindow (dpy),
- width, height, xrender_format->depth);
- xtc->drawable_is_pixmap = TRUE;
- break;
- case CAIRO_CONTENT_COLOR:
- visual = DefaultVisual (dpy, DefaultScreen (dpy));
- xrender_format = XRenderFindVisualFormat (dpy, visual);
- attr.override_redirect = True;
- xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
- width, height, 0, xrender_format->depth,
- InputOutput, visual, CWOverrideRedirect, &attr);
- XMapWindow (dpy, xtc->drawable);
- xtc->drawable_is_pixmap = FALSE;
- break;
- case CAIRO_CONTENT_ALPHA:
- default:
- CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
- return NULL;
- }
- if (xrender_format == NULL) {
- CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
- return NULL;
- }
-
- return cairo_xlib_surface_create_with_xrender_format (dpy, xtc->drawable,
- DefaultScreenOfDisplay (dpy),
- xrender_format,
- width, height);
-}
-
-static cairo_surface_t *
-create_xlib_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- xlib_target_closure_t *xtc;
- Display *dpy;
-
- *closure = xtc = xmalloc (sizeof (xlib_target_closure_t));
-
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- xtc->dpy = dpy = XOpenDisplay (NULL);
- if (xtc->dpy == NULL) {
- CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
- return NULL;
- }
-
- if (mode == CAIRO_BOILERPLATE_MODE_TEST)
- return create_xlib_test_surface (dpy, content, width, height, xtc);
- else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
- return create_xlib_perf_surface (dpy, content, width, height, xtc);
-}
-
-static void
-cleanup_xlib (void *closure)
-{
- xlib_target_closure_t *xtc = closure;
-
- if (xtc->drawable_is_pixmap)
- XFreePixmap (xtc->dpy, xtc->drawable);
- else
- XDestroyWindow (xtc->dpy, xtc->drawable);
- XCloseDisplay (xtc->dpy);
- free (xtc);
-}
-#endif
-
#if CAIRO_HAS_PS_SURFACE
#include "cairo-ps.h"
@@ -1443,15 +1277,15 @@ static cairo_boilerplate_target_t target
create_xcb_surface, cairo_surface_write_to_png, cleanup_xcb,
boilerplate_xcb_synchronize},
#endif
-#if CAIRO_HAS_XLIB_SURFACE
+#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", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA, 1,
- create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib,
- boilerplate_xlib_synchronize},
+ _cairo_boilerplate_xlib_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_xlib_cleanup,
+ _cairo_boilerplate_xlib_synchronize},
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
- create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib,
- boilerplate_xlib_synchronize},
+ _cairo_boilerplate_xlib_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_xlib_cleanup,
+ _cairo_boilerplate_xlib_synchronize},
#endif
#if CAIRO_HAS_PS_SURFACE
{ "ps", CAIRO_SURFACE_TYPE_PS,
@@ -1508,6 +1342,7 @@ static cairo_boilerplate_target_t target
_cairo_boilerplate_beos_create_surface_for_bitmap, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup_bitmap},
#endif
+
#if CAIRO_HAS_DIRECTFB_SURFACE
{ "directfb", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
_cairo_boilerplate_directfb_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_directfb_cleanup},
diff-tree d945f6434643ac35f0e86352cfe3ccf021f568de (from 0130cca6924f5c0969ca285585c68a458301a882)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 19:44:57 2007 -0400
[boilerplate] Move includes around
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 85e69c0..66febfb 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -26,10 +26,6 @@
#include "cairo-boilerplate.h"
-#if CAIRO_HAS_QUARTZ_SURFACE
-#include "cairo-boilerplate-quartz-private.h"
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -48,6 +44,16 @@
#include <fontconfig/fontconfig.h>
#endif
+#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_QUARTZ_SURFACE
+#include "cairo-boilerplate-quartz-private.h"
+#endif
+
/* This is copied from cairoint.h. That makes it painful to keep in
* sync, but the slim stuff makes cairoint.h "hard" to include when
* not actually building the cairo library itself. Fortunately, since
@@ -1023,15 +1029,6 @@ cleanup_xlib (void *closure)
}
#endif
-#if CAIRO_HAS_BEOS_SURFACE
-/* BeOS test functions are external as they need to be C++ */
-#include "cairo-boilerplate-beos-private.h"
-#endif
-
-#if CAIRO_HAS_DIRECTFB_SURFACE
-#include "cairo-boilerplate-directfb-private.h"
-#endif
-
#if CAIRO_HAS_PS_SURFACE
#include "cairo-ps.h"
diff-tree 0130cca6924f5c0969ca285585c68a458301a882 (from fb2c0daa09af083278024c3da6f7e9e3f851984f)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 19:39:58 2007 -0400
[boilerplate] Rename test-directfb to boilerplate-directfb
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 09d1f1f..f82b2e6 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -20,7 +20,8 @@ libcairoboilerplate_la_CXXFLAGS = -Wno-m
endif
if CAIRO_HAS_DIRECTFB_SURFACE
-libcairoboilerplate_la_SOURCES += cairo-test-directfb.c cairo-test-directfb.h
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-directfb-private.h
endif
if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
diff --git a/boilerplate/cairo-boilerplate-directfb-private.h b/boilerplate/cairo-boilerplate-directfb-private.h
new file mode 100644
index 0000000..c8c936d
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-directfb-private.h
@@ -0,0 +1,23 @@
+#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,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ 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
new file mode 100644
index 0000000..07fe17c
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-directfb.c
@@ -0,0 +1,143 @@
+/*
+Test were run with the following script
+target can be directfb_bitmap or directfb
+
+export CAIRO_TEST_TARGET=directfb_bitmap
+export DFBARGS=quiet,no-banner,no-debug,log-file=dfblog,system=x11
+cd cairo/test
+make check
+
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "cairo-boilerplate.h"
+#include <directfb.h>
+#include "cairo-directfb.h"
+#include "cairo-boilerplate-directfb-private.h"
+
+/* macro for a safe call to DirectFB functions */
+#define DFBCHECK(x...) \
+{ \
+ err = x; \
+ if (err != DFB_OK) { \
+ fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
+ DirectFBErrorFatal( #x, err ); \
+ } \
+}
+
+typedef struct _DFBInfo {
+ IDirectFB *dfb;
+ IDirectFBDisplayLayer *layer;
+ IDirectFBWindow *window;
+ IDirectFBSurface *surface;
+} DFBInfo ;
+
+static DFBInfo *init(void) {
+ DFBDisplayLayerConfig layer_config;
+ DFBGraphicsDeviceDescription desc;
+ int err;
+ DFBInfo *info = calloc(1,sizeof(DFBInfo));
+ if( !info )
+ return NULL;
+
+ DFBCHECK(DirectFBInit( NULL,NULL));
+ DFBCHECK(DirectFBCreate( &info->dfb ));
+ info->dfb->GetDeviceDescription(info->dfb, &desc );
+
+ DFBCHECK(info->dfb->GetDisplayLayer( info->dfb, DLID_PRIMARY, &info->layer ));
+ info->layer->SetCooperativeLevel( info->layer, DLSCL_ADMINISTRATIVE );
+
+ if (!((desc.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
+ (desc.blitting_flags & DSBLIT_BLEND_COLORALPHA )))
+ {
+ layer_config.flags = DLCONF_BUFFERMODE;
+ layer_config.buffermode = DLBM_BACKSYSTEM;
+ info->layer->SetConfiguration( info->layer, &layer_config );
+ }
+ return info;
+}
+
+static cairo_surface_t *
+create_directfb_window_surface (DFBInfo *info,
+ cairo_content_t content,
+ int width,
+ int height) {
+ DFBWindowDescription desc;
+ int err;
+ desc.flags = ( DWDESC_POSX | DWDESC_POSY |
+ DWDESC_WIDTH | DWDESC_HEIGHT /*| DWDESC_CAPS|DSDESC_PIXELFORMAT*/ );
+ desc.posx = 0;
+ desc.posy = 0;
+ desc.width = width;
+ desc.height = height;
+#if 0 /*Test using native format by default*/
+ desc.caps = DWCAPS_DOUBLEBUFFER;
+ desc.caps |= DWCAPS_ALPHACHANNEL;
+ desc.pixelformat = DSPF_ARGB;
+#endif
+
+ DFBCHECK(info->layer->CreateWindow( info->layer, &desc, &info->window ) );
+ info->window->SetOpacity( info->window, 0xFF );
+ info->window->GetSurface( info->window, &info->surface );
+ info->surface->SetColor( info->surface, 0xFF, 0xFF, 0xFF, 0xFF );
+ info->surface->FillRectangle( info->surface,0, 0, desc.width, desc.height );
+ info->surface->Flip( info->surface, NULL, 0 );
+ return cairo_directfb_surface_create(info->dfb,info->surface);
+}
+
+static cairo_surface_t *
+create_directfb_bitmap_surface (DFBInfo *info,
+ cairo_content_t content,
+ int width,
+ int height) {
+ int err;
+ DFBSurfaceDescription desc;
+
+ desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
+ desc.caps = DSCAPS_NONE;
+ desc.width = width;
+ desc.height = height;
+ desc.pixelformat = DSPF_ARGB;
+ DFBCHECK(info->dfb->CreateSurface (info->dfb, &desc,&info->surface));
+ return cairo_directfb_surface_create(info->dfb,info->surface);
+}
+
+void
+_cairo_boilerplate_directfb_cleanup (void* closure) {
+ DFBInfo *info = (DFBInfo *)closure;
+ if( info->surface )
+ info->surface->Release( info->surface );
+ if( info->window )
+ info->window->Release( info->window );
+ if( info->layer )
+ info->layer->Release( info->layer );
+ if( info->dfb )
+ info->dfb->Release( info->dfb );
+}
+
+cairo_surface_t *
+_cairo_boilerplate_directfb_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure) {
+
+ DFBInfo* info= init();
+ *closure = info;
+ if( !info ) {
+ CAIRO_BOILERPLATE_LOG ("Failed to init directfb:\n");
+ return NULL;
+ }
+
+ if (width == 0)
+ width = 1;
+ if (height == 0)
+ height = 1;
+
+ if (mode == CAIRO_BOILERPLATE_MODE_TEST)
+ return create_directfb_bitmap_surface (info, content, width, height);
+ else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
+ return create_directfb_window_surface (info, content, width, height);
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 76c7073..85e69c0 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -1029,7 +1029,7 @@ cleanup_xlib (void *closure)
#endif
#if CAIRO_HAS_DIRECTFB_SURFACE
-#include "cairo-test-directfb.h"
+#include "cairo-boilerplate-directfb-private.h"
#endif
#if CAIRO_HAS_PS_SURFACE
@@ -1513,9 +1513,9 @@ static cairo_boilerplate_target_t target
#if CAIRO_HAS_DIRECTFB_SURFACE
{ "directfb", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR, 0,
- create_directfb_surface, cairo_surface_write_to_png, cleanup_directfb},
+ _cairo_boilerplate_directfb_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_directfb_cleanup},
{ "directfb-bitmap", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA, 0,
- create_directfb_surface, cairo_surface_write_to_png,cleanup_directfb},
+ _cairo_boilerplate_directfb_create_surface, cairo_surface_write_to_png,_cairo_boilerplate_directfb_cleanup},
#endif
};
diff --git a/boilerplate/cairo-test-directfb.c b/boilerplate/cairo-test-directfb.c
deleted file mode 100644
index 3d216b3..0000000
--- a/boilerplate/cairo-test-directfb.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-Test were run with the following script
-target can be directfb_bitmap or directfb
-
-export CAIRO_TEST_TARGET=directfb_bitmap
-export DFBARGS=quiet,no-banner,no-debug,log-file=dfblog,system=x11
-cd cairo/test
-make check
-
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "cairo-boilerplate.h"
-#include <directfb.h>
-#include "cairo-directfb.h"
-#include "cairo-test-directfb.h"
-
-/* macro for a safe call to DirectFB functions */
-#define DFBCHECK(x...) \
-{ \
- err = x; \
- if (err != DFB_OK) { \
- fprintf( stderr, "%s <%d>:\n\t", __FILE__, __LINE__ ); \
- DirectFBErrorFatal( #x, err ); \
- } \
-}
-
-typedef struct _DFBInfo {
- IDirectFB *dfb;
- IDirectFBDisplayLayer *layer;
- IDirectFBWindow *window;
- IDirectFBSurface *surface;
-} DFBInfo ;
-
-static DFBInfo *init(void) {
- DFBDisplayLayerConfig layer_config;
- DFBGraphicsDeviceDescription desc;
- int err;
- DFBInfo *info = calloc(1,sizeof(DFBInfo));
- if( !info )
- return NULL;
-
- DFBCHECK(DirectFBInit( NULL,NULL));
- DFBCHECK(DirectFBCreate( &info->dfb ));
- info->dfb->GetDeviceDescription(info->dfb, &desc );
-
- DFBCHECK(info->dfb->GetDisplayLayer( info->dfb, DLID_PRIMARY, &info->layer ));
- info->layer->SetCooperativeLevel( info->layer, DLSCL_ADMINISTRATIVE );
-
- if (!((desc.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
- (desc.blitting_flags & DSBLIT_BLEND_COLORALPHA )))
- {
- layer_config.flags = DLCONF_BUFFERMODE;
- layer_config.buffermode = DLBM_BACKSYSTEM;
- info->layer->SetConfiguration( info->layer, &layer_config );
- }
- return info;
-}
-
-static cairo_surface_t *
-create_directfb_window_surface (DFBInfo *info,
- cairo_content_t content,
- int width,
- int height) {
- DFBWindowDescription desc;
- int err;
- desc.flags = ( DWDESC_POSX | DWDESC_POSY |
- DWDESC_WIDTH | DWDESC_HEIGHT /*| DWDESC_CAPS|DSDESC_PIXELFORMAT*/ );
- desc.posx = 0;
- desc.posy = 0;
- desc.width = width;
- desc.height = height;
-#if 0 /*Test using native format by default*/
- desc.caps = DWCAPS_DOUBLEBUFFER;
- desc.caps |= DWCAPS_ALPHACHANNEL;
- desc.pixelformat = DSPF_ARGB;
-#endif
-
- DFBCHECK(info->layer->CreateWindow( info->layer, &desc, &info->window ) );
- info->window->SetOpacity( info->window, 0xFF );
- info->window->GetSurface( info->window, &info->surface );
- info->surface->SetColor( info->surface, 0xFF, 0xFF, 0xFF, 0xFF );
- info->surface->FillRectangle( info->surface,0, 0, desc.width, desc.height );
- info->surface->Flip( info->surface, NULL, 0 );
- return cairo_directfb_surface_create(info->dfb,info->surface);
-}
-
-static cairo_surface_t *
-create_directfb_bitmap_surface (DFBInfo *info,
- cairo_content_t content,
- int width,
- int height) {
- int err;
- DFBSurfaceDescription desc;
-
- desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT;
- desc.caps = DSCAPS_NONE;
- desc.width = width;
- desc.height = height;
- desc.pixelformat = DSPF_ARGB;
- DFBCHECK(info->dfb->CreateSurface (info->dfb, &desc,&info->surface));
- return cairo_directfb_surface_create(info->dfb,info->surface);
-}
-
-void
-cleanup_directfb (void* closure) {
- DFBInfo *info = (DFBInfo *)closure;
- if( info->surface )
- info->surface->Release( info->surface );
- if( info->window )
- info->window->Release( info->window );
- if( info->layer )
- info->layer->Release( info->layer );
- if( info->dfb )
- info->dfb->Release( info->dfb );
-}
-
-cairo_surface_t *
-create_directfb_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure) {
-
- DFBInfo* info= init();
- *closure = info;
- if( !info ) {
- CAIRO_BOILERPLATE_LOG ("Failed to init directfb:\n");
- return NULL;
- }
-
- if (width == 0)
- width = 1;
- if (height == 0)
- height = 1;
-
- if (mode == CAIRO_BOILERPLATE_MODE_TEST)
- return create_directfb_bitmap_surface (info, content, width, height);
- else /* mode == CAIRO_BOILERPLATE_MODE_PERF */
- return create_directfb_window_surface (info, content, width, height);
-}
diff --git a/boilerplate/cairo-test-directfb.h b/boilerplate/cairo-test-directfb.h
deleted file mode 100644
index 7b92ad3..0000000
--- a/boilerplate/cairo-test-directfb.h
+++ /dev/null
@@ -1,23 +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 void
-cleanup_directfb (void* closure);
-
-extern cairo_surface_t *
-create_directfb_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure);
-
-CAIRO_END_DECLS
-
-#endif
diff-tree fb2c0daa09af083278024c3da6f7e9e3f851984f (from 01760286b388870e5bebf3851b4bef1350d89852)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 19:38:20 2007 -0400
[boilerplate] Rename test-beos to boilerplate-beos
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index f097d9e..09d1f1f 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -13,7 +13,8 @@ libcairoboilerplate_la_SOURCES += cairo-
endif
if CAIRO_HAS_BEOS_SURFACE
-libcairoboilerplate_la_SOURCES += cairo-test-beos.cpp cairo-test-beos.h
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos-private.h
# BeOS system headers trigger this warning
libcairoboilerplate_la_CXXFLAGS = -Wno-multichar
endif
diff --git a/boilerplate/cairo-boilerplate-beos-private.h b/boilerplate/cairo-boilerplate-beos-private.h
new file mode 100644
index 0000000..b572353
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-beos-private.h
@@ -0,0 +1,34 @@
+#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,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ 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,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ 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
new file mode 100644
index 0000000..2ebe297
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -0,0 +1,258 @@
+/* vim:set ts=8 sw=4 noet cin: */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.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/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Communications Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Takashi Toyoshima <toyoshim at be-in.org>
+ * Fredrik Holmqvist <thesuckiestemail at yahoo.se>
+ * Christian Biesinger <cbiesinger at web.de>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+// Part of this code was originally part of
+// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
+
+#include <Application.h>
+#include <Window.h>
+#include <View.h>
+#include <Bitmap.h>
+
+// BeOS's C++ compiler does not support varargs in macros
+// So, define CAIRO_BOILERPLATE_LOG here
+#define CAIRO_BOILERPLATE_LOG cairo_beos_boilerplate_log
+
+extern "C" {
+#include "cairo-boilerplate.h"
+}
+
+#include "cairo-boilerplate-beos-private.h"
+#include "cairo-beos.h"
+
+static int cairo_beos_boilerplate_log(const char* format, ...) {
+ va_list args;
+ int rv;
+ va_start(args, format);
+ rv = vfprintf(stderr, format, args);
+ va_end(args);
+ return rv;
+}
+
+class CairoTestWindow : public BWindow
+{
+public:
+ CairoTestWindow(BRect frame, const char* title);
+ virtual ~CairoTestWindow();
+ BView* View() const { return mView; }
+private:
+ BView* mView;
+};
+
+CairoTestWindow::CairoTestWindow(BRect frame, const char* title)
+ : BWindow(frame, title, B_TITLED_WINDOW,
+ B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
+{
+ mView = new BView(frame, "CairoWindowTestView", B_FOLLOW_ALL_SIDES, 0);
+ AddChild(mView);
+ Show();
+
+ // Make sure the window is actually on screen
+ Lock();
+ Sync();
+ mView->SetViewColor(B_TRANSPARENT_COLOR);
+ mView->Sync();
+ Unlock();
+}
+
+CairoTestWindow::~CairoTestWindow()
+{
+ RemoveChild(mView);
+ delete mView;
+}
+
+
+class nsBeOSApp : public BApplication
+{
+public:
+ nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem)
+ {}
+
+ void ReadyToRun()
+ {
+ release_sem(init);
+ }
+
+ static int32 Main(void *args)
+ {
+ nsBeOSApp *app = new nsBeOSApp( (sem_id)args );
+ if(app == NULL)
+ return B_ERROR;
+ return app->Run();
+ }
+
+private:
+
+ const char *GetAppSig()
+ {
+ return "application/x-vnd.cairo-test-app";
+ }
+
+ sem_id init;
+}; //class nsBeOSApp
+
+class AppRunner
+{
+ public:
+ AppRunner();
+ ~AppRunner();
+};
+
+AppRunner::AppRunner()
+{
+ if (be_app)
+ return;
+
+ sem_id initsem = create_sem(0, "Cairo BApplication init");
+ if (initsem < B_OK) {
+ CAIRO_BOILERPLATE_LOG("Error creating BeOS initialization semaphore\n");
+ return;
+ }
+
+ thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem);
+ if (tid < B_OK || B_OK != resume_thread(tid)) {
+ CAIRO_BOILERPLATE_LOG("Error spawning thread\n");
+ return;
+ }
+
+ if (B_OK != acquire_sem(initsem)) {
+ CAIRO_BOILERPLATE_LOG("Error acquiring semaphore\n");
+ return;
+ }
+
+ delete_sem(initsem);
+ return;
+}
+
+AppRunner::~AppRunner()
+{
+ if (be_app) {
+ if (be_app->Lock())
+ be_app->Quit();
+ delete be_app;
+ be_app = NULL;
+ }
+}
+
+// Make sure that the BApplication is initialized
+static AppRunner sAppRunner;
+
+struct beos_boilerplate_closure
+{
+ BView* view;
+ BBitmap* bitmap;
+ BWindow* window;
+};
+
+// Test a real window
+cairo_surface_t *
+_cairo_boilerplate_beos_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ float right = width ? width - 1 : 0;
+ float bottom = height ? height - 1 : 0;
+ BRect rect(0.0, 0.0, right, bottom);
+ CairoTestWindow* wnd = new CairoTestWindow(rect, name);
+
+ beos_boilerplate_closure* bclosure = new beos_boilerplate_closure;
+ bclosure->view = wnd->View();
+ bclosure->bitmap = NULL;
+ bclosure->window = wnd;
+
+ *closure = bclosure;
+
+ return cairo_beos_surface_create(wnd->View());
+}
+
+void
+_cairo_boilerplate_beos_cleanup (void* closure)
+{
+ beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
+
+ bclosure->window->Lock();
+ bclosure->window->Quit();
+
+ delete bclosure;
+}
+
+// Test a bitmap
+cairo_surface_t *
+_cairo_boilerplate_beos_create_surface_for_bitmap (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ BRect rect(0.0, 0.0, width - 1, height - 1);
+ color_space beosformat = (content == CAIRO_CONTENT_COLOR_ALPHA) ? B_RGBA32
+ : B_RGB32;
+ BBitmap* bmp = new BBitmap(rect, beosformat, true);
+ BView* view = new BView(rect, "Cairo test view", B_FOLLOW_ALL_SIDES, 0);
+ bmp->AddChild(view);
+
+ beos_boilerplate_closure* bclosure = new beos_boilerplate_closure;
+ bclosure->view = view;
+ bclosure->bitmap = bmp;
+ bclosure->window = NULL;
+ *closure = bclosure;
+
+ return cairo_beos_surface_create_for_bitmap(view, bmp);
+}
+
+void
+_cairo_boilerplate_beos_cleanup_bitmap (void* closure)
+{
+ beos_boilerplate_closure* bclosure = reinterpret_cast<beos_boilerplate_closure*>(closure);
+
+ bclosure->bitmap->RemoveChild(bclosure->view);
+
+
+ delete bclosure->view;
+ delete bclosure->bitmap;
+
+ delete bclosure;
+}
+
+
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 79912b3..76c7073 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -1025,7 +1025,7 @@ cleanup_xlib (void *closure)
#if CAIRO_HAS_BEOS_SURFACE
/* BeOS test functions are external as they need to be C++ */
-#include "cairo-test-beos.h"
+#include "cairo-boilerplate-beos-private.h"
#endif
#if CAIRO_HAS_DIRECTFB_SURFACE
@@ -1504,11 +1504,11 @@ static cairo_boilerplate_target_t target
* is related to the fact that it doesn't use premultiplied alpha...
* Just ignore the small difference. */
{ "beos", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
- create_beos_surface, cairo_surface_write_to_png, cleanup_beos},
+ _cairo_boilerplate_beos_create_surface, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup},
{ "beos-bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR, 1,
- create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
+ _cairo_boilerplate_beos_create_surface_for_bitmap, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup_bitmap},
{ "beos-bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA, 1,
- create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
+ _cairo_boilerplate_beos_create_surface_for_bitmap, cairo_surface_write_to_png, _cairo_boilerplate_beos_cleanup_bitmap},
#endif
#if CAIRO_HAS_DIRECTFB_SURFACE
diff --git a/boilerplate/cairo-test-beos.cpp b/boilerplate/cairo-test-beos.cpp
deleted file mode 100644
index 78831e8..0000000
--- a/boilerplate/cairo-test-beos.cpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/* vim:set ts=8 sw=4 noet cin: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.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/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator client code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Takashi Toyoshima <toyoshim at be-in.org>
- * Fredrik Holmqvist <thesuckiestemail at yahoo.se>
- * Christian Biesinger <cbiesinger at web.de>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Part of this code was originally part of
-// xpfe/bootstrap/nsNativeAppSupportBeOS.cpp in the Mozilla source code.
-
-#include <Application.h>
-#include <Window.h>
-#include <View.h>
-#include <Bitmap.h>
-
-// BeOS's C++ compiler does not support varargs in macros
-// So, define CAIRO_BOILERPLATE_LOG here
-#define CAIRO_BOILERPLATE_LOG cairo_beos_boilerplate_log
-
-extern "C" {
-#include "cairo-boilerplate.h"
-}
-
-#include "cairo-test-beos.h"
-#include "cairo-beos.h"
-
-static int cairo_beos_boilerplate_log(const char* format, ...) {
- va_list args;
- int rv;
- va_start(args, format);
- rv = vfprintf(stderr, format, args);
- va_end(args);
- return rv;
-}
-
-class CairoTestWindow : public BWindow
-{
-public:
- CairoTestWindow(BRect frame, const char* title);
- virtual ~CairoTestWindow();
- BView* View() const { return mView; }
-private:
- BView* mView;
-};
-
-CairoTestWindow::CairoTestWindow(BRect frame, const char* title)
- : BWindow(frame, title, B_TITLED_WINDOW,
- B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
-{
- mView = new BView(frame, "CairoWindowTestView", B_FOLLOW_ALL_SIDES, 0);
- AddChild(mView);
- Show();
-
- // Make sure the window is actually on screen
- Lock();
- Sync();
- mView->SetViewColor(B_TRANSPARENT_COLOR);
- mView->Sync();
- Unlock();
-}
-
-CairoTestWindow::~CairoTestWindow()
-{
- RemoveChild(mView);
- delete mView;
-}
-
-
-class nsBeOSApp : public BApplication
-{
-public:
- nsBeOSApp(sem_id sem) : BApplication(GetAppSig()), init(sem)
- {}
-
- void ReadyToRun()
- {
- release_sem(init);
- }
-
- static int32 Main(void *args)
- {
- nsBeOSApp *app = new nsBeOSApp( (sem_id)args );
- if(app == NULL)
- return B_ERROR;
- return app->Run();
- }
-
-private:
-
- const char *GetAppSig()
- {
- return "application/x-vnd.cairo-test-app";
- }
-
- sem_id init;
-}; //class nsBeOSApp
-
-class AppRunner
-{
- public:
- AppRunner();
- ~AppRunner();
-};
-
-AppRunner::AppRunner()
-{
- if (be_app)
- return;
-
- sem_id initsem = create_sem(0, "Cairo BApplication init");
- if (initsem < B_OK) {
- CAIRO_BOILERPLATE_LOG("Error creating BeOS initialization semaphore\n");
- return;
- }
-
- thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem);
- if (tid < B_OK || B_OK != resume_thread(tid)) {
- CAIRO_BOILERPLATE_LOG("Error spawning thread\n");
- return;
- }
-
- if (B_OK != acquire_sem(initsem)) {
- CAIRO_BOILERPLATE_LOG("Error acquiring semaphore\n");
- return;
- }
-
- delete_sem(initsem);
- return;
-}
-
-AppRunner::~AppRunner()
-{
- if (be_app) {
- if (be_app->Lock())
- be_app->Quit();
- delete be_app;
- be_app = NULL;
- }
-}
-
-// Make sure that the BApplication is initialized
-static AppRunner sAppRunner;
-
-struct beos_test_closure
-{
- BView* view;
- BBitmap* bitmap;
- BWindow* window;
-};
-
-// Test a real window
-cairo_surface_t *
-create_beos_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- float right = width ? width - 1 : 0;
- float bottom = height ? height - 1 : 0;
- BRect rect(0.0, 0.0, right, bottom);
- CairoTestWindow* wnd = new CairoTestWindow(rect, name);
-
- beos_test_closure* bclosure = new beos_test_closure;
- bclosure->view = wnd->View();
- bclosure->bitmap = NULL;
- bclosure->window = wnd;
-
- *closure = bclosure;
-
- return cairo_beos_surface_create(wnd->View());
-}
-
-void
-cleanup_beos (void* closure)
-{
- beos_test_closure* bclosure = reinterpret_cast<beos_test_closure*>(closure);
-
- bclosure->window->Lock();
- bclosure->window->Quit();
-
- delete bclosure;
-}
-
-// Test a bitmap
-cairo_surface_t *
-create_beos_bitmap_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- BRect rect(0.0, 0.0, width - 1, height - 1);
- color_space beosformat = (content == CAIRO_CONTENT_COLOR_ALPHA) ? B_RGBA32
- : B_RGB32;
- BBitmap* bmp = new BBitmap(rect, beosformat, true);
- BView* view = new BView(rect, "Cairo test view", B_FOLLOW_ALL_SIDES, 0);
- bmp->AddChild(view);
-
- beos_test_closure* bclosure = new beos_test_closure;
- bclosure->view = view;
- bclosure->bitmap = bmp;
- bclosure->window = NULL;
- *closure = bclosure;
-
- return cairo_beos_surface_create_for_bitmap(view, bmp);
-}
-
-void
-cleanup_beos_bitmap (void* closure)
-{
- beos_test_closure* bclosure = reinterpret_cast<beos_test_closure*>(closure);
-
- bclosure->bitmap->RemoveChild(bclosure->view);
-
-
- delete bclosure->view;
- delete bclosure->bitmap;
-
- delete bclosure;
-}
-
-
diff --git a/boilerplate/cairo-test-beos.h b/boilerplate/cairo-test-beos.h
deleted file mode 100644
index 1e562cc..0000000
--- a/boilerplate/cairo-test-beos.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef CAIRO_TEST_BEOS_H_
-#define CAIRO_TEST_BEOS_H_
-
-/* Two functions: One for a real window, one for a bitmap */
-
-#include <cairo.h>
-
-CAIRO_BEGIN_DECLS
-
-extern cairo_surface_t *
-create_beos_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure);
-
-extern void
-cleanup_beos (void* closure);
-
-extern cairo_surface_t *
-create_beos_bitmap_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure);
-
-extern void
-cleanup_beos_bitmap (void* closure);
-
-CAIRO_END_DECLS
-
-#endif
diff-tree 01760286b388870e5bebf3851b4bef1350d89852 (from d64ef355217db7a555da0029187d19c80ec12609)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Apr 19 19:32:52 2007 -0400
[boilerplate] Rename quartz-boilerplate to boilerplate-quartz
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 429fff4..f097d9e 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -8,8 +8,8 @@ xmalloc.h
libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LDADD)
if CAIRO_HAS_QUARTZ_SURFACE
-libcairoboilerplate_la_SOURCES += cairo-quartz-boilerplate.c
-libcairoboilerplate_la_SOURCES += cairo-quartz-boilerplate-private.h
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz.c
+libcairoboilerplate_la_SOURCES += cairo-boilerplate-quartz-private.h
endif
if CAIRO_HAS_BEOS_SURFACE
diff --git a/boilerplate/cairo-boilerplate-quartz-private.h b/boilerplate/cairo-boilerplate-quartz-private.h
new file mode 100644
index 0000000..808342f
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-quartz-private.h
@@ -0,0 +1,41 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_BOILERPLATE_QUARTZ_PRIVATE_H_
+#define _CAIRO_BOILERPLATE_QUARTZ_PRIVATE_H_
+
+cairo_surface_t *
+_cairo_boilerplate_quartz_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure);
+
+void
+_cairo_boilerplate_quartz_cleanup (void *closure);
+
+#endif
diff --git a/boilerplate/cairo-boilerplate-quartz.c b/boilerplate/cairo-boilerplate-quartz.c
new file mode 100644
index 0000000..ccfd79f
--- /dev/null
+++ b/boilerplate/cairo-boilerplate-quartz.c
@@ -0,0 +1,60 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright © 2004,2007 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-boilerplate.h"
+#include "cairo-boilerplate-quartz-private.h"
+
+#include <cairo-quartz.h>
+
+cairo_surface_t *
+_cairo_boilerplate_quartz_create_surface (const char *name,
+ cairo_content_t content,
+ int width,
+ int height,
+ cairo_boilerplate_mode_t mode,
+ void **closure)
+{
+ cairo_format_t format;
+
+ switch (content) {
+ case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
+ case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
+ case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
+ default:
+ assert (0); /* not reached */
+ return NULL;
+ }
+
+ *closure = NULL;
+
+ return cairo_quartz_surface_create (format, width, height);
+}
+
+void
+_cairo_boilerplate_quartz_cleanup (void *closure)
+{
+ /* nothing */
+}
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 8c73916..79912b3 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -27,7 +27,7 @@
#include "cairo-boilerplate.h"
#if CAIRO_HAS_QUARTZ_SURFACE
-#include "cairo-quartz-boilerplate-private.h"
+#include "cairo-boilerplate-quartz-private.h"
#endif
#include <stdio.h>
@@ -1427,11 +1427,11 @@ static cairo_boilerplate_target_t target
#endif /* CAIRO_HAS_GLITZ_SURFACE */
#if CAIRO_HAS_QUARTZ_SURFACE
{ "quartz", CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR_ALPHA, 0,
- _cairo_quartz_boilerplate_create_surface, cairo_surface_write_to_png,
- _cairo_quartz_boilerplate_cleanup },
+ _cairo_boilerplate_quartz_create_surface, cairo_surface_write_to_png,
+ _cairo_boilerplate_quartz_cleanup },
{ "quartz", CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR, 0,
- _cairo_quartz_boilerplate_create_surface, cairo_surface_write_to_png,
- _cairo_quartz_boilerplate_cleanup },
+ _cairo_boilerplate_quartz_create_surface, cairo_surface_write_to_png,
+ _cairo_boilerplate_quartz_cleanup },
#endif
#if CAIRO_HAS_WIN32_SURFACE
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR, 0,
diff --git a/boilerplate/cairo-quartz-boilerplate-private.h b/boilerplate/cairo-quartz-boilerplate-private.h
deleted file mode 100644
index ef5ea2c..0000000
--- a/boilerplate/cairo-quartz-boilerplate-private.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/*
- * Copyright © 2004,2007 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth at cworth.org>
- */
-
-#ifndef _CAIRO_QUARTZ_BOILERPLATE_PRIVATE_H_
-#define _CAIRO_QUARTZ_BOILERPLATE_PRIVATE_H_
-
-cairo_surface_t *
-_cairo_quartz_boilerplate_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure);
-
-void
-_cairo_quartz_boilerplate_cleanup (void *closure);
-
-#endif
diff --git a/boilerplate/cairo-quartz-boilerplate.c b/boilerplate/cairo-quartz-boilerplate.c
deleted file mode 100644
index 369b2da..0000000
--- a/boilerplate/cairo-quartz-boilerplate.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
-/*
- * Copyright © 2004,2007 Red Hat, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Red Hat, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Red Hat, Inc. makes no representations about the
- * suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
- * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Carl D. Worth <cworth at cworth.org>
- */
-
-#include "cairo-boilerplate.h"
-#include "cairo-quartz-boilerplate-private.h"
-
-#include <cairo-quartz.h>
-
-cairo_surface_t *
-_cairo_quartz_boilerplate_create_surface (const char *name,
- cairo_content_t content,
- int width,
- int height,
- cairo_boilerplate_mode_t mode,
- void **closure)
-{
- cairo_format_t format;
-
- switch (content) {
- case CAIRO_CONTENT_COLOR: format = CAIRO_FORMAT_RGB24; break;
- case CAIRO_CONTENT_COLOR_ALPHA: format = CAIRO_FORMAT_ARGB32; break;
- case CAIRO_CONTENT_ALPHA: format = CAIRO_FORMAT_A8; break;
- default:
- assert (0); /* not reached */
- return NULL;
- }
-
- *closure = NULL;
-
- return cairo_quartz_surface_create (format, width, height);
-}
-
-void
-_cairo_quartz_boilerplate_cleanup (void *closure)
-{
- /* nothing */
-}
More information about the cairo-commit
mailing list