/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef PathOpsTSectDebug_DEFINED #define PathOpsTSectDebug_DEFINED #include "SkPathOpsTSect.h" template char SkTCoincident::dumpIsCoincidentStr() const { if (!!fMatch != fMatch) { return '?'; } return fMatch ? '*' : 0; } template void SkTCoincident::dump() const { SkDebugf("t=%1.9g pt=(%1.9g,%1.9g)%s\n", fPerpT, fPerpPt.fX, fPerpPt.fY, fMatch ? " match" : ""); } template const SkTSpan* SkTSect::debugSpan(int id) const { const SkTSpan* test = fHead; do { if (test->debugID() == id) { return test; } } while ((test = test->next())); return nullptr; } template const SkTSpan* SkTSect::debugT(double t) const { const SkTSpan* test = fHead; const SkTSpan* closest = nullptr; 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; } template void SkTSect::dump() const { dumpCommon(fHead); } extern int gDumpTSectNum; template void SkTSect::dumpBoth(SkTSect* opp) const { #if DEBUG_T_SECT_DUMP <= 2 #if DEBUG_T_SECT_DUMP == 2 SkDebugf("%d ", ++gDumpTSectNum); #endif this->dump(); SkDebugf("\n"); opp->dump(); SkDebugf("\n"); #elif DEBUG_T_SECT_DUMP == 3 SkDebugf("
\n", ++gDumpTSectNum); if (this->fHead) { this->dumpCurves(); } if (opp->fHead) { opp->dumpCurves(); } SkDebugf("
\n\n"); #endif } template void SkTSect::dumpBounded(int id) const { const SkTSpan* bounded = debugSpan(id); if (!bounded) { SkDebugf("no span matches %d\n", id); return; } const SkTSpan* test = bounded->debugOpp()->fHead; do { if (test->findOppSpan(bounded)) { test->dump(); SkDebugf(" "); } } while ((test = test->next())); SkDebugf("\n"); } template void SkTSect::dumpBounds() const { const SkTSpan* test = fHead; do { test->dumpBounds(); } while ((test = test->next())); } template void SkTSect::dumpCoin() const { dumpCommon(fCoincident); } template void SkTSect::dumpCoinCurves() const { dumpCommonCurves(fCoincident); } template void SkTSect::dumpCommon(const SkTSpan* test) const { SkDebugf("id=%d", debugID()); if (!test) { SkDebugf(" (empty)"); return; } do { SkDebugf(" "); test->dump(); } while ((test = test->next())); } template void SkTSect::dumpCommonCurves(const SkTSpan* test) const { do { test->fPart.dumpID(test->debugID()); } while ((test = test->next())); } template void SkTSect::dumpCurves() const { dumpCommonCurves(fHead); } template const SkTSpan* SkTSpan::debugSpan(int id) const { return SkDEBUGRELEASE(fDebugSect->debugSpan(id), nullptr); } template const SkTSpan* SkTSpan::debugT(double t) const { return SkDEBUGRELEASE(fDebugSect->debugT(t), nullptr); } template void SkTSpan::dumpAll() const { dumpID(); SkDebugf("=(%g,%g) [", fStartT, fEndT); const SkTSpanBounded* testBounded = fBounded; while (testBounded) { const SkTSpan* span = testBounded->fBounded; const SkTSpanBounded* next = testBounded->fNext; span->dumpID(); SkDebugf("=(%g,%g)", span->fStartT, span->fEndT); if (next) { SkDebugf(" "); } testBounded = next; } SkDebugf("]\n"); } template void SkTSpan::dump() const { dumpID(); SkDebugf("=(%g,%g) [", fStartT, fEndT); const SkTSpanBounded* testBounded = fBounded; while (testBounded) { const SkTSpan* span = testBounded->fBounded; const SkTSpanBounded* next = testBounded->fNext; span->dumpID(); if (next) { SkDebugf(","); } testBounded = next; } SkDebugf("]"); } template void SkTSpan::dumpBounded(int id) const { SkDEBUGCODE(fDebugSect->dumpBounded(id)); } template void SkTSpan::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 void SkTSpan::dumpCoin() const { dumpID(); SkDebugf(" coinStart "); fCoinStart.dump(); SkDebugf(" coinEnd "); fCoinEnd.dump(); } template void SkTSpan::dumpID() const { char cS = fCoinStart.dumpIsCoincidentStr(); if (cS) { SkDebugf("%c", cS); } SkDebugf("%d", debugID()); char cE = fCoinEnd.dumpIsCoincidentStr(); if (cE) { SkDebugf("%c", cE); } } #endif // PathOpsTSectDebug_DEFINED