diff options
| author | chevalam <chevalam.s@samsung.com> | 2014-04-15 18:16:06 +0530 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-04-16 19:09:22 -0700 |
| commit | efbc73399e862e72063271983c643de4f0dd0604 (patch) | |
| tree | e4cbdcad0eb246cce23c5353571d81e931117f97 /src/cairo-shapes.cpp | |
| parent | 6ce3ba4a1e61d9cf396cea9a58fcb5e828ad45c4 (diff) | |
Issue#2 - Establish shared shapes code for cairo and skia tests
Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Diffstat (limited to 'src/cairo-shapes.cpp')
| -rw-r--r-- | src/cairo-shapes.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/cairo-shapes.cpp b/src/cairo-shapes.cpp new file mode 100644 index 0000000..4c774d9 --- /dev/null +++ b/src/cairo-shapes.cpp @@ -0,0 +1,57 @@ +#include "cairo-shapes.h" + + + + +void cairoDrawCircle(caskbench_context_t *ctx, shapes_t *args) +{ + cairo_arc (ctx->cairo_cr, args->centre_x, args->centre_y, args->radius, 0, 2*M_PI); +} + +void cairoDrawRectangle(caskbench_context_t *ctx, shapes_t *args) +{ + cairo_rectangle (ctx->cairo_cr, args->centre_x, args->centre_y, args->width, args->height); +} + +void cairoDrawTriangle(caskbench_context_t *ctx, shapes_t *args) +{ + for (int p = 0; p < args->numpoints; p++ ) { + if(p == 0) + cairo_move_to (ctx->cairo_cr, args->points[p][0], args->points[0][1]); + else + cairo_rel_line_to (ctx->cairo_cr, args->points[p][0], args->points[p][1]); + } + +} + +void cairoDrawStar(caskbench_context_t *ctx, shapes_t *args) +{ + for (int p = 0; p < args->numpoints; p++ ) { + if(p == 0) + cairo_move_to (ctx->cairo_cr, args->points[p][0], args->points[0][1]); + else + cairo_line_to (ctx->cairo_cr, args->points[p][0], args->points[p][1]); + } + cairo_close_path(ctx->cairo_cr); +} + + +void +cairoDrawRoundedRectangle (caskbench_context_t *ctx, shapes_t *args) +{ + cairo_move_to (ctx->cairo_cr, args->centre_x+args->radius, args->centre_y); + cairo_arc (ctx->cairo_cr, args->centre_x+args->width-args->radius, args->centre_y+args->radius, args->radius, M_PI + M_PI / 2, M_PI * 2 ); + cairo_arc (ctx->cairo_cr, args->centre_x+args->width-args->radius, args->centre_y+args->height-args->radius, args->radius, 0, M_PI / 2 ); + cairo_arc (ctx->cairo_cr, args->centre_x+args->radius, args->centre_y+args->height-args->radius, args->radius, M_PI/2, M_PI ); + cairo_arc (ctx->cairo_cr, args->centre_x+args->radius, args->centre_y+args->radius, args->radius, M_PI, 270 * M_PI / 180); +} + + +void (*cairoShapes[5])(caskbench_context_t *ctx , shapes_t *args) = { + cairoDrawCircle, + cairoDrawRectangle, + cairoDrawTriangle, + cairoDrawStar, + cairoDrawRoundedRectangle + }; + |