summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-tests/roundrect.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2013-11-12 18:59:36 -0800
committerBryce Harrington <b.harrington@samsung.com>2013-11-13 13:19:18 -0800
commit5a0770ee6117c8b1f9cd9bf5820e8ae268fd09a2 (patch)
treef664b830102e3406a1dbba37c8ad497c2d220696 /src/cairo-tests/roundrect.cpp
parent8eb35dc7db018b9187c30454604fcfd88a8dadca (diff)
Add a rounded rectangle stroking test
Diffstat (limited to 'src/cairo-tests/roundrect.cpp')
-rw-r--r--src/cairo-tests/roundrect.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cairo-tests/roundrect.cpp b/src/cairo-tests/roundrect.cpp
new file mode 100644
index 0000000..4c8c4b7
--- /dev/null
+++ b/src/cairo-tests/roundrect.cpp
@@ -0,0 +1,49 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <cairo.h>
+
+#include "caskbench.h"
+
+static int line_length;
+
+int
+ca_setup_roundrect(caskbench_context_t *ctx)
+{
+ line_length = 60;
+ return 1;
+}
+
+void
+ca_teardown_roundrect(void)
+{
+}
+
+static void
+rounded_rectangle (cairo_t *cr,
+ double x, double y, double w, double h,
+ double radius)
+{
+ cairo_move_to (cr, x+radius, y);
+ cairo_arc (cr, x+w-radius, y+radius, radius, M_PI + M_PI / 2, M_PI * 2 );
+ cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI / 2 );
+ cairo_arc (cr, x+radius, y+h-radius, radius, M_PI/2, M_PI );
+ cairo_arc (cr, x+radius, y+radius, radius, M_PI, 270 * M_PI / 180);
+}
+
+
+int
+ca_test_roundrect(caskbench_context_t *ctx)
+{
+ int i, w, x, y;
+ for (i=0; i<ctx->size; i++) {
+ randomize_color (ctx->cr);
+ x = 10 + ((double)800*rand())/RAND_MAX;
+ y = 10 + ((double)300*rand())/RAND_MAX;;
+ w = ((double)ctx->size*rand())/RAND_MAX + 1;
+
+ rounded_rectangle (ctx->cr, x, y, 100, 40, 4);
+ cairo_set_line_width (ctx->cr, w);
+ cairo_stroke (ctx->cr);
+ }
+ return 1;
+}