aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pathops/SkLineParameters.h
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-21 17:04:29 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-21 17:04:29 +0000
commit866f4e34a943c115ac372c22123a1520aa5f9b06 (patch)
treed2b7e2b36ae069cc1a6936d797d94cf1d3e86d27 /src/pathops/SkLineParameters.h
parent8660783e196dc3cb4ead492253a493844fa43f7a (diff)
optimize pathops coverage
Remove unused code from SkOpSegment.cpp and friends. Add new tests exposed by coverage. Fix a bug exposed by coverage -- removing the need to detect points that are nearby when intersecting. Add gyp rule for building coverage flavor on Mac. R=mtklein@google.com Author: caryclark@google.com Review URL: https://codereview.chromium.org/75453003 git-svn-id: http://skia.googlecode.com/svn/trunk@12344 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/pathops/SkLineParameters.h')
-rw-r--r--src/pathops/SkLineParameters.h51
1 files changed, 45 insertions, 6 deletions
diff --git a/src/pathops/SkLineParameters.h b/src/pathops/SkLineParameters.h
index 9cbd8524aa..04074854a8 100644
--- a/src/pathops/SkLineParameters.h
+++ b/src/pathops/SkLineParameters.h
@@ -23,13 +23,42 @@
class SkLineParameters {
public:
+
void cubicEndPoints(const SkDCubic& pts) {
- cubicEndPoints(pts, 0, 1);
- if (dx() == 0 && dy() == 0) {
- cubicEndPoints(pts, 0, 2);
- if (dx() == 0 && dy() == 0) {
- cubicEndPoints(pts, 0, 3);
+ int endIndex = 1;
+ cubicEndPoints(pts, 0, endIndex);
+ if (dy() != 0) {
+ return;
+ }
+ if (dx() == 0) {
+ cubicEndPoints(pts, 0, ++endIndex);
+ SkASSERT(endIndex == 2);
+ if (dy() != 0) {
+ return;
+ }
+ if (dx() == 0) {
+ cubicEndPoints(pts, 0, ++endIndex); // line
+ SkASSERT(endIndex == 3);
+ return;
+ }
+ }
+ if (dx() < 0) { // only worry about y bias when breaking cw/ccw tie
+ return;
+ }
+ // if cubic tangent is on x axis, look at next control point to break tie
+ // control point may be approximate, so it must move significantly to account for error
+ if (NotAlmostEqualUlps(pts[0].fY, pts[++endIndex].fY)) {
+ if (pts[0].fY > pts[endIndex].fY) {
+ a = DBL_EPSILON; // push it from 0 to slightly negative (y() returns -a)
}
+ return;
+ }
+ if (endIndex == 3) {
+ return;
+ }
+ SkASSERT(endIndex == 2);
+ if (pts[0].fY > pts[3].fY) {
+ a = DBL_EPSILON; // push it from 0 to slightly negative (y() returns -a)
}
}
@@ -55,8 +84,18 @@ public:
void quadEndPoints(const SkDQuad& pts) {
quadEndPoints(pts, 0, 1);
- if (dx() == 0 && dy() == 0) {
+ if (dy() != 0) {
+ return;
+ }
+ if (dx() == 0) {
quadEndPoints(pts, 0, 2);
+ return;
+ }
+ if (dx() < 0) { // only worry about y bias when breaking cw/ccw tie
+ return;
+ }
+ if (pts[0].fY > pts[2].fY) {
+ a = DBL_EPSILON;
}
}