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>
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 0ff5edf..ff4208a 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -450,6 +450,7 @@
 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 @@
                     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 @@
     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 @@
         //    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) {