[cairo-commit] 2 commits - perf/cairo-perf-compare-backends.c util/cairo-script

Chris Wilson ickle at kemper.freedesktop.org
Thu Jun 11 07:20:11 PDT 2009


 perf/cairo-perf-compare-backends.c         |   17 ++-----
 util/cairo-script/cairo-script-operators.c |   70 ++++++++++++++++++++++-------
 2 files changed, 61 insertions(+), 26 deletions(-)

New commits:
commit f7dbdf1fd1d7cc14491a9419c316b078247e145e
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 8 09:39:20 2009 +0100

    [script] Hide pixman-ops when copying pixels
    
    Seeing unexpected time inside pixman composite is quite disturbing when
    trying to track down the apparent slowness in some benchmarks. Remove one
    source of this artefact by simply memcpy'ing pixel data when trivial.

diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 5166665..f311805 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -2445,12 +2445,12 @@ _image_read_raw (csi_file_t *src,
 		    row[4*x + 3] = *--bp;
 		    row[4*x + 2] = *--bp;
 		    row[4*x + 1] = *--bp;
-		    row[4*x + 0] = 0;
+		    row[4*x + 0] = 0xff;
 #else
 		    row[4*x + 0] = *--bp;
 		    row[4*x + 1] = *--bp;
 		    row[4*x + 2] = *--bp;
-		    row[4*x + 3] = 0;
+		    row[4*x + 3] = 0xff;
 #endif
 		}
 		break;
