summaryrefslogtreecommitdiffstatsci
path: root/src/skia-tests/rect.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-06-11 18:41:22 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-06-12 13:52:59 -0700
commit13690032ef2bbbe68ff9a66179eb8c03f20c0942 (patch)
tree7865b79a81097571cf10ec0bb16db10366dd3b8a /src/skia-tests/rect.cpp
parent99227b95316c38f47192891081a0c7ca99c813ad (diff)
canvas_perf: Run the rect testcase
Diffstat (limited to 'src/skia-tests/rect.cpp')
-rw-r--r--src/skia-tests/rect.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/skia-tests/rect.cpp b/src/skia-tests/rect.cpp
new file mode 100644
index 0000000..99bd09b
--- /dev/null
+++ b/src/skia-tests/rect.cpp
@@ -0,0 +1,75 @@
+/*
+ * 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:
+ * - How to specify fill?
+ * - Specify with or without alpha
+ * - With or without antialiasing?
+ * - Stroke width should be via the shape defaults
+ */
+
+int
+sk_setup_rect(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_rect(void)
+{
+}
+
+int
+sk_test_rect(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++) {
+ 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;
+
+ shape.x = MIN(x1, x2);
+ shape.y = MIN(x1, x2);
+ shape.width = abs(x2 - x1);
+ shape.height = abs(y2 - y1);
+
+ 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 :