| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (startT == endT) { // this can happen in very large compares | 204 if (startT == endT) { // this can happen in very large compares |
| 205 continue; | 205 continue; |
| 206 } | 206 } |
| 207 double oStartT = coincidence.fTs[1][0]; | 207 double oStartT = coincidence.fTs[1][0]; |
| 208 double oEndT = coincidence.fTs[1][1]; | 208 double oEndT = coincidence.fTs[1][1]; |
| 209 if (oStartT == oEndT) { | 209 if (oStartT == oEndT) { |
| 210 continue; | 210 continue; |
| 211 } | 211 } |
| 212 bool swapStart = startT > endT; | 212 bool swapStart = startT > endT; |
| 213 bool swapOther = oStartT > oEndT; | 213 bool swapOther = oStartT > oEndT; |
| 214 const SkPoint* startPt = &coincidence.fPts[0]; |
| 215 const SkPoint* endPt = &coincidence.fPts[1]; |
| 214 if (swapStart) { | 216 if (swapStart) { |
| 215 SkTSwap<double>(startT, endT); | 217 SkTSwap(startT, endT); |
| 216 SkTSwap<double>(oStartT, oEndT); | 218 SkTSwap(oStartT, oEndT); |
| 219 SkTSwap(startPt, endPt); |
| 217 } | 220 } |
| 218 bool cancel = swapOther != swapStart; | 221 bool cancel = swapOther != swapStart; |
| 219 int step = swapStart ? -1 : 1; | 222 int step = swapStart ? -1 : 1; |
| 220 int oStep = swapOther ? -1 : 1; | 223 int oStep = swapOther ? -1 : 1; |
| 221 double oMatchStart = cancel ? oEndT : oStartT; | 224 double oMatchStart = cancel ? oEndT : oStartT; |
| 222 if (partial ? startT != 0 || oMatchStart != 0 : (startT == 0) != (oMatch
Start == 0)) { | 225 if (partial ? startT != 0 || oMatchStart != 0 : (startT == 0) != (oMatch
Start == 0)) { |
| 223 bool added = false; | 226 bool added = false; |
| 224 if (oMatchStart != 0) { | 227 if (oMatchStart != 0) { |
| 225 added = thisOne.joinCoincidence(&other, oMatchStart, oStep, canc
el); | 228 const SkPoint& oMatchStartPt = cancel ? *endPt : *startPt; |
| 229 added = thisOne.joinCoincidence(&other, oMatchStart, oMatchStart
Pt, oStep, cancel); |
| 226 } | 230 } |
| 227 if (!cancel && startT != 0 && !added) { | 231 if (!cancel && startT != 0 && !added) { |
| 228 (void) other.joinCoincidence(&thisOne, startT, step, cancel); | 232 (void) other.joinCoincidence(&thisOne, startT, *startPt, step, c
ancel); |
| 229 } | 233 } |
| 230 } | 234 } |
| 231 double oMatchEnd = cancel ? oStartT : oEndT; | 235 double oMatchEnd = cancel ? oStartT : oEndT; |
| 232 if (partial ? endT != 1 || oMatchEnd != 1 : (endT == 1) != (oMatchEnd ==
1)) { | 236 if (partial ? endT != 1 || oMatchEnd != 1 : (endT == 1) != (oMatchEnd ==
1)) { |
| 233 bool added = false; | 237 bool added = false; |
| 234 if (cancel && endT != 1 && !added) { | 238 if (cancel && endT != 1 && !added) { |
| 235 (void) other.joinCoincidence(&thisOne, endT, -step, cancel); | 239 (void) other.joinCoincidence(&thisOne, endT, *endPt, -step, canc
el); |
| 236 } | 240 } |
| 237 } | 241 } |
| 238 } | 242 } |
| 239 } | 243 } |
| 240 | 244 |
| 241 void SkOpContour::calcCommonCoincidentWinding(const SkCoincidence& coincidence)
{ | 245 void SkOpContour::calcCommonCoincidentWinding(const SkCoincidence& coincidence)
{ |
| 242 int thisIndex = coincidence.fSegments[0]; | 246 int thisIndex = coincidence.fSegments[0]; |
| 243 SkOpSegment& thisOne = fSegments[thisIndex]; | 247 SkOpSegment& thisOne = fSegments[thisIndex]; |
| 244 if (thisOne.done()) { | 248 if (thisOne.done()) { |
| 245 return; | 249 return; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 fDone = true; // may be cleared below | 326 fDone = true; // may be cleared below |
| 323 for ( ; sortedIndex < segmentCount; ++sortedIndex) { | 327 for ( ; sortedIndex < segmentCount; ++sortedIndex) { |
| 324 SkOpSegment* testSegment = fSortedSegments[sortedIndex]; | 328 SkOpSegment* testSegment = fSortedSegments[sortedIndex]; |
| 325 if (testSegment->done()) { | 329 if (testSegment->done()) { |
| 326 if (sortedIndex == fFirstSorted) { | 330 if (sortedIndex == fFirstSorted) { |
| 327 ++fFirstSorted; | 331 ++fFirstSorted; |
| 328 } | 332 } |
| 329 continue; | 333 continue; |
| 330 } | 334 } |
| 331 fDone = false; | 335 fDone = false; |
| 332 SkPoint testXY = testSegment->activeLeftTop(true, NULL); | 336 SkPoint testXY = testSegment->activeLeftTop(NULL); |
| 333 if (*topStart) { | 337 if (*topStart) { |
| 334 if (testXY.fY < topLeft.fY) { | 338 if (testXY.fY < topLeft.fY) { |
| 335 continue; | 339 continue; |
| 336 } | 340 } |
| 337 if (testXY.fY == topLeft.fY && testXY.fX < topLeft.fX) { | 341 if (testXY.fY == topLeft.fY && testXY.fX < topLeft.fX) { |
| 338 continue; | 342 continue; |
| 339 } | 343 } |
| 340 if (bestXY->fY < testXY.fY) { | 344 if (bestXY->fY < testXY.fY) { |
| 341 continue; | 345 continue; |
| 342 } | 346 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 SkDebugf("%s empty contour\n", __FUNCTION__); | 400 SkDebugf("%s empty contour\n", __FUNCTION__); |
| 397 SkASSERT(0); | 401 SkASSERT(0); |
| 398 // FIXME: delete empty contour? | 402 // FIXME: delete empty contour? |
| 399 return; | 403 return; |
| 400 } | 404 } |
| 401 fBounds = fSegments.front().bounds(); | 405 fBounds = fSegments.front().bounds(); |
| 402 for (int index = 1; index < count; ++index) { | 406 for (int index = 1; index < count; ++index) { |
| 403 fBounds.add(fSegments[index].bounds()); | 407 fBounds.add(fSegments[index].bounds()); |
| 404 } | 408 } |
| 405 } | 409 } |
| OLD | NEW |