caryclark | 45fa447 | 2015-01-16 07:04:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "SkPathOpsTSect.h" |
| 9 | |
| 10 | template<typename TCurve> |
| 11 | void SkTSect<TCurve>::dump() const { |
| 12 | SkDebugf("id=%d", debugID()); |
| 13 | const SkTSpan<TCurve>* test = fHead; |
| 14 | if (!test) { |
| 15 | SkDebugf(" (empty)"); |
| 16 | return; |
| 17 | } |
| 18 | do { |
| 19 | SkDebugf(" "); |
| 20 | test->dump(this); |
| 21 | } while ((test = test->next())); |
| 22 | } |
| 23 | |
| 24 | template<typename TCurve> |
| 25 | void SkTSect<TCurve>::dumpBoth(const SkTSect& opp) const { |
| 26 | dump(); |
| 27 | SkDebugf(" "); |
| 28 | opp.dump(); |
| 29 | SkDebugf("\n"); |
| 30 | } |
| 31 | |
| 32 | template<typename TCurve> |
| 33 | void SkTSect<TCurve>::dumpBoth(const SkTSect* opp) const { |
| 34 | dumpBoth(*opp); |
| 35 | } |
| 36 | |
| 37 | template<typename TCurve> |
| 38 | void SkTSect<TCurve>::dumpCurves() const { |
| 39 | const SkTSpan<TCurve>* test = fHead; |
| 40 | do { |
| 41 | test->fPart.dump(); |
| 42 | } while ((test = test->next())); |
| 43 | } |
| 44 | |
| 45 | #if !DEBUG_T_SECT |
| 46 | template<typename TCurve> |
| 47 | int SkTSpan<TCurve>::debugID(const SkTSect<TCurve>* sect) const { |
| 48 | if (!sect) { |
| 49 | return -1; |
| 50 | } |
| 51 | int id = 1; |
| 52 | const SkTSpan* test = sect->fHead; |
| 53 | while (test && test != this) { |
| 54 | ++id; |
| 55 | test = test->fNext; |
| 56 | } |
| 57 | return id; |
| 58 | } |
| 59 | #endif |
| 60 | |
| 61 | template<typename TCurve> |
| 62 | void SkTSpan<TCurve>::dumpID(const SkTSect<TCurve>* sect) const { |
| 63 | if (fCoinStart.isCoincident()) { |
| 64 | SkDebugf("%c", '*'); |
| 65 | } |
| 66 | SkDebugf("%d", debugID(sect)); |
| 67 | if (fCoinEnd.isCoincident()) { |
| 68 | SkDebugf("%c", '*'); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | template<typename TCurve> |
| 73 | void SkTSpan<TCurve>::dump(const SkTSect<TCurve>* sect) const { |
| 74 | dumpID(sect); |
| 75 | SkDebugf("=(%g,%g) [", fStartT, fEndT); |
| 76 | for (int index = 0; index < fBounded.count(); ++index) { |
| 77 | SkTSpan* span = fBounded[index]; |
| 78 | span->dumpID(sect); |
| 79 | if (index < fBounded.count() - 1) { |
| 80 | SkDebugf(","); |
| 81 | } |
| 82 | } |
| 83 | SkDebugf("]"); |
| 84 | } |