summaryrefslogtreecommitdiff
path: root/boilerplate
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2007-08-20 14:50:02 -0700
committerCarl Worth <cworth@cworth.org>2007-08-21 16:46:40 -0700
commitd05593a5fb9fef586171cb9973a9942a105d50d7 (patch)
treef2c5f4b983f0a34a923f365cac1780bc6a95d624 /boilerplate
parent590717f03b4a396600734c4dac1dd0a9f140283c (diff)
Add a new xlib-fallback target to test xlib using image fallbacks instead of the Render extension
Diffstat (limited to 'boilerplate')
-rw-r--r--boilerplate/cairo-boilerplate-xlib-private.h8
-rw-r--r--boilerplate/cairo-boilerplate-xlib.c72
-rw-r--r--boilerplate/cairo-boilerplate.c9
3 files changed, 89 insertions, 0 deletions
diff --git a/boilerplate/cairo-boilerplate-xlib-private.h b/boilerplate/cairo-boilerplate-xlib-private.h
index 80826d5ae..65da94762 100644
--- a/boilerplate/cairo-boilerplate-xlib-private.h
+++ b/boilerplate/cairo-boilerplate-xlib-private.h
@@ -35,6 +35,14 @@ _cairo_boilerplate_xlib_create_surface (const char *name,
cairo_boilerplate_mode_t mode,
void **closure);
+cairo_surface_t *
+_cairo_boilerplate_xlib_fallback_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);
diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index bfdc7d082..f95869f8c 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -192,6 +192,78 @@ _cairo_boilerplate_xlib_create_surface (const char *name,
return _cairo_boilerplate_xlib_perf_create_surface (dpy, content, width, height, xtc);
}
+/* The xlib-fallback target differs from the xlib target in two ways:
+ *
+ * 1. It creates its surfaces without relying on the Render extension
+ *
+ * 2. It disables use of the Render extension for its surfaces
+ *
+ * This provides testing of the non-Render fallback paths we have in
+ * cairo-xlib-surface.c
+ */
+cairo_surface_t *
+_cairo_boilerplate_xlib_fallback_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;
+ int screen;
+ XSetWindowAttributes attr;
+ cairo_surface_t *surface;
+
+ /* We're not yet bothering to support perf mode for the
+ * xlib-fallback surface. */
+ if (mode == CAIRO_BOILERPLATE_MODE_PERF)
+ return NULL;
+
+ /* We also don't support drawing with destination-alpha in the
+ * xlib-fallback surface. */
+ if (content == CAIRO_CONTENT_COLOR_ALPHA)
+ return NULL;
+
+ *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;
+ }
+
+ /* This kills performance, but it makes debugging much
+ * easier. That's why we have it here only after explicitly not
+ * supporting PERF mode.*/
+ XSynchronize (dpy, 1);
+
+ screen = DefaultScreen (dpy);
+ attr.override_redirect = True;
+ xtc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy),
+ 0, 0,
+ width, height, 0,
+ DefaultDepth (dpy, screen),
+ InputOutput,
+ DefaultVisual (dpy, screen),
+ CWOverrideRedirect, &attr);
+ XMapWindow (dpy, xtc->drawable);
+ xtc->drawable_is_pixmap = FALSE;
+
+ surface = cairo_xlib_surface_create (dpy, xtc->drawable,
+ DefaultVisual (dpy, screen),
+ width, height);
+
+ cairo_boilerplate_xlib_surface_disable_render (surface);
+
+ return surface;
+}
+
void
_cairo_boilerplate_xlib_cleanup (void *closure)
{
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 7a0f7e8e3..792dee455 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -261,6 +261,15 @@ static cairo_boilerplate_target_t targets[] =
_cairo_boilerplate_xlib_cleanup,
_cairo_boilerplate_xlib_synchronize},
#endif
+#if CAIRO_HAS_XLIB_SURFACE
+ /* This is a fallback surface which uses xlib fallbacks instead of
+ * the Render extension. */
+ { "xlib-fallback", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR, 1,
+ _cairo_boilerplate_xlib_fallback_create_surface,
+ cairo_surface_write_to_png,
+ _cairo_boilerplate_xlib_cleanup,
+ _cairo_boilerplate_xlib_synchronize},
+#endif
#if CAIRO_HAS_PS_SURFACE && CAIRO_CAN_TEST_PS_SURFACE
{ "ps", CAIRO_SURFACE_TYPE_PS,
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED, 0,