avoid degenerate point in addPath extend mode
SkPath::addPath(... SkPath::kExtend_AddPathMode) duplicates
the last point if the added path first point is the same,
resulting in:
path.xVerbTo(..., pt);
path.lineTo(pt);
The extra point has no effect in filling or stroking.
Pathops uses extend mode a lot; fixing this avoids
the output of Op() and Simplify() requiring another pass
through Simplify() to reduce the path to its minimum.
R=reed@google.com,robertphillips@google.com
Bug: skia:8227
Change-Id: I7d660b6dc45e37221abf351dd291b90c303943ec
Reviewed-on: https://skia-review.googlesource.com/147810
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index d852cb6..b51bb2d 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1592,7 +1592,11 @@
proc(matrix, &pts[0], &pts[0], 1);
if (firstVerb && mode == kExtend_AddPathMode && !isEmpty()) {
injectMoveToIfNeeded(); // In case last contour is closed
- this->lineTo(pts[0]);
+ SkPoint lastPt;
+ // don't add lineTo if it is degenerate
+ if (fLastMoveToIndex < 0 || !this->getLastPt(&lastPt) || lastPt != pts[0]) {
+ this->lineTo(pts[0]);
+ }
} else {
this->moveTo(pts[0]);
}