summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/rectangles.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2013-11-12 19:52:58 -0800
committerBryce Harrington <b.harrington@samsung.com>2013-11-13 13:19:18 -0800
commit04cdffeed4d3c58c81f79e1c3869e3cb58f81cb7 (patch)
treed1454541c5a14cd13fdd9f4cbdf530dd2737345e /src/cairo-tests/rectangles.cpp
parent8d30cc5e32d4c098c1382594e0799de44a44f1bf (diff)
Add a rectangles test case
Derived from Cairo's rectangles micro benchmark
Diffstat (limited to 'src/cairo-tests/rectangles.cpp')
-rw-r--r--src/cairo-tests/rectangles.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cairo-tests/rectangles.cpp b/src/cairo-tests/rectangles.cpp
new file mode 100644
index 0000000..0115f1c
--- /dev/null
+++ b/src/cairo-tests/rectangles.cpp
@@ -0,0 +1,34 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cairo.h>
+
+#include "caskbench.h"
+
+int
+ca_setup_rectangles(caskbench_context_t *ctx)
+{
+ return 1;
+}
+
+void
+ca_teardown_rectangles(void)
+{
+}
+
+int
+ca_test_rectangles(caskbench_context_t *ctx)
+{
+ int i, w, h, x, y;
+ for (i=0; i<ctx->size; i++) {
+ randomize_color (ctx->cr);
+ w = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX + 1;
+ h = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX + 1;
+ x = (0.5*(double)ctx->canvas_width*rand())/RAND_MAX;
+ y = (0.5*(double)ctx->canvas_height*rand())/RAND_MAX;
+
+ cairo_rectangle(ctx->cr, x, y, w, h);
+ cairo_set_line_width (ctx->cr, 1);
+ cairo_stroke (ctx->cr);
+ }
+ return 1;
+}