From 34d7c6bd273ae760c77cd423b99c0fbd46d00fca Mon Sep 17 00:00:00 2001 From: suyambulingamrm Date: Thu, 8 May 2014 19:22:14 +0530 Subject: roundrect: stroke width must not exceed twice of radius This limitation is due to a Skia limitation. See: https://github.com/Samsung/skia/issues/4 --- src/cairo-tests/roundrect.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/cairo-tests/roundrect.cpp') diff --git a/src/cairo-tests/roundrect.cpp b/src/cairo-tests/roundrect.cpp index 45d1bb6..b40e915 100644 --- a/src/cairo-tests/roundrect.cpp +++ b/src/cairo-tests/roundrect.cpp @@ -44,7 +44,7 @@ int ca_test_roundrect(caskbench_context_t *ctx) { int i; - double line_width, x, y; + double line_width, x, y, radius; cairo_t *cr = ctx->cairo_cr; for (i=0; isize; i++) { @@ -52,12 +52,16 @@ ca_test_roundrect(caskbench_context_t *ctx) x = 10 + trunc( (((double)ctx->canvas_width-20.0)*rand())/RAND_MAX ); y = 10 + trunc( (((double)ctx->canvas_height-20.0)*rand())/RAND_MAX ); + + /* vary radius upto half of MIN(X,Y) */ + radius = (double)rand()/RAND_MAX * 20; #if USE_CAIROGLES - cairo_rounded_rectangle (cr, x, y, 100, 40, 4, 4, 4, 4); + cairo_rounded_rectangle (cr, x, y, 100, 40, radius, radius, radius, radius); #else - rounded_rectangle (cr, x, y, 100, 40, 4); + rounded_rectangle (cr, x, y, 100, 40, radius); #endif - line_width = trunc( ((double)ctx->size*rand())/RAND_MAX ) + 1; + /* line_width cannot be more than twice of radius due to skia limitation - Issue #4 in skia https://github.com/Samsung/skia/issues/4 */ + line_width = (double)rand()/RAND_MAX * (2*radius); cairo_set_line_width (cr, line_width); cairo_stroke (cr); -- cgit v1.3.1-4-g156e