Index: src/core/SkStroke.cpp |
diff --git a/src/core/SkStroke.cpp b/src/core/SkStroke.cpp |
index ede3d21055ee68a68b67775623ec268c71c117ed..7462cabb972b98f4854f7e713a095fb00a7e523c 100644 |
--- a/src/core/SkStroke.cpp |
+++ b/src/core/SkStroke.cpp |
@@ -121,6 +121,9 @@ public: |
SkScalar radius, SkScalar miterLimit, SkPaint::Cap, |
SkPaint::Join, SkScalar resScale); |
+ bool hasOnlyMoveTo() const { return 0 == fSegmentCount; } |
+ SkPoint moveToPt() const { return fFirstPt; } |
+ |
void moveTo(const SkPoint&); |
void lineTo(const SkPoint&); |
void quadTo(const SkPoint&, const SkPoint&); |
@@ -242,7 +245,11 @@ bool SkPathStroker::preJoinTo(const SkPoint& currPt, SkVector* normal, |
SkScalar prevY = fPrevPt.fY; |
if (!set_normal_unitnormal(fPrevPt, currPt, fRadius, normal, unitNormal)) { |
- return false; |
+ if (SkStrokerPriv::CapFactory(SkPaint::kButt_Cap) == fCapper) { |
+ return false; |
+ } |
+ normal->set(fRadius, 0); |
+ unitNormal->set(1, 0); |
} |
if (fSegmentCount == 0) { |
@@ -356,7 +363,8 @@ void SkPathStroker::line_to(const SkPoint& currPt, const SkVector& normal) { |
} |
void SkPathStroker::lineTo(const SkPoint& currPt) { |
- if (SkPath::IsLineDegenerate(fPrevPt, currPt, false)) { |
+ if (SkStrokerPriv::CapFactory(SkPaint::kButt_Cap) == fCapper |
+ && SkPath::IsLineDegenerate(fPrevPt, currPt, false)) { |
return; |
} |
SkVector normal, unitNormal; |
@@ -1334,6 +1342,11 @@ void SkStroke::strokePath(const SkPath& src, SkPath* dst) const { |
lastSegment = SkPath::kCubic_Verb; |
break; |
case SkPath::kClose_Verb: |
+ if (stroker.hasOnlyMoveTo() && SkPaint::kButt_Cap != this->getCap()) { |
+ stroker.lineTo(stroker.moveToPt()); |
+ lastSegment = SkPath::kLine_Verb; |
+ break; |
+ } |
stroker.close(lastSegment == SkPath::kLine_Verb); |
break; |
case SkPath::kDone_Verb: |