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

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

Issue 1427913005: path ops: fix fuzz-found divide by zero (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: mark failing test as such Created 5 years, 1 month 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 | tests/PathOpsOpTest.cpp » ('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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 SkOpSpanBase* start = startPtT->span(); 84 SkOpSpanBase* start = startPtT->span();
85 SkOpSpanBase* oStart = oStartPtT->span(); 85 SkOpSpanBase* oStart = oStartPtT->span();
86 const SkOpSpanBase* end = coin->fCoinPtTEnd->span(); 86 const SkOpSpanBase* end = coin->fCoinPtTEnd->span();
87 const SkOpSpanBase* oEnd = coin->fOppPtTEnd->span(); 87 const SkOpSpanBase* oEnd = coin->fOppPtTEnd->span();
88 SkOpSpanBase* test = start->upCast()->next(); 88 SkOpSpanBase* test = start->upCast()->next();
89 SkOpSpanBase* oTest = coin->fFlipped ? oStart->prev() : oStart->upCast() ->next(); 89 SkOpSpanBase* oTest = coin->fFlipped ? oStart->prev() : oStart->upCast() ->next();
90 while (test != end || oTest != oEnd) { 90 while (test != end || oTest != oEnd) {
91 if (!test->ptT()->contains(oTest->ptT())) { 91 if (!test->ptT()->contains(oTest->ptT())) {
92 // use t ranges to guess which one is missing 92 // use t ranges to guess which one is missing
93 double startRange = coin->fCoinPtTEnd->fT - startPtT->fT; 93 double startRange = coin->fCoinPtTEnd->fT - startPtT->fT;
94 if (!startRange) {
95 return false;
96 }
94 double startPart = (test->t() - startPtT->fT) / startRange; 97 double startPart = (test->t() - startPtT->fT) / startRange;
95 double oStartRange = coin->fOppPtTEnd->fT - oStartPtT->fT; 98 double oStartRange = coin->fOppPtTEnd->fT - oStartPtT->fT;
99 if (!oStartRange) {
100 return false;
101 }
96 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange; 102 double oStartPart = (oTest->t() - oStartPtT->fT) / oStartRange;
97 if (startPart == oStartPart) { 103 if (startPart == oStartPart) {
98 return false; 104 return false;
99 } 105 }
100 SkOpPtT* newPt; 106 SkOpPtT* newPt;
101 if (startPart < oStartPart) { 107 if (startPart < oStartPart) {
102 double newT = oStartPtT->fT + oStartRange * startPart; 108 double newT = oStartPtT->fT + oStartRange * startPart;
103 newPt = oStart->segment()->addT(newT, SkOpSegment::kAllowAli as, allocator); 109 newPt = oStart->segment()->addT(newT, SkOpSegment::kAllowAli as, allocator);
104 newPt->fPt = test->pt(); 110 newPt->fPt = test->pt();
105 test->ptT()->addOpp(newPt); 111 test->ptT()->addOpp(newPt);
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f T)); 664 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f T));
659 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f T)); 665 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f T));
660 return *overS < *overE; 666 return *overS < *overE;
661 } 667 }
662 668
663 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S kOpPtT* testS, 669 bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const S kOpPtT* testS,
664 const SkOpPtT* testE) const { 670 const SkOpPtT* testE) const {
665 return testS->segment()->testForCoincidence(testS, testE, testS->span(), 671 return testS->segment()->testForCoincidence(testS, testE, testS->span(),
666 testE->span(), outer->fCoinPtTStart->segment(), 120000); // FIXME: replace with tuned 672 testE->span(), outer->fCoinPtTStart->segment(), 120000); // FIXME: replace with tuned
667 } 673 }
OLDNEW
« no previous file with comments | « no previous file | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698