commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 1 | #include "SkOpContour.h" |
| 2 | #include "SkIntersectionHelper.h" |
| 3 | #include "SkOpSegment.h" |
| 4 | |
| 5 | inline void DebugDumpDouble(double x) { |
| 6 | if (x == floor(x)) { |
| 7 | SkDebugf("%.0f", x); |
| 8 | } else { |
| 9 | SkDebugf("%1.19g", x); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | inline void DebugDumpFloat(float x) { |
| 14 | if (x == floorf(x)) { |
| 15 | SkDebugf("%.0f", x); |
| 16 | } else { |
| 17 | SkDebugf("%1.9gf", x); |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | // if not defined by PathOpsDebug.cpp ... |
| 22 | #if !defined SK_DEBUG && FORCE_RELEASE |
| 23 | bool SkPathOpsDebug::ValidWind(int wind) { |
| 24 | return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; |
| 25 | } |
| 26 | |
| 27 | void SkPathOpsDebug::WindingPrintf(int wind) { |
| 28 | if (wind == SK_MinS32) { |
| 29 | SkDebugf("?"); |
| 30 | } else { |
| 31 | SkDebugf("%d", wind); |
| 32 | } |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | void SkOpAngle::dump() const { |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 37 | dumpOne(true); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 38 | SkDebugf("\n"); |
| 39 | } |
| 40 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 41 | void SkOpAngle::dumpOne(bool functionHeader) const { |
| 42 | // fSegment->debugValidate(); |
| 43 | const SkOpSpan& mSpan = fSegment->span(SkMin32(fStart, fEnd)); |
| 44 | if (functionHeader) { |
| 45 | SkDebugf("%s ", __FUNCTION__); |
| 46 | } |
| 47 | SkDebugf("[%d", fSegment->debugID()); |
| 48 | SkDebugf("/%d", debugID()); |
| 49 | SkDebugf("] next="); |
| 50 | if (fNext) { |
| 51 | SkDebugf("%d", fNext->fSegment->debugID()); |
| 52 | SkDebugf("/%d", fNext->debugID()); |
| 53 | } else { |
| 54 | SkDebugf("?"); |
| 55 | } |
| 56 | SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd); |
| 57 | SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fSegment->span(fStart).fT, fStart, |
| 58 | fSegment->span(fEnd).fT, fEnd); |
| 59 | SkDebugf(" sgn=%d windVal=%d", sign(), mSpan.fWindValue); |
| 60 | |
| 61 | SkDebugf(" windSum="); |
| 62 | SkPathOpsDebug::WindingPrintf(mSpan.fWindSum); |
| 63 | if (mSpan.fOppValue != 0 || mSpan.fOppSum != SK_MinS32) { |
| 64 | SkDebugf(" oppVal=%d", mSpan.fOppValue); |
| 65 | SkDebugf(" oppSum="); |
| 66 | SkPathOpsDebug::WindingPrintf(mSpan.fOppSum); |
| 67 | } |
| 68 | if (mSpan.fDone) { |
| 69 | SkDebugf(" done"); |
| 70 | } |
| 71 | if (unorderable()) { |
| 72 | SkDebugf(" unorderable"); |
| 73 | } |
| 74 | if (small()) { |
| 75 | SkDebugf(" small"); |
| 76 | } |
| 77 | if (mSpan.fTiny) { |
| 78 | SkDebugf(" tiny"); |
| 79 | } |
| 80 | if (fSegment->operand()) { |
| 81 | SkDebugf(" operand"); |
| 82 | } |
| 83 | if (fStop) { |
| 84 | SkDebugf(" stop"); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 89 | const SkOpAngle* first = this; |
| 90 | const SkOpAngle* next = this; |
| 91 | const char* indent = ""; |
| 92 | do { |
| 93 | SkDebugf("%s", indent); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 94 | next->dumpOne(false); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 95 | if (segment == next->fSegment) { |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 96 | if (this == fNext) { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 97 | SkDebugf(" << from"); |
| 98 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 99 | if (to == fNext) { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 100 | SkDebugf(" << to"); |
| 101 | } |
| 102 | } |
| 103 | SkDebugf("\n"); |
| 104 | indent = " "; |
| 105 | next = next->fNext; |
| 106 | } while (next && next != first); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | void SkOpAngle::dumpLoop() const { |
| 110 | const SkOpAngle* first = this; |
| 111 | const SkOpAngle* next = this; |
| 112 | do { |
| 113 | next->dump(); |
| 114 | next = next->fNext; |
| 115 | } while (next && next != first); |
| 116 | } |
| 117 | |
| 118 | void SkOpAngle::dumpPartials() const { |
| 119 | const SkOpAngle* first = this; |
| 120 | const SkOpAngle* next = this; |
| 121 | do { |
| 122 | next->fCurvePart.dumpNumber(); |
| 123 | next = next->fNext; |
| 124 | } while (next && next != first); |
| 125 | } |
| 126 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 127 | void SkOpAngleSet::dump() const { |
| 128 | // FIXME: unimplemented |
| 129 | /* This requires access to the internal SkChunkAlloc data |
| 130 | Defer implementing this until it is needed for debugging |
| 131 | */ |
| 132 | SkASSERT(0); |
| 133 | } |
| 134 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 135 | void SkOpContour::dump() const { |
| 136 | int segmentCount = fSegments.count(); |
| 137 | SkDebugf("((SkOpContour*) 0x%p) [%d]\n", this, debugID()); |
| 138 | for (int test = 0; test < segmentCount; ++test) { |
| 139 | SkDebugf(" [%d] ((SkOpSegment*) 0x%p) [%d]\n", test, &fSegments[test], |
| 140 | fSegments[test].debugID()); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | void SkOpContour::dumpAngles() const { |
| 145 | int segmentCount = fSegments.count(); |
| 146 | SkDebugf("((SkOpContour*) 0x%p) [%d]\n", this, debugID()); |
| 147 | for (int test = 0; test < segmentCount; ++test) { |
| 148 | SkDebugf(" [%d] ", test); |
| 149 | fSegments[test].dumpAngles(); |
| 150 | } |
| 151 | } |
| 152 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 153 | void SkOpContour::dumpCoincidence(const SkCoincidence& coin) const { |
| 154 | int thisIndex = coin.fSegments[0]; |
| 155 | const SkOpSegment& s1 = fSegments[thisIndex]; |
| 156 | int otherIndex = coin.fSegments[1]; |
| 157 | const SkOpSegment& s2 = coin.fOther->fSegments[otherIndex]; |
| 158 | SkDebugf("((SkOpSegment*) 0x%p) [%d] ((SkOpSegment*) 0x%p) [%d]\n", &s1, s1.debugID(), |
| 159 | &s2, s2.debugID()); |
| 160 | for (int index = 0; index < 2; ++index) { |
| 161 | SkDebugf(" {%1.9gf, %1.9gf}", coin.fPts[0][index].fX, coin.fPts[0][index].fY); |
| 162 | if (coin.fNearly[index]) { |
| 163 | SkDebugf(" {%1.9gf, %1.9gf}", coin.fPts[1][index].fX, coin.fPts[1][index].fY); |
| 164 | } |
| 165 | SkDebugf(" seg1t=%1.9g seg2t=%1.9g\n", coin.fTs[0][index], coin.fTs[1][index]); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | void SkOpContour::dumpCoincidences() const { |
| 170 | int count = fCoincidences.count(); |
| 171 | if (count > 0) { |
| 172 | SkDebugf("fCoincidences count=%d\n", count); |
| 173 | for (int test = 0; test < count; ++test) { |
| 174 | dumpCoincidence(fCoincidences[test]); |
| 175 | } |
| 176 | } |
| 177 | count = fPartialCoincidences.count(); |
| 178 | if (count == 0) { |
| 179 | return; |
| 180 | } |
| 181 | SkDebugf("fPartialCoincidences count=%d\n", count); |
| 182 | for (int test = 0; test < count; ++test) { |
| 183 | dumpCoincidence(fPartialCoincidences[test]); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | void SkOpContour::dumpPt(int index) const { |
| 188 | int segmentCount = fSegments.count(); |
| 189 | for (int test = 0; test < segmentCount; ++test) { |
| 190 | const SkOpSegment& segment = fSegments[test]; |
| 191 | if (segment.debugID() == index) { |
| 192 | fSegments[test].dumpPts(); |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 197 | void SkOpContour::dumpPts() const { |
| 198 | int segmentCount = fSegments.count(); |
| 199 | SkDebugf("((SkOpContour*) 0x%p) [%d]\n", this, debugID()); |
| 200 | for (int test = 0; test < segmentCount; ++test) { |
| 201 | SkDebugf(" [%d] ", test); |
| 202 | fSegments[test].dumpPts(); |
| 203 | } |
| 204 | } |
| 205 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 206 | void SkOpContour::dumpSpan(int index) const { |
| 207 | int segmentCount = fSegments.count(); |
| 208 | for (int test = 0; test < segmentCount; ++test) { |
| 209 | const SkOpSegment& segment = fSegments[test]; |
| 210 | if (segment.debugID() == index) { |
| 211 | fSegments[test].dumpSpans(); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 216 | void SkOpContour::dumpSpans() const { |
| 217 | int segmentCount = fSegments.count(); |
| 218 | SkDebugf("((SkOpContour*) 0x%p) [%d]\n", this, debugID()); |
| 219 | for (int test = 0; test < segmentCount; ++test) { |
| 220 | SkDebugf(" [%d] ", test); |
| 221 | fSegments[test].dumpSpans(); |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | void SkDCubic::dump() const { |
| 226 | SkDebugf("{{"); |
| 227 | int index = 0; |
| 228 | do { |
| 229 | fPts[index].dump(); |
| 230 | SkDebugf(", "); |
| 231 | } while (++index < 3); |
| 232 | fPts[index].dump(); |
| 233 | SkDebugf("}}\n"); |
| 234 | } |
| 235 | |
| 236 | void SkDCubic::dumpNumber() const { |
| 237 | SkDebugf("{{"); |
| 238 | int index = 0; |
| 239 | bool dumpedOne = false; |
| 240 | do { |
| 241 | if (!(fPts[index].fX == fPts[index].fX && fPts[index].fY == fPts[index].fY)) { |
| 242 | continue; |
| 243 | } |
| 244 | if (dumpedOne) { |
| 245 | SkDebugf(", "); |
| 246 | } |
| 247 | fPts[index].dump(); |
| 248 | dumpedOne = true; |
| 249 | } while (++index < 3); |
| 250 | if (fPts[index].fX == fPts[index].fX && fPts[index].fY == fPts[index].fY) { |
| 251 | if (dumpedOne) { |
| 252 | SkDebugf(", "); |
| 253 | } |
| 254 | fPts[index].dump(); |
| 255 | } |
| 256 | SkDebugf("}}\n"); |
| 257 | } |
| 258 | |
| 259 | void SkDLine::dump() const { |
| 260 | SkDebugf("{{"); |
| 261 | fPts[0].dump(); |
| 262 | SkDebugf(", "); |
| 263 | fPts[1].dump(); |
| 264 | SkDebugf("}}\n"); |
| 265 | } |
| 266 | |
| 267 | void SkDPoint::dump() const { |
| 268 | SkDebugf("{"); |
| 269 | DebugDumpDouble(fX); |
| 270 | SkDebugf(", "); |
| 271 | DebugDumpDouble(fY); |
| 272 | SkDebugf("}"); |
| 273 | } |
| 274 | |
| 275 | void SkDPoint::Dump(const SkPoint& pt) { |
| 276 | SkDebugf("{"); |
| 277 | DebugDumpFloat(pt.fX); |
| 278 | SkDebugf(", "); |
| 279 | DebugDumpFloat(pt.fY); |
| 280 | SkDebugf("}"); |
| 281 | } |
| 282 | |
| 283 | |
| 284 | void SkDQuad::dumpComma(const char* comma) const { |
| 285 | SkDebugf("{{"); |
| 286 | int index = 0; |
| 287 | do { |
| 288 | fPts[index].dump(); |
| 289 | SkDebugf(", "); |
| 290 | } while (++index < 2); |
| 291 | fPts[index].dump(); |
| 292 | SkDebugf("}}%s\n", comma ? comma : ""); |
| 293 | } |
| 294 | |
| 295 | void SkDQuad::dump() const { |
| 296 | dumpComma(""); |
| 297 | } |
| 298 | |
| 299 | void SkIntersectionHelper::dump() const { |
| 300 | SkDPoint::Dump(pts()[0]); |
| 301 | SkDPoint::Dump(pts()[1]); |
| 302 | if (verb() >= SkPath::kQuad_Verb) { |
| 303 | SkDPoint::Dump(pts()[2]); |
| 304 | } |
| 305 | if (verb() >= SkPath::kCubic_Verb) { |
| 306 | SkDPoint::Dump(pts()[3]); |
| 307 | } |
| 308 | } |
| 309 | |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 310 | const SkTDArray<SkOpSpan>& SkOpSegment::debugSpans() const { |
| 311 | return fTs; |
| 312 | } |
| 313 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 314 | void SkOpSegment::dumpAngles() const { |
| 315 | SkDebugf("((SkOpSegment*) 0x%p) [%d]\n", this, debugID()); |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 316 | const SkOpAngle* fromAngle = NULL; |
| 317 | const SkOpAngle* toAngle = NULL; |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 318 | for (int index = 0; index < count(); ++index) { |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 319 | const SkOpAngle* fAngle = fTs[index].fFromAngle; |
| 320 | const SkOpAngle* tAngle = fTs[index].fToAngle; |
| 321 | if (fromAngle == fAngle && toAngle == tAngle) { |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 322 | continue; |
| 323 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 324 | if (fAngle) { |
| 325 | SkDebugf(" [%d] from=%d ", index, fAngle->debugID()); |
| 326 | fAngle->dumpTo(this, tAngle); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 327 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 328 | if (tAngle) { |
| 329 | SkDebugf(" [%d] to=%d ", index, tAngle->debugID()); |
| 330 | tAngle->dumpTo(this, fAngle); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 331 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 332 | fromAngle = fAngle; |
| 333 | toAngle = tAngle; |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 334 | } |
| 335 | } |
| 336 | |
| 337 | void SkOpSegment::dumpContour(int firstID, int lastID) const { |
| 338 | if (debugID() < 0) { |
| 339 | return; |
| 340 | } |
| 341 | const SkOpSegment* test = this - (debugID() - 1); |
| 342 | test += (firstID - 1); |
| 343 | const SkOpSegment* last = test + (lastID - firstID); |
| 344 | while (test <= last) { |
| 345 | test->dumpSpans(); |
| 346 | ++test; |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | void SkOpSegment::dumpPts() const { |
| 351 | int last = SkPathOpsVerbToPoints(fVerb); |
| 352 | SkDebugf("((SkOpSegment*) 0x%p) [%d] {{", this, debugID()); |
| 353 | int index = 0; |
| 354 | do { |
| 355 | SkDPoint::Dump(fPts[index]); |
| 356 | SkDebugf(", "); |
| 357 | } while (++index < last); |
| 358 | SkDPoint::Dump(fPts[index]); |
| 359 | SkDebugf("}}\n"); |
| 360 | } |
| 361 | |
| 362 | void SkOpSegment::dumpDPts() const { |
| 363 | int count = SkPathOpsVerbToPoints(fVerb); |
| 364 | SkDebugf("((SkOpSegment*) 0x%p) [%d] {{", this, debugID()); |
| 365 | int index = 0; |
| 366 | do { |
| 367 | SkDPoint dPt = {fPts[index].fX, fPts[index].fY}; |
| 368 | dPt.dump(); |
| 369 | if (index != count) { |
| 370 | SkDebugf(", "); |
| 371 | } |
| 372 | } while (++index <= count); |
| 373 | SkDebugf("}}\n"); |
| 374 | } |
| 375 | |
| 376 | void SkOpSegment::dumpSpans() const { |
| 377 | int count = this->count(); |
| 378 | SkDebugf("((SkOpSegment*) 0x%p) [%d]\n", this, debugID()); |
| 379 | for (int index = 0; index < count; ++index) { |
| 380 | const SkOpSpan& span = this->span(index); |
| 381 | SkDebugf(" [%d] ", index); |
| 382 | span.dumpOne(); |
| 383 | } |
| 384 | } |
| 385 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 386 | void SkPathOpsDebug::DumpCoincidence(const SkTArray<SkOpContour, true>& contours) { |
| 387 | int count = contours.count(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 388 | for (int index = 0; index < count; ++index) { |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 389 | contours[index].dumpCoincidences(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 390 | } |
| 391 | } |
| 392 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 393 | void SkPathOpsDebug::DumpCoincidence(const SkTArray<SkOpContour* , true>& contours) { |
| 394 | int count = contours.count(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 395 | for (int index = 0; index < count; ++index) { |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 396 | contours[index]->dumpCoincidences(); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 397 | } |
| 398 | } |
| 399 | |
| 400 | void SkPathOpsDebug::DumpContours(const SkTArray<SkOpContour, true>& contours) { |
| 401 | int count = contours.count(); |
| 402 | for (int index = 0; index < count; ++index) { |
| 403 | contours[index].dump(); |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | void SkPathOpsDebug::DumpContours(const SkTArray<SkOpContour* , true>& contours) { |
| 408 | int count = contours.count(); |
| 409 | for (int index = 0; index < count; ++index) { |
| 410 | contours[index]->dump(); |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | void SkPathOpsDebug::DumpContourAngles(const SkTArray<SkOpContour, true>& contours) { |
| 415 | int count = contours.count(); |
| 416 | for (int index = 0; index < count; ++index) { |
| 417 | contours[index].dumpAngles(); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | void SkPathOpsDebug::DumpContourAngles(const SkTArray<SkOpContour* , true>& contours) { |
| 422 | int count = contours.count(); |
| 423 | for (int index = 0; index < count; ++index) { |
| 424 | contours[index]->dumpAngles(); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | void SkPathOpsDebug::DumpContourPts(const SkTArray<SkOpContour, true>& contours) { |
| 429 | int count = contours.count(); |
| 430 | for (int index = 0; index < count; ++index) { |
| 431 | contours[index].dumpPts(); |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | void SkPathOpsDebug::DumpContourPts(const SkTArray<SkOpContour* , true>& contours) { |
| 436 | int count = contours.count(); |
| 437 | for (int index = 0; index < count; ++index) { |
| 438 | contours[index]->dumpPts(); |
| 439 | } |
| 440 | } |
| 441 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 442 | void SkPathOpsDebug::DumpContourPt(const SkTArray<SkOpContour, true>& contours, int segmentID) { |
| 443 | int count = contours.count(); |
| 444 | for (int index = 0; index < count; ++index) { |
| 445 | contours[index].dumpPt(segmentID); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | void SkPathOpsDebug::DumpContourPt(const SkTArray<SkOpContour* , true>& contours, int segmentID) { |
| 450 | int count = contours.count(); |
| 451 | for (int index = 0; index < count; ++index) { |
| 452 | contours[index]->dumpPt(segmentID); |
| 453 | } |
| 454 | } |
| 455 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 456 | void SkPathOpsDebug::DumpContourSpans(const SkTArray<SkOpContour, true>& contours) { |
| 457 | int count = contours.count(); |
| 458 | for (int index = 0; index < count; ++index) { |
| 459 | contours[index].dumpSpans(); |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | void SkPathOpsDebug::DumpContourSpans(const SkTArray<SkOpContour* , true>& contours) { |
| 464 | int count = contours.count(); |
| 465 | for (int index = 0; index < count; ++index) { |
| 466 | contours[index]->dumpSpans(); |
| 467 | } |
| 468 | } |
| 469 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 470 | void SkPathOpsDebug::DumpContourSpan(const SkTArray<SkOpContour, true>& contours, int segmentID) { |
| 471 | int count = contours.count(); |
| 472 | for (int index = 0; index < count; ++index) { |
| 473 | contours[index].dumpSpan(segmentID); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | void SkPathOpsDebug::DumpContourSpan(const SkTArray<SkOpContour* , true>& contours, int segmentID) { |
| 478 | int count = contours.count(); |
| 479 | for (int index = 0; index < count; ++index) { |
| 480 | contours[index]->dumpSpan(segmentID); |
| 481 | } |
| 482 | } |
| 483 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 484 | void SkPathOpsDebug::DumpSpans(const SkTDArray<SkOpSpan *>& spans) { |
| 485 | int count = spans.count(); |
| 486 | for (int index = 0; index < count; ++index) { |
| 487 | const SkOpSpan* span = spans[index]; |
| 488 | const SkOpSpan& oSpan = span->fOther->span(span->fOtherIndex); |
| 489 | const SkOpSegment* segment = oSpan.fOther; |
| 490 | SkDebugf("((SkOpSegment*) 0x%p) [%d] ", segment, segment->debugID()); |
| 491 | SkDebugf("spanIndex:%d ", oSpan.fOtherIndex); |
| 492 | span->dumpOne(); |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | // this does not require that other T index is initialized or correct |
| 497 | const SkOpSegment* SkOpSpan::debugToSegment(ptrdiff_t* spanIndex) const { |
| 498 | if (!fOther) { |
| 499 | return NULL; |
| 500 | } |
| 501 | int oppCount = fOther->count(); |
| 502 | for (int index = 0; index < oppCount; ++index) { |
| 503 | const SkOpSpan& otherSpan = fOther->span(index); |
| 504 | double otherTestT = otherSpan.fT; |
| 505 | if (otherTestT < fOtherT) { |
| 506 | continue; |
| 507 | } |
| 508 | SkASSERT(otherTestT == fOtherT); |
| 509 | const SkOpSegment* candidate = otherSpan.fOther; |
commit-bot@chromium.org | 8cb1daa | 2014-04-25 12:59:11 +0000 | [diff] [blame] | 510 | const SkOpSpan* first = candidate->debugSpans().begin(); |
| 511 | const SkOpSpan* last = candidate->debugSpans().end() - 1; |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 512 | if (first <= this && this <= last) { |
| 513 | if (spanIndex) { |
| 514 | *spanIndex = this - first; |
| 515 | } |
| 516 | return candidate; |
| 517 | } |
| 518 | } |
| 519 | SkASSERT(0); |
| 520 | return NULL; |
| 521 | } |
| 522 | |
| 523 | void SkOpSpan::dumpOne() const { |
| 524 | SkDebugf("t="); |
| 525 | DebugDumpDouble(fT); |
| 526 | SkDebugf(" pt="); |
| 527 | SkDPoint::Dump(fPt); |
| 528 | if (fOther) { |
| 529 | SkDebugf(" other.fID=%d", fOther->debugID()); |
| 530 | SkDebugf(" [%d] otherT=", fOtherIndex); |
| 531 | DebugDumpDouble(fOtherT); |
| 532 | } else { |
| 533 | SkDebugf(" other.fID=? [?] otherT=?"); |
| 534 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 535 | if (fWindSum != SK_MinS32) { |
| 536 | SkDebugf(" windSum=%d", fWindSum); |
| 537 | } |
| 538 | if (fOppSum != SK_MinS32 && (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0)) { |
| 539 | SkDebugf(" oppSum=%d", fOppSum); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 540 | } |
| 541 | SkDebugf(" windValue=%d", fWindValue); |
| 542 | if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) { |
| 543 | SkDebugf(" oppValue=%d", fOppValue); |
| 544 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 545 | if (fFromAngle && fFromAngle->debugID()) { |
| 546 | SkDebugf(" from=%d", fFromAngle->debugID()); |
| 547 | } |
| 548 | if (fToAngle && fToAngle->debugID()) { |
| 549 | SkDebugf(" to=%d", fToAngle->debugID()); |
| 550 | } |
| 551 | if (fChased) { |
| 552 | SkDebugf(" chased"); |
| 553 | } |
| 554 | if (fCoincident) { |
| 555 | SkDebugf(" coincident"); |
| 556 | } |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 557 | if (fDone) { |
| 558 | SkDebugf(" done"); |
| 559 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 560 | if (fLoop) { |
| 561 | SkDebugf(" loop"); |
| 562 | } |
| 563 | if (fMultiple) { |
| 564 | SkDebugf(" multiple"); |
| 565 | } |
| 566 | if (fNear) { |
| 567 | SkDebugf(" near"); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 568 | } |
| 569 | if (fSmall) { |
| 570 | SkDebugf(" small"); |
| 571 | } |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 572 | if (fTiny) { |
| 573 | SkDebugf(" tiny"); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 574 | } |
| 575 | SkDebugf("\n"); |
| 576 | } |
| 577 | |
| 578 | void SkOpSpan::dump() const { |
| 579 | ptrdiff_t spanIndex; |
| 580 | const SkOpSegment* segment = debugToSegment(&spanIndex); |
| 581 | if (segment) { |
| 582 | SkDebugf("((SkOpSegment*) 0x%p) [%d]\n", segment, segment->debugID()); |
| 583 | SkDebugf(" [%d] ", spanIndex); |
| 584 | } else { |
| 585 | SkDebugf("((SkOpSegment*) ?) [?]\n"); |
| 586 | SkDebugf(" [?] "); |
| 587 | } |
| 588 | dumpOne(); |
| 589 | } |
| 590 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 591 | void Dump(const SkTArray<class SkOpContour, true>& contours) { |
| 592 | SkPathOpsDebug::DumpContours(contours); |
| 593 | } |
| 594 | |
| 595 | void Dump(const SkTArray<class SkOpContour* , true>& contours) { |
| 596 | SkPathOpsDebug::DumpContours(contours); |
| 597 | } |
| 598 | |
| 599 | void Dump(const SkTArray<class SkOpContour, true>* contours) { |
| 600 | SkPathOpsDebug::DumpContours(*contours); |
| 601 | } |
| 602 | |
| 603 | void Dump(const SkTArray<class SkOpContour* , true>* contours) { |
| 604 | SkPathOpsDebug::DumpContours(*contours); |
| 605 | } |
| 606 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 607 | void Dump(const SkTDArray<SkOpSpan *>& chase) { |
| 608 | SkPathOpsDebug::DumpSpans(chase); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 609 | } |
| 610 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 611 | void Dump(const SkTDArray<SkOpSpan *>* chase) { |
| 612 | SkPathOpsDebug::DumpSpans(*chase); |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | void DumpAngles(const SkTArray<class SkOpContour, true>& contours) { |
| 616 | SkPathOpsDebug::DumpContourAngles(contours); |
| 617 | } |
| 618 | |
| 619 | void DumpAngles(const SkTArray<class SkOpContour* , true>& contours) { |
| 620 | SkPathOpsDebug::DumpContourAngles(contours); |
| 621 | } |
| 622 | |
| 623 | void DumpAngles(const SkTArray<class SkOpContour, true>* contours) { |
| 624 | SkPathOpsDebug::DumpContourAngles(*contours); |
| 625 | } |
| 626 | |
| 627 | void DumpAngles(const SkTArray<class SkOpContour* , true>* contours) { |
| 628 | SkPathOpsDebug::DumpContourAngles(*contours); |
| 629 | } |
| 630 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 631 | void DumpCoin(const SkTArray<class SkOpContour, true>& contours) { |
| 632 | SkPathOpsDebug::DumpCoincidence(contours); |
| 633 | } |
| 634 | |
| 635 | void DumpCoin(const SkTArray<class SkOpContour* , true>& contours) { |
| 636 | SkPathOpsDebug::DumpCoincidence(contours); |
| 637 | } |
| 638 | |
| 639 | void DumpCoin(const SkTArray<class SkOpContour, true>* contours) { |
| 640 | SkPathOpsDebug::DumpCoincidence(*contours); |
| 641 | } |
| 642 | |
| 643 | void DumpCoin(const SkTArray<class SkOpContour* , true>* contours) { |
| 644 | SkPathOpsDebug::DumpCoincidence(*contours); |
| 645 | } |
| 646 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 647 | void DumpSpans(const SkTArray<class SkOpContour, true>& contours) { |
| 648 | SkPathOpsDebug::DumpContourSpans(contours); |
| 649 | } |
| 650 | |
| 651 | void DumpSpans(const SkTArray<class SkOpContour* , true>& contours) { |
| 652 | SkPathOpsDebug::DumpContourSpans(contours); |
| 653 | } |
| 654 | |
| 655 | void DumpSpans(const SkTArray<class SkOpContour, true>* contours) { |
| 656 | SkPathOpsDebug::DumpContourSpans(*contours); |
| 657 | } |
| 658 | |
| 659 | void DumpSpans(const SkTArray<class SkOpContour* , true>* contours) { |
| 660 | SkPathOpsDebug::DumpContourSpans(*contours); |
| 661 | } |
| 662 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 663 | void DumpSpan(const SkTArray<class SkOpContour, true>& contours, int segmentID) { |
| 664 | SkPathOpsDebug::DumpContourSpan(contours, segmentID); |
| 665 | } |
| 666 | |
| 667 | void DumpSpan(const SkTArray<class SkOpContour* , true>& contours, int segmentID) { |
| 668 | SkPathOpsDebug::DumpContourSpan(contours, segmentID); |
| 669 | } |
| 670 | |
| 671 | void DumpSpan(const SkTArray<class SkOpContour, true>* contours, int segmentID) { |
| 672 | SkPathOpsDebug::DumpContourSpan(*contours, segmentID); |
| 673 | } |
| 674 | |
| 675 | void DumpSpan(const SkTArray<class SkOpContour* , true>* contours, int segmentID) { |
| 676 | SkPathOpsDebug::DumpContourSpan(*contours, segmentID); |
| 677 | } |
| 678 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 679 | void DumpPts(const SkTArray<class SkOpContour, true>& contours) { |
| 680 | SkPathOpsDebug::DumpContourPts(contours); |
| 681 | } |
| 682 | |
| 683 | void DumpPts(const SkTArray<class SkOpContour* , true>& contours) { |
| 684 | SkPathOpsDebug::DumpContourPts(contours); |
| 685 | } |
| 686 | |
| 687 | void DumpPts(const SkTArray<class SkOpContour, true>* contours) { |
| 688 | SkPathOpsDebug::DumpContourPts(*contours); |
| 689 | } |
| 690 | |
| 691 | void DumpPts(const SkTArray<class SkOpContour* , true>* contours) { |
| 692 | SkPathOpsDebug::DumpContourPts(*contours); |
| 693 | } |
| 694 | |
caryclark | dac1d17 | 2014-06-17 05:15:38 -0700 | [diff] [blame^] | 695 | void DumpPt(const SkTArray<class SkOpContour, true>& contours, int segmentID) { |
| 696 | SkPathOpsDebug::DumpContourPt(contours, segmentID); |
| 697 | } |
| 698 | |
| 699 | void DumpPt(const SkTArray<class SkOpContour* , true>& contours, int segmentID) { |
| 700 | SkPathOpsDebug::DumpContourPt(contours, segmentID); |
| 701 | } |
| 702 | |
| 703 | void DumpPt(const SkTArray<class SkOpContour, true>* contours, int segmentID) { |
| 704 | SkPathOpsDebug::DumpContourPt(*contours, segmentID); |
| 705 | } |
| 706 | |
| 707 | void DumpPt(const SkTArray<class SkOpContour* , true>* contours, int segmentID) { |
| 708 | SkPathOpsDebug::DumpContourPt(*contours, segmentID); |
| 709 | } |
| 710 | |
commit-bot@chromium.org | 4431e77 | 2014-04-14 17:08:59 +0000 | [diff] [blame] | 711 | static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) { |
| 712 | SkDebugf("<div id=\"quad%d\">\n", testNo); |
| 713 | quad1.dumpComma(","); |
| 714 | quad2.dump(); |
| 715 | SkDebugf("</div>\n\n"); |
| 716 | } |
| 717 | |
| 718 | static void dumpTestTrailer() { |
| 719 | SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n"); |
| 720 | SkDebugf(" var testDivs = [\n"); |
| 721 | } |
| 722 | |
| 723 | static void dumpTestList(int testNo, double min) { |
| 724 | SkDebugf(" quad%d,", testNo); |
| 725 | if (min > 0) { |
| 726 | SkDebugf(" // %1.9g", min); |
| 727 | } |
| 728 | SkDebugf("\n"); |
| 729 | } |
| 730 | |
| 731 | void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) { |
| 732 | SkDebugf("\n"); |
| 733 | dumpTestCase(quad1, quad2, testNo); |
| 734 | dumpTestTrailer(); |
| 735 | dumpTestList(testNo, 0); |
| 736 | SkDebugf("\n"); |
| 737 | } |
| 738 | |
| 739 | void DumpT(const SkDQuad& quad, double t) { |
| 740 | SkDLine line = {{quad.ptAtT(t), quad[0]}}; |
| 741 | line.dump(); |
| 742 | } |