From 54ff302cdc5a0c1308998c8794b7d02fc2b68040 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 17 Aug 2018 10:58:23 -0400 Subject: [PATCH] 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 Commit-Queue: Cary Clark --- src/core/SkPath.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index d852cb68f5..b51bb2d07c 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1592,7 +1592,11 @@ SkPath& SkPath::addPath(const SkPath& path, const SkMatrix& matrix, AddPathMode 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]); }