From 8c1aed17ca5dafb00175ac413d56760a3ef012f9 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 29 Jul 2009 13:24:19 +0100 Subject: [perf] Add another stroking micro-benchmark The original stroke only contains a single subpath. Self-intersection removal particularly affects strokes with multiple curved segments, so add a path that encompasses both straight edges and rounded corners. --- perf/stroke.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/perf/stroke.c b/perf/stroke.c index 7b3990d5..b3602261 100644 --- a/perf/stroke.c +++ b/perf/stroke.c @@ -44,6 +44,41 @@ do_stroke (cairo_t *cr, int width, int height) return cairo_perf_timer_elapsed (); } +static void +rounded_rectangle (cairo_t *cr, + double x, double y, double w, double h, + double radius) +{ + cairo_move_to (cr, x+radius, y); + cairo_arc (cr, x+w-radius, y+radius, radius, M_PI + M_PI / 2, M_PI * 2 ); + cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI / 2 ); + cairo_arc (cr, x+radius, y+h-radius, radius, M_PI/2, M_PI ); + cairo_arc (cr, x+radius, y+radius, radius, M_PI, 270 * M_PI / 180); +} + +static cairo_perf_ticks_t +do_strokes (cairo_t *cr, int width, int height) +{ + /* a pair of overlapping rectangles */ + rounded_rectangle (cr, + 2, 2, width/2. + 10, height/2. + 10, + 10); + rounded_rectangle (cr, + width/2. - 10, height/2. - 10, + width - 2, height - 2, + 10); + + cairo_set_line_width (cr, 2.); + + cairo_perf_timer_start (); + + cairo_stroke (cr); + + cairo_perf_timer_stop (); + + return cairo_perf_timer_elapsed (); +} + void stroke (cairo_perf_t *perf, cairo_t *cr, int width, int height) { @@ -51,4 +86,5 @@ stroke (cairo_perf_t *perf, cairo_t *cr, int width, int height) return; cairo_perf_cover_sources_and_operators (perf, "stroke", do_stroke); + cairo_perf_cover_sources_and_operators (perf, "strokes", do_strokes); } -- cgit v1.2.3