diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-06-12 14:37:59 -0700 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-06-12 14:37:59 -0700 |
| commit | 49df5c9edc2829e8a26592f912eaf7bfb5d86104 (patch) | |
| tree | 051e0cc840270f724d2d88082a9f414db21da551 /src/skia-tests/star.cpp | |
| parent | 193a59ec28b6b84f0df25bebc67c61812ab98e72 (diff) | |
Add stroked star test
Diffstat (limited to 'src/skia-tests/star.cpp')
| -rw-r--r-- | src/skia-tests/star.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/skia-tests/star.cpp b/src/skia-tests/star.cpp new file mode 100644 index 0000000..96eef2a --- /dev/null +++ b/src/skia-tests/star.cpp @@ -0,0 +1,63 @@ +/* + * Copyright 2014 © Samsung Research America, Silicon Valley + * + * Use of this source code is governed by the 3-Clause BSD license + * specified in the COPYING file included with this source code. + */ +#include <config.h> + +#include <math.h> + +#include <SkCanvas.h> +#include <SkPaint.h> +#include <SkRect.h> + +#include "caskbench.h" +#include "caskbench_context.h" +#include "skia-shapes.h" + +int +sk_setup_star(caskbench_context_t *ctx) +{ + ctx->skia_paint->setAntiAlias(false); + ctx->skia_paint->setStrokeWidth(1); + ctx->skia_paint->setStyle(SkPaint::kStroke_Style); + return 1; +} + +void +sk_teardown_star(void) +{ +} + +int +sk_test_star(caskbench_context_t *ctx) +{ + int w = ctx->canvas_width; + int h = ctx->canvas_height; + + shapes_t shape; + shape_copy(&ctx->shape_defaults, &shape); + for (int i=0; i<ctx->size; i++) { + shape.x = (double)rand()/RAND_MAX * w; + shape.y = (double)rand()/RAND_MAX * h; + shape.radius = (double)rand()/RAND_MAX * MIN( + MIN(shape.x, w-shape.x), MIN(shape.y, h-shape.y)); + + skiaRandomizePaintColor(ctx); + skiaDrawStar(ctx, &shape); + } + + return 1; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |