From 3e1ed4d2bf3cc01a7841ed80fc69f772169e83c0 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 5 Mar 2014 17:34:29 -0800 Subject: roundrect: Make these two test cases consistent This test case varies line width on rectangles and allows anti-aliasing. --- src/cairo-tests/roundrect.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/cairo-tests/roundrect.cpp') diff --git a/src/cairo-tests/roundrect.cpp b/src/cairo-tests/roundrect.cpp index 79f573c..8141d15 100644 --- a/src/cairo-tests/roundrect.cpp +++ b/src/cairo-tests/roundrect.cpp @@ -1,15 +1,18 @@ +#include #include #include #include #include "caskbench.h" -static int line_length; - int ca_setup_roundrect(caskbench_context_t *ctx) { - line_length = 60; + cairo_t *cr = ctx->cairo_cr; + + cairo_set_antialias (cr, CAIRO_ANTIALIAS_BEST); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_paint (cr); return 1; } @@ -34,17 +37,20 @@ rounded_rectangle (cairo_t *cr, int ca_test_roundrect(caskbench_context_t *ctx) { - int i, w, x, y; + int i; + double line_width, x, y; cairo_t *cr = ctx->cairo_cr; for (i=0; isize; i++) { randomize_color (cr); - x = 10 + ((double)ctx->canvas_width*rand())/RAND_MAX; - y = 10 + ((double)ctx->canvas_height*rand())/RAND_MAX;; - w = ((double)ctx->size*rand())/RAND_MAX + 1; + x = 10 + trunc( (((double)ctx->canvas_width-20.0)*rand())/RAND_MAX ); + y = 10 + trunc( (((double)ctx->canvas_height-20.0)*rand())/RAND_MAX ); rounded_rectangle (cr, x, y, 100, 40, 4); - cairo_set_line_width (cr, w); + + line_width = trunc( ((double)ctx->size*rand())/RAND_MAX ) + 1; + cairo_set_line_width (cr, line_width); + cairo_stroke (cr); } return 1; -- cgit v1.3.1-4-g156e