[cairo-commit] 2 commits - boilerplate/cairo-boilerplate.c boilerplate/cairo-boilerplate-xlib.c boilerplate/cairo-boilerplate-xlib-private.h src/cairo-xlib-display.c test/fill-rule.c

Carl Worth cworth at kemper.freedesktop.org
Tue Aug 21 17:15:06 PDT 2007


 boilerplate/cairo-boilerplate-xlib-private.h |    8 +++
 boilerplate/cairo-boilerplate-xlib.c         |   72 +++++++++++++++++++++++++++
 boilerplate/cairo-boilerplate.c              |    9 +++
 src/cairo-xlib-display.c                     |    9 +++
 test/fill-rule.c                             |    2 
 5 files changed, 99 insertions(+), 1 deletion(-)

New commits:
diff-tree 9f4e6436496fe561aa124bb2b89e1c6711684d98 (from d05593a5fb9fef586171cb9973a9942a105d50d7)
Author: Carl Worth <cworth at cworth.org>
Date:   Tue Aug 21 10:03:00 2007 -0700

    Ensure the Render extension is initialized before calling XESetCloseDisplay
    
    This avoids a potential crash from the Render extension being cleaned
    up during XCloseDisplay before the cairo CloseDisplay hook goes on to
    call into XRenderFreePicture.

diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c
index c7c3c43..b8f35cb 100644
--- a/src/cairo-xlib-display.c
+++ b/src/cairo-xlib-display.c
@@ -226,6 +226,7 @@ _cairo_xlib_display_get (Display *dpy)
     cairo_xlib_display_t *display;
     cairo_xlib_display_t **prev;
     XExtCodes *codes;
+    int major_unused, minor_unused;
 
     /* There is an apparent deadlock between this mutex and the
      * mutex for the display, but it's actually safe. For the
@@ -260,6 +261,14 @@ _cairo_xlib_display_get (Display *dpy)
     if (display == NULL)
 	goto UNLOCK;
 
+    /* Xlib calls out to the extension close_display hooks in LIFO
+     * order. So we have to ensure that all extensions that we depend
+     * on in our close_display hook are properly initialized before we
+     * add our hook. For now, that means Render, so we call into its
+     * QueryVersion function to ensure it gets initialized.
+     */
+    XRenderQueryVersion (dpy, &major_unused, &minor_unused);
+
     codes = XAddExtension (dpy);
     if (codes == NULL) {
 	free (display);
diff-tree d05593a5fb9fef586171cb9973a9942a105d50d7 (from 590717f03b4a396600734c4dac1dd0a9f140283c)
Author: Carl Worth <cworth at cworth.org>
Date:   Mon Aug 20 14:50:02 2007 -0700

    Add a new xlib-fallback target to test xlib using image fallbacks instead of the Render extension

diff --git a/boilerplate/cairo-boilerplate-xlib-private.h b/boilerplate/cairo-boilerplate-xlib-private.h
index 80826d5..65da947 100644
--- a/boilerplate/cairo-boilerplate-xlib-private.h
+++ b/boilerplate/cairo-boilerplate-xlib-private.h
@@ -35,6 +35,14 @@ _cairo_boilerplate_xlib_create_surface (
 					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 bfdc7d0..f95869f 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -192,6 +192,78 @@ _cairo_boilerplate_xlib_create_surface (
 	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 7a0f7e8..792dee4 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -261,6 +261,15 @@ static cairo_boilerplate_target_t target
       _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,
diff --git a/test/fill-rule.c b/test/fill-rule.c
index 6b186ef..a9ce295 100644
--- a/test/fill-rule.c
+++ b/test/fill-rule.c
@@ -70,7 +70,7 @@ static cairo_test_draw_function_t draw;
 
 cairo_test_t test = {
     "fill-rule",
-    "Tests cairo_set_full_rule with some star shapes",
+    "Tests cairo_set_fill_rule with some star shapes",
     BIG_STAR_SIZE * 2 + 3, BIG_STAR_SIZE + LITTLE_STAR_SIZE + 3,
     draw
 };


More information about the cairo-commit mailing list