Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Unified Diff: src/core/SkPath.cpp

Issue 1533873002: Use the unswapped end point y for early out case in winding_line (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPath.cpp
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index d32fb4cba3b92f464d93546e44b2bcfb5c120808..d7e047e343be097586be739808dcedc934f8cc0d 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2844,7 +2844,7 @@ static int winding_line(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurv
if (y < y0 || y > y1) {
return 0;
}
- if (y == y1) {
+ if (y == pts[1].fY) {
if (y0 == y1 && between(x0, x, x1) && x != x1) { // check if on horizontal line
*onCurveCount += 1;
}
@@ -2853,9 +2853,10 @@ static int winding_line(const SkPoint pts[], SkScalar x, SkScalar y, int* onCurv
SkScalar cross = SkScalarMul(x1 - x0, y - pts[0].fY) - SkScalarMul(dy, x - x0);
if (!cross) {
- if (x != x1 || y != pts[1].fY) { // don't test end points since they're also start points
- *onCurveCount += 1; // zero cross means the point is on the line
- }
+ // zero cross means the point is on the line, and since the case where
+ // y of the query point is at the end point is handled above, we can be
+ // sure that we're on the line (excluding the end point) here
+ *onCurveCount += 1;
dir = 0;
} else if (SkScalarSignAsInt(cross) == dir) {
dir = 0;
« no previous file with comments | « no previous file | tests/PathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698