detect wrapped rect in path
Allow a rect to start in the middle of a span, and
wrap all the way around.
Initialize variable to suppress warning.
Add tests to detect rects constructed from a stroked
path.
Review URL: https://codereview.appspot.com/6847082
git-svn-id: http://skia.googlecode.com/svn/trunk@6522 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index dbdd448..307f7fd 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -492,7 +492,7 @@
int corners = 0;
SkPoint first, last;
const SkPoint* pts = *ptsPtr;
- const SkPoint* savePts;
+ const SkPoint* savePts = NULL;
first.set(0, 0);
last.set(0, 0);
int firstDirection = 0;
@@ -532,6 +532,9 @@
if (closedOrMoved) {
return false; // closed followed by a line
}
+ if (autoClose && nextDirection == firstDirection) {
+ break; // colinear with first
+ }
closedOrMoved = autoClose;
if (lastDirection != nextDirection) {
if (++corners > 4) {
@@ -564,8 +567,10 @@
lastDirection = nextDirection;
}
// Success if 4 corners and first point equals last
- bool result = 4 == corners && first == last;
- *ptsPtr = savePts;
+ bool result = 4 == corners && (first == last || autoClose);
+ if (savePts) {
+ *ptsPtr = savePts;
+ }
return result;
}