remove dead code

Use code coverage and a new '-c' flag to find
and remove unneeded code.

TBR=reed@google.com

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2397593002

patch from issue 2397593002 at patchset 1 (http://crrev.com/2397593002#ps1)

Change-Id: I741a82de9191146c10457d4c0b9cb9605dff2069
Reviewed-on: https://skia-review.googlesource.com/2983
Reviewed-by: Cary Clark <caryclark@google.com>
This commit is contained in:
Cary Clark 2016-10-05 08:51:39 -04:00
parent 85a45d93ed
commit e47ae2998c
14 changed files with 35 additions and 485 deletions

View File

@ -635,17 +635,6 @@ void SkOpAngle::insert(SkOpAngle* angle) {
}
last = next;
next = next->fNext;
if (last == this) {
if (next->fUnorderable) {
fUnorderable = true;
} else {
globalState()->setAngleCoincidence();
this->fNext = angle;
angle->fNext = next;
angle->fCheckCoincidence = true;
}
return;
}
} while (true);
}

View File

@ -125,26 +125,6 @@ bool SkCoincidentSpans::contains(const SkOpPtT* s, const SkOpPtT* e) const {
}
}
// returns the number of segment span's contained by this, or -1 if inconsistent
int SkCoincidentSpans::spanCount() const {
// most commonly, concidence are one span long; check for that first
const SkOpSpanBase* start = coinPtTStart()->span();
const SkOpSpanBase* end = coinPtTEnd()->span();
int coinIntervals = 0;
while (start != end) {
coinIntervals++;
start = start->upCast()->next();
}
const SkOpSpanBase* oppStart = (flipped() ? oppPtTEnd() : oppPtTStart())->span();
const SkOpSpanBase* oppEnd = (flipped() ? oppPtTStart() : oppPtTEnd())->span();
int oppIntervals = 0;
while (oppStart != oppEnd) {
oppIntervals++;
oppStart = oppStart->upCast()->next();
}
return coinIntervals == oppIntervals ? coinIntervals : -1;
}
// A coincident span is unordered if the pairs of points in the main and opposite curves'
// t values do not ascend or descend. For instance, if a tightly arced quadratic is
// coincident with another curve, it may intersect it out of order.
@ -179,33 +159,6 @@ bool SkCoincidentSpans::ordered() const {
return true;
}
// returns true if the point is on a coincident edge, and if it is the start of that edge
bool SkOpCoincidence::edge(const SkOpPtT* test, bool* start) const {
SkCoincidentSpans* coinRec = fHead;
if (!coinRec) {
return false;
}
do {
if (coinRec->coinPtTStart() == test) {
*start = true;
return true;
}
if (coinRec->coinPtTEnd() == test) {
*start = false;
return true;
}
if (coinRec->oppPtTStart() == test) {
*start = !coinRec->flipped();
return true;
}
if (coinRec->coinPtTEnd() == test) {
*start = coinRec->flipped();
return true;
}
} while ((coinRec = coinRec->next()));
return false;
}
// if there is an existing pair that overlaps the addition, extend it
bool SkOpCoincidence::extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) {
@ -533,47 +486,6 @@ bool SkOpCoincidence::addExpanded(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
return true;
}
// checks to see if coincidence has already been found
bool SkOpCoincidence::alreadyAdded(const SkCoincidentSpans* check, const SkCoincidentSpans* outer,
const SkOpPtT* over1s, const SkOpPtT* over1e) const {
do {
if (check->oppPtTStart() == outer->coinPtTStart() && check->coinPtTStart() == over1s
&& check->oppPtTEnd() == outer->coinPtTEnd() && check->coinPtTEnd() == over1e) {
return true;
}
if (check->coinPtTStart() == outer->coinPtTStart() && check->oppPtTStart() == over1s
&& check->coinPtTEnd() == outer->coinPtTEnd() && check->oppPtTEnd() == over1e) {
return true;
}
if (check->startEquals(outer->oppPtTStart()->span(), over1s->span())) {
SkDEBUGCODE(check->debugStartCheck(outer->oppPtTEnd()->span(), over1e->span(),
fGlobalState));
return true;
}
if (check->startEquals(over1s->span(), outer->coinPtTStart()->span())) {
SkDEBUGCODE(check->debugStartCheck(over1e->span(), outer->oppPtTEnd()->span(),
fGlobalState));
return true;
}
} while ((check = check->next()));
return false;
}
/* Please keep this in sync with debugAddIfMissing() */
bool SkOpCoincidence::addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s,
SkOpPtT* over1e) {
SkASSERT(fTop);
if (this->alreadyAdded(fTop, outer, over1s, over1e)) {
return false;
}
if (fHead && this->alreadyAdded(fHead, outer, over1s, over1e)) {
return false;
}
this->add(outer->coinPtTStart(), outer->coinPtTEnd(), over1s, over1e);
this->debugValidate();
return true;
}
// given a t span, map the same range on the coincident span
/*
the curves may not scale linearly, so interpolation may only happen within known points
@ -928,55 +840,20 @@ bool SkOpCoincidence::addMissing(bool* added DEBUG_COIN_DECLARE_PARAMS()) {
bool SkOpCoincidence::addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg1o,
const SkOpSegment* seg2, const SkOpSegment* seg2o,
const SkOpPtT* overS, const SkOpPtT* overE) {
const SkOpPtT* s1, * e1, * s2, * e2;
if (!(s1 = overS->find(seg1))) {
return true;
}
if (!(e1 = overE->find(seg1))) {
return true;
}
if (s1 == e1) {
return true;
}
if (approximately_equal_half(s1->fT, e1->fT)) {
return false;
}
const SkOpPtT* s1 = overS->find(seg1);
const SkOpPtT* e1 = overE->find(seg1);
if (!s1->starter(e1)->span()->upCast()->windValue()) {
if (!(s1 = overS->find(seg1o))) {
return true;
}
if (!(e1 = overE->find(seg1o))) {
return true;
}
if (s1 == e1) {
return true;
}
s1 = overS->find(seg1o);
e1 = overE->find(seg1o);
if (!s1->starter(e1)->span()->upCast()->windValue()) {
return true;
}
}
if (!(s2 = overS->find(seg2))) {
return true;
}
if (!(e2 = overE->find(seg2))) {
return true;
}
if (s2 == e2) {
return true;
}
if (approximately_equal_half(s2->fT, e2->fT)) {
return false;
}
const SkOpPtT* s2 = overS->find(seg2);
const SkOpPtT* e2 = overE->find(seg2);
if (!s2->starter(e2)->span()->upCast()->windValue()) {
if (!(s2 = overS->find(seg2o))) {
return true;
}
if (!(e2 = overE->find(seg2o))) {
return true;
}
if (s2 == e2) {
return true;
}
s2 = overS->find(seg2o);
e2 = overE->find(seg2o);
if (!s2->starter(e2)->span()->upCast()->windValue()) {
return true;
}
@ -992,59 +869,6 @@ bool SkOpCoincidence::addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg
return true;
}
/* look for pairs of coincidence with no common segments
if there's no existing coincidence found that matches up the segments, and
if the pt-t list for one contains the other, create coincident pairs for what's left */
bool SkOpCoincidence::addUncommon() {
SkCoincidentSpans* outer = fHead;
if (!outer) {
return false;
}
bool added = false;
fTop = outer;
fHead = nullptr;
do {
// addifmissing can modify the list that this is walking
// save head so that walker can iterate over old data unperturbed
// addifmissing adds to head freely then add saved head in the end
const SkOpSegment* outerCoin = outer->coinPtTStart()->segment();
const SkOpSegment* outerOpp = outer->oppPtTStart()->segment();
if (outerCoin->done() || outerOpp->done()) {
continue;
}
SkCoincidentSpans* inner = outer;
while ((inner = inner->next())) {
this->debugValidate();
const SkOpSegment* innerCoin = inner->coinPtTStart()->segment();
const SkOpSegment* innerOpp = inner->oppPtTStart()->segment();
if (innerCoin->done() || innerOpp->done()) {
continue;
}
// check to see if outer span overlaps the inner span
// look for inner segment in pt-t list
// if present, and if t values are in coincident range
// add two pairs of new coincidence
const SkOpPtT* testS = outer->coinPtTStart()->contains(innerCoin);
const SkOpPtT* testE = outer->coinPtTEnd()->contains(innerCoin);
if (testS && testS->fT >= inner->coinPtTStart()->fT
&& testE && testE->fT <= inner->coinPtTEnd()->fT
&& this->testForCoincidence(outer, testS, testE)) {
added |= this->addIfMissing(outer, testS, testE);
} else {
testS = inner->coinPtTStart()->contains(outerCoin);
testE = inner->coinPtTEnd()->contains(outerCoin);
if (testS && testS->fT >= outer->coinPtTStart()->fT
&& testE && testE->fT <= outer->coinPtTEnd()->fT
&& this->testForCoincidence(inner, testS, testE)) {
added |= this->addIfMissing(inner, testS, testE);
}
}
}
} while ((outer = outer->next()));
this->restoreHead();
return added;
}
bool SkOpCoincidence::contains(const SkOpSegment* seg, const SkOpSegment* opp, double oppT) const {
if (this->contains(fHead, seg, opp, oppT)) {
return true;
@ -1128,11 +952,11 @@ void SkOpCoincidence::correctEnds(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
}
// walk span sets in parallel, moving winding from one to the other
bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
void SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
DEBUG_SET_PHASE();
SkCoincidentSpans* coin = fHead;
if (!coin) {
return true;
return;
}
do {
SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast();
@ -1240,9 +1064,6 @@ bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
if (next == end) {
break;
}
if (!next->upCastable()) {
return false;
}
start = next->upCast();
// if the opposite ran out too soon, just reuse the last span
if (!oNext || !oNext->upCastable()) {
@ -1251,7 +1072,6 @@ bool SkOpCoincidence::apply(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
oStart = oNext->upCast();
} while (true);
} while ((coin = coin->next()));
return true;
}
// Please keep this in sync with debugRelease()
@ -1356,7 +1176,7 @@ bool SkOpCoincidence::expand(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
return expanded;
}
bool SkOpCoincidence::findOverlaps(SkOpCoincidence* overlaps DEBUG_COIN_DECLARE_PARAMS()) const {
void SkOpCoincidence::findOverlaps(SkOpCoincidence* overlaps DEBUG_COIN_DECLARE_PARAMS()) const {
DEBUG_SET_PHASE();
overlaps->fHead = overlaps->fTop = nullptr;
SkCoincidentSpans* outer = fHead;
@ -1381,15 +1201,12 @@ bool SkOpCoincidence::findOverlaps(SkOpCoincidence* overlaps DEBUG_COIN_DECLARE
|| (outerOpp == innerOpp && SkOpPtT::Overlaps(outer->oppPtTStart(),
outer->oppPtTEnd(), inner->oppPtTStart(), inner->oppPtTEnd(),
&overlapS, &overlapE))) {
if (!overlaps->addOverlap(outerCoin, outerOpp, innerCoin, innerOpp,
overlapS, overlapE)) {
return false;
}
SkAssertResult(overlaps->addOverlap(outerCoin, outerOpp, innerCoin, innerOpp,
overlapS, overlapE));
}
}
outer = outer->next();
}
return true;
}
void SkOpCoincidence::fixUp(SkOpPtT* deleted, const SkOpPtT* kept) {
@ -1438,20 +1255,19 @@ void SkOpCoincidence::fixUp(SkCoincidentSpans* coin, SkOpPtT* deleted, const SkO
// Please keep this in sync with debugMark()
/* this sets up the coincidence links in the segments when the coincidence crosses multiple spans */
bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
void SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
DEBUG_SET_PHASE();
SkCoincidentSpans* coin = fHead;
if (!coin) {
return true;
return;
}
do {
FAIL_IF(!coin->coinPtTStartWritable()->span()->upCastable());
SkOpSpan* start = coin->coinPtTStartWritable()->span()->upCast();
SkASSERT(!start->deleted());
SkOpSpanBase* end = coin->coinPtTEndWritable()->span();
SkASSERT(!end->deleted());
SkOpSpanBase* oStart = coin->oppPtTStartWritable()->span();
FAIL_IF(oStart->deleted());
SkASSERT(!oStart->deleted());
SkOpSpanBase* oEnd = coin->oppPtTEndWritable()->span();
SkASSERT(!oEnd->deleted());
bool flipped = coin->flipped();
@ -1468,19 +1284,12 @@ bool SkOpCoincidence::mark(DEBUG_COIN_DECLARE_ONLY_PARAMS()) {
SkOpSpanBase* oNext = oStart;
bool ordered = coin->ordered();
while ((next = next->upCast()->next()) != end) {
FAIL_IF(!next->upCastable());
if (!next->upCast()->insertCoincidence(oSegment, flipped, ordered)) {
return false;
}
SkAssertResult(next->upCast()->insertCoincidence(oSegment, flipped, ordered));
}
while ((oNext = oNext->upCast()->next()) != oEnd) {
FAIL_IF(!oNext->upCastable());
if (!oNext->upCast()->insertCoincidence(segment, flipped, ordered)) {
return false;
}
SkAssertResult(oNext->upCast()->insertCoincidence(segment, flipped, ordered));
}
} while ((coin = coin->next()));
return true;
}
// Please keep in sync with debugMarkCollapsed()
@ -1552,9 +1361,3 @@ void SkOpCoincidence::release(const SkOpSegment* deleted) {
}
} while ((coin = coin->next()));
}
bool SkOpCoincidence::testForCoincidence(const SkCoincidentSpans* outer, const SkOpPtT* testS,
const SkOpPtT* testE) const {
return testS->segment()->testForCoincidence(testS, testE, testS->span(),
testE->span(), outer->coinPtTStart()->segment());
}

View File

@ -74,7 +74,6 @@ public:
SkOpPtT* oppPtTStartWritable() const { return const_cast<SkOpPtT*>(fOppPtTStart); }
SkOpPtT* oppPtTEndWritable() const { return const_cast<SkOpPtT*>(fOppPtTEnd); }
bool ordered() const;
int spanCount() const;
void set(SkCoincidentSpans* next, const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd);
@ -123,10 +122,6 @@ public:
void setNext(SkCoincidentSpans* next) { fNext = next; }
bool startEquals(const SkOpSpanBase* outer, const SkOpSpanBase* over) const {
return fCoinPtTStart->span() == over && fOppPtTStart->span() == outer;
}
private:
SkCoincidentSpans* fNext;
const SkOpPtT* fCoinPtTStart;
@ -155,8 +150,7 @@ public:
bool addEndMovedSpans(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool addExpanded(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool addMissing(bool* added DEBUG_COIN_DECLARE_PARAMS());
bool addUncommon();
bool apply(DEBUG_COIN_DECLARE_ONLY_PARAMS());
void apply(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool contains(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd,
const SkOpPtT* oppPtTStart, const SkOpPtT* oppPtTEnd) const;
void correctEnds(DEBUG_COIN_DECLARE_ONLY_PARAMS());
@ -203,7 +197,6 @@ public:
}
#if DEBUG_COIN
void debugRemoveCollapsed(SkPathOpsDebug::GlitchLog* ) const;
void debugRelease(SkPathOpsDebug::GlitchLog* , const SkCoincidentSpans* ,
const SkCoincidentSpans* ) const;
void debugRelease(SkPathOpsDebug::GlitchLog* , const SkOpSegment* ) const;
@ -216,11 +209,10 @@ public:
void debugValidate() const;
void dump() const;
bool edge(const SkOpPtT* , bool* start) const;
bool expand(DEBUG_COIN_DECLARE_ONLY_PARAMS());
bool extend(const SkOpPtT* coinPtTStart, const SkOpPtT* coinPtTEnd, const SkOpPtT* oppPtTStart,
const SkOpPtT* oppPtTEnd);
bool findOverlaps(SkOpCoincidence* DEBUG_COIN_DECLARE_PARAMS()) const;
void findOverlaps(SkOpCoincidence* DEBUG_COIN_DECLARE_PARAMS()) const;
void fixUp(SkOpPtT* deleted, const SkOpPtT* kept);
SkOpGlobalState* globalState() {
@ -235,7 +227,7 @@ public:
return !fHead && !fTop;
}
bool mark(DEBUG_COIN_DECLARE_ONLY_PARAMS());
void mark(DEBUG_COIN_DECLARE_ONLY_PARAMS());
void markCollapsed(SkOpPtT* );
static bool Ordered(const SkOpPtT* coinPtTStart, const SkOpPtT* oppPtTStart) {
@ -256,13 +248,6 @@ private:
bool addEndMovedSpans(const SkOpSpan* base, const SkOpSpanBase* testSpan);
bool addEndMovedSpans(const SkOpPtT* ptT);
bool addIfMissing(const SkCoincidentSpans* outer, SkOpPtT* over1s, SkOpPtT* over1e);
bool addIfMissing(const SkCoincidentSpans* outer, const SkOpPtT* over1s,
const SkOpPtT* over1e) {
return addIfMissing(outer, const_cast<SkOpPtT*>(over1s), const_cast<SkOpPtT*>(over1e));
}
bool addIfMissing(const SkOpPtT* over1s, const SkOpPtT* over2s,
double tStart, double tEnd, SkOpSegment* coinSeg, SkOpSegment* oppSeg,
bool* added
@ -272,8 +257,6 @@ private:
bool addOverlap(const SkOpSegment* seg1, const SkOpSegment* seg1o,
const SkOpSegment* seg2, const SkOpSegment* seg2o,
const SkOpPtT* overS, const SkOpPtT* overE);
bool alreadyAdded(const SkCoincidentSpans* check, const SkCoincidentSpans* outer,
const SkOpPtT* over1s, const SkOpPtT* over1e) const;
bool checkOverlap(SkCoincidentSpans* check,
const SkOpSegment* coinSeg, const SkOpSegment* oppSeg,
double coinTs, double coinTe, double oppTs, double oppTe,
@ -303,8 +286,6 @@ private:
bool release(SkCoincidentSpans* coin, SkCoincidentSpans* );
void releaseDeleted(SkCoincidentSpans* );
void restoreHead();
bool testForCoincidence(const SkCoincidentSpans* outer, const SkOpPtT* testS,
const SkOpPtT* testE) const;
// return coinPtT->segment()->t mapped from overS->fT <= t <= overE->fT
static double TRange(const SkOpPtT* overS, double t, const SkOpSegment* coinPtT
SkDEBUGPARAMS(const SkOpPtT* overE));

View File

@ -232,11 +232,7 @@ public:
SkOpSegment* segment = &fHead;
bool result = false;
do {
if (fState->angleCoincidence()) {
#if DEBUG_ANGLE
segment->debugCheckAngleCoin();
#endif
} else if (segment->missingCoincidence()) {
if (segment->missingCoincidence()) {
result = true;
}
segment = segment->next();

View File

@ -321,14 +321,6 @@ void SkOpSegment::clearOne(SkOpSpan* span) {
this->markDone(span);
}
// Quads and conics collapse if the end points are the same, because
// the curve doesn't enclose an area.
bool SkOpSegment::collapsed() const {
// FIXME: cubics can have also collapsed -- need to check if the
// control points are on a line with the end points
return fVerb < SkPath::kCubic_Verb && fHead.pt() == fTail.pt();
}
bool SkOpSegment::collapsed(double s, double e) const {
const SkOpSpanBase* span = &fHead;
do {
@ -490,6 +482,8 @@ void SkOpSegment::release(const SkOpSpan* span) {
SkOPASSERT(fCount >= fDoneCount);
}
#if DEBUG_ANGLE
// called only by debugCheckNearCoincidence
double SkOpSegment::distSq(double t, const SkOpAngle* oppAngle) const {
SkDPoint testPt = this->dPtAtT(t);
SkDLine testPerp = {{ testPt, testPt }};
@ -511,6 +505,7 @@ double SkOpSegment::distSq(double t, const SkOpAngle* oppAngle) const {
}
return closestDistSq;
}
#endif
/*
The M and S variable name parts stand for the operators.
@ -1534,60 +1529,6 @@ void SkOpSegment::sortAngles() {
} while (!span->final() && (span = span->upCast()->next()));
}
// return true if midpoints were computed
bool SkOpSegment::subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end,
SkOpCurve* edge) const {
SkASSERT(start != end);
const SkOpPtT& startPtT = *start->ptT();
const SkOpPtT& endPtT = *end->ptT();
SkDEBUGCODE(edge->fVerb = fVerb);
edge->fPts[0] = startPtT.fPt;
int points = SkPathOpsVerbToPoints(fVerb);
edge->fPts[points] = endPtT.fPt;
edge->fWeight = 1;
if (fVerb == SkPath::kLine_Verb) {
return false;
}
double startT = startPtT.fT;
double endT = endPtT.fT;
if ((startT == 0 || endT == 0) && (startT == 1 || endT == 1)) {
// don't compute midpoints if we already have them
if (fVerb == SkPath::kQuad_Verb) {
edge->fPts[1] = fPts[1];
return false;
}
if (fVerb == SkPath::kConic_Verb) {
edge->fPts[1] = fPts[1];
edge->fWeight = fWeight;
return false;
}
SkASSERT(fVerb == SkPath::kCubic_Verb);
if (start < end) {
edge->fPts[1] = fPts[1];
edge->fPts[2] = fPts[2];
return false;
}
edge->fPts[1] = fPts[2];
edge->fPts[2] = fPts[1];
return false;
}
const SkDPoint sub[2] = {{ edge->fPts[0].fX, edge->fPts[0].fY},
{edge->fPts[points].fX, edge->fPts[points].fY }};
if (fVerb == SkPath::kQuad_Verb) {
edge->fPts[1] = SkDQuad::SubDivide(fPts, sub[0], sub[1], startT, endT).asSkPoint();
} else if (fVerb == SkPath::kConic_Verb) {
edge->fPts[1] = SkDConic::SubDivide(fPts, fWeight, sub[0], sub[1],
startT, endT, &edge->fWeight).asSkPoint();
} else {
SkASSERT(fVerb == SkPath::kCubic_Verb);
SkDPoint ctrl[2];
SkDCubic::SubDivide(fPts, sub[0], sub[1], startT, endT, ctrl);
edge->fPts[1] = ctrl[0].asSkPoint();
edge->fPts[2] = ctrl[1].asSkPoint();
}
return true;
}
bool SkOpSegment::subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end,
SkDCurve* edge) const {
SkASSERT(start != end);

View File

@ -107,7 +107,6 @@ public:
}
void calcAngles();
bool collapsed() const;
bool collapsed(double startT, double endT) const;
static void ComputeOneSum(const SkOpAngle* baseAngle, SkOpAngle* nextAngle,
SkOpAngle::IncludeType );
@ -186,8 +185,9 @@ public:
}
#endif
void release(const SkOpSpan* );
#if DEBUG_ANGLE
double distSq(double t, const SkOpAngle* opp) const;
#endif
bool done() const {
SkOPASSERT(fDoneCount <= fCount);
@ -331,15 +331,10 @@ public:
return ptsDisjoint(span.fT, span.fPt, t, pt);
}
bool ptsDisjoint(const SkOpSpanBase* span, const SkOpSpanBase* test) const {
SkASSERT(this == span->segment());
SkASSERT(this == test->segment());
return ptsDisjoint(span->t(), span->pt(), test->t(), test->pt());
}
bool ptsDisjoint(double t1, const SkPoint& pt1, double t2, const SkPoint& pt2) const;
void rayCheck(const SkOpRayHit& base, SkOpRayDir dir, SkOpRayHit** hits, SkChunkAlloc*);
void release(const SkOpSpan* );
#if DEBUG_COIN
void resetDebugVisited() const {
@ -391,7 +386,6 @@ public:
}
bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkDCurve* result) const;
bool subDivide(const SkOpSpanBase* start, const SkOpSpanBase* end, SkOpCurve* result) const;
const SkOpSpanBase* tail() const {
return &fTail;

View File

@ -28,16 +28,6 @@ const SkOpPtT* SkOpPtT::active() const {
return this;
}
bool SkOpPtT::collapsed(const SkOpPtT* check) const {
if (fPt != check->fPt) {
return false;
}
SkASSERT(this != check);
const SkOpSegment* segment = this->segment();
SkASSERT(segment == check->segment());
return segment->collapsed();
}
bool SkOpPtT::contains(const SkOpPtT* check) const {
SkOPASSERT(this != check);
const SkOpPtT* ptT = this;
@ -146,38 +136,6 @@ SkOpPtT* SkOpPtT::prev() {
return result;
}
SkOpPtT* SkOpPtT::remove(const SkOpPtT* kept) {
SkOpPtT* prev = this;
do {
SkOpPtT* next = prev->fNext;
if (next == this) {
prev->removeNext(kept);
SkASSERT(prev->fNext != prev);
fDeleted = true;
return prev;
}
prev = next;
} while (prev != this);
SkASSERT(0);
return nullptr;
}
void SkOpPtT::removeNext(const SkOpPtT* kept) {
SkASSERT(this->fNext);
SkOpPtT* next = this->fNext;
SkASSERT(this != next->fNext);
this->fNext = next->fNext;
SkOpSpanBase* span = next->span();
SkOpCoincidence* coincidence = span->globalState()->coincidence();
if (coincidence) {
coincidence->fixUp(next, kept);
}
next->setDeleted();
if (span->ptT() == next) {
span->upCast()->release(kept);
}
}
const SkOpSegment* SkOpPtT::segment() const {
return span()->segment();
}
@ -202,26 +160,6 @@ void SkOpSpanBase::addOpp(SkOpSpanBase* opp) {
this->checkForCollapsedCoincidence();
}
// Please keep this in sync with debugMergeContained()
void SkOpSpanBase::mergeContained(const SkPathOpsBounds& bounds) {
// while adjacent spans' points are contained by the bounds, merge them
SkOpSpanBase* prev = this;
SkOpSegment* seg = this->segment();
while ((prev = prev->prev()) && bounds.contains(prev->pt()) && !seg->ptsDisjoint(prev, this)) {
this->mergeMatches(prev);
this->addOpp(prev);
}
SkOpSpanBase* next = this;
while (next->upCastable() && (next = next->upCast()->next())
&& bounds.contains(next->pt()) && !seg->ptsDisjoint(this, next)) {
this->mergeMatches(next);
this->addOpp(next);
}
#if DEBUG_COINCIDENCE
this->globalState()->coincidence()->debugValidate();
#endif
}
bool SkOpSpanBase::collapsed(double s, double e) const {
const SkOpPtT* start = &fPtT;
const SkOpPtT* walk = start;

View File

@ -41,7 +41,6 @@ public:
bool alias() const;
bool coincident() const { return fCoincident; }
bool collapsed(const SkOpPtT* ) const;
bool contains(const SkOpPtT* ) const;
bool contains(const SkOpSegment*, const SkPoint& ) const;
bool contains(const SkOpSegment*, double t) const;
@ -137,8 +136,6 @@ public:
bool ptAlreadySeen(const SkOpPtT* head) const;
SkOpPtT* prev();
SkOpPtT* remove(const SkOpPtT* kept);
void removeNext(const SkOpPtT* kept);
const SkOpSegment* segment() const;
SkOpSegment* segment();
@ -241,8 +238,6 @@ public:
#if DEBUG_COIN
void debugInsertCoinEnd(SkPathOpsDebug::GlitchLog* ,
const SkOpSpanBase* ) const;
void debugMergeContained(SkPathOpsDebug::GlitchLog* ,
const SkPathOpsBounds& bounds, bool* deleted) const;
void debugMergeMatches(SkPathOpsDebug::GlitchLog* log,
const SkOpSpanBase* opp) const;
#endif
@ -293,7 +288,6 @@ public:
}
void merge(SkOpSpan* span);
void mergeContained(const SkPathOpsBounds& bounds);
void mergeMatches(SkOpSpanBase* opp);
const SkOpSpan* prev() const {
@ -426,10 +420,6 @@ public:
return false;
}
bool checkAlreadyAdded() const {
return fAlreadyAdded;
}
bool clearCoincident() {
SkASSERT(!final());
if (fCoincident == this) {

View File

@ -259,7 +259,7 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
if (!coincidence->addEndMovedSpans(DEBUG_COIN_ONLY_PARAMS())) {
return false;
}
const int SAFETY_COUNT = 100; // FIXME: tune
const int SAFETY_COUNT = 3;
int safetyHatch = SAFETY_COUNT;
// look for coincidence present in A-B and A-C but missing in B-C
do {
@ -276,8 +276,6 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
}
move_nearby(contourList DEBUG_ITER_PARAMS(SAFETY_COUNT - safetyHatch - 1));
} while (true);
// FIXME: only call this if addMissing modified something when returning false
move_nearby(contourList DEBUG_COIN_PARAMS());
// check to see if, loosely, coincident ranges may be expanded
if (coincidence->expand(DEBUG_COIN_ONLY_PARAMS())) {
bool added;
@ -296,20 +294,15 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
if (!coincidence->addExpanded(DEBUG_PHASE_ONLY_PARAMS(kWalking))) {
return false;
}
coincidence->correctEnds(DEBUG_COIN_ONLY_PARAMS());
// mark spans of coincident segments as coincident
if (!coincidence->mark(DEBUG_COIN_ONLY_PARAMS())) {
return false;
}
coincidence->mark(DEBUG_COIN_ONLY_PARAMS());
// look for coincidence lines and curves undetected by intersection
if (missing_coincidence(contourList DEBUG_COIN_PARAMS())) {
(void) coincidence->expand(DEBUG_PHASE_ONLY_PARAMS(kIntersecting));
if (!coincidence->addExpanded(DEBUG_COIN_ONLY_PARAMS())) {
return false;
}
if (!coincidence->mark(DEBUG_PHASE_ONLY_PARAMS(kWalking))) {
return false;
}
coincidence->mark(DEBUG_PHASE_ONLY_PARAMS(kWalking));
} else {
(void) coincidence->expand(DEBUG_COIN_ONLY_PARAMS());
}
@ -320,14 +313,10 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
do {
SkOpCoincidence* pairs = overlaps.isEmpty() ? coincidence : &overlaps;
// adjust the winding value to account for coincident edges
if (!pairs->apply(DEBUG_ITER_ONLY_PARAMS(SAFETY_COUNT - safetyHatch))) {
return false;
}
pairs->apply(DEBUG_ITER_ONLY_PARAMS(SAFETY_COUNT - safetyHatch));
// For each coincident pair that overlaps another, when the receivers (the 1st of the pair)
// are different, construct a new pair to resolve their mutual span
if (!pairs->findOverlaps(&overlaps DEBUG_ITER_PARAMS(SAFETY_COUNT - safetyHatch))) {
return false;
}
pairs->findOverlaps(&overlaps DEBUG_ITER_PARAMS(SAFETY_COUNT - safetyHatch));
if (!--safetyHatch) {
SkASSERT(globalState->debugSkipAssert());
return false;
@ -335,12 +324,6 @@ bool HandleCoincidence(SkOpContourHead* contourList, SkOpCoincidence* coincidenc
} while (!overlaps.isEmpty());
calc_angles(contourList DEBUG_COIN_PARAMS());
sort_angles(contourList);
if (globalState->angleCoincidence()) {
(void) missing_coincidence(contourList DEBUG_COIN_PARAMS());
if (!coincidence->apply(DEBUG_COIN_ONLY_PARAMS())) {
return false;
}
}
#if DEBUG_COINCIDENCE_VERBOSE
coincidence->debugShowCoincidence();
#endif

View File

@ -437,7 +437,6 @@ void SkPathOpsDebug::DumpGlitchType(GlitchType glitchType) {
case kMarkCoinInsert_Glitch: SkDebugf(" MarkCoinInsert"); break;
case kMarkCoinMissing_Glitch: SkDebugf(" MarkCoinMissing"); break;
case kMarkCoinStart_Glitch: SkDebugf(" MarkCoinStart"); break;
case kMergeContained_Glitch: SkDebugf(" MergeContained"); break;
case kMergeMatches_Glitch: SkDebugf(" MergeMatches"); break;
case kMissingCoin_Glitch: SkDebugf(" MissingCoin"); break;
case kMissingDone_Glitch: SkDebugf(" MissingDone"); break;
@ -2307,11 +2306,7 @@ void SkOpContour::debugMissingCoincidence(SkPathOpsDebug::GlitchLog* log) const
const SkOpSegment* segment = &fHead;
// bool result = false;
do {
if (fState->angleCoincidence()) {
// #if DEBUG_ANGLE
// segment->debugCheckAngleCoin();
// #endif
} else if (segment->debugMissingCoincidence(log), false) {
if (segment->debugMissingCoincidence(log), false) {
// result = true;
}
segment = segment->next();
@ -2468,42 +2463,6 @@ void SkOpSpanBase::debugInsertCoinEnd(SkPathOpsDebug::GlitchLog* log, const SkOp
debugValidate();
}
// Commented-out lines keep this in sync with mergeContained()
void SkOpSpanBase::debugMergeContained(SkPathOpsDebug::GlitchLog* log, const SkPathOpsBounds& bounds, bool* deleted) const {
// while adjacent spans' points are contained by the bounds, merge them
const SkOpSpanBase* prev = this;
const SkOpSegment* seg = this->segment();
while ((prev = prev->prev()) && bounds.contains(prev->pt()) && !seg->ptsDisjoint(prev, this)) {
if (prev->prev()) {
log->record(SkPathOpsDebug::kMergeContained_Glitch, this, prev);
} else if (this->final()) {
log->record(SkPathOpsDebug::kMergeContained_Glitch, this, prev);
// return;
} else {
log->record(SkPathOpsDebug::kMergeContained_Glitch, prev, this);
}
}
const SkOpSpanBase* current = this;
const SkOpSpanBase* next = this;
while (next->upCastable() && (next = next->upCast()->next())
&& bounds.contains(next->pt()) && !seg->ptsDisjoint(this, next)) {
if (!current->prev() && next->final()) {
log->record(SkPathOpsDebug::kMergeContained_Glitch, next, current);
current = next;
}
if (current->prev()) {
log->record(SkPathOpsDebug::kMergeContained_Glitch, next, current);
current = next;
} else {
log->record(SkPathOpsDebug::kMergeContained_Glitch, next, current);
current = next;
}
}
#if DEBUG_COINCIDENCE
// this->globalState()->coincidence()->debugValidate();
#endif
}
// Commented-out lines keep this in sync with mergeMatches()
// Look to see if pt-t linked list contains same segment more than once
// if so, and if each pt-t is directly pointed to by spans in that segment,

View File

@ -259,7 +259,6 @@ public:
kMarkCoinInsert_Glitch,
kMarkCoinMissing_Glitch,
kMarkCoinStart_Glitch,
kMergeContained_Glitch,
kMergeMatches_Glitch,
kMissingCoin_Glitch,
kMissingDone_Glitch,

View File

@ -33,19 +33,6 @@ static bool bridgeWinding(SkOpContourHead* contourList, SkPathWriter* simple) {
SkOpSegment* next = current->findNextWinding(&chase, &nextStart, &nextEnd,
&unsortable);
if (!next) {
if (!unsortable && simple->hasMove()
&& current->verb() != SkPath::kLine_Verb
&& !simple->isClosed()) {
// FIXME: put in the next two lines to avoid handling already added
if (start->starter(end)->checkAlreadyAdded()) {
simple->finishContour();
} else if (!current->addCurveTo(start, end, simple)) {
return false;
}
if (!simple->isClosed()) {
SkPathOpsDebug::ShowActiveSpans(contourList);
}
}
break;
}
#if DEBUG_FLOW

View File

@ -233,7 +233,6 @@ SkOpGlobalState::SkOpGlobalState(SkOpContourHead* head,
, fContourHead(head)
, fNested(0)
, fWindingFailed(false)
, fAngleCoincidence(false)
, fPhase(SkOpPhase::kIntersecting)
SkDEBUGPARAMS(fDebugTestName(testName))
SkDEBUGPARAMS(fAngleID(0))

View File

@ -54,10 +54,6 @@ public:
return fAllocator;
}
bool angleCoincidence() const {
return fAngleCoincidence;
}
void bumpNested() {
++fNested;
}
@ -155,10 +151,6 @@ public:
fAllocatedOpSpan = true;
}
void setAngleCoincidence() {
fAngleCoincidence = true;
}
void setCoincidence(SkOpCoincidence* coincidence) {
fCoincidence = coincidence;
}
@ -191,7 +183,6 @@ private:
int fNested;
bool fAllocatedOpSpan;
bool fWindingFailed;
bool fAngleCoincidence;
SkOpPhase fPhase;
#ifdef SK_DEBUG
const char* fDebugTestName;