summaryrefslogtreecommitdiffstatsci
path: root/src/cairo-shapes.cpp
diff options
context:
space:
mode:
authorBryce Harrington <b.harrington@samsung.com>2014-05-09 12:03:56 -0700
committerBryce Harrington <b.harrington@samsung.com>2014-05-09 19:15:13 -0700
commitcea09733638d03edb68ceeac2c578705b4f78893 (patch)
treec44a9717a1cb95b0ae87f64adcf0c37275515119 /src/cairo-shapes.cpp
parent83fdc66541abebabd919ca3b772f38e16858a785 (diff)
Split fill test into three tests: fill, multishape, and animation
Diffstat (limited to 'src/cairo-shapes.cpp')
-rw-r--r--src/cairo-shapes.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cairo-shapes.cpp b/src/cairo-shapes.cpp
index 4a88eb0..56a3910 100644
--- a/src/cairo-shapes.cpp
+++ b/src/cairo-shapes.cpp
@@ -11,6 +11,8 @@
#include <cairo.h>
#include <math.h>
+#include "forward.h"
+#include "caskbench.h"
#include "cairo-shapes.h"
@@ -92,6 +94,69 @@ void (*cairoShapes[5])(caskbench_context_t *ctx , shapes_t *args) = {
cairoDrawRoundedRectangle
};
+void
+cairoDrawRandomizedShape(caskbench_context_t *ctx, shapes_t *shape)
+{
+ cairo_pattern_t *pattern = NULL;
+ cairo_surface_t *image = NULL;
+
+ static const double dashed3[] = {1.0};
+ static const double dashed2[] = {14.0, 6.0};
+
+ // Shape Type
+ if (shape->shape_type == CB_SHAPE_NONE)
+ shape->shape_type = (shape_type_t) (1 + (4.0 * rand())/RAND_MAX);
+
+ // Stroke styles
+ if (shape->stroke_width)
+ {
+ cairo_set_line_width(ctx->cairo_cr, shape->stroke_width);
+ cairo_set_line_join(ctx->cairo_cr, (cairo_line_join_t)shape->join_style);
+ cairo_set_line_cap(ctx->cairo_cr, (cairo_line_cap_t)shape->cap_style);
+ if (shape->dash_style == 1)
+ cairo_set_dash(ctx->cairo_cr, dashed3, 1, 0);
+ else if (shape->dash_style == 2)
+ cairo_set_dash(ctx->cairo_cr, dashed2, 2, 0);
+ }
+
+ // Options for fill, gradient, and transparency
+ switch (shape->fill_type) {
+ case CB_FILL_IMAGE_PATTERN:
+ // TODO
+ break;
+ case CB_FILL_RADIAL_GRADIENT:
+ // TODO
+ break;
+ case CB_FILL_LINEAR_GRADIENT:
+ // TODO
+ break;
+ case CB_FILL_NONE:
+ case CB_FILL_SOLID:
+ default:
+ if (shape->red > 0 || shape->blue > 0 || shape->green > 0 || shape->alpha > 0)
+ {
+ cairo_set_source_rgba(ctx->cairo_cr,
+ shape->red ? (double)shape->red : 0.0,
+ shape->green ? (double)shape->green : 0.0,
+ shape->blue ? (double)shape->blue : 0.0,
+ shape->alpha ? (double)shape->alpha : 1.0 );
+ }
+ else {
+ cairoRandomizeColor(ctx);
+ }
+ break;
+ }
+
+ // Draw
+ cairoShapes[shape->shape_type] (ctx, shape);
+
+ // Cleanup
+ if (pattern != NULL)
+ cairo_pattern_destroy(pattern);
+ if (image != NULL)
+ cairo_surface_destroy (image);
+}
+
/*
Local Variables:
mode:c++