aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-04-17 11:53:34 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-17 16:42:04 +0000
commit1cd6098d52a531451f194437861cd7a548f825a7 (patch)
tree2b00127b616df01c3038c5c5661968ebe87bb71d /src/core
parenta580fb3f9ec5c177e4e8f827f6aa14239f984121 (diff)
path is rect bug number twelve
Exposes that final close along a diagonal need not include a close verb if the subsequent verb is move; so we have to check for a diagonal then. The later check for diagonal included a comment that it may not be needed which does appear to be the case. R=robertphillips@google.com Bug: 824145,skia:7792 Change-Id: I17a9414e8b3e69b82c2eda28195696eae4e3d513 Reviewed-on: https://skia-review.googlesource.com/121801 Commit-Queue: Cary Clark <caryclark@skia.org> Commit-Queue: Robert Phillips <robertphillips@google.com> Auto-Submit: Cary Clark <caryclark@skia.org> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkPath.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 0ff5edf109..ff4208a346 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -450,6 +450,7 @@ static int rect_make_dir(SkScalar dx, SkScalar dy) {
bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** ptsPtr,
bool* isClosed, Direction* direction, SkRect* rect) const {
int corners = 0;
+ SkPoint closeXY; // used to determine if final line falls on a diagonal
SkPoint lineStart; // used to construct line from previous point
const SkPoint* firstPt = nullptr; // first point in the rect (last of first moves)
const SkPoint* lastPt = nullptr; // last point in the rect (last of lines or first if closed)
@@ -538,6 +539,10 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
firstPt = pts;
accumulatingRect = true;
} else {
+ closeXY = *firstPt - *lastPt;
+ if (closeXY.fX && closeXY.fY) {
+ return false; // we're diagonal, abort
+ }
accumulatingRect = false;
}
lineStart = *pts++;
@@ -555,7 +560,7 @@ addMissingClose:
if (corners < 3 || corners > 4) {
return false;
}
- SkPoint closeXY = *firstPt - *lastPt;
+ closeXY = *firstPt - *lastPt;
// If autoClose, check if close generates diagonal
bool result = 4 == corners && (closeXY.isZero() || (autoClose && (!closeXY.fX || !closeXY.fY)));
if (!result) {
@@ -565,9 +570,6 @@ addMissingClose:
// 3 sided rectangle
// 4 sided but the last edge is not long enough to reach the start
//
- if (closeXY.fX && closeXY.fY) {
- return false; // we're diagonal, abort (can we ever reach this?)
- }
int closeDirection = rect_make_dir(closeXY.fX, closeXY.fY);
// make sure the close-segment doesn't double-back on itself
if (3 == corners || (closeDirection ^ directions[1]) == 2) {