void SkOpSegment::dumpContour(int firstID, int lastID) const { if (debugID() < 0) { return; } const SkOpSegment* test = this - (debugID() - 1); test += (firstID - 1); const SkOpSegment* last = test + (lastID - firstID); while (test <= last) { test->dumpSpans(); ++test; } }
void SkOpContour::dumpAngles() const { int segmentCount = fSegments.count(); SkDebugf("((SkOpContour*) 0x%p) [%d]\n", this, debugID()); for (int test = 0; test < segmentCount; ++test) { SkDebugf(" [%d] ", test); fSegments[test].dumpAngles(); } }
void SkOpSegment::dumpSpans() const { int count = this->count(); SkDebugf("((SkOpSegment*) 0x%p) [%d]\n", this, debugID()); for (int index = 0; index < count; ++index) { const SkOpSpan& span = this->span(index); SkDebugf(" [%d] ", index); span.dumpOne(); } }
void SkOpSegment::dumpPts() const { int last = SkPathOpsVerbToPoints(fVerb); SkDebugf("((SkOpSegment*) 0x%p) [%d] {{", this, debugID()); int index = 0; do { SkDPoint::Dump(fPts[index]); SkDebugf(", "); } while (++index < last); SkDPoint::Dump(fPts[index]); SkDebugf("}}\n"); }
void SkOpSegment::dumpDPts() const { int count = SkPathOpsVerbToPoints(fVerb); SkDebugf("((SkOpSegment*) 0x%p) [%d] {{", this, debugID()); int index = 0; do { SkDPoint dPt = {fPts[index].fX, fPts[index].fY}; dPt.dump(); if (index != count) { SkDebugf(", "); } } while (++index <= count); SkDebugf("}}\n"); }
void SkOpSegment::dumpAngles() const { SkDebugf("((SkOpSegment*) 0x%p) [%d]\n", this, debugID()); int fromIndex = -1, toIndex = -1; for (int index = 0; index < count(); ++index) { int fIndex = fTs[index].fFromAngleIndex; int tIndex = fTs[index].fToAngleIndex; if (fromIndex == fIndex && tIndex == toIndex) { continue; } if (fIndex >= 0) { SkDebugf(" [%d] from=%d ", index, fIndex); const SkOpAngle& angle = this->angle(fIndex); angle.dumpFromTo(this, fIndex, tIndex); } if (tIndex >= 0) { SkDebugf(" [%d] to=%d ", index, tIndex); const SkOpAngle& angle = this->angle(tIndex); angle.dumpFromTo(this, fIndex, tIndex); } fromIndex = fIndex; toIndex = tIndex; } }
// return true if lh < this < rh bool SkOpAngle::after(const SkOpAngle* test) const { const SkOpAngle& lh = *test; const SkOpAngle& rh = *lh.fNext; SkASSERT(&lh != &rh); #if DEBUG_ANGLE SkString bugOut; bugOut.printf("%s [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g" " < [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g" " < [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g ", __FUNCTION__, lh.fSegment->debugID(), lh.debugID(), lh.fSectorStart, lh.fSectorEnd, lh.fSegment->t(lh.fStart), lh.fSegment->t(lh.fEnd), fSegment->debugID(), debugID(), fSectorStart, fSectorEnd, fSegment->t(fStart), fSegment->t(fEnd), rh.fSegment->debugID(), rh.debugID(), rh.fSectorStart, rh.fSectorEnd, rh.fSegment->t(rh.fStart), rh.fSegment->t(rh.fEnd)); #endif if (lh.fComputeSector && !const_cast<SkOpAngle&>(lh).computeSector()) { return COMPARE_RESULT(1, true); } if (fComputeSector && !const_cast<SkOpAngle*>(this)->computeSector()) { return COMPARE_RESULT(2, true); } if (rh.fComputeSector && !const_cast<SkOpAngle&>(rh).computeSector()) { return COMPARE_RESULT(3, true); } #if DEBUG_ANGLE // reset bugOut with computed sectors bugOut.printf("%s [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g" " < [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g" " < [%d/%d] %d/%d tStart=%1.9g tEnd=%1.9g ", __FUNCTION__, lh.fSegment->debugID(), lh.debugID(), lh.fSectorStart, lh.fSectorEnd, lh.fSegment->t(lh.fStart), lh.fSegment->t(lh.fEnd), fSegment->debugID(), debugID(), fSectorStart, fSectorEnd, fSegment->t(fStart), fSegment->t(fEnd), rh.fSegment->debugID(), rh.debugID(), rh.fSectorStart, rh.fSectorEnd, rh.fSegment->t(rh.fStart), rh.fSegment->t(rh.fEnd)); #endif bool ltrOverlap = (lh.fSectorMask | rh.fSectorMask) & fSectorMask; bool lrOverlap = lh.fSectorMask & rh.fSectorMask; int lrOrder; // set to -1 if either order works if (!lrOverlap) { // no lh/rh sector overlap if (!ltrOverlap) { // no lh/this/rh sector overlap return COMPARE_RESULT(4, (lh.fSectorEnd > rh.fSectorStart) ^ (fSectorStart > lh.fSectorEnd) ^ (fSectorStart > rh.fSectorStart)); } int lrGap = (rh.fSectorStart - lh.fSectorStart + 32) & 0x1f; /* A tiny change can move the start +/- 4. The order can only be determined if lr gap is not 12 to 20 or -12 to -20. -31 ..-21 1 -20 ..-12 -1 -11 .. -1 0 0 shouldn't get here 11 .. 1 1 12 .. 20 -1 21 .. 31 0 */ lrOrder = lrGap > 20 ? 0 : lrGap > 11 ? -1 : 1; } else { lrOrder = (int) lh.orderable(rh); if (!ltrOverlap) { return COMPARE_RESULT(5, !lrOrder); } } int ltOrder; SkASSERT((lh.fSectorMask & fSectorMask) || (rh.fSectorMask & fSectorMask)); if (lh.fSectorMask & fSectorMask) { ltOrder = (int) lh.orderable(*this); } else { int ltGap = (fSectorStart - lh.fSectorStart + 32) & 0x1f; ltOrder = ltGap > 20 ? 0 : ltGap > 11 ? -1 : 1; } int trOrder; if (rh.fSectorMask & fSectorMask) { trOrder = (int) orderable(rh); } else { int trGap = (rh.fSectorStart - fSectorStart + 32) & 0x1f; trOrder = trGap > 20 ? 0 : trGap > 11 ? -1 : 1; } if (lrOrder >= 0 && ltOrder >= 0 && trOrder >= 0) { return COMPARE_RESULT(7, lrOrder ? (ltOrder & trOrder) : (ltOrder | trOrder)); } SkASSERT(lrOrder >= 0 || ltOrder >= 0 || trOrder >= 0); // There's not enough information to sort. Get the pairs of angles in opposite planes. // If an order is < 0, the pair is already in an opposite plane. Check the remaining pairs. // FIXME : once all variants are understood, rewrite this more simply if (ltOrder == 0 && lrOrder == 0) { SkASSERT(trOrder < 0); // FIXME : once this is verified to work, remove one opposite angle call SkDEBUGCODE(bool lrOpposite = lh.oppositePlanes(rh)); bool ltOpposite = lh.oppositePlanes(*this); SkASSERT(lrOpposite != ltOpposite); return COMPARE_RESULT(8, ltOpposite); } else if (ltOrder == 1 && trOrder == 0) { SkASSERT(lrOrder < 0); SkDEBUGCODE(bool ltOpposite = lh.oppositePlanes(*this)); bool trOpposite = oppositePlanes(rh); SkASSERT(ltOpposite != trOpposite); return COMPARE_RESULT(9, trOpposite); } else if (lrOrder == 1 && trOrder == 1) { SkASSERT(ltOrder < 0); SkDEBUGCODE(bool trOpposite = oppositePlanes(rh)); bool lrOpposite = lh.oppositePlanes(rh); SkASSERT(lrOpposite != trOpposite); return COMPARE_RESULT(10, lrOpposite); } if (lrOrder < 0) { if (ltOrder < 0) { return COMPARE_RESULT(11, trOrder); } return COMPARE_RESULT(12, ltOrder); } return COMPARE_RESULT(13, !lrOrder); }