fix path is rect flaw exposed by gold
One of the path is rect bug fixes changed
the behavior of zero-length strokes which
showed up as a change in Gold.
The bug is if a rect is defined by a
series of colinear movetos, the bounds
did not work out if the rect started
and stopped in the middle of a side.
R=robertphillips@google.com
Bug: 824145,skia:7792
Change-Id: I226545efeda03dedd928eebc120d2508b428fef0
Reviewed-on: https://skia-review.googlesource.com/122002
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 7110a30..0bfeae1 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -506,6 +506,9 @@
closedOrMoved = autoClose;
lineStart = lineEnd;
if (directions[corners - 1] == nextDirection) {
+ if (3 == corners && kLine_Verb == verb) {
+ lastCountedPt = lastPt;
+ }
break; // colinear segment
}
if (corners >= 4) {
@@ -513,12 +516,12 @@
}
directions[corners++] = nextDirection;
// opposite lines must point in opposite directions; xoring them should equal 2
- if (corners == 3) {
+ if (3 == corners) {
if ((directions[0] ^ directions[2]) != 2) {
return false;
}
accumulatingRect = false;
- } else if (corners == 4) {
+ } else if (4 == corners) {
if ((directions[1] ^ directions[3]) != 2) {
return false;
}
@@ -575,7 +578,7 @@
//
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) {
+ if (3 == corners || 2 == (closeDirection ^ directions[1])) {
result = true;
autoClose = false; // we are not closed
}