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

Unified Diff: src/pathops/SkOpCoincidence.cpp

Issue 1037953004: add conics to path ops (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix linux build Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/pathops/SkOpCoincidence.cpp
diff --git a/src/pathops/SkOpCoincidence.cpp b/src/pathops/SkOpCoincidence.cpp
index 45eee0a38ecc77e2986a21f3af4f3ade1956b0ce..f5804476eaaff0ace4c17831421a4d0ec27f24ce 100755
--- a/src/pathops/SkOpCoincidence.cpp
+++ b/src/pathops/SkOpCoincidence.cpp
@@ -22,7 +22,7 @@ void SkOpCoincidence::add(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* o
this->fHead = coinRec;
}
-static void tRange(const SkOpPtT* overS, const SkOpPtT* overE, double tStart, double tEnd,
+static void t_range(const SkOpPtT* overS, const SkOpPtT* overE, double tStart, double tEnd,
const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, double* coinTs, double* coinTe) {
double denom = overE->fT - overS->fT;
double start = 0 < denom ? tStart : tEnd;
@@ -38,8 +38,8 @@ bool SkOpCoincidence::addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over1e,
SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd, SkChunkAlloc* allocator) {
double coinTs, coinTe, oppTs, oppTe;
- tRange(over1s, over1e, tStart, tEnd, coinPtTStart, coinPtTEnd, &coinTs, &coinTe);
- tRange(over2s, over2e, tStart, tEnd, oppPtTStart, oppPtTEnd, &oppTs, &oppTe);
+ t_range(over1s, over1e, tStart, tEnd, coinPtTStart, coinPtTEnd, &coinTs, &coinTe);
+ t_range(over2s, over2e, tStart, tEnd, oppPtTStart, oppPtTEnd, &oppTs, &oppTe);
SkOpSegment* coinSeg = coinPtTStart->segment();
SkOpSegment* oppSeg = oppPtTStart->segment();
SkASSERT(coinSeg != oppSeg);
@@ -103,7 +103,7 @@ bool SkOpCoincidence::addMissing(SkChunkAlloc* allocator) {
double overS, overE;
if (this->overlap(outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, &overS, &overE)) {
- if (!addIfMissing(outer->fCoinPtTStart, outer->fCoinPtTEnd,
+ if (!this->addIfMissing(outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, overS, overE,
outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, allocator)) {
@@ -111,7 +111,7 @@ bool SkOpCoincidence::addMissing(SkChunkAlloc* allocator) {
}
} else if (this->overlap(outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, &overS, &overE)) {
- if (!addIfMissing(outer->fCoinPtTStart, outer->fCoinPtTEnd,
+ if (!this->addIfMissing(outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, overS, overE,
outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, allocator)) {
@@ -119,7 +119,7 @@ bool SkOpCoincidence::addMissing(SkChunkAlloc* allocator) {
}
} else if (this->overlap(outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, &overS, &overE)) {
- if (!addIfMissing(outer->fOppPtTStart, outer->fOppPtTEnd,
+ if (!this->addIfMissing(outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, overS, overE,
outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, allocator)) {
@@ -127,7 +127,7 @@ bool SkOpCoincidence::addMissing(SkChunkAlloc* allocator) {
}
} else if (this->overlap(outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, &overS, &overE)) {
- if (!addIfMissing(outer->fOppPtTStart, outer->fOppPtTEnd,
+ if (!this->addIfMissing(outer->fOppPtTStart, outer->fOppPtTEnd,
inner->fOppPtTStart, inner->fOppPtTEnd, overS, overE,
outer->fCoinPtTStart, outer->fCoinPtTEnd,
inner->fCoinPtTStart, inner->fCoinPtTEnd, allocator)) {
@@ -140,7 +140,6 @@ bool SkOpCoincidence::addMissing(SkChunkAlloc* allocator) {
return true;
}
-
bool SkOpCoincidence::contains(SkOpPtT* coinPtTStart, SkOpPtT* coinPtTEnd, SkOpPtT* oppPtTStart,
SkOpPtT* oppPtTEnd, bool flipped) {
SkCoincidentSpans* coin = fHead;
@@ -245,11 +244,9 @@ bool SkOpCoincidence::apply() {
break;
}
start = next->upCast();
- if (!oNext) {
- return false;
- }
- if (!oNext->upCastable()) {
- return false;
+ // if the opposite ran out too soon, just reuse the last span
+ if (!oNext || !oNext->upCastable()) {
+ oNext = oStart;
}
oStart = oNext->upCast();
} while (true);

Powered by Google App Engine
This is Rietveld 408576698