aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkPathOpsTSect.h
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-12-16 12:28:35 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-16 12:28:35 -0800
commitb669300a9753893ef900207c38aeff2d467764e5 (patch)
treeedfcba83547eb0897237a2547468bb6e708448c8 /src/pathops/SkPathOpsTSect.h
parent54c6fe8519f2927181a0847d22a61190529645e8 (diff)
only call scalar finite when necessary
Mike points that the the ulps compares rank high in path ops profiles. The check for finite scalars is rarely required. Call it less by: - specializing _pin version of compares - checking for 0 divides up front - handling failing cases before comparing - casting float to double before adding R=reed@google.com Review URL: https://codereview.chromium.org/1522183002
Diffstat (limited to 'src/pathops/SkPathOpsTSect.h')
-rw-r--r--src/pathops/SkPathOpsTSect.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pathops/SkPathOpsTSect.h b/src/pathops/SkPathOpsTSect.h
index bebdf40208..074fe37654 100644
--- a/src/pathops/SkPathOpsTSect.h
+++ b/src/pathops/SkPathOpsTSect.h
@@ -1467,11 +1467,17 @@ int SkTSect<TCurve, OppCurve>::linesIntersect(SkTSpan<TCurve, OppCurve>* span,
workT += tStep;
workPt = fCurve.ptAtT(workT);
coinW.setPerp(fCurve, workT, workPt, opp->fCurve);
+ if (coinW.perpT() < 0) {
+ continue;
+ }
SkDVector perpW = workPt - coinW.perpPt();
if ((perpS.dot(perpW) >= 0) == (tStep < 0)) {
tStep = -tStep;
}
- } while (!workPt.approximatelyEqual(coinW.perpPt()));
+ if (workPt.approximatelyEqual(coinW.perpPt())) {
+ break;
+ }
+ } while (true);
double oppTTest = coinW.perpT();
if (!opp->fHead->contains(oppTTest)) {
return 0;