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

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

Issue 1140813002: deal more consistently with unsortable edges (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux warning Created 5 years, 7 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 | « src/pathops/SkOpCoincidence.h ('k') | src/pathops/SkOpSegment.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
11 bool SkOpCoincidence::extend(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT * oppPtTStart,
12 SkOpPtT* oppPtTEnd) {
13 // if there is an existing pair that overlaps the addition, extend it
14 SkCoincidentSpans* coinRec = fHead;
15 if (coinRec) {
16 do {
17 if (coinRec->fCoinPtTStart->segment() != coinPtTStart->segment()) {
18 continue;
19 }
20 if (coinRec->fOppPtTStart->segment() != oppPtTStart->segment()) {
21 continue;
22 }
23 if (coinRec->fCoinPtTStart->fT > coinPtTEnd->fT) {
24 continue;
25 }
26 if (coinRec->fCoinPtTEnd->fT < coinPtTStart->fT) {
27 continue;
28 }
29 if (coinRec->fCoinPtTStart->fT > coinPtTStart->fT) {
30 coinRec->fCoinPtTStart = coinPtTStart;
31 coinRec->fOppPtTStart = oppPtTStart;
32 }
33 if (coinRec->fCoinPtTEnd->fT < coinPtTEnd->fT) {
34 coinRec->fCoinPtTEnd = coinPtTEnd;
35 coinRec->fOppPtTEnd = oppPtTEnd;
36 }
37 return true;
38 } while ((coinRec = coinRec->fNext));
39 }
40 return false;
41 }
42
11 void SkOpCoincidence::add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* o ppPtTStart, 43 void SkOpCoincidence::add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* o ppPtTStart,
12 SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator) { 44 SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator) {
13 SkASSERT(coinPtTStart->fT < coinPtTEnd->fT); 45 SkASSERT(coinPtTStart->fT < coinPtTEnd->fT);
14 bool flipped = oppPtTStart->fT > oppPtTEnd->fT; 46 bool flipped = oppPtTStart->fT > oppPtTEnd->fT;
15 SkCoincidentSpans* coinRec = SkOpTAllocator<SkCoincidentSpans>::Allocate(all ocator); 47 SkCoincidentSpans* coinRec = SkOpTAllocator<SkCoincidentSpans>::Allocate(all ocator);
16 coinRec->fNext = this->fHead; 48 coinRec->fNext = this->fHead;
17 coinRec->fCoinPtTStart = coinPtTStart; 49 coinRec->fCoinPtTStart = coinPtTStart;
18 coinRec->fCoinPtTEnd = coinPtTEnd; 50 coinRec->fCoinPtTEnd = coinPtTEnd;
19 coinRec->fOppPtTStart = oppPtTStart; 51 coinRec->fOppPtTStart = oppPtTStart;
20 coinRec->fOppPtTEnd = oppPtTEnd; 52 coinRec->fOppPtTEnd = oppPtTEnd;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 413
382 bool SkOpCoincidence::overlap(const SkOpPtT* coin1s, const SkOpPtT* coin1e, 414 bool SkOpCoincidence::overlap(const SkOpPtT* coin1s, const SkOpPtT* coin1e,
383 const SkOpPtT* coin2s, const SkOpPtT* coin2e, double* overS, double* ove rE) const { 415 const SkOpPtT* coin2s, const SkOpPtT* coin2e, double* overS, double* ove rE) const {
384 if (coin1s->segment() != coin2s->segment()) { 416 if (coin1s->segment() != coin2s->segment()) {
385 return false; 417 return false;
386 } 418 }
387 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f T)); 419 *overS = SkTMax(SkTMin(coin1s->fT, coin1e->fT), SkTMin(coin2s->fT, coin2e->f T));
388 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f T)); 420 *overE = SkTMin(SkTMax(coin1s->fT, coin1e->fT), SkTMax(coin2s->fT, coin2e->f T));
389 return *overS < *overE; 421 return *overS < *overE;
390 } 422 }
OLDNEW
« no previous file with comments | « src/pathops/SkOpCoincidence.h ('k') | src/pathops/SkOpSegment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698