| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
| 9 #include "SkPathOpsTSect.h" | 9 #include "SkPathOpsTSect.h" |
| 10 | 10 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 do { | 418 do { |
| 419 const SkOpPtT* startPtT = coin->coinPtTStart(); | 419 const SkOpPtT* startPtT = coin->coinPtTStart(); |
| 420 const SkOpPtT* oStartPtT = coin->oppPtTStart(); | 420 const SkOpPtT* oStartPtT = coin->oppPtTStart(); |
| 421 SkASSERT(startPtT->contains(oStartPtT)); | 421 SkASSERT(startPtT->contains(oStartPtT)); |
| 422 SkASSERT(coin->coinPtTEnd()->contains(coin->oppPtTEnd())); | 422 SkASSERT(coin->coinPtTEnd()->contains(coin->oppPtTEnd())); |
| 423 const SkOpSpanBase* start = startPtT->span(); | 423 const SkOpSpanBase* start = startPtT->span(); |
| 424 const SkOpSpanBase* oStart = oStartPtT->span(); | 424 const SkOpSpanBase* oStart = oStartPtT->span(); |
| 425 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); | 425 const SkOpSpanBase* end = coin->coinPtTEnd()->span(); |
| 426 const SkOpSpanBase* oEnd = coin->oppPtTEnd()->span(); | 426 const SkOpSpanBase* oEnd = coin->oppPtTEnd()->span(); |
| 427 FAIL_IF(oEnd->deleted()); | 427 FAIL_IF(oEnd->deleted()); |
| 428 FAIL_IF(!start->upCastable()); |
| 428 const SkOpSpanBase* test = start->upCast()->next(); | 429 const SkOpSpanBase* test = start->upCast()->next(); |
| 429 const SkOpSpanBase* oTest = coin->flipped() ? oStart->prev() : oStart->u
pCast()->next(); | 430 const SkOpSpanBase* oTest = coin->flipped() ? oStart->prev() : oStart->u
pCast()->next(); |
| 430 if (!oTest) { | 431 if (!oTest) { |
| 431 return false; | 432 return false; |
| 432 } | 433 } |
| 433 while (test != end || oTest != oEnd) { | 434 while (test != end || oTest != oEnd) { |
| 434 if (!test->ptT()->contains(oStart->segment()) | 435 if (!test->ptT()->contains(oStart->segment()) |
| 435 || !oTest->ptT()->contains(start->segment())) { | 436 || !oTest->ptT()->contains(start->segment())) { |
| 436 // use t ranges to guess which one is missing | 437 // use t ranges to guess which one is missing |
| 437 double startRange = coin->coinPtTEnd()->fT - startPtT->fT; | 438 double startRange = coin->coinPtTEnd()->fT - startPtT->fT; |
| 438 FAIL_IF(!startRange); | 439 FAIL_IF(!startRange); |
| 439 double startPart = (test->t() - startPtT->fT) / startRange; | 440 double startPart = (test->t() - startPtT->fT) / startRange; |
| 440 double oStartRange = coin->oppPtTEnd()->fT - oStartPtT->fT; | 441 double oStartRange = coin->oppPtTEnd()->fT - oStartPtT->fT; |
| 441 FAIL_IF(!oStartRange); | 442 FAIL_IF(!oStartRange); |
| 442 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange; | 443 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange; |
| 443 FAIL_IF(startPart == oStartPart); | 444 FAIL_IF(startPart == oStartPart); |
| 444 bool startOver = false; | 445 bool startOver = false; |
| 445 bool success = startPart < oStartPart | 446 bool success = startPart < oStartPart |
| 446 ? oStart->segment()->addExpanded( | 447 ? oStart->segment()->addExpanded( |
| 447 oStartPtT->fT + oStartRange * startPart, test, &
startOver) | 448 oStartPtT->fT + oStartRange * startPart, test, &
startOver) |
| 448 : start->segment()->addExpanded( | 449 : start->segment()->addExpanded( |
| 449 startPtT->fT + startRange * oStartPart, oTest, &
startOver); | 450 startPtT->fT + startRange * oStartPart, oTest, &
startOver); |
| 450 if (!success) { | 451 if (!success) { |
| 451 SkASSERT(fGlobalState->debugSkipAssert()); | 452 SkOPASSERT(false); |
| 452 return false; | 453 return false; |
| 453 } | 454 } |
| 454 if (startOver) { | 455 if (startOver) { |
| 455 test = start; | 456 test = start; |
| 456 oTest = oStart; | 457 oTest = oStart; |
| 457 } | 458 } |
| 458 } | 459 } |
| 459 if (test != end) { | 460 if (test != end) { |
| 460 test = test->upCast()->next(); | 461 test = test->upCast()->next(); |
| 461 } | 462 } |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1448 this->release(fHead, coin); | 1449 this->release(fHead, coin); |
| 1449 } | 1450 } |
| 1450 } while ((coin = coin->next())); | 1451 } while ((coin = coin->next())); |
| 1451 } | 1452 } |
| 1452 | 1453 |
| 1453 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, | 1454 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S
kOpPtT* testS, |
| 1454 const SkOpPtT* testE) const { | 1455 const SkOpPtT* testE) const { |
| 1455 return testS->segment()->testForCoincidence(testS, testE, testS->span(), | 1456 return testS->segment()->testForCoincidence(testS, testE, testS->span(), |
| 1456 testE->span(), outer->coinPtTStart()->segment()); | 1457 testE->span(), outer->coinPtTStart()->segment()); |
| 1457 } | 1458 } |
| OLD | NEW |