Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: src/pathops/SkOpCoincidence.cpp

Issue 2185703002: fix fuzz bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pathops/SkPathOpsTSect.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | src/pathops/SkPathOpsTSect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698