[cairo-commit] 3 commits - src/cairo-surface-observer.c

Chris Wilson ickle at kemper.freedesktop.org
Mon Aug 15 03:28:10 PDT 2011


 src/cairo-surface-observer.c |  114 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 112 insertions(+), 2 deletions(-)

New commits:
commit 2a694a969ca795979c572fd08b877680f579e765
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 15 11:27:24 2011 +0100

    observer: print stroke caps/joins frequencies
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index 045ba01..e5ffe16 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -568,6 +568,8 @@ _cairo_surface_observer_stroke (void				*abstract_surface,
     surface->log.stroke.count++;
     surface->log.stroke.operators[op]++;
     surface->log.stroke.antialias[antialias]++;
+    surface->log.stroke.caps[style->line_cap]++;
+    surface->log.stroke.joins[style->line_join]++;
     add_pattern (&surface->log.stroke.source, source, surface->target);
     add_path (&surface->log.stroke.path, path, FALSE);
     add_clip (&surface->log.stroke.clip, clip);
@@ -575,6 +577,8 @@ _cairo_surface_observer_stroke (void				*abstract_surface,
     device->log.stroke.count++;
     device->log.stroke.operators[op]++;
     device->log.stroke.antialias[antialias]++;
+    device->log.stroke.caps[style->line_cap]++;
+    device->log.stroke.joins[style->line_join]++;
     add_pattern (&device->log.stroke.source, source, surface->target);
     add_path (&device->log.stroke.path, path, FALSE);
     add_clip (&device->log.stroke.clip, clip);
@@ -879,6 +883,27 @@ static inline int ordercmp (int a, int b, unsigned int *array)
 CAIRO_COMBSORT_DECLARE_WITH_DATA (sort_order, int, ordercmp)
 
 static void
+print_array (cairo_output_stream_t *stream,
+	     unsigned int *array,
+	     const char **names,
+	     int count)
+{
+    int order[64];
+    int i, j;
+
+    assert (count < ARRAY_LENGTH (order));
+    for (i = j = 0; i < count; i++) {
+	if (array[i] != 0)
+	    order[j++] = i;
+    }
+
+    sort_order (order, j, array);
+    for (i = 0; i < j; i++)
+	_cairo_output_stream_printf (stream, " %d %s",
+				     array[order[i]], names[order[i]]);
+}
+
+static void
 print_operators (cairo_output_stream_t *stream, unsigned int *array)
 {
     static const char *names[] = {
@@ -916,19 +941,35 @@ print_operators (cairo_output_stream_t *stream, unsigned int *array)
 	"HSL_COLOR",	/* CAIRO_OPERATOR_HSL_COLOR */
 	"HSL_LUMINOSITY" /* CAIRO_OPERATOR_HSL_LUMINOSITY */
     };
-    int order[NUM_OPERATORS];
-    int i, j;
-
-    for (i = j = 0; i < NUM_OPERATORS; i++) {
-	if (array[i] != 0)
-	    order[j++] = i;
-    }
 
     _cairo_output_stream_printf (stream, "  op:");
-    sort_order (order, j, array);
-    for (i = 0; i < j; i++)
-	_cairo_output_stream_printf (stream, " %d %s",
-				     array[order[i]], names[order[i]]);
+    print_array (stream, array, names, NUM_OPERATORS);
+    _cairo_output_stream_printf (stream, "\n");
+}
+
+static void
+print_line_caps (cairo_output_stream_t *stream, unsigned int *array)
+{
+    static const char *names[] = {
+	"butt",		/* CAIRO_LINE_CAP_BUTT */
+	"round",	/* CAIRO_LINE_CAP_ROUND */
+	"square"	/* CAIRO_LINE_CAP_SQUARE */
+    };
+    _cairo_output_stream_printf (stream, "  caps:");
+    print_array (stream, array, names, NUM_CAPS);
+    _cairo_output_stream_printf (stream, "\n");
+}
+
+static void
+print_line_joins (cairo_output_stream_t *stream, unsigned int *array)
+{
+    static const char *names[] = {
+	"miter",	/* CAIRO_LINE_JOIN_MITER */
+	"round",	/* CAIRO_LINE_JOIN_ROUND */
+	"bevel",	/* CAIRO_LINE_JOIN_BEVEL */
+    };
+    _cairo_output_stream_printf (stream, "  joins:");
+    print_array (stream, array, names, NUM_JOINS);
     _cairo_output_stream_printf (stream, "\n");
 }
 
@@ -1020,6 +1061,8 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 	print_operators (stream, log->stroke.operators);
 	print_pattern (stream, "source", &log->stroke.source);
 	print_path (stream, &log->stroke.path);
+	print_line_caps (stream, log->stroke.caps);
+	print_line_joins (stream, log->stroke.joins);
 	print_clip (stream, &log->stroke.clip);
     }
 
commit f3b414abfad24219d0fbff531ed994b766a48e0f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 15 11:19:56 2011 +0100

    observer: print operator frequencies
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index 3db6b8c..045ba01 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -35,6 +35,7 @@
 
 #include "cairoint.h"
 
+#include "cairo-combsort-private.h"
 #include "cairo-composite-rectangles-private.h"
 #include "cairo-error-private.h"
 #include "cairo-image-surface-private.h"
@@ -870,6 +871,67 @@ print_extents (cairo_output_stream_t *stream, const struct extents *e)
 				 e->unbounded);
 }
 
