diff options
author | caryclark <caryclark@google.com> | 2016-03-18 06:04:26 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-18 06:04:26 -0700 |
commit | eb75c7db3a7372de68347d0df8d58acebc33a9ad (patch) | |
tree | d170c50baee0665d75c0eeecbb26eaa1751b4f8d /gm | |
parent | 92701ab7836124e8a57eacab17b26c567ad20dd7 (diff) |
allow one zero length dash
If the constructed stroke that represents a dash has a
single dash of length zero, and the end cap is square or
round, draw the cap.
The old code initialized the initial dash length to zero,
making it ambiguous whether the first length is zero or
not.
R=robertphillips@google.com
BUG=583299
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1805963002
Committed: https://skia.googlesource.com/skia/+/5e1a24808415df2748822e8082e21a361362cdfe
Review URL: https://codereview.chromium.org/1805963002
Diffstat (limited to 'gm')
-rw-r--r-- | gm/arcto.cpp | 21 | ||||
-rw-r--r-- | gm/dashing.cpp | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gm/arcto.cpp b/gm/arcto.cpp index cd26eef35a..584fca3c4f 100644 --- a/gm/arcto.cpp +++ b/gm/arcto.cpp @@ -205,3 +205,24 @@ DEF_SIMPLE_GM(bug593049, canvas, 300, 300) { canvas->drawPath(p, paint); } + +#include "SkDashPathEffect.h" +#include "SkPathMeasure.h" + +DEF_SIMPLE_GM(bug583299, canvas, 300, 300) { + const char* d="M60,60 A50,50 0 0 0 160,60 A50,50 0 0 0 60,60z"; + SkPaint p; + p.setStyle(SkPaint::kStroke_Style); + p.setStrokeWidth(100); + p.setAntiAlias(true); + p.setColor(0xFF008200); + p.setStrokeCap(SkPaint::kSquare_Cap); + SkPath path; + SkParsePath::FromSVGString(d, &path); + SkPathMeasure meas(path, false); + SkScalar length = meas.getLength(); + SkScalar intervals[] = {0, length }; + int intervalCount = (int) SK_ARRAY_COUNT(intervals); + p.setPathEffect(SkDashPathEffect::Create(intervals, intervalCount, 0))->unref(); + canvas->drawPath(path, p); +} diff --git a/gm/dashing.cpp b/gm/dashing.cpp index dfd1b629c1..c728d15a1a 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -21,7 +21,8 @@ static void drawline(SkCanvas* canvas, int on, int off, const SkPaint& paint, SkIntToScalar(off), }; - p.setPathEffect(SkDashPathEffect::Create(intervals, 2, phase))->unref(); + SkAutoTUnref<SkPathEffect> effect(SkDashPathEffect::Create(intervals, 2, phase)); + p.setPathEffect(effect); canvas->drawLine(startX, startY, finalX, finalY, p); } |