diff options
| author | Bryce Harrington <b.harrington@samsung.com> | 2014-07-03 12:06:37 -0700 |
|---|---|---|
| committer | Bryce Harrington <b.harrington@samsung.com> | 2014-07-03 12:06:37 -0700 |
| commit | d2fb40482089a5d333438c4f59c5e8788e15c6d8 (patch) | |
| tree | 80f17ea3f613c1341d6f7841c5a8cda200265398 | |
| parent | b056641ef302205719974aac5f8f4e2e56fe9f3e (diff) | |
| parent | 1f267c34ccf8b6fa319859235555dbbdbd9fae07 (diff) | |
Merge pull request #123 from Samsung/Issue_5
Issue #5 Clean up and randomize stroke settings.
| -rw-r--r-- | src/cairo-shapes.cpp | 14 | ||||
| -rw-r--r-- | src/skia-shapes.cpp | 18 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/cairo-shapes.cpp b/src/cairo-shapes.cpp index 28320ae..1c301b0 100644 --- a/src/cairo-shapes.cpp +++ b/src/cairo-shapes.cpp @@ -277,8 +277,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; @@ -325,12 +324,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 |