+static inline int ordercmp (int a, int b, unsigned int *array)
+{
+    /* high to low */
+    return array[b] - array[a];
+}
+CAIRO_COMBSORT_DECLARE_WITH_DATA (sort_order, int, ordercmp)
+
+static void
+print_operators (cairo_output_stream_t *stream, unsigned int *array)
+{
+    static const char *names[] = {
+	"CLEAR",	/* CAIRO_OPERATOR_CLEAR */
+
+	"SOURCE",	/* CAIRO_OPERATOR_SOURCE */
+	"OVER",		/* CAIRO_OPERATOR_OVER */
+	"IN",		/* CAIRO_OPERATOR_IN */
+	"OUT",		/* CAIRO_OPERATOR_OUT */
+	"ATOP",		/* CAIRO_OPERATOR_ATOP */
+
+	"DEST",		/* CAIRO_OPERATOR_DEST */
+	"DEST_OVER",	/* CAIRO_OPERATOR_DEST_OVER */
+	"DEST_IN",	/* CAIRO_OPERATOR_DEST_IN */
+	"DEST_OUT",	/* CAIRO_OPERATOR_DEST_OUT */
+	"DEST_ATOP",	/* CAIRO_OPERATOR_DEST_ATOP */
+
+	"XOR",		/* CAIRO_OPERATOR_XOR */
+	"ADD",		/* CAIRO_OPERATOR_ADD */
+	"SATURATE",	/* CAIRO_OPERATOR_SATURATE */
+
+	"MULTIPLY",	/* CAIRO_OPERATOR_MULTIPLY */
+	"SCREEN",	/* CAIRO_OPERATOR_SCREEN */
+	"OVERLAY",	/* CAIRO_OPERATOR_OVERLAY */
+	"DARKEN",	/* CAIRO_OPERATOR_DARKEN */
+	"LIGHTEN",	/* CAIRO_OPERATOR_LIGHTEN */
+	"DODGE",	/* CAIRO_OPERATOR_COLOR_DODGE */
+	"BURN",		/* CAIRO_OPERATOR_COLOR_BURN */
+	"HARD_LIGHT",	/* CAIRO_OPERATOR_HARD_LIGHT */
+	"SOFT_LIGHT",	/* CAIRO_OPERATOR_SOFT_LIGHT */
+	"DIFFERENCE",	/* CAIRO_OPERATOR_DIFFERENCE */
+	"EXCLUSION",	/* CAIRO_OPERATOR_EXCLUSION */
+	"HSL_HUE",	/* CAIRO_OPERATOR_HSL_HUE */
+	"HSL_SATURATION", /* CAIRO_OPERATOR_HSL_SATURATION */
+	"HSL_COLOR",	/* CAIRO_OPERATOR_HSL_COLOR */
+	"HSL_LUMINOSITY" /* CAIRO_OPERATOR_HSL_LUMINOSITY */
+    };
+    int order[NUM_OPERATORS];
+    int i, j;
+
+    for (i = j = 0; i < NUM_OPERATORS; i++) {
+	if (array[i] != 0)
+	    order[j++] = i;
+    }
+
+    _cairo_output_stream_printf (stream, "  op:");
+    sort_order (order, j, array);
+    for (i = 0; i < j; i++)
+	_cairo_output_stream_printf (stream, " %d %s",
+				     array[order[i]], names[order[i]]);
+    _cairo_output_stream_printf (stream, "\n");
+}
+
 static void
 print_pattern (cairo_output_stream_t *stream,
 	       const char *name,
@@ -926,6 +988,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 				 log->paint.count, log->paint.noop);
     if (log->paint.count) {
 	print_extents (stream, &log->paint.extents);
+	print_operators (stream, log->paint.operators);
 	print_pattern (stream, "source", &log->paint.source);
 	print_clip (stream, &log->paint.clip);
     }
