summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-07-29 13:24:19 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-07-29 16:17:12 +0100
commit8c1aed17ca5dafb00175ac413d56760a3ef012f9 (patch)
tree3e7fd9273395a954ac7e6c1920250770adfebb45
parent71f5649846aa8e9e2178e7caf69ab47554f86c4d (diff)
[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.
-rw-r--r--perf/stroke.c36
1 files changed, 36 insertions, 0 deletions
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);
}