diff options
author | 2011-10-31 12:12:12 +0000 | |
---|---|---|
committer | 2011-10-31 12:12:12 +0000 | |
commit | 4d03c110a08a4087fb094729e664c77a8f20dc73 (patch) | |
tree | 2f925b4477352e2c17764fd8ffd937ee73a32058 | |
parent | fc5da9266eae18f1ee3635a061af27788ad4b62e (diff) |
don't assume a 2-point path is convex, unless its also not closed
git-svn-id: http://skia.googlecode.com/svn/trunk@2561 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | src/core/SkStroke.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp index bf3ceac3b7..32de31f776 100644 --- a/src/core/SkStroke.cpp +++ b/src/core/SkStroke.cpp @@ -583,6 +583,7 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const { SkPath::Iter iter(src, false); SkPoint pts[4]; SkPath::Verb verb, lastSegment = SkPath::kMove_Verb; + bool hasCloseVerb = false; while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { switch (verb) { @@ -607,6 +608,7 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const { break; case SkPath::kClose_Verb: stroker.close(lastSegment == SkPath::kLine_Verb); + hasCloseVerb = true; break; default: break; @@ -627,7 +629,21 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const { if (fDoFill) { dst->addPath(src); } else { - if (src.countPoints() == 2) { + // I though all 2-point paths would be convex, but if its closed (i.e. + // a line that doubles back on itself) it may not be convex. + // + // e.g. this construct is not convex (though maybe that's a bug) + // + // path.moveTo(100, 25); path.lineTo(200, 25); path.close(); + // paint.setStrokeWidth(250); paint.setStrokeJoin(kRound); + // + // Hence our safety test to see if it was closed + // + if (2 == src.countPoints() && !hasCloseVerb) { +#ifdef SK_DEBUG + SkPath::Convexity c = dst->getConvexity(); + SkASSERT(SkPath::kConvex_Convexity == c); +#endif dst->setIsConvex(true); } } |