summaryrefslogtreecommitdiffstatsci
path: root/src
diff options
context:
space:
mode:
authorsuyambulingamrm <suyambu.rm@samsung.com>2014-07-03 19:10:01 +0530
committersuyambulingamrm <suyambu.rm@samsung.com>2014-07-03 19:10:01 +0530
commit1f267c34ccf8b6fa319859235555dbbdbd9fae07 (patch)
tree8ac584f4c2969d93189050cc693d986577d069dc /src
parent47de2e7053b90da347e739a220c698bde8313ce9 (diff)
Issue #5 Clean up and randomize stroke settings.
Diffstat (limited to 'src')
-rw-r--r--src/cairo-shapes.cpp14
-rw-r--r--src/skia-shapes.cpp18
2 files changed, 12 insertions, 20 deletions
diff --git a/src/cairo-shapes.cpp b/src/cairo-shapes.cpp
index 50ce77b..608e2fd 100644
--- a/src/cairo-shapes.cpp
+++ b/src/cairo-shapes.cpp
@@ -264,8 +264,7 @@ void (*cairoShapes[CB_SHAPE_END-1])(caskbench_context_t *ctx , shapes_t *args) =
void
cairoDrawRandomizedShape(caskbench_context_t *ctx, shapes_t *shape)
{
- static const double dashed3[] = {1.0};
- static const double dashed2[] = {14.0, 6.0};
+ static double dashed[] = {14.0, 6.0};
cairo_path_t *new_path;
@@ -312,12 +311,11 @@ cairoDrawRandomizedShape(caskbench_context_t *ctx, shapes_t *shape)
cairo_append_path (ctx->cairo_cr, new_path);
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 == 0)
- cairo_set_dash (ctx->cairo_cr, dashed3, 1, 0);
- else if (shape->dash_style == 1)
- cairo_set_dash (ctx->cairo_cr, dashed2, 2, 0);
+ cairo_set_line_join (ctx->cairo_cr, (cairo_line_join_t) (int)(drand48()*2));
+ cairo_set_line_cap (ctx->cairo_cr, (cairo_line_cap_t)(int)(drand48()*2));
+ dashed[0] = (drand48()*20);
+ dashed[1] = (drand48()*20);
+ cairo_set_dash (ctx->cairo_cr, dashed, 2, 0);
if (shape->stroke_color != -1) {
cairo_set_source_rgb (ctx->cairo_cr,
diff --git a/src/skia-shapes.cpp b/src/skia-shapes.cpp
index ca6acd2..ba10f1d 100644
--- a/src/skia-shapes.cpp
+++ b/src/skia-shapes.cpp
@@ -17,9 +17,7 @@
#include "caskbench_context.h"
#include "skia-shapes.h"
-SkAutoTUnref<SkPathEffect> pE;
SkPath path;
-
#ifndef SkToS32
int32_t SkToS32(intmax_t x) { return (int32_t)x; }
#endif
@@ -323,16 +321,11 @@ skiaDrawRandomizedShape(caskbench_context_t *ctx, shapes_t *shape)
ctx->skia_paint->setShader (NULL);
ctx->skia_paint->setStyle(SkPaint::kStroke_Style);
ctx->skia_paint->setStrokeWidth(shape->stroke_width);
- ctx->skia_paint->setStrokeJoin((SkPaint::Join)shape->join_style);
- ctx->skia_paint->setStrokeCap((SkPaint::Cap)shape->cap_style);
- if (shape->dash_style == 0)
- {
- SkScalar vals[] = { SkIntToScalar(1), SkIntToScalar(1) };
- ctx->skia_paint->setPathEffect(NULL);
- pE.reset(SkDashPathEffect::Create(vals, 2, 0));
- ctx->skia_paint->setPathEffect(SkDashPathEffect::Create(vals, 2, 0))->unref();
- }
- ctx->skia_paint->setStyle(SkPaint::kStroke_Style);
+ ctx->skia_paint->setStrokeJoin((SkPaint::Join)(int)(drand48()*2));
+ ctx->skia_paint->setStrokeCap((SkPaint::Cap)(int)(drand48()*2));
+ SkScalar vals[] = { SkIntToScalar((drand48()*20)), SkIntToScalar((drand48()*20)) };
+ ctx->skia_paint->setPathEffect(NULL);
+ ctx->skia_paint->setPathEffect(SkDashPathEffect::Create(vals, 2, 0))->unref();
SkColor color;
if (shape->stroke_color != -1) {
color = SkColorSetRGB (shape->stroke_color >> 24 & 255,
@@ -344,6 +337,7 @@ skiaDrawRandomizedShape(caskbench_context_t *ctx, shapes_t *shape)
}
ctx->skia_paint->setColor(color);
skiaShapes[shape->shape_type-1] (ctx, shape);
+ ctx->skia_paint->setStrokeWidth(1);
}
// Cleanup