[cairo-commit] 3 commits - perf/cairo-perf-compare-backends.c perf/cairo-perf-report.c src/cairo-bentley-ottmann-rectangular.c src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Sep 28 19:05:17 PDT 2009


 perf/cairo-perf-compare-backends.c      |   22 ++++++------
 perf/cairo-perf-report.c                |   29 ++++++++++------
 src/cairo-bentley-ottmann-rectangular.c |    2 +
 src/cairo-xlib-surface.c                |   57 ++++++++++++++++++++++++++++++++
 4 files changed, 90 insertions(+), 20 deletions(-)

New commits:
commit f8c49b4187a32b60408b23b2c2abce1778a8dc95
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 29 03:02:40 2009 +0100

    [xlib] XRequest bread crumbing
    
    Add bread crumbs in the form of NoOperations that can be parsed by
    xtrace and very useful when debugging protocol/server errors.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index fe87561..66311ea 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -69,6 +69,41 @@
 #define UNSUPPORTED(reason) CAIRO_INT_STATUS_UNSUPPORTED
 #endif
 
+#if DEBUG
+#include <X11/Xlibint.h>
+static void CAIRO_PRINTF_FORMAT (2, 3)
+_x_bread_crumb (Display *dpy,
+		const char *fmt,
+		...)
+{
+    xReq *req;
+    char buf[2048];
+    unsigned int len, len_dwords;
+    va_list ap;
+
+    va_start (ap, fmt);
+    len = vsnprintf (buf, sizeof (buf), fmt, ap);
+    va_end (ap);
+
+    buf[len++] = '\0';
+    while (len & 3)
+	buf[len++] = '\0';
+
+    LockDisplay (dpy);
+    GetEmptyReq (NoOperation, req);
+
+    len_dwords = len >> 2;
+    SetReqLen (req, len_dwords, len_dwords);
+    Data (dpy, buf, len);
+
+    UnlockDisplay (dpy);
+    SyncHandle ();
+}
+#define X_DEBUG(x) _x_bread_crumb x
+#else
+#define X_DEBUG
+#endif
+
 /* Xlib doesn't define a typedef, so define one ourselves */
 typedef int (*cairo_xlib_error_func_t) (Display     *display,
 					XErrorEvent *event);
@@ -336,6 +371,8 @@ _cairo_xlib_surface_finish (void *abstract_surface)
     cairo_xlib_display_t *display = surface->display;
     cairo_status_t        status  = CAIRO_STATUS_SUCCESS;
 
