diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-03-05 17:13:19 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-03-05 17:16:43 -0800 |
| commit | f6a3a24d62db8aa844f785fd38c8e1d21de8794c (patch) | |
| tree | 65ef4f605c1f2849129d615d2749d3d799835896 /src/cairo-tests/rectangles.cpp | |
| parent | 83303324b218f7ee97c8ce65f71c04d35f250e97 (diff) | |
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.
Diffstat (limited to 'src/cairo-tests/rectangles.cpp')
| -rw-r--r-- | src/cairo-tests/rectangles.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
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 <math.h> #include <stdio.h> #include <stdlib.h> #include <cairo.h> @@ -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; i<ctx->size; 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; |