[cairo-commit] 3 commits - boilerplate/cairo-boilerplate-test-surfaces.c perf/cairo-perf.h perf/cairo-perf-trace.c src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 30 14:13:20 PDT 2009


 boilerplate/cairo-boilerplate-test-surfaces.c |   10 ++
 perf/cairo-perf-trace.c                       |  104 ++++++++++++++++----------
 perf/cairo-perf.h                             |    1 
 src/cairo-xlib-surface.c                      |   12 ---
 4 files changed, 78 insertions(+), 49 deletions(-)

New commits:
commit e5b4f78bff20903fef5f55a0fcd026590ea444a4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 30 22:12:50 2009 +0100

    [boilerplate] Only include null-test-surface >= cairo-1.9.3

diff --git a/boilerplate/cairo-boilerplate-test-surfaces.c b/boilerplate/cairo-boilerplate-test-surfaces.c
index 0fec393..255472c 100644
--- a/boilerplate/cairo-boilerplate-test-surfaces.c
+++ b/boilerplate/cairo-boilerplate-test-surfaces.c
@@ -24,14 +24,18 @@
  * Author: Carl D. Worth <cworth at cworth.org>
  */
 
+#include "../cairo-version.h"
+
 #include "cairo-boilerplate.h"
 #include "cairo-boilerplate-test-surfaces-private.h"
 
 #include <test-fallback-surface.h>
 #include <test-fallback16-surface.h>
 #include <test-meta-surface.h>
-#include <test-null-surface.h>
 #include <test-paginated-surface.h>
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,3)
+#include <test-null-surface.h>
+#endif
 
 #include <assert.h>
 
@@ -92,7 +96,11 @@ _cairo_boilerplate_test_null_create_surface (const char			 *name,
 					     void			**closure)
 {
     *closure = NULL;
+#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,3)
     return _cairo_test_null_surface_create (content);
+#else
+    return NULL;
+#endif
 }
 
 static const cairo_user_data_key_t test_paginated_closure_key;
