diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-07-22 13:56:30 -0700 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-07-23 15:09:04 -0700 |
| commit | 270c748e14a6388360917d187d408c025a579fd2 (patch) | |
| tree | 0ecf7cb1269cb9ad3e537c6ca4ded5bc3aa9418e /src/skia-tests/linear-gradient.cpp | |
| parent | 80ad156d402aac8255245cc0f8003cf6270cf339 (diff) | |
Add linear gradient tests
Diffstat (limited to 'src/skia-tests/linear-gradient.cpp')
| -rw-r--r-- | src/skia-tests/linear-gradient.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/skia-tests/linear-gradient.cpp b/src/skia-tests/linear-gradient.cpp new file mode 100644 index 0000000..0f06868 --- /dev/null +++ b/src/skia-tests/linear-gradient.cpp @@ -0,0 +1,81 @@ +/* + * 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" + +/* TODO: + * - Specify with or without alpha + * - With or without antialiasing? + * - Stroke width should be via the shape defaults + */ + +int +sk_setup_linear_gradient(caskbench_context_t *ctx) +{ + return 1; +} + +void +sk_teardown_linear_gradient(void) +{ +} + +int +sk_test_linear_gradient(caskbench_context_t *ctx) +{ + int w = ctx->canvas_width; + int h = ctx->canvas_height; + int stops = 10; + + shapes_t shape; + shape_copy(&ctx->shape_defaults, &shape); + for (int i=0; i<ctx->size; i++) { + double x1 = (double)rand()/RAND_MAX * w; + double x2 = (double)rand()/RAND_MAX * w; + double y1 = (double)rand()/RAND_MAX * h; + double y2 = (double)rand()/RAND_MAX * h; + + double xx = MIN(x1, x2); + double yy = MIN(x1, x2); + double ww = abs(x2 - x1); + double hh = abs(y2 - y1); + + // transform(shape.width/100, 0, 0, shape.height/100, 0, 0) + shape.x = 0; + shape.y = 0; + shape.width = 100; + shape.height = 100; + shape.fill_type = CB_FILL_LINEAR_GRADIENT; + + sk_set_fill_style(ctx, &shape); + + skiaRandomizePaintColor(ctx); + skiaDrawRectangle(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 : |