diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-11 18:16:39 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-01-11 18:16:39 +0000 |
commit | 3d19c385e7c0bdd94171bf4892b991b77880c5ed (patch) | |
tree | 37b03fc7a4cbdb0ef8f07879ec825c64f13ba6f8 /src/core/SkPath.cpp | |
parent | b9349e1cb5a0fedcb7ee7a2fd3c6585b5302bfe8 (diff) |
fix cheapComputeDirection() in the non-convex case to pivot on the y-max point
rather than pivoting on the next. Also remove the loop, as it is just logically
wrong to think we can use this trick only a non-extrema pt.
git-svn-id: http://skia.googlecode.com/svn/trunk@3014 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkPath.cpp')
-rw-r--r-- | src/core/SkPath.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 50c7c59265..fc2ba42346 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1947,21 +1947,9 @@ bool SkPath::cheapComputeDirection(Direction* dir) const { } } else { int i = find_max_y(pts, n); - // loop around until we get a non-zero cross - for (int j = 0; j < n; ++j) { - if (i < n - 2) { - cross = cross_prod(pts[i], pts[i + 1], pts[i + 2]); - } else { - cross = cross_prod(pts[i], pts[(i + 1) % n], pts[(i + 2) % n]); - } - if (cross) { - break; - } - SkASSERT(i < n); - if (++i == n) { - i = 0; - } - } + // can't always say (i-1) % n, in case i-1 goes negative, so we + // use (i+n-1) % n instead + cross = cross_prod(pts[(i + n - 1) % n], pts[i], pts[(i + 1) % n]); } if (cross) { if (dir) { |