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 "SkOpCoincidence.h" | 7 #include "SkOpCoincidence.h" |
8 #include "SkOpContour.h" | 8 #include "SkOpContour.h" |
9 #include "SkOpSegment.h" | 9 #include "SkOpSegment.h" |
10 #include "SkPathWriter.h" | 10 #include "SkPathWriter.h" |
(...skipping 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 } | 1112 } |
1113 if (this->done()) { | 1113 if (this->done()) { |
1114 return; | 1114 return; |
1115 } | 1115 } |
1116 SkOpSpan* prior = NULL; | 1116 SkOpSpan* prior = NULL; |
1117 SkOpSpanBase* spanBase = &fHead; | 1117 SkOpSpanBase* spanBase = &fHead; |
1118 do { | 1118 do { |
1119 SkOpPtT* ptT = spanBase->ptT(), * spanStopPtT = ptT; | 1119 SkOpPtT* ptT = spanBase->ptT(), * spanStopPtT = ptT; |
1120 SkASSERT(ptT->span() == spanBase); | 1120 SkASSERT(ptT->span() == spanBase); |
1121 while ((ptT = ptT->next()) != spanStopPtT) { | 1121 while ((ptT = ptT->next()) != spanStopPtT) { |
| 1122 if (ptT->deleted()) { |
| 1123 continue; |
| 1124 } |
1122 SkOpSegment* opp = ptT->span()->segment(); | 1125 SkOpSegment* opp = ptT->span()->segment(); |
1123 if (opp->verb() == SkPath::kLine_Verb) { | 1126 if (opp->verb() == SkPath::kLine_Verb) { |
1124 continue; | 1127 continue; |
1125 } | 1128 } |
1126 if (opp->done()) { | 1129 if (opp->done()) { |
1127 continue; | 1130 continue; |
1128 } | 1131 } |
1129 // when opp is encounted the 1st time, continue; on 2nd encounter, l
ook for coincidence | 1132 // when opp is encounted the 1st time, continue; on 2nd encounter, l
ook for coincidence |
1130 if (!opp->visited()) { | 1133 if (!opp->visited()) { |
1131 continue; | 1134 continue; |
(...skipping 10 matching lines...) Expand all Loading... |
1142 if (spanBase->containsCoinEnd(opp)) { | 1145 if (spanBase->containsCoinEnd(opp)) { |
1143 continue; | 1146 continue; |
1144 } | 1147 } |
1145 SkOpPtT* priorPtT = NULL, * priorStopPtT; | 1148 SkOpPtT* priorPtT = NULL, * priorStopPtT; |
1146 // find prior span containing opp segment | 1149 // find prior span containing opp segment |
1147 SkOpSegment* priorOpp = NULL; | 1150 SkOpSegment* priorOpp = NULL; |
1148 SkOpSpan* priorTest = spanBase->prev(); | 1151 SkOpSpan* priorTest = spanBase->prev(); |
1149 while (!priorOpp && priorTest) { | 1152 while (!priorOpp && priorTest) { |
1150 priorStopPtT = priorPtT = priorTest->ptT(); | 1153 priorStopPtT = priorPtT = priorTest->ptT(); |
1151 while ((priorPtT = priorPtT->next()) != priorStopPtT) { | 1154 while ((priorPtT = priorPtT->next()) != priorStopPtT) { |
| 1155 if (priorPtT->deleted()) { |
| 1156 continue; |
| 1157 } |
1152 SkOpSegment* segment = priorPtT->span()->segment(); | 1158 SkOpSegment* segment = priorPtT->span()->segment(); |
1153 if (segment == opp) { | 1159 if (segment == opp) { |
1154 prior = priorTest; | 1160 prior = priorTest; |
1155 priorOpp = opp; | 1161 priorOpp = opp; |
1156 break; | 1162 break; |
1157 } | 1163 } |
1158 } | 1164 } |
1159 priorTest = priorTest->prev(); | 1165 priorTest = priorTest->prev(); |
1160 } | 1166 } |
1161 if (!priorOpp) { | 1167 if (!priorOpp) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 oppDxdy.normalize(); | 1202 oppDxdy.normalize(); |
1197 dxdy.normalize(); | 1203 dxdy.normalize(); |
1198 SkScalar flatness = SkScalarAbs(dxdy.cross(oppDxdy)
/ FLT_EPSILON); | 1204 SkScalar flatness = SkScalarAbs(dxdy.cross(oppDxdy)
/ FLT_EPSILON); |
1199 coincident |= flatness < 5000; // FIXME: replace wi
th tuned value | 1205 coincident |= flatness < 5000; // FIXME: replace wi
th tuned value |
1200 } | 1206 } |
1201 } | 1207 } |
1202 } | 1208 } |
1203 } | 1209 } |
1204 if (coincident) { | 1210 if (coincident) { |
1205 // mark coincidence | 1211 // mark coincidence |
1206 if (!coincidences->extend(priorPtT, ptT, oppStart, oppEnd)) { | 1212 if (!coincidences->extend(priorPtT, ptT, oppStart, oppEnd) |
| 1213 && !coincidences->extend(oppStart, oppEnd, priorPtT, ptT
)) { |
1207 coincidences->add(priorPtT, ptT, oppStart, oppEnd, allocator
); | 1214 coincidences->add(priorPtT, ptT, oppStart, oppEnd, allocator
); |
1208 } | 1215 } |
1209 clear_visited(&fHead); | 1216 clear_visited(&fHead); |
1210 return; | 1217 return; |
1211 } | 1218 } |
1212 swapBack: | 1219 swapBack: |
1213 if (swapped) { | 1220 if (swapped) { |
1214 SkTSwap(priorPtT, ptT); | 1221 SkTSwap(priorPtT, ptT); |
1215 } | 1222 } |
1216 } | 1223 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 int absOut = abs(outerWinding); | 1673 int absOut = abs(outerWinding); |
1667 int absIn = abs(innerWinding); | 1674 int absIn = abs(innerWinding); |
1668 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; | 1675 bool result = absOut == absIn ? outerWinding < 0 : absOut < absIn; |
1669 return result; | 1676 return result; |
1670 } | 1677 } |
1671 | 1678 |
1672 int SkOpSegment::windSum(const SkOpAngle* angle) const { | 1679 int SkOpSegment::windSum(const SkOpAngle* angle) const { |
1673 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); | 1680 const SkOpSpan* minSpan = angle->start()->starter(angle->end()); |
1674 return minSpan->windSum(); | 1681 return minSpan->windSum(); |
1675 } | 1682 } |
OLD | NEW |