aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops
diff options
context:
space:
mode:
authorGravatar Cary Clark <caryclark@skia.org>2018-02-27 08:48:32 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-27 18:39:29 +0000
commit1c2c2e253fe0ab3a5bb5134f7e6cf100b7126005 (patch)
tree4bdcbca03fa2b3ac13adb78aff22358a42023dc0 /src/pathops
parent75959391681495896570e7bf8d7f9effdd1306f3 (diff)
avoid divide in pathopsquad
Bug: skia: Change-Id: I535b1833712e87bb562e2cbef450a4f6e16ec2c5 Reviewed-on: https://skia-review.googlesource.com/110441 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Cary Clark <caryclark@skia.org>
Diffstat (limited to 'src/pathops')
-rw-r--r--src/pathops/SkPathOpsQuad.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pathops/SkPathOpsQuad.cpp b/src/pathops/SkPathOpsQuad.cpp
index ab1ba05c56..f410ea3737 100644
--- a/src/pathops/SkPathOpsQuad.cpp
+++ b/src/pathops/SkPathOpsQuad.cpp
@@ -21,11 +21,14 @@ static bool pointInTriangle(const SkDPoint fPts[3], const SkDPoint& test) {
double dot11 = v1.dot(v1);
double dot12 = v1.dot(v2);
// Compute barycentric coordinates
- double invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
- double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
- double v = (dot00 * dot12 - dot01 * dot02) * invDenom;
+ double denom = dot00 * dot11 - dot01 * dot01;
+ double u = dot11 * dot02 - dot01 * dot12;
+ double v = dot00 * dot12 - dot01 * dot02;
// Check if point is in triangle
- return u >= 0 && v >= 0 && u + v < 1;
+ if (denom >= 0) {
+ return u >= 0 && v >= 0 && u + v < denom;
+ }
+ return u <= 0 && v <= 0 && u + v > denom;
}
static bool matchesEnd(const SkDPoint fPts[3], const SkDPoint& test) {