| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkOpContour.h" | 8 #include "SkOpContour.h" |
| 9 #include "SkPathWriter.h" | 9 #include "SkPathWriter.h" |
| 10 #include "SkTSort.h" | 10 #include "SkTSort.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if ((thisOne.done() || other.done()) && thisOne.complete() && other.comp
lete()) { | 57 if ((thisOne.done() || other.done()) && thisOne.complete() && other.comp
lete()) { |
| 58 // OPTIMIZATION: remove from array | 58 // OPTIMIZATION: remove from array |
| 59 continue; | 59 continue; |
| 60 } | 60 } |
| 61 #if DEBUG_CONCIDENT | 61 #if DEBUG_CONCIDENT |
| 62 thisOne.debugShowTs(); | 62 thisOne.debugShowTs(); |
| 63 other.debugShowTs(); | 63 other.debugShowTs(); |
| 64 #endif | 64 #endif |
| 65 double startT = coincidence.fTs[0][0]; | 65 double startT = coincidence.fTs[0][0]; |
| 66 double endT = coincidence.fTs[0][1]; | 66 double endT = coincidence.fTs[0][1]; |
| 67 bool cancelers; | 67 bool startSwapped, oStartSwapped, cancelers; |
| 68 if ((cancelers = startT > endT)) { | 68 if ((cancelers = startSwapped = startT > endT)) { |
| 69 SkTSwap(startT, endT); | 69 SkTSwap(startT, endT); |
| 70 SkTSwap(coincidence.fPts[0], coincidence.fPts[1]); | |
| 71 } | 70 } |
| 72 SkASSERT(!approximately_negative(endT - startT)); | 71 SkASSERT(!approximately_negative(endT - startT)); |
| 73 double oStartT = coincidence.fTs[1][0]; | 72 double oStartT = coincidence.fTs[1][0]; |
| 74 double oEndT = coincidence.fTs[1][1]; | 73 double oEndT = coincidence.fTs[1][1]; |
| 75 if (oStartT > oEndT) { | 74 if ((oStartSwapped = oStartT > oEndT)) { |
| 76 SkTSwap<double>(oStartT, oEndT); | 75 SkTSwap(oStartT, oEndT); |
| 77 cancelers ^= true; | 76 cancelers ^= true; |
| 78 } | 77 } |
| 79 SkASSERT(!approximately_negative(oEndT - oStartT)); | 78 SkASSERT(!approximately_negative(oEndT - oStartT)); |
| 80 bool opp = fOperand ^ otherContour->fOperand; | 79 if (cancelers) { |
| 81 if (cancelers && !opp) { | |
| 82 // make sure startT and endT have t entries | 80 // make sure startT and endT have t entries |
| 83 if (startT > 0 || oEndT < 1 | 81 if (startT > 0 || oEndT < 1 |
| 84 || thisOne.isMissing(startT) || other.isMissing(oEndT)) { | 82 || thisOne.isMissing(startT) || other.isMissing(oEndT)) { |
| 85 thisOne.addTPair(startT, &other, oEndT, true, coincidence.fPts[0
]); | 83 thisOne.addTPair(startT, &other, oEndT, true, coincidence.fPts[s
tartSwapped]); |
| 86 } | 84 } |
| 87 if (oStartT > 0 || endT < 1 | 85 if (oStartT > 0 || endT < 1 |
| 88 || thisOne.isMissing(endT) || other.isMissing(oStartT)) { | 86 || thisOne.isMissing(endT) || other.isMissing(oStartT)) { |
| 89 other.addTPair(oStartT, &thisOne, endT, true, coincidence.fPts[1
]); | 87 other.addTPair(oStartT, &thisOne, endT, true, coincidence.fPts[o
StartSwapped]); |
| 90 } | 88 } |
| 91 } else { | 89 } else { |
| 92 if (startT > 0 || oStartT > 0 | 90 if (startT > 0 || oStartT > 0 |
| 93 || thisOne.isMissing(startT) || other.isMissing(oStartT)) { | 91 || thisOne.isMissing(startT) || other.isMissing(oStartT)) { |
| 94 thisOne.addTPair(startT, &other, oStartT, true, coincidence.fPts
[0]); | 92 thisOne.addTPair(startT, &other, oStartT, true, coincidence.fPts
[startSwapped]); |
| 95 } | 93 } |
| 96 if (endT < 1 || oEndT < 1 | 94 if (endT < 1 || oEndT < 1 |
| 97 || thisOne.isMissing(endT) || other.isMissing(oEndT)) { | 95 || thisOne.isMissing(endT) || other.isMissing(oEndT)) { |
| 98 other.addTPair(oEndT, &thisOne, endT, true, coincidence.fPts[1])
; | 96 other.addTPair(oEndT, &thisOne, endT, true, coincidence.fPts[!oS
tartSwapped]); |
| 99 } | 97 } |
| 100 } | 98 } |
| 101 #if DEBUG_CONCIDENT | 99 #if DEBUG_CONCIDENT |
| 102 thisOne.debugShowTs(); | 100 thisOne.debugShowTs(); |
| 103 other.debugShowTs(); | 101 other.debugShowTs(); |
| 104 #endif | 102 #endif |
| 105 } | 103 } |
| 106 } | 104 } |
| 107 | 105 |
| 108 void SkOpContour::calcCoincidentWinding() { | 106 void SkOpContour::calcCoincidentWinding() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 128 SkTSwap<double>(startT, endT); | 126 SkTSwap<double>(startT, endT); |
| 129 } | 127 } |
| 130 SkASSERT(!approximately_negative(endT - startT)); | 128 SkASSERT(!approximately_negative(endT - startT)); |
| 131 double oStartT = coincidence.fTs[1][0]; | 129 double oStartT = coincidence.fTs[1][0]; |
| 132 double oEndT = coincidence.fTs[1][1]; | 130 double oEndT = coincidence.fTs[1][1]; |
| 133 if (oStartT > oEndT) { | 131 if (oStartT > oEndT) { |
| 134 SkTSwap<double>(oStartT, oEndT); | 132 SkTSwap<double>(oStartT, oEndT); |
| 135 cancelers ^= true; | 133 cancelers ^= true; |
| 136 } | 134 } |
| 137 SkASSERT(!approximately_negative(oEndT - oStartT)); | 135 SkASSERT(!approximately_negative(oEndT - oStartT)); |
| 138 bool opp = fOperand ^ otherContour->fOperand; | 136 if (cancelers) { |
| 139 if (cancelers && !opp) { | |
| 140 // make sure startT and endT have t entries | 137 // make sure startT and endT have t entries |
| 141 if (!thisOne.done() && !other.done()) { | 138 if (!thisOne.done() && !other.done()) { |
| 142 thisOne.addTCancel(startT, endT, &other, oStartT, oEndT); | 139 thisOne.addTCancel(startT, endT, &other, oStartT, oEndT); |
| 143 } | 140 } |
| 144 } else { | 141 } else { |
| 145 if (!thisOne.done() && !other.done()) { | 142 if (!thisOne.done() && !other.done()) { |
| 146 thisOne.addTCoincident(startT, endT, &other, oStartT, oEndT); | 143 thisOne.addTCoincident(startT, endT, &other, oStartT, oEndT); |
| 147 } | 144 } |
| 148 } | 145 } |
| 149 #if DEBUG_CONCIDENT | 146 #if DEBUG_CONCIDENT |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 SkDebugf("%s empty contour\n", __FUNCTION__); | 252 SkDebugf("%s empty contour\n", __FUNCTION__); |
| 256 SkASSERT(0); | 253 SkASSERT(0); |
| 257 // FIXME: delete empty contour? | 254 // FIXME: delete empty contour? |
| 258 return; | 255 return; |
| 259 } | 256 } |
| 260 fBounds = fSegments.front().bounds(); | 257 fBounds = fSegments.front().bounds(); |
| 261 for (int index = 1; index < count; ++index) { | 258 for (int index = 1; index < count; ++index) { |
| 262 fBounds.add(fSegments[index].bounds()); | 259 fBounds.add(fSegments[index].bounds()); |
| 263 } | 260 } |
| 264 } | 261 } |
| OLD | NEW |