diff options
| author | suyambulingamrm <suyambu.rm@samsung.com> | 2014-05-08 19:22:14 +0530 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-05-08 19:16:41 -0700 |
| commit | 34d7c6bd273ae760c77cd423b99c0fbd46d00fca (patch) | |
| tree | f33a3d3e4e027d189e02de3c09e055ddb0f544aa /src | |
| parent | f639a346569d01f36303b78d81e8ab9559657bf2 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/cairo-tests/roundrect.cpp | 12 | ||||
| -rw-r--r-- | src/skia-tests/roundrect.cpp | 11 |
2 files changed, 15 insertions, 8 deletions
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; i<ctx->size; 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); diff --git a/src/skia-tests/roundrect.cpp b/src/skia-tests/roundrect.cpp index e3aba75..722c95a 100644 --- a/src/skia-tests/roundrect.cpp +++ b/src/skia-tests/roundrect.cpp @@ -32,7 +32,7 @@ int sk_test_roundrect(caskbench_context_t *ctx) { int i; - double line_width, x, y; + double line_width, x, y, radius; SkRect rect; for (i=0; i<ctx->size; i++) { @@ -42,10 +42,13 @@ sk_test_roundrect(caskbench_context_t *ctx) y = trunc( (((double)ctx->canvas_height-20)*rand())/RAND_MAX ) + 10; rect.set(x, y, x+100, y+40); - line_width = trunc( ((double)ctx->size*rand())/RAND_MAX ) + 1; - ctx->skia_paint->setStrokeWidth(line_width); + /* vary radius upto half of MIN(X,Y) */ + radius = (double)rand()/RAND_MAX * 20; - ctx->skia_canvas->drawRoundRect(rect, 4.0, 4.0, *(ctx->skia_paint)); + /* 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); + ctx->skia_paint->setStrokeWidth(line_width); + ctx->skia_canvas->drawRoundRect(rect, radius, radius, *(ctx->skia_paint)); } return 1; |