@@ -2478,12 +2478,12 @@ _image_read_raw (csi_file_t *src,
 		data[4*x + 3] = *--bp;
 		data[4*x + 2] = *--bp;
 		data[4*x + 1] = *--bp;
-		data[4*x + 0] = 0;
+		data[4*x + 0] = 0xff;
 #else
 		data[4*x + 0] = *--bp;
 		data[4*x + 1] = *--bp;
 		data[4*x + 2] = *--bp;
-		data[4*x + 3] = 0;
+		data[4*x + 3] = 0xff;
 #endif
 	    }
 	    if (width > 1) {
@@ -2496,27 +2496,27 @@ _image_read_raw (csi_file_t *src,
 		rgb[0][1] = data[1];
 		rgb[0][2] = data[0];
 #ifdef WORDS_BIGENDIAN
-		data[4] = 0;
+		data[4] = 0xff;
 		data[5] = rgb[1][2];
 		data[6] = rgb[1][1];
 		data[7] = rgb[1][0];
-		data[0] = 0;
+		data[0] = 0xff;
 		data[1] = rgb[0][2];
 		data[2] = rgb[0][1];
 		data[3] = rgb[0][0];
 #else
-		data[7] = 0;
+		data[7] = 0xff;
 		data[6] = rgb[1][2];
 		data[5] = rgb[1][1];
 		data[4] = rgb[1][0];
-		data[3] = 0;
+		data[3] = 0xff;
 		data[2] = rgb[0][2];
 		data[1] = rgb[0][1];
 		data[0] = rgb[0][0];
 #endif
 	    } else {
 #ifdef WORDS_BIGENDIAN
-		data[0] = 0;
+		data[0] = 0xff;
 		data[1] = data[0];
 		data[2] = data[1];
 		data[3] = data[2];
@@ -2524,7 +2524,7 @@ _image_read_raw (csi_file_t *src,
 		data[3] = data[0];
 		data[0] = data[2];
 		data[2] = data[3];
-		data[3] = 0;
+		data[3] = 0xff;
 #endif
 	    }
 	    break;
@@ -4407,13 +4407,42 @@ _set_source (csi_t *ctx)
     return CSI_STATUS_SUCCESS;
 }
 
+static csi_boolean_t
+_matching_images (cairo_surface_t *a, cairo_surface_t *b)
+{
+    cairo_format_t format_a, format_b;
+
+    if (cairo_surface_get_type (a) != CAIRO_SURFACE_TYPE_IMAGE)
+	return FALSE;
+    if (cairo_surface_get_type (b) != CAIRO_SURFACE_TYPE_IMAGE)
+	return FALSE;
+
+    if (cairo_image_surface_get_height (a) != cairo_image_surface_get_height (b))
+	return FALSE;
+
+    if (cairo_image_surface_get_width (a) != cairo_image_surface_get_width (b))
+	return FALSE;
+
+    format_a = cairo_image_surface_get_format (a);
+    if (format_a == CAIRO_FORMAT_RGB24)
+	format_a = CAIRO_FORMAT_ARGB32;
+
+    format_b = cairo_image_surface_get_format (b);
+    if (format_b == CAIRO_FORMAT_RGB24)
+	format_b = CAIRO_FORMAT_ARGB32;
+
+    if (format_a != format_b)
+	return FALSE;
+
+    return TRUE;
+}
+
 static csi_status_t
 _set_source_image (csi_t *ctx)
 {
     csi_status_t status;
     cairo_surface_t *surface;
     cairo_surface_t *source;
-    cairo_t *cr;
 
     check (2);
 
@@ -4424,10 +4453,21 @@ _set_source_image (csi_t *ctx)
     if (_csi_unlikely (status))
 	return status;
 
-    cr = cairo_create (surface);
-    cairo_set_source_surface (cr, source, 0, 0);
-    cairo_paint (cr);
-    cairo_destroy (cr);
+    /* Catch the most frequent use of simply uploading pixel data,
+     * principally to remove the pixman ops from the profiles.
+     */
+    if (_csi_likely (_matching_images (surface, source))) {
+	memcpy (cairo_image_surface_get_data (surface),
+		cairo_image_surface_get_data (source),
+		cairo_image_surface_get_height (source) * cairo_image_surface_get_stride (source));
+    } else {
+	cairo_t *cr;
+
+	cr = cairo_create (surface);
+	cairo_set_source_surface (cr, source, 0, 0);
+	cairo_paint (cr);
+	cairo_destroy (cr);
+    }
 
     pop (1);
     return CSI_STATUS_SUCCESS;
commit ecee5663bf900ab97d2bb7ec41ade838f167e1cd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Jun 8 01:05:28 2009 +0100

    [perf] Fixup compare-backends to work with just a single test.

diff --git a/perf/cairo-perf-compare-backends.c b/perf/cairo-perf-compare-backends.c
index 8212849..1f737eb 100644
--- a/perf/cairo-perf-compare-backends.c
+++ b/perf/cairo-perf-compare-backends.c
@@ -41,7 +41,6 @@ typedef struct _cairo_perf_report_options {
     double min_change;
     int use_utf;
     int print_change_bars;
-    int use_ms;
 } cairo_perf_report_options_t;
 
 typedef struct _cairo_perf_diff_files_args {
@@ -132,8 +131,7 @@ test_diff_print (test_diff_t			*diff,
 
     for (i = 0; i < diff->num_tests; i++) {
 	test_time = diff->tests[i]->stats.min_ticks;
-	if (options->use_ms)
-	    test_time /= diff->tests[i]->stats.ticks_per_ms;
+	test_time /= diff->tests[i]->stats.ticks_per_ms;
 	change = diff->max / test_time;
 	printf ("%8s-%s-%s\t%6.2f: %5.2fx ",
 		diff->tests[i]->backend,
@@ -230,8 +228,7 @@ cairo_perf_reports_compare (cairo_perf_report_t		*reports,
 	    {
 		test_time = tests[i]->stats.min_ticks;
 		if (test_time > 0) {
-		    if (options->use_ms)
-			test_time /= tests[i]->stats.ticks_per_ms;
+		    test_time /= tests[i]->stats.ticks_per_ms;
 		    if (diff->num_tests == 0) {
 			diff->min = test_time;
 			diff->max = test_time;
@@ -251,7 +248,7 @@ cairo_perf_reports_compare (cairo_perf_report_t		*reports,
 	diff++;
 	num_diffs++;
     }
-    if (num_diffs < 2)
+    if (num_diffs == 0)
 	goto DONE;
 
     qsort (diffs, num_diffs, sizeof (test_diff_t), test_diff_cmp);
@@ -274,9 +271,9 @@ cairo_perf_reports_compare (cairo_perf_report_t		*reports,
 	test_diff_print (diff, max_change, options);
     }
 
- DONE:
     for (i = 0; i < num_diffs; i++)
 	free (diffs[i].tests);
+ DONE:
     free (diffs);
     free (tests);
 }
@@ -325,9 +322,6 @@ parse_args(int				  argc,
 	else if (strcmp (argv[i], "--no-bars") == 0) {
 	    args->options.print_change_bars = 0;
 	}
-	else if (strcmp (argv[i], "--use-ms") == 0) {
-	    args->options.use_ms = 1;
-	}
 	else if (strcmp (argv[i], "--min-change") == 0) {
 	    char *end = NULL;
 	    i++;
@@ -377,7 +371,8 @@ main (int argc, const char *argv[])
     for (i = 0; i < args.num_filenames; i++) {
 	cairo_perf_report_load (&reports[i], args.filenames[i],
 		                test_report_cmp_name);
-	printf ("loaded: %s\n", args.filenames[i]);
+	printf ("loaded: %s, %d tests\n",
+		args.filenames[i], reports[i].tests_count);
     }
 
     cairo_perf_reports_compare (reports, args.num_filenames, &args.options);


More information about the cairo-commit mailing list