OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkIntersections.h" | 8 #include "SkIntersections.h" |
9 #include "SkPathOpsCubic.h" | 9 #include "SkPathOpsCubic.h" |
10 #include "SkPathOpsLine.h" | 10 #include "SkPathOpsLine.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // FIXME: local edge may be coincident -- experiment with not propagating co
incidence to caller | 127 // FIXME: local edge may be coincident -- experiment with not propagating co
incidence to caller |
128 // SkASSERT(!locals.isCoincident(tIdx)); | 128 // SkASSERT(!locals.isCoincident(tIdx)); |
129 if (&cubic1 != &cubic2 || !approximately_equal(to1, to2)) { | 129 if (&cubic1 != &cubic2 || !approximately_equal(to1, to2)) { |
130 if (i.swapped()) { // FIXME: insert should respect swa
p | 130 if (i.swapped()) { // FIXME: insert should respect swa
p |
131 i.insert(to2, to1, p1); | 131 i.insert(to2, to1, p1); |
132 } else { | 132 } else { |
133 i.insert(to1, to2, p1); | 133 i.insert(to1, to2, p1); |
134 } | 134 } |
135 } | 135 } |
136 } else { | 136 } else { |
137 double offset = precisionScale / 16; // FIME: const is arbi
trary: test, refine | 137 /*for random cubics, 16 below catches 99.997% of the intersections. To test for
the remaining 0.003% |
| 138 look for nearly coincident curves. and check each 1/16th section. |
| 139 */ |
| 140 double offset = precisionScale / 16; // FIXME: const is arb
itrary: test, refine |
138 double c1Bottom = tIdx == 0 ? 0 : | 141 double c1Bottom = tIdx == 0 ? 0 : |
139 (t1Start + (t1 - t1Start) * locals[0][tIdx - 1] + to
1) / 2; | 142 (t1Start + (t1 - t1Start) * locals[0][tIdx - 1] + to
1) / 2; |
140 double c1Min = SkTMax(c1Bottom, to1 - offset); | 143 double c1Min = SkTMax(c1Bottom, to1 - offset); |
141 double c1Top = tIdx == tCount - 1 ? 1 : | 144 double c1Top = tIdx == tCount - 1 ? 1 : |
142 (t1Start + (t1 - t1Start) * locals[0][tIdx + 1] + to
1) / 2; | 145 (t1Start + (t1 - t1Start) * locals[0][tIdx + 1] + to
1) / 2; |
143 double c1Max = SkTMin(c1Top, to1 + offset); | 146 double c1Max = SkTMin(c1Top, to1 + offset); |
144 double c2Min = SkTMax(0., to2 - offset); | 147 double c2Min = SkTMax(0., to2 - offset); |
145 double c2Max = SkTMin(1., to2 + offset); | 148 double c2Max = SkTMin(1., to2 + offset); |
146 #if ONE_OFF_DEBUG | 149 #if ONE_OFF_DEBUG |
147 SkDebugf("%.*s %s 1 contains1=%d/%d contains2=%d/%d\n", i.de
pth()*2, tab, | 150 SkDebugf("%.*s %s 1 contains1=%d/%d contains2=%d/%d\n", i.de
pth()*2, tab, |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 } | 641 } |
639 (void) intersect(c, c); | 642 (void) intersect(c, c); |
640 if (used() > 0) { | 643 if (used() > 0) { |
641 SkASSERT(used() == 1); | 644 SkASSERT(used() == 1); |
642 if (fT[0][0] > fT[1][0]) { | 645 if (fT[0][0] > fT[1][0]) { |
643 swapPts(); | 646 swapPts(); |
644 } | 647 } |
645 } | 648 } |
646 return used(); | 649 return used(); |
647 } | 650 } |
OLD | NEW |