+    X_DEBUG ((surface->dpy, "finish (drawable=%x)", (unsigned int) surface->drawable));
+
     if (surface->owns_pixmap) {
 	cairo_status_t status2;
 
@@ -2121,6 +2158,8 @@ _cairo_xlib_surface_composite (cairo_operator_t		op,
     if (operation == DO_UNSUPPORTED)
 	return UNSUPPORTED ("unsupported operation");
 
+    X_DEBUG ((dst->dpy, "composite (dst=%x)", (unsigned int) dst->drawable));
+
     needs_alpha_composite =
 	_operator_needs_alpha_composite (op,
 					 _surface_has_alpha (dst),
@@ -2329,6 +2368,8 @@ _cairo_xlib_surface_solid_fill_rectangles (cairo_xlib_surface_t    *surface,
     if (unlikely (status))
         return status;
 
+    X_DEBUG ((surface->dpy, "solid_fill_rectangles (dst=%x)", (unsigned int) surface->drawable));
+
     status = _cairo_pattern_acquire_surface (&solid.base, &surface->base,
 					     CAIRO_CONTENT_COLOR_ALPHA,
 					     0, 0,
@@ -2392,6 +2433,8 @@ _cairo_xlib_surface_fill_rectangles (void		     *abstract_surface,
 	return UNSUPPORTED ("no support for FillRectangles with this op");
     }
 
+    X_DEBUG ((surface->dpy, "fill_rectangles (dst=%x)", (unsigned int) surface->drawable));
+
     render_color.red   = color->red_short;
     render_color.green = color->green_short;
     render_color.blue  = color->blue_short;
@@ -2515,6 +2558,8 @@ _cairo_xlib_surface_composite_trapezoids (cairo_operator_t	op,
     if (operation == DO_UNSUPPORTED)
 	return UNSUPPORTED ("unsupported operation");
 
+    X_DEBUG ((dst->dpy, "composite_trapezoids (dst=%x)", (unsigned int) dst->drawable));
+
     status = _cairo_xlib_surface_acquire_pattern_surface (dst,
 							  pattern,
 							  CAIRO_CONTENT_COLOR_ALPHA,
@@ -2783,6 +2828,8 @@ _cairo_xlib_surface_detach_display (cairo_xlib_display_t *display, void *data)
     dpy = surface->dpy;
     surface->dpy = NULL;
 
+    X_DEBUG ((dpy, "detach (drawable=%x)", (unsigned int) surface->drawable));
+
     if (surface->dst_picture != None) {
 	XRenderFreePicture (dpy, surface->dst_picture);
 	surface->dst_picture = None;
@@ -3032,6 +3079,8 @@ cairo_xlib_surface_create (Display     *dpy,
     if (unlikely (status))
 	return _cairo_surface_create_in_error (status);
 
+    X_DEBUG ((dpy, "create (drawable=%x)", (unsigned int) drawable));
+
     surface = _cairo_xlib_surface_create_internal (screen, drawable,
 						   visual, NULL,
 						   width, height, 0);
@@ -3072,6 +3121,8 @@ cairo_xlib_surface_create_for_bitmap (Display  *dpy,
     if (unlikely (status))
 	return _cairo_surface_create_in_error (status);
 
+    X_DEBUG ((dpy, "create_for_bitmap (drawable=%x)", (unsigned int) bitmap));
+
     surface = _cairo_xlib_surface_create_internal (screen, bitmap,
 						   NULL, NULL,
 						   width, height, 1);
@@ -3120,6 +3171,8 @@ cairo_xlib_surface_create_with_xrender_format (Display		    *dpy,
     if (unlikely (status))
 	return _cairo_surface_create_in_error (status);
 
+    X_DEBUG ((dpy, "create_with_xrender_format (drawable=%x)", (unsigned int) drawable));
+
     surface = _cairo_xlib_surface_create_internal (screen, drawable,
 						   NULL, format,
 						   width, height, 0);
@@ -3238,6 +3291,8 @@ cairo_xlib_surface_set_drawable (cairo_surface_t   *abstract_surface,
 	return;
 
     if (surface->drawable != drawable) {
+	X_DEBUG ((surface->dpy, "set_drawable (drawable=%x)", (unsigned int) drawable));
+
 	if (surface->dst_picture != None) {
 	    status = _cairo_xlib_display_queue_resource (
 		                                  surface->display,
@@ -4358,6 +4413,8 @@ _cairo_xlib_surface_show_glyphs (void                *abstract_dst,
     if (! _cairo_xlib_surface_owns_font (dst, scaled_font))
 	return UNSUPPORTED ("unowned font");
 
+    X_DEBUG ((dst->dpy, "show_glyphs (dst=%x)", (unsigned int) dst->drawable));
+
     if (clip_region != NULL &&
 	cairo_region_num_rectangles (clip_region) == 1)
     {
commit 1c4f61ec5068a5935eb6d5dd1d6f2c0275b70529
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 29 03:01:37 2009 +0100

    [tessellator] Invalid conversion of list head to edge.
    
    When scanning for collinear right edges, we need to check that we do not
    go beyond the end of the array.

diff --git a/src/cairo-bentley-ottmann-rectangular.c b/src/cairo-bentley-ottmann-rectangular.c
index 53faba6..9887b82 100644
--- a/src/cairo-bentley-ottmann-rectangular.c
+++ b/src/cairo-bentley-ottmann-rectangular.c
@@ -380,6 +380,8 @@ _active_edges_to_traps (cairo_bo_sweep_line_t	*sweep,
 			break;
 		    }
 
+		    if (right->link.next == &sweep->sweep)
+			break;
 		    right = link_to_edge (right->link.next);
 		}
 	    }
commit f23ae97e307f00a79cbf2e01f9ca20da29ea87c3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Sep 24 16:30:57 2009 +0100

    [perf] Support parsing reports from stdin

diff --git a/perf/cairo-perf-compare-backends.c b/perf/cairo-perf-compare-backends.c
index 1448169..277536e 100644
--- a/perf/cairo-perf-compare-backends.c
+++ b/perf/cairo-perf-compare-backends.c
@@ -363,16 +363,18 @@ main (int argc, const char *argv[])
 
     parse_args (argc, argv, &args);
 
-    if (args.num_filenames < 1)
-	usage (argv[0]);
-
-    reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
-
-    for (i = 0; i < args.num_filenames; i++) {
-	cairo_perf_report_load (&reports[i], args.filenames[i],
-		                test_report_cmp_name);
-	printf ("loaded: %s, %d tests\n",
-		args.filenames[i], reports[i].tests_count);
+    if (args.num_filenames) {
+	reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
+	for (i = 0; i < args.num_filenames; i++) {
+	    cairo_perf_report_load (&reports[i], args.filenames[i],
+				    test_report_cmp_name);
+	    printf ("loaded: %s, %d tests\n",
+		    args.filenames[i], reports[i].tests_count);
+	}
+    } else {
+	args.num_filenames = 1;
+	reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
+	cairo_perf_report_load (&reports[0], NULL, test_report_cmp_name);
     }
 
     cairo_perf_reports_compare (reports, args.num_filenames, &args.options);
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c
index 1690e62..2029a88 100644
--- a/perf/cairo-perf-report.c
+++ b/perf/cairo-perf-report.c
@@ -437,9 +437,14 @@ cairo_perf_report_load (cairo_perf_report_t *report,
     char *configuration;
     char *dot;
     char *baseName;
+    const char *name;
 
-    configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
-    strcpy (configuration, filename);
+    name = filename;
+    if (name == NULL)
+	name = "stdin";
+
+    configuration = xmalloc (strlen (name) * sizeof (char) + 1);
+    strcpy (configuration, name);
     baseName = basename (configuration);
     report->configuration = xmalloc (strlen (baseName) * sizeof (char) + 1);
     strcpy (report->configuration, baseName);
@@ -449,16 +454,20 @@ cairo_perf_report_load (cairo_perf_report_t *report,
     if (dot)
 	*dot = '\0';
 
-    report->name = filename;
+    report->name = name;
     report->tests_size = 16;
     report->tests = xmalloc (report->tests_size * sizeof (test_report_t));
     report->tests_count = 0;
 
-    file = fopen (filename, "r");
-    if (file == NULL) {
-	fprintf (stderr, "Failed to open %s: %s\n",
-		 filename, strerror (errno));
-	exit (1);
+    if (filename == NULL) {
+	file = stdin;
+    } else {
+	file = fopen (filename, "r");
+	if (file == NULL) {
+	    fprintf (stderr, "Failed to open %s: %s\n",
+		     filename, strerror (errno));
+	    exit (1);
+	}
     }
 
     while (1) {
@@ -485,7 +494,8 @@ cairo_perf_report_load (cairo_perf_report_t *report,
     if (line)
 	free (line);
 
-    fclose (file);
+    if (filename != NULL)
+	fclose (file);
 
     cairo_perf_report_sort_and_compute_stats (report, cmp);
 
@@ -497,4 +507,3 @@ cairo_perf_report_load (cairo_perf_report_t *report,
     }
     report->tests[report->tests_count].name = NULL;
 }
-


More information about the cairo-commit mailing list