2015-01-16 15:04:10 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2014 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkPathOpsTSect.h"
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTCoincident<TCurve, OppCurve>::dump() const {
|
|
|
|
SkDebugf("t=%1.9g pt=(%1.9g,%1.9g)%s\n", fPerpT, fPerpPt.fX, fPerpPt.fY,
|
|
|
|
fCoincident ? " coincident" : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
const SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::debugSpan(int id) const {
|
|
|
|
const SkTSpan<TCurve, OppCurve>* test = fHead;
|
2015-03-26 14:52:43 +00:00
|
|
|
do {
|
|
|
|
if (test->debugID() == id) {
|
|
|
|
return test;
|
|
|
|
}
|
|
|
|
} while ((test = test->next()));
|
2015-08-27 14:41:13 +00:00
|
|
|
return nullptr;
|
2015-03-26 14:52:43 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
const SkTSpan<TCurve, OppCurve>* SkTSect<TCurve, OppCurve>::debugT(double t) const {
|
|
|
|
const SkTSpan<TCurve, OppCurve>* test = fHead;
|
2015-08-27 14:41:13 +00:00
|
|
|
const SkTSpan<TCurve, OppCurve>* closest = nullptr;
|
2015-03-26 14:52:43 +00:00
|
|
|
double bestDist = DBL_MAX;
|
|
|
|
do {
|
|
|
|
if (between(test->fStartT, t, test->fEndT)) {
|
|
|
|
return test;
|
|
|
|
}
|
|
|
|
double testDist = SkTMin(fabs(test->fStartT - t), fabs(test->fEndT - t));
|
|
|
|
if (bestDist > testDist) {
|
|
|
|
bestDist = testDist;
|
|
|
|
closest = test;
|
|
|
|
}
|
|
|
|
} while ((test = test->next()));
|
|
|
|
SkASSERT(closest);
|
|
|
|
return closest;
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dump() const {
|
2015-03-26 14:52:43 +00:00
|
|
|
dumpCommon(fHead);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int gDumpTSectNum;
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpBoth(SkTSect<OppCurve, TCurve>* opp) const {
|
2015-03-26 14:52:43 +00:00
|
|
|
#if DEBUG_T_SECT_DUMP <= 2
|
|
|
|
#if DEBUG_T_SECT_DUMP == 2
|
|
|
|
SkDebugf("%d ", ++gDumpTSectNum);
|
|
|
|
#endif
|
|
|
|
this->dump();
|
|
|
|
SkDebugf(" ");
|
|
|
|
opp->dump();
|
|
|
|
SkDebugf("\n");
|
|
|
|
#elif DEBUG_T_SECT_DUMP == 3
|
|
|
|
SkDebugf("<div id=\"sect%d\">\n", ++gDumpTSectNum);
|
|
|
|
if (this->fHead) {
|
|
|
|
this->dumpCurves();
|
|
|
|
}
|
|
|
|
if (opp->fHead) {
|
2015-04-20 15:31:59 +00:00
|
|
|
opp->dumpCurves();
|
2015-03-26 14:52:43 +00:00
|
|
|
}
|
|
|
|
SkDebugf("</div>\n\n");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpBounded(int id) const {
|
|
|
|
const SkTSpan<TCurve, OppCurve>* bounded = debugSpan(id);
|
2015-03-26 14:52:43 +00:00
|
|
|
if (!bounded) {
|
|
|
|
SkDebugf("no span matches %d\n", id);
|
|
|
|
return;
|
|
|
|
}
|
2015-04-20 15:31:59 +00:00
|
|
|
const SkTSpan<OppCurve, TCurve>* test = bounded->debugOpp()->fHead;
|
2015-03-26 14:52:43 +00:00
|
|
|
do {
|
|
|
|
if (test->findOppSpan(bounded)) {
|
|
|
|
test->dump();
|
|
|
|
}
|
|
|
|
} while ((test = test->next()));
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpBounds() const {
|
|
|
|
const SkTSpan<TCurve, OppCurve>* test = fHead;
|
|
|
|
do {
|
|
|
|
test->dumpBounds();
|
|
|
|
} while ((test = test->next()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpCoin() const {
|
2015-03-26 14:52:43 +00:00
|
|
|
dumpCommon(fCoincident);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpCoinCurves() const {
|
2015-03-26 14:52:43 +00:00
|
|
|
dumpCommonCurves(fCoincident);
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpCommon(const SkTSpan<TCurve, OppCurve>* test) const {
|
2015-03-24 14:28:17 +00:00
|
|
|
SkDebugf("id=%d", debugID());
|
|
|
|
if (!test) {
|
|
|
|
SkDebugf(" (empty)");
|
|
|
|
return;
|
|
|
|
}
|
2015-01-16 15:04:10 +00:00
|
|
|
do {
|
2015-03-24 14:28:17 +00:00
|
|
|
SkDebugf(" ");
|
2015-03-26 14:52:43 +00:00
|
|
|
test->dump();
|
2015-01-16 15:04:10 +00:00
|
|
|
} while ((test = test->next()));
|
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpCommonCurves(const SkTSpan<TCurve, OppCurve>* test) const {
|
2015-03-26 14:52:43 +00:00
|
|
|
do {
|
|
|
|
test->fPart.dumpID(test->debugID());
|
|
|
|
} while ((test = test->next()));
|
2015-03-24 20:55:33 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSect<TCurve, OppCurve>::dumpCurves() const {
|
2015-03-26 14:52:43 +00:00
|
|
|
dumpCommonCurves(fHead);
|
2015-01-16 15:04:10 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
const SkTSpan<TCurve, OppCurve>* SkTSpan<TCurve, OppCurve>::debugSpan(int id) const {
|
2015-08-27 14:41:13 +00:00
|
|
|
return SkDEBUGRELEASE(fDebugSect->debugSpan(id), nullptr);
|
2015-03-24 14:28:17 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
const SkTSpan<TCurve, OppCurve>* SkTSpan<TCurve, OppCurve>::debugT(double t) const {
|
2015-08-27 14:41:13 +00:00
|
|
|
return SkDEBUGRELEASE(fDebugSect->debugT(t), nullptr);
|
2015-03-26 14:52:43 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSpan<TCurve, OppCurve>::dump() const {
|
2015-03-26 14:52:43 +00:00
|
|
|
dumpID();
|
|
|
|
SkDebugf("=(%g,%g) [", fStartT, fEndT);
|
2015-04-20 15:31:59 +00:00
|
|
|
const SkTSpanBounded<OppCurve, TCurve>* testBounded = fBounded;
|
2015-03-26 14:52:43 +00:00
|
|
|
while (testBounded) {
|
2015-04-20 15:31:59 +00:00
|
|
|
const SkTSpan<OppCurve, TCurve>* span = testBounded->fBounded;
|
|
|
|
const SkTSpanBounded<OppCurve, TCurve>* next = testBounded->fNext;
|
2015-03-26 14:52:43 +00:00
|
|
|
span->dumpID();
|
|
|
|
if (next) {
|
|
|
|
SkDebugf(",");
|
|
|
|
}
|
|
|
|
testBounded = next;
|
2015-03-24 20:55:33 +00:00
|
|
|
}
|
2015-03-26 14:52:43 +00:00
|
|
|
SkDebugf("]");
|
2015-03-24 14:28:17 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSpan<TCurve, OppCurve>::dumpBounded(int id) const {
|
|
|
|
SkDEBUGCODE(fDebugSect->dumpBounded(id));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSpan<TCurve, OppCurve>::dumpBounds() const {
|
|
|
|
dumpID();
|
|
|
|
SkDebugf(" bounds=(%1.9g,%1.9g, %1.9g,%1.9g) boundsMax=%1.9g%s\n",
|
|
|
|
fBounds.fLeft, fBounds.fTop, fBounds.fRight, fBounds.fBottom, fBoundsMax,
|
|
|
|
fCollapsed ? " collapsed" : "");
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSpan<TCurve, OppCurve>::dumpCoin() const {
|
|
|
|
dumpID();
|
|
|
|
SkDebugf(" coinStart ");
|
|
|
|
fCoinStart.dump();
|
|
|
|
SkDebugf(" coinEnd ");
|
|
|
|
fCoinEnd.dump();
|
2015-03-26 14:52:43 +00:00
|
|
|
}
|
|
|
|
|
2015-04-20 15:31:59 +00:00
|
|
|
template<typename TCurve, typename OppCurve>
|
|
|
|
void SkTSpan<TCurve, OppCurve>::dumpID() const {
|
2015-03-24 20:55:33 +00:00
|
|
|
if (fCoinStart.isCoincident()) {
|
|
|
|
SkDebugf("%c", '*');
|
|
|
|
}
|
2015-03-26 14:52:43 +00:00
|
|
|
SkDebugf("%d", debugID());
|
2015-03-24 20:55:33 +00:00
|
|
|
if (fCoinEnd.isCoincident()) {
|
|
|
|
SkDebugf("%c", '*');
|
|
|
|
}
|
2015-01-16 15:04:10 +00:00
|
|
|
}
|