[cairo-commit] 3 commits - boilerplate/cairo-boilerplate.c boilerplate/cairo-boilerplate.h boilerplate/cairo-boilerplate-xlib.c src/cairo-quartz-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Sat Jan 3 13:53:39 PST 2009


 boilerplate/cairo-boilerplate-xlib.c |   18 +++++++++---------
 boilerplate/cairo-boilerplate.c      |   11 +++++++++--
 boilerplate/cairo-boilerplate.h      |    4 ++++
 src/cairo-quartz-surface.c           |    5 +++++
 4 files changed, 27 insertions(+), 11 deletions(-)

New commits:
commit acb2717372f3862ddbde8cfdc814132808b71f86
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jan 3 21:50:55 2009 +0000

    [quartz] Define RTLD_DEFAULT
    
    RTLD_DEFAULT is a gnu-ism (at least according to the manpage on my linux
    system) so declare _GNU_SOURCE before including dlfcn.h and failing that
    provide our own definition.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 7ced686..9dae70f 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -34,12 +34,17 @@
  *	Vladimir Vukicevic <vladimir at mozilla.com>
  */
 
+#define _GNU_SOURCE /* required for RTLD_DEFAULT */
 #include "cairoint.h"
 
 #include "cairo-quartz-private.h"
 
 #include <dlfcn.h>
 
+#ifndef RTLD_DEFAULT
+#define RTLD_DEFAULT ((void *) 0)
+#endif
+
 /* The 10.5 SDK includes a funky new definition of FloatToFixed which
  * causes all sorts of breakage; so reset to old-style definition
  */
commit ff1f5de5511ba0b7842b53223c26986e4bcdc38a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jan 3 11:44:58 2009 +0000

    [boilerplate] Suppress xlib warnings on stderr
    
    If we cannot test the xlib backend simply because there is no Display,
    just report UNTESTED and do not clutter the output with superfluous
    warnings [see the output from the buildbots for an example]. However,
    keep the warnings around so that a developer can re-enable them
    and so simply move them to a new "lower priority" macro.

diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index 250b23f..e9642e5 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -108,11 +108,11 @@ _cairo_boilerplate_xlib_test_create_surface (Display			*dpy,
 	break;
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
+	CAIRO_BOILERPLATE_DEBUG ("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");
+	CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
 	return NULL;
     }
 
@@ -141,7 +141,7 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
     case CAIRO_CONTENT_COLOR_ALPHA:
 	xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
 	if (xrender_format == NULL) {
-	    CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+	    CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
 	    return NULL;
 	}
 
@@ -154,14 +154,14 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
 	if (! _cairo_boilerplate_xlib_check_screen_size (dpy,
 		                                         DefaultScreen (dpy),
 		                                         width, height)) {
-	    CAIRO_BOILERPLATE_LOG ("Surface is larger than the Screen.\n");
+	    CAIRO_BOILERPLATE_DEBUG ("Surface is larger than the Screen.\n");
 	    return NULL;
 	}
 
 	visual = DefaultVisual (dpy, DefaultScreen (dpy));
 	xrender_format = XRenderFindVisualFormat (dpy, visual);
 	if (xrender_format == NULL) {
-	    CAIRO_BOILERPLATE_LOG ("X server does not have the Render extension.\n");
+	    CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
 	    return NULL;
 	}
 
@@ -175,7 +175,7 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
 
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for xlib test: %d\n", content);
+	CAIRO_BOILERPLATE_DEBUG ("Invalid content for xlib test: %d\n", content);
 	return NULL;
     }
 
@@ -210,7 +210,7 @@ _cairo_boilerplate_xlib_create_surface (const char			 *name,
     xtc->dpy = dpy = XOpenDisplay (NULL);
     if (xtc->dpy == NULL) {
 	free (xtc);
-	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+	CAIRO_BOILERPLATE_DEBUG ("Failed to open display: %s\n", XDisplayName(0));
 	return NULL;
     }
 
@@ -272,7 +272,7 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
 
     xtc->dpy = dpy = XOpenDisplay (NULL);
     if (xtc->dpy == NULL) {
-	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+	CAIRO_BOILERPLATE_DEBUG ("Failed to open display: %s\n", XDisplayName(0));
 	free (xtc);
 	return NULL;
     }
@@ -285,7 +285,7 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
     screen = DefaultScreen (dpy);
     if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen,
 		                                     width, height)) {
-	CAIRO_BOILERPLATE_LOG ("Surface is larger than the Screen.\n");
+	CAIRO_BOILERPLATE_DEBUG ("Surface is larger than the Screen.\n");
 	XCloseDisplay (dpy);
 	free (xtc);
 	return NULL;
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 19b2957..b2d79a7 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -74,6 +74,10 @@
 #define CAIRO_BOILERPLATE_LOG(...) fprintf(stderr, __VA_ARGS__)
 #endif
 
+#ifndef CAIRO_BOILERPLATE_DEBUG
+#define CAIRO_BOILERPLATE_DEBUG(...)
+#endif
+
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
 #define CAIRO_BOILERPLATE_PRINTF_FORMAT(fmt_index, va_index) \
 	__attribute__((__format__(__printf__, fmt_index, va_index)))
commit 75538962c8af11b1ec669caca6259b7769b5cc1d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jan 2 17:45:26 2009 +0000

    [boilerplate] Check the return of pclose()
    
    pclose() returns the child exit status, so we can use that to detect
    errors in the convertor process.

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 1f06b19..91032cd 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -1031,6 +1031,7 @@ cairo_boilerplate_convert_to_image (const char *filename, int page)
     FILE *file;
     unsigned int flags = 0;
     cairo_surface_t *image;
+    int ret;
 
   RETRY:
     file = cairo_boilerplate_open_any2ppm (filename, page, flags);
@@ -1038,17 +1039,23 @@ cairo_boilerplate_convert_to_image (const char *filename, int page)
 	return cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR);
 
     image = cairo_boilerplate_image_surface_create_from_ppm_stream (file);
-    pclose (file);
+    ret = pclose (file);
 
     if (cairo_surface_status (image) == CAIRO_STATUS_READ_ERROR) {
 	if (flags == 0) {
-	    /* Try again in process, e.g. to propagate a CRASH. */
+	    /* Try again in a standalone process. */
 	    cairo_surface_destroy (image);
 	    flags = CAIRO_BOILERPLATE_OPEN_NO_DAEMON;
 	    goto RETRY;
 	}
     }
 
+    if (cairo_surface_status (image) == CAIRO_STATUS_SUCCESS && ret != 0) {
+	cairo_surface_destroy (image);
+	image =
+	    cairo_boilerplate_surface_create_in_error (CAIRO_STATUS_READ_ERROR);
+    };
+
     return image;
 }
 


More information about the cairo-commit mailing list