aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-21 13:56:20 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-11-21 13:56:20 +0000
commitbfe90370ea68798b2b9b5ba44142db67d99555e8 (patch)
treeec35b873afc09a80e7fb05d19d64d8c03a595050 /src
parentb0a327e9390da5865d4c56db5e5259adc3380d37 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPath.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index dbdd448291..307f7fddd0 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -492,7 +492,7 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
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 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
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 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
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;
}