@@ -934,6 +997,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 				 log->mask.count, log->mask.noop);
     if (log->mask.count) {
 	print_extents (stream, &log->mask.extents);
+	print_operators (stream, log->mask.operators);
 	print_pattern (stream, "source", &log->mask.source);
 	print_pattern (stream, "mask", &log->mask.mask);
 	print_clip (stream, &log->mask.clip);
@@ -943,6 +1007,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 				 log->fill.count, log->fill.noop);
     if (log->fill.count) {
 	print_extents (stream, &log->fill.extents);
+	print_operators (stream, log->fill.operators);
 	print_pattern (stream, "source", &log->fill.source);
 	print_path (stream, &log->fill.path);
 	print_clip (stream, &log->fill.clip);
@@ -952,6 +1017,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 				 log->stroke.count, log->stroke.noop);
     if (log->stroke.count) {
 	print_extents (stream, &log->stroke.extents);
+	print_operators (stream, log->stroke.operators);
 	print_pattern (stream, "source", &log->stroke.source);
 	print_path (stream, &log->stroke.path);
 	print_clip (stream, &log->stroke.clip);
@@ -961,6 +1027,7 @@ _cairo_observation_print (cairo_output_stream_t *stream,
 				 log->glyphs.count, log->glyphs.noop);
     if (log->glyphs.count) {
 	print_extents (stream, &log->glyphs.extents);
+	print_operators (stream, log->glyphs.operators);
 	print_pattern (stream, "source", &log->glyphs.source);
 	print_clip (stream, &log->glyphs.clip);
     }
commit 7ad4c8e711cc4bdae7b22332fb2d4d95ad484e79
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Aug 15 11:06:17 2011 +0100

    observer: report number of solid patterns first
    
    As these tend to be the quickest, and putting them first keeps the reports
    are in an estimated fast->slow order.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index ca11909..3db6b8c 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -876,12 +876,12 @@ print_pattern (cairo_output_stream_t *stream,
 	       const struct pattern *p)
 {
     _cairo_output_stream_printf (stream,
-				 "  %s: %d native, %d record, %d other surface, %d solid, %d linear, %d radial, %d mesh\n",
+				 "  %s: %d solid, %d native, %d record, %d other surface, %d linear, %d radial, %d mesh\n",
 				 name,
+				 p->type[3], /* solid first */
 				 p->type[0],
 				 p->type[1],
 				 p->type[2],
-				 p->type[3],
 				 p->type[4],
 				 p->type[5],
 				 p->type[6]);


More information about the cairo-commit mailing list