From f6a3a24d62db8aa844f785fd38c8e1d21de8794c Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Wed, 5 Mar 2014 17:13:19 -0800 Subject: rectangles: Make skia and cairo test cases consistent Both tests now produce identical output, so this is now providing a solid apples-to-apples comparison. This shows cairo trumping skia's performance by about 300% on the image backend. Note that I disabled antialiasing in the cairo case in order to make the rectangle lines draw as sharply as they do in skia. It looks like skia may have antialiasing off by default; to be certain I've forced it off. --- src/cairo-tests/rectangles.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/cairo-tests/rectangles.cpp') diff --git a/src/cairo-tests/rectangles.cpp b/src/cairo-tests/rectangles.cpp index a53a155..803cd31 100644 --- a/src/cairo-tests/rectangles.cpp +++ b/src/cairo-tests/rectangles.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -7,6 +8,12 @@ int ca_setup_rectangles(caskbench_context_t *ctx) { + cairo_t *cr = ctx->cairo_cr; + + cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_paint (cr); + cairo_set_line_width (cr, 1); return 1; } @@ -18,18 +25,19 @@ ca_teardown_rectangles(void) int ca_test_rectangles(caskbench_context_t *ctx) { - int i, w, h, x, y; + int i; + double w, h, x, y; cairo_t *cr = ctx->cairo_cr; for (i=0; isize; i++) { randomize_color (cr); - w = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX + 1; - h = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX + 1; - x = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX; - y = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX; - cairo_rectangle(cr, x, y, w, h); - cairo_set_line_width (cr, 1); + w = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX ) + 1; + h = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX ) + 1; + x = trunc( (0.5*(double)ctx->canvas_width*rand())/RAND_MAX ); + y = trunc( (0.5*(double)ctx->canvas_height*rand())/RAND_MAX ); + cairo_rectangle(cr, x+1, y+1, w, h); + cairo_stroke (cr); } return 1; -- cgit v1.3.1-4-g156e