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 #include "SkIntersections.h" | 7 #include "SkIntersections.h" |
8 #include "SkPathOpsLine.h" | 8 #include "SkPathOpsLine.h" |
9 | 9 |
10 void SkIntersections::cleanUpParallelLines(bool parallel) { | 10 void SkIntersections::cleanUpParallelLines(bool parallel) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 /* Slopes match when denom goes to zero: | 101 /* Slopes match when denom goes to zero: |
102 axLen / ayLen == bxLen / byLen | 102 axLen / ayLen == bxLen / byLen |
103 (ayLen * byLen) * axLen / ayLen == (ayLen * byLen) * bxLen / byLen | 103 (ayLen * byLen) * axLen / ayLen == (ayLen * byLen) * bxLen / byLen |
104 byLen * axLen == ayLen * bxLen | 104 byLen * axLen == ayLen * bxLen |
105 byLen * axLen - ayLen * bxLen == 0 ( == denom ) | 105 byLen * axLen - ayLen * bxLen == 0 ( == denom ) |
106 */ | 106 */ |
107 double axByLen = axLen * byLen; | 107 double axByLen = axLen * byLen; |
108 double ayBxLen = ayLen * bxLen; | 108 double ayBxLen = ayLen * bxLen; |
109 // detect parallel lines the same way here and in SkOpAngle operator < | 109 // detect parallel lines the same way here and in SkOpAngle operator < |
110 // so that non-parallel means they are also sortable | 110 // so that non-parallel means they are also sortable |
111 bool unparallel = fAllowNear ? NotAlmostEqualUlps(axByLen, ayBxLen) | 111 bool unparallel = fAllowNear ? NotAlmostEqualUlps_Pin(axByLen, ayBxLen) |
112 : NotAlmostDequalUlps(axByLen, ayBxLen); | 112 : NotAlmostDequalUlps(axByLen, ayBxLen); |
113 if (unparallel && fUsed == 0) { | 113 if (unparallel && fUsed == 0) { |
114 double ab0y = a[0].fY - b[0].fY; | 114 double ab0y = a[0].fY - b[0].fY; |
115 double ab0x = a[0].fX - b[0].fX; | 115 double ab0x = a[0].fX - b[0].fX; |
116 double numerA = ab0y * bxLen - byLen * ab0x; | 116 double numerA = ab0y * bxLen - byLen * ab0x; |
117 double numerB = ab0y * axLen - ayLen * ab0x; | 117 double numerB = ab0y * axLen - ayLen * ab0x; |
118 double denom = axByLen - ayBxLen; | 118 double denom = axByLen - ayBxLen; |
119 if (between(0, numerA, denom) && between(0, numerB, denom)) { | 119 if (between(0, numerA, denom) && between(0, numerB, denom)) { |
120 fT[0][0] = numerA / denom; | 120 fT[0][0] = numerA / denom; |
121 fT[1][0] = numerB / denom; | 121 fT[1][0] = numerB / denom; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 insert((double) index, flipped ? 1 - t : t, line[index]); | 324 insert((double) index, flipped ? 1 - t : t, line[index]); |
325 } | 325 } |
326 } | 326 } |
327 } | 327 } |
328 } | 328 } |
329 cleanUpParallelLines(result == 2); | 329 cleanUpParallelLines(result == 2); |
330 SkASSERT(fUsed <= 2); | 330 SkASSERT(fUsed <= 2); |
331 return fUsed; | 331 return fUsed; |
332 } | 332 } |
333 | 333 |
OLD | NEW |