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) { |
11 while (fUsed > 2) { | 11 while (fUsed > 2) { |
12 removeOne(1); | 12 removeOne(1); |
13 } | 13 } |
14 if (fUsed == 2 && !parallel) { | 14 if (fUsed == 2 && !parallel) { |
15 bool startMatch = fT[0][0] == 0 || fT[1][0] == 0 || fT[1][0] == 1; | 15 bool startMatch = fT[0][0] == 0 || zero_or_one(fT[1][0]); |
16 bool endMatch = fT[0][1] == 1 || fT[1][1] == 0 || fT[1][1] == 1; | 16 bool endMatch = fT[0][1] == 1 || zero_or_one(fT[1][1]); |
17 if ((!startMatch && !endMatch) || approximately_equal(fT[0][0], fT[0][1]
)) { | 17 if ((!startMatch && !endMatch) || approximately_equal(fT[0][0], fT[0][1]
)) { |
18 SkASSERT(startMatch || endMatch); | 18 SkASSERT(startMatch || endMatch); |
19 removeOne(endMatch); | 19 if (startMatch && endMatch && (fT[0][0] != 0 || !zero_or_one(fT[1][0
])) |
| 20 && fT[0][1] == 1 && zero_or_one(fT[1][1])) { |
| 21 removeOne(0); |
| 22 } else { |
| 23 removeOne(endMatch); |
| 24 } |
20 } | 25 } |
21 } | 26 } |
22 if (fUsed == 2) { | 27 if (fUsed == 2) { |
23 fIsCoincident[0] = fIsCoincident[1] = 0x03; | 28 fIsCoincident[0] = fIsCoincident[1] = 0x03; |
24 } | 29 } |
25 } | 30 } |
26 | 31 |
27 void SkIntersections::computePoints(const SkDLine& line, int used) { | 32 void SkIntersections::computePoints(const SkDLine& line, int used) { |
28 fPt[0] = line.ptAtT(fT[0][0]); | 33 fPt[0] = line.ptAtT(fT[0][0]); |
29 if ((fUsed = used) == 2) { | 34 if ((fUsed = used) == 2) { |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 insert((double) index, flipped ? 1 - t : t, line[index]); | 324 insert((double) index, flipped ? 1 - t : t, line[index]); |
320 } | 325 } |
321 } | 326 } |
322 } | 327 } |
323 } | 328 } |
324 cleanUpParallelLines(result == 2); | 329 cleanUpParallelLines(result == 2); |
325 SkASSERT(fUsed <= 2); | 330 SkASSERT(fUsed <= 2); |
326 return fUsed; | 331 return fUsed; |
327 } | 332 } |
328 | 333 |
OLD | NEW |