diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-03-05 17:34:29 -0800 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-03-05 17:34:29 -0800 |
| commit | 3e1ed4d2bf3cc01a7841ed80fc69f772169e83c0 (patch) | |
| tree | ac56dd5ada0cc5e28a08596a44c97ce6f0561a8c /src/skia-tests/roundrect.cpp | |
| parent | f6a3a24d62db8aa844f785fd38c8e1d21de8794c (diff) | |
roundrect: Make these two test cases consistent
This test case varies line width on rectangles and allows anti-aliasing.
Diffstat (limited to 'src/skia-tests/roundrect.cpp')
| -rw-r--r-- | src/skia-tests/roundrect.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/skia-tests/roundrect.cpp b/src/skia-tests/roundrect.cpp index db3ca4d..9795907 100644 --- a/src/skia-tests/roundrect.cpp +++ b/src/skia-tests/roundrect.cpp @@ -1,3 +1,4 @@ +#include <math.h> #include <SkCanvas.h> #include <SkPaint.h> #include <SkRect.h> @@ -8,7 +9,9 @@ int sk_setup_roundrect(caskbench_context_t *ctx) { - ctx->skia_paint->setARGB(255, 255, 255, 255); + ctx->skia_paint->setARGB(255, 0, 0, 0); + ctx->skia_paint->setAntiAlias(true); + ctx->skia_paint->setStyle(SkPaint::kStroke_Style); return 1; } @@ -20,16 +23,25 @@ sk_teardown_roundrect(void) int sk_test_roundrect(caskbench_context_t *ctx) { - int i, x, y, w; + unsigned char red, green, blue, alpha; + int i; + double line_width, x, y; SkRect rect; for (i=0; i<ctx->size; i++) { - ctx->skia_paint->setColor(rand()); - w = ((double)ctx->size*rand())/RAND_MAX + 1; - x = ((double)ctx->canvas_width*rand())/RAND_MAX + 10; - y = ((double)ctx->canvas_height*rand())/RAND_MAX + 10; + red = int( 255 * (double)rand()/RAND_MAX ); + green = int( 255 * (double)rand()/RAND_MAX ); + blue = int( 255 * (double)rand()/RAND_MAX ); + alpha = int( 255 * (double)rand()/RAND_MAX ); + ctx->skia_paint->setARGB(alpha, red, green, blue); + + x = trunc( (((double)ctx->canvas_width-20)*rand())/RAND_MAX ) + 10; + y = trunc( (((double)ctx->canvas_height-20)*rand())/RAND_MAX ) + 10; rect.set(x, y, x+100, y+40); - ctx->skia_paint->setStrokeWidth(w); + + line_width = trunc( ((double)ctx->size*rand())/RAND_MAX ) + 1; + ctx->skia_paint->setStrokeWidth(line_width); + ctx->skia_canvas->drawRoundRect(rect, 4.0, 4.0, *(ctx->skia_paint)); } |