commit e0bdbb437ee699d6f75df34494a6e290dc55aa39
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 30 22:04:01 2009 +0100

    [xlib] Remove redundant checks for src_picture==None
    
    Before attempting to even set the attributes on the source Picture, we
    ensure that it exists. So remove the redundant safe-guards to do nothing
    if it doesn't exist.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 99da0d5..54cfd63 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -834,8 +834,7 @@ _get_image_surface (cairo_xlib_surface_t    *surface,
 static void
 _cairo_xlib_surface_ensure_src_picture (cairo_xlib_surface_t    *surface)
 {
-    if (!surface->src_picture)
-    {
+    if (!surface->src_picture) {
 	XRenderPictureAttributes pa;
 	int mask = 0;
 
@@ -1361,9 +1360,6 @@ _cairo_xlib_surface_set_matrix (cairo_xlib_surface_t *surface,
 {
     XTransform xtransform;
 
-    if (!surface->src_picture)
-	return CAIRO_STATUS_SUCCESS;
-
     /* Casting between pixman_transform_t and XTransform is safe because
      * they happen to be the exact same type.
      */
@@ -1389,9 +1385,6 @@ _cairo_xlib_surface_set_filter (cairo_xlib_surface_t *surface,
 {
     const char *render_filter;
 
-    if (!surface->src_picture)
-	return CAIRO_STATUS_SUCCESS;
-
     if (surface->filter == filter)
 	return CAIRO_STATUS_SUCCESS;
 
@@ -1443,9 +1436,6 @@ _cairo_xlib_surface_set_repeat (cairo_xlib_surface_t *surface, int repeat)
     XRenderPictureAttributes pa;
     unsigned long	     mask;
 
-    if (!surface->src_picture)
-	return;
-
     if (surface->repeat == repeat)
 	return;
 
commit b7f68d3518e25fb02c9d36d14de9dc0c905ffe8f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 30 20:46:12 2009 +0100

    [perf] Enable trace directory recursion.
    
    I have an idea to categorise traces within their own subdirectories and so
    for convenience added path walking to cairo-perf-trace. Principally this
    should allow for forests of symlinks of all types.

diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 340601b..f3cff0a 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -46,6 +46,7 @@
 #include <ctype.h> /* isspace() */
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <dirent.h>
 
 #include <signal.h>
@@ -126,6 +127,9 @@ cairo_perf_can_run (cairo_perf_t	*perf,
     char *copy, *dot;
     cairo_bool_t ret;
 
+    if (perf->exact_names)
+	return TRUE;
+
     if (perf->num_names == 0 && perf->num_exclude_names == 0)
 	return TRUE;
 
@@ -635,12 +639,63 @@ warn_no_traces (const char *message, const char *trace_dir)
 	    message, trace_dir);
 }
 
+static int
+cairo_perf_trace_dir (cairo_perf_t *perf,
+		      const cairo_boilerplate_target_t *target,
+		      const char *dirname)
+{
+    DIR *dir;
+    struct dirent *de;
+    int num_traces = 0;
+
+    dir = opendir (dirname);
+    if (dir == NULL) {
+	fprintf (stderr, "Failed to open directory '%s'\n", dirname);
+	return 0;
+    }
+
+    while ((de = readdir (dir)) != NULL) {
+	char *trace;
+	struct stat st;
+
+	if (de->d_name[0] == '.')
+	    continue;
+
+	xasprintf (&trace, "%s/%s", dirname, de->d_name);
+	if (stat (trace, &st) != 0)
+	    goto next;
+
+	if (S_ISDIR(st.st_mode)) {
+	    num_traces += cairo_perf_trace_dir (perf, target, trace);
+	} else {
+	    const char *dot;
+
+	    dot = strrchr (de->d_name, '.');
+	    if (dot == NULL)
+		goto next;
+	    if (strcmp (dot, ".trace"))
+		goto next;
+
+	    num_traces++;
+	    if (! cairo_perf_can_run (perf, de->d_name))
+		goto next;
+
+	    cairo_perf_trace (perf, target, trace);
+	}
+next:
+	free (trace);
+
+    }
+    closedir (dir);
+
+    return num_traces;
+}
+
 int
 main (int argc, char *argv[])
 {
     cairo_perf_t perf;
     const char *trace_dir = "cairo-traces";
-    cairo_bool_t names_are_traces;
     unsigned int n;
     int i;
 
@@ -667,7 +722,7 @@ main (int argc, char *argv[])
     perf.times = xmalloc (perf.iterations * sizeof (cairo_perf_ticks_t));
 
     /* do we have a list of filenames? */
-    names_are_traces = have_trace_filenames (&perf);
+    perf.exact_names = have_trace_filenames (&perf);
 
     for (i = 0; i < perf.num_targets; i++) {
         const cairo_boilerplate_target_t *target = perf.targets[i];
@@ -678,44 +733,19 @@ main (int argc, char *argv[])
 	perf.target = target;
 	perf.test_number = 0;
 
-	if (names_are_traces) {
+	if (perf.exact_names) {
 	    for (n = 0; n < perf.num_names; n++) {
-		if (access (perf.names[n], R_OK) == 0)
-		    cairo_perf_trace (&perf, target, perf.names[n]);
-	    }
-	} else {
-	    DIR *dir;
-	    struct dirent *de;
-	    int num_traces = 0;
-
-	    dir = opendir (trace_dir);
-	    if (dir == NULL) {
-		warn_no_traces ("Failed to open directory", trace_dir);
-		return 1;
-	    }
-
-	    while ((de = readdir (dir)) != NULL) {
-		char *trace;
-		const char *dot;
-
-		dot = strrchr (de->d_name, '.');
-		if (dot == NULL)
-		    continue;
-		if (strcmp (dot, ".trace"))
-		    continue;
-
-		num_traces++;
-		if (! cairo_perf_can_run (&perf, de->d_name))
-		    continue;
-
-		xasprintf (&trace, "%s/%s", trace_dir, de->d_name);
-		cairo_perf_trace (&perf, target, trace);
-		free (trace);
+		struct stat st;
 
+		if (stat (perf.names[n], &st) == 0) {
+		    if (S_ISDIR (st.st_mode)) {
+			cairo_perf_trace_dir (&perf, target, perf.names[n]);
+		    } else
+			cairo_perf_trace (&perf, target, perf.names[n]);
+		}
 	    }
-	    closedir (dir);
-
-	    if (num_traces == 0) {
+	} else {
+	    if (cairo_perf_trace_dir (&perf, target, trace_dir) == 0) {
 		warn_no_traces ("Found no traces in", trace_dir);
 		return 1;
 	    }
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 8ea9149..b6c502c 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -81,6 +81,7 @@ typedef struct _cairo_perf {
     unsigned int num_names;
     char **exclude_names;
     unsigned int num_exclude_names;
+    cairo_bool_t exact_names;
 
     /* Stuff used internally */
     cairo_perf_ticks_t *times;


More information about the cairo-commit mailing list