blob: 9535f3cecc7d751aa4d51217ab82c48b2ae66d7e [file] [log] [blame]
caryclark54359292015-03-26 07:52:43 -07001/*
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
Cary Clarkf3949122018-08-07 16:38:21 -04008#include "PathOpsDebug.h"
caryclark54359292015-03-26 07:52:43 -07009#include "PathOpsTSectDebug.h"
10#include "SkOpCoincidence.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000011#include "SkOpContour.h"
12#include "SkIntersectionHelper.h"
caryclark1049f122015-04-20 08:31:59 -070013#include "SkMutex.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000014#include "SkOpSegment.h"
caryclark19eb3b22014-07-18 05:08:14 -070015#include "SkString.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000016
Cary Clarkf3949122018-08-07 16:38:21 -040017bool PathOpsDebug::gJson;
Cary Clarkda6289c2018-08-27 16:10:28 -040018bool PathOpsDebug::gMarkJsonFlaky;
Cary Clarkf3949122018-08-07 16:38:21 -040019bool PathOpsDebug::gOutFirst;
Cary Clark4533f3d2018-08-08 09:48:09 -040020bool PathOpsDebug::gCheckForDuplicateNames;
Cary Clark9c9611f2018-08-08 13:17:25 -040021bool PathOpsDebug::gOutputSVG;
Cary Clarkf3949122018-08-07 16:38:21 -040022FILE* PathOpsDebug::gOut;
23
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000024inline void DebugDumpDouble(double x) {
25 if (x == floor(x)) {
26 SkDebugf("%.0f", x);
27 } else {
28 SkDebugf("%1.19g", x);
29 }
30}
31
32inline void DebugDumpFloat(float x) {
33 if (x == floorf(x)) {
34 SkDebugf("%.0f", x);
35 } else {
36 SkDebugf("%1.9gf", x);
37 }
38}
39
caryclark65f55312014-11-13 06:58:52 -080040inline void DebugDumpHexFloat(float x) {
41 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
42}
caryclark19eb3b22014-07-18 05:08:14 -070043
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000044// if not defined by PathOpsDebug.cpp ...
45#if !defined SK_DEBUG && FORCE_RELEASE
46bool SkPathOpsDebug::ValidWind(int wind) {
47 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
48}
49
50void SkPathOpsDebug::WindingPrintf(int wind) {
51 if (wind == SK_MinS32) {
52 SkDebugf("?");
53 } else {
54 SkDebugf("%d", wind);
55 }
56}
57#endif
58
caryclark55888e42016-07-18 10:01:36 -070059static void DumpID(int id) {
60 SkDebugf("} ");
61 if (id >= 0) {
62 SkDebugf("id=%d", id);
63 }
64 SkDebugf("\n");
65}
66
caryclark1049f122015-04-20 08:31:59 -070067void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070068 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070069 SkDebugf("},\n");
70}
71
72void SkDConic::dumpID(int id) const {
73 dumpInner();
caryclark55888e42016-07-18 10:01:36 -070074 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -070075}
76
77void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070078 SkDebugf("{");
79 fPts.dumpInner();
80 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070081}
82
83void SkDCubic::dump() const {
84 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070085 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070086}
87
caryclark54359292015-03-26 07:52:43 -070088void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070089 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -070090 SkDebugf("}");
91 DumpID(id);
reed0dc4dd62015-03-24 13:55:33 -070092}
93
caryclark54359292015-03-26 07:52:43 -070094static inline bool double_is_NaN(double x) { return x != x; }
95
96void SkDCubic::dumpInner() const {
97 SkDebugf("{{");
98 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070099 do {
caryclark54359292015-03-26 07:52:43 -0700100 if (index != 0) {
101 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
102 return;
reed0dc4dd62015-03-24 13:55:33 -0700103 }
caryclark54359292015-03-26 07:52:43 -0700104 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700105 }
caryclark54359292015-03-26 07:52:43 -0700106 fPts[index].dump();
107 } while (++index < 3);
108 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -0700109 return;
110 }
caryclark54359292015-03-26 07:52:43 -0700111 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700112 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000113}
114
caryclark55888e42016-07-18 10:01:36 -0700115void SkDCurve::dump() const {
116 dumpID(-1);
117}
118
caryclark1049f122015-04-20 08:31:59 -0700119void SkDCurve::dumpID(int id) const {
120#ifndef SK_RELEASE
121 switch(fVerb) {
122 case SkPath::kLine_Verb:
123 fLine.dumpID(id);
124 break;
125 case SkPath::kQuad_Verb:
126 fQuad.dumpID(id);
127 break;
128 case SkPath::kConic_Verb:
129 fConic.dumpID(id);
130 break;
131 case SkPath::kCubic_Verb:
132 fCubic.dumpID(id);
133 break;
134 default:
135 SkASSERT(0);
136 }
137#else
138 fCubic.dumpID(id);
139#endif
140}
141
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000142void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700143 this->dumpInner();
144 SkDebugf("}},\n");
145}
146
147void SkDLine::dumpID(int id) const {
148 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700149 SkDebugf("}");
150 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -0700151}
152
153void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000154 SkDebugf("{{");
155 fPts[0].dump();
156 SkDebugf(", ");
157 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000158}
159
160void SkDPoint::dump() const {
161 SkDebugf("{");
162 DebugDumpDouble(fX);
163 SkDebugf(", ");
164 DebugDumpDouble(fY);
165 SkDebugf("}");
166}
167
168void SkDPoint::Dump(const SkPoint& pt) {
169 SkDebugf("{");
170 DebugDumpFloat(pt.fX);
171 SkDebugf(", ");
172 DebugDumpFloat(pt.fY);
173 SkDebugf("}");
174}
175
caryclark65f55312014-11-13 06:58:52 -0800176void SkDPoint::DumpHex(const SkPoint& pt) {
177 SkDebugf("{");
178 DebugDumpHexFloat(pt.fX);
179 SkDebugf(", ");
180 DebugDumpHexFloat(pt.fY);
181 SkDebugf("}");
182}
183
184void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700185 dumpInner();
186 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800187}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000188
caryclark54359292015-03-26 07:52:43 -0700189void SkDQuad::dumpID(int id) const {
190 dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700191 SkDebugf("}");
192 DumpID(id);
caryclark54359292015-03-26 07:52:43 -0700193}
194
195void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000196 SkDebugf("{{");
197 int index = 0;
198 do {
199 fPts[index].dump();
200 SkDebugf(", ");
201 } while (++index < 2);
202 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000203}
204
caryclark54359292015-03-26 07:52:43 -0700205void SkIntersections::dump() const {
206 SkDebugf("used=%d of %d", fUsed, fMax);
207 for (int index = 0; index < fUsed; ++index) {
208 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
209 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
210 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
211 fPt[index].fX, fPt[index].fY);
212 if (index < 2 && fNearlySame[index]) {
213 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000214 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000215 }
216 SkDebugf("\n");
217}
218
Cary Clarkb2c7d842018-10-16 18:16:59 +0000219namespace SkOpDebug {
220
221const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700222 return angle->debugAngle(id);
223}
224
Cary Clarkb2c7d842018-10-16 18:16:59 +0000225::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700226 return angle->debugContour(id);
227}
228
Cary Clarkb2c7d842018-10-16 18:16:59 +0000229const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700230 return angle->debugPtT(id);
231}
232
Cary Clarkb2c7d842018-10-16 18:16:59 +0000233const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700234 return angle->debugSegment(id);
235}
236
Cary Clarkb2c7d842018-10-16 18:16:59 +0000237const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700238 return angle->debugSpan(id);
239}
240
Cary Clarkb2c7d842018-10-16 18:16:59 +0000241const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700242 return contour->debugAngle(id);
243}
244
Cary Clarkb2c7d842018-10-16 18:16:59 +0000245::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700246 return contour->debugContour(id);
247}
248
Cary Clarkb2c7d842018-10-16 18:16:59 +0000249const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700250 return contour->debugPtT(id);
251}
252
Cary Clarkb2c7d842018-10-16 18:16:59 +0000253const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700254 return contour->debugSegment(id);
255}
256
Cary Clarkb2c7d842018-10-16 18:16:59 +0000257const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700258 return contour->debugSpan(id);
259}
260
Cary Clarkb2c7d842018-10-16 18:16:59 +0000261const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700262 return coin->debugAngle(id);
263}
264
Cary Clarkb2c7d842018-10-16 18:16:59 +0000265::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700266 return coin->debugContour(id);
267}
268
Cary Clarkb2c7d842018-10-16 18:16:59 +0000269const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700270 return coin->debugPtT(id);
271}
272
Cary Clarkb2c7d842018-10-16 18:16:59 +0000273const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700274 return coin->debugSegment(id);
275}
276
Cary Clarkb2c7d842018-10-16 18:16:59 +0000277const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700278 return coin->debugSpan(id);
279}
280
Cary Clarkb2c7d842018-10-16 18:16:59 +0000281const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700282 return ptT->debugAngle(id);
283}
284
Cary Clarkb2c7d842018-10-16 18:16:59 +0000285::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700286 return ptT->debugContour(id);
287}
288
Cary Clarkb2c7d842018-10-16 18:16:59 +0000289const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700290 return ptT->debugPtT(id);
291}
292
Cary Clarkb2c7d842018-10-16 18:16:59 +0000293const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700294 return ptT->debugSegment(id);
295}
296
Cary Clarkb2c7d842018-10-16 18:16:59 +0000297const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700298 return ptT->debugSpan(id);
299}
300
Cary Clarkb2c7d842018-10-16 18:16:59 +0000301const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700302 return span->debugAngle(id);
303}
304
Cary Clarkb2c7d842018-10-16 18:16:59 +0000305::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700306 return span->debugContour(id);
307}
308
Cary Clarkb2c7d842018-10-16 18:16:59 +0000309const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700310 return span->debugPtT(id);
311}
312
Cary Clarkb2c7d842018-10-16 18:16:59 +0000313const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700314 return span->debugSegment(id);
315}
316
Cary Clarkb2c7d842018-10-16 18:16:59 +0000317const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700318 return span->debugSpan(id);
319}
320
Cary Clarkb2c7d842018-10-16 18:16:59 +0000321const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700322 return span->debugAngle(id);
323}
324
Cary Clarkb2c7d842018-10-16 18:16:59 +0000325::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700326 return span->debugContour(id);
327}
328
Cary Clarkb2c7d842018-10-16 18:16:59 +0000329const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700330 return span->debugPtT(id);
331}
332
Cary Clarkb2c7d842018-10-16 18:16:59 +0000333const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700334 return span->debugSegment(id);
335}
336
Cary Clarkb2c7d842018-10-16 18:16:59 +0000337const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700338 return span->debugSpan(id);
339}
340
Cary Clarkb2c7d842018-10-16 18:16:59 +0000341} // namespace SkPathOpsDebug
342
Cary Clarkab87d7a2016-10-04 10:01:04 -0400343#if DEBUG_COIN
344void SkPathOpsDebug::DumpCoinDict() {
Cary Clarkb8421ed2018-03-14 15:55:02 -0400345 SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false);
346 SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true);
Cary Clarkab87d7a2016-10-04 10:01:04 -0400347}
348
349void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const {
350 int count = fDict.count();
351 for (int index = 0; index < count; ++index) {
352 const auto& entry = fDict[index];
353 if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) {
354 SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName,
355 entry.fLineNumber, entry.fIteration);
356 DumpGlitchType(entry.fGlitchType);
357 SkDebugf("\n");
358 }
359 }
360}
361#endif
362
caryclark624637c2015-05-11 07:21:27 -0700363void SkOpContour::dumpContours() const {
364 SkOpContour* contour = this->globalState()->contourHead();
365 do {
366 contour->dump();
367 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000368}
369
caryclark624637c2015-05-11 07:21:27 -0700370void SkOpContour::dumpContoursAll() const {
371 SkOpContour* contour = this->globalState()->contourHead();
372 do {
373 contour->dumpAll();
374 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000375}
376
caryclark624637c2015-05-11 07:21:27 -0700377void SkOpContour::dumpContoursAngles() const {
378 SkOpContour* contour = this->globalState()->contourHead();
379 do {
380 contour->dumpAngles();
381 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000382}
383
caryclark624637c2015-05-11 07:21:27 -0700384void SkOpContour::dumpContoursPts() const {
385 SkOpContour* contour = this->globalState()->contourHead();
386 do {
387 contour->dumpPts();
388 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000389}
390
caryclark624637c2015-05-11 07:21:27 -0700391void SkOpContour::dumpContoursPt(int segmentID) const {
392 SkOpContour* contour = this->globalState()->contourHead();
393 do {
394 contour->dumpPt(segmentID);
395 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000396}
397
caryclark624637c2015-05-11 07:21:27 -0700398void SkOpContour::dumpContoursSegment(int segmentID) const {
399 SkOpContour* contour = this->globalState()->contourHead();
400 do {
401 contour->dumpSegment(segmentID);
402 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000403}
404
caryclark624637c2015-05-11 07:21:27 -0700405void SkOpContour::dumpContoursSpan(int spanID) const {
406 SkOpContour* contour = this->globalState()->contourHead();
407 do {
408 contour->dumpSpan(spanID);
409 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000410}
411
caryclark624637c2015-05-11 07:21:27 -0700412void SkOpContour::dumpContoursSpans() const {
413 SkOpContour* contour = this->globalState()->contourHead();
414 do {
415 contour->dumpSpans();
416 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000417}
418
Cary Clarkb2c7d842018-10-16 18:16:59 +0000419template <typename TCurve, typename OppCurve>
420const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700421 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000422}
423
Cary Clarkb2c7d842018-10-16 18:16:59 +0000424void DontCallDebugSpan(int id);
425void DontCallDebugSpan(int id) { // exists to instantiate the templates
426#if !PATH_OP_COMPILE_FOR_SIZE
427 SkDQuad quad;
428 SkDConic conic;
429 SkDCubic cubic;
430 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
435 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
436 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
437 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
438 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
439 DebugSpan(&q1q2, id);
440 DebugSpan(&q1k2, id);
441 DebugSpan(&q1c2, id);
442 DebugSpan(&k1q2, id);
443 DebugSpan(&k1k2, id);
444 DebugSpan(&k1c2, id);
445 DebugSpan(&c1q2, id);
446 DebugSpan(&c1k2, id);
447 DebugSpan(&c1c2, id);
448#endif
449}
450
451template <typename TCurve, typename OppCurve>
452const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700453 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000454}
caryclarkdac1d172014-06-17 05:15:38 -0700455
Cary Clarkb2c7d842018-10-16 18:16:59 +0000456void DontCallDebugT(double t);
457void DontCallDebugT(double t) { // exists to instantiate the templates
458#if !PATH_OP_COMPILE_FOR_SIZE
459 SkDQuad quad;
460 SkDConic conic;
461 SkDCubic cubic;
462 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
466 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
467 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
468 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
469 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
470 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
471 DebugT(&q1q2, t);
472 DebugT(&q1k2, t);
473 DebugT(&q1c2, t);
474 DebugT(&k1q2, t);
475 DebugT(&k1k2, t);
476 DebugT(&k1c2, t);
477 DebugT(&c1q2, t);
478 DebugT(&c1k2, t);
479 DebugT(&c1c2, t);
480#endif
481}
482
483template <typename TCurve, typename OppCurve>
484void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700485 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000486}
487
Cary Clarkb2c7d842018-10-16 18:16:59 +0000488void DontCallDumpTSect();
489void DontCallDumpTSect() { // exists to instantiate the templates
490#if !PATH_OP_COMPILE_FOR_SIZE
491 SkDQuad quad;
492 SkDConic conic;
493 SkDCubic cubic;
494 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
495 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
496 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
497 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
498 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
499 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
500 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
501 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
502 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
503 Dump(&q1q2);
504 Dump(&q1k2);
505 Dump(&q1c2);
506 Dump(&k1q2);
507 Dump(&k1k2);
508 Dump(&k1c2);
509 Dump(&c1q2);
510 Dump(&c1k2);
511 Dump(&c1c2);
512#endif
513}
514
515template <typename TCurve, typename OppCurve>
516void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700517 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700518}
519
Cary Clarkb2c7d842018-10-16 18:16:59 +0000520void DontCallDumpBoth();
521void DontCallDumpBoth() { // exists to instantiate the templates
522#if !PATH_OP_COMPILE_FOR_SIZE
523 SkDQuad quad;
524 SkDConic conic;
525 SkDCubic cubic;
526 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
527 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
528 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
529 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
530 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
531 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
532 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
533 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
534 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
535 DumpBoth(&q1q2, &q1q2);
536 DumpBoth(&q1k2, &k1q2);
537 DumpBoth(&q1c2, &c1q2);
538 DumpBoth(&k1q2, &q1k2);
539 DumpBoth(&k1k2, &k1k2);
540 DumpBoth(&k1c2, &c1k2);
541 DumpBoth(&c1q2, &q1c2);
542 DumpBoth(&c1k2, &k1c2);
543 DumpBoth(&c1c2, &c1c2);
544#endif
545}
546
547template <typename TCurve, typename OppCurve>
548void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
caryclark1049f122015-04-20 08:31:59 -0700549 sect1->dumpBounded(id);
550}
551
Cary Clarkb2c7d842018-10-16 18:16:59 +0000552void DontCallDumpBounded();
553void DontCallDumpBounded() {
554#if !PATH_OP_COMPILE_FOR_SIZE
555 SkDQuad quad;
556 SkDConic conic;
557 SkDCubic cubic;
558 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
559 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
560 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
561 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
562 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
563 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
564 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
565 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
566 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
567 DumpBounded(&q1q2, 0);
568 DumpBounded(&q1k2, 0);
569 DumpBounded(&q1c2, 0);
570 DumpBounded(&k1q2, 0);
571 DumpBounded(&k1k2, 0);
572 DumpBounded(&k1c2, 0);
573 DumpBounded(&c1q2, 0);
574 DumpBounded(&c1k2, 0);
575 DumpBounded(&c1c2, 0);
576#endif
577}
578
579template <typename TCurve, typename OppCurve>
580void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
caryclark1049f122015-04-20 08:31:59 -0700581 sect1->dumpBounds();
582}
583
Cary Clarkb2c7d842018-10-16 18:16:59 +0000584void DontCallDumpBounds();
585void DontCallDumpBounds() {
586#if !PATH_OP_COMPILE_FOR_SIZE
587 SkDQuad quad;
588 SkDConic conic;
589 SkDCubic cubic;
590 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
591 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
592 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
593 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
594 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
595 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
596 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
597 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
598 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
599 DumpBounds(&q1q2);
600 DumpBounds(&q1k2);
601 DumpBounds(&q1c2);
602 DumpBounds(&k1q2);
603 DumpBounds(&k1k2);
604 DumpBounds(&k1c2);
605 DumpBounds(&c1q2);
606 DumpBounds(&c1k2);
607 DumpBounds(&c1c2);
608#endif
609}
610
611template <typename TCurve, typename OppCurve>
612void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700613 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700614}
615
Cary Clarkb2c7d842018-10-16 18:16:59 +0000616void DontCallDumpCoin();
617void DontCallDumpCoin() { // exists to instantiate the templates
618#if !PATH_OP_COMPILE_FOR_SIZE
619 SkDQuad quad;
620 SkDConic conic;
621 SkDCubic cubic;
622 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
623 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
624 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
625 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
626 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
627 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
628 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
629 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
630 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
631 DumpCoin(&q1q2);
632 DumpCoin(&q1k2);
633 DumpCoin(&q1c2);
634 DumpCoin(&k1q2);
635 DumpCoin(&k1k2);
636 DumpCoin(&k1c2);
637 DumpCoin(&c1q2);
638 DumpCoin(&c1k2);
639 DumpCoin(&c1c2);
640#endif
641}
642
643template <typename TCurve, typename OppCurve>
644void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700645 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000646}
647
Cary Clarkb2c7d842018-10-16 18:16:59 +0000648void DontCallDumpCoinCurves();
649void DontCallDumpCoinCurves() { // exists to instantiate the templates
650#if !PATH_OP_COMPILE_FOR_SIZE
651 SkDQuad quad;
652 SkDConic conic;
653 SkDCubic cubic;
654 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
655 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
656 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
657 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
658 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
659 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
660 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
661 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
662 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
663 DumpCoinCurves(&q1q2);
664 DumpCoinCurves(&q1k2);
665 DumpCoinCurves(&q1c2);
666 DumpCoinCurves(&k1q2);
667 DumpCoinCurves(&k1k2);
668 DumpCoinCurves(&k1c2);
669 DumpCoinCurves(&c1q2);
670 DumpCoinCurves(&c1k2);
671 DumpCoinCurves(&c1c2);
672#endif
673}
674
675template <typename TCurve, typename OppCurve>
676void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700677 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000678}
679
Cary Clarkb2c7d842018-10-16 18:16:59 +0000680void DontCallDumpCurves();
681void DontCallDumpCurves() { // exists to instantiate the templates
682#if !PATH_OP_COMPILE_FOR_SIZE
683 SkDQuad quad;
684 SkDConic conic;
685 SkDCubic cubic;
686 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
687 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
688 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
689 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
690 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
691 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
692 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
693 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
694 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
695 DumpCurves(&q1q2);
696 DumpCurves(&q1k2);
697 DumpCurves(&q1c2);
698 DumpCurves(&k1q2);
699 DumpCurves(&k1k2);
700 DumpCurves(&k1c2);
701 DumpCurves(&c1q2);
702 DumpCurves(&c1k2);
703 DumpCurves(&c1c2);
704#endif
705}
706
707template <typename TCurve, typename OppCurve>
708void Dump(const SkTSpan<TCurve, OppCurve>* span) {
caryclark1049f122015-04-20 08:31:59 -0700709 span->dump();
710}
711
Cary Clarkb2c7d842018-10-16 18:16:59 +0000712void DontCallDumpTSpan();
713void DontCallDumpTSpan() { // exists to instantiate the templates
714#if !PATH_OP_COMPILE_FOR_SIZE
715 SkArenaAlloc heap(0);
716 SkDQuad quad;
717 SkTSpan<SkDQuad, SkDQuad> q1q2(quad, heap); q1q2.debugInit();
718 SkTSpan<SkDQuad, SkDConic> q1k2(quad, heap); q1k2.debugInit();
719 SkTSpan<SkDQuad, SkDCubic> q1c2(quad, heap); q1c2.debugInit();
720 SkDConic conic;
721 SkTSpan<SkDConic, SkDQuad> k1q2(conic, heap); k1q2.debugInit();
722 SkTSpan<SkDConic, SkDConic> k1k2(conic, heap); k1k2.debugInit();
723 SkTSpan<SkDConic, SkDCubic> k1c2(conic, heap); k1c2.debugInit();
724 SkDCubic cubic;
725 SkTSpan<SkDCubic, SkDQuad> c1q2(cubic, heap); c1q2.debugInit();
726 SkTSpan<SkDCubic, SkDConic> c1k2(cubic, heap); c1k2.debugInit();
727 SkTSpan<SkDCubic, SkDCubic> c1c2(cubic, heap); c1c2.debugInit();
728 Dump(&q1q2);
729 Dump(&q1k2);
730 Dump(&q1c2);
731 Dump(&k1q2);
732 Dump(&k1k2);
733 Dump(&k1c2);
734 Dump(&c1q2);
735 Dump(&c1k2);
736 Dump(&c1c2);
737#endif
738}
739
740template <typename TCurve, typename OppCurve>
741void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
caryclark26ad22a2015-10-16 09:03:38 -0700742 span->dumpAll();
743}
744
Cary Clarkb2c7d842018-10-16 18:16:59 +0000745void DontCallDumpSpanAll();
746void DontCallDumpSpanAll() { // exists to instantiate the templates
747#if !PATH_OP_COMPILE_FOR_SIZE
748 SkArenaAlloc heap(0);
749 SkDQuad quad;
750 SkTSpan<SkDQuad, SkDQuad> q1q2(quad, heap); q1q2.debugInit();
751 SkTSpan<SkDQuad, SkDConic> q1k2(quad, heap); q1k2.debugInit();
752 SkTSpan<SkDQuad, SkDCubic> q1c2(quad, heap); q1c2.debugInit();
753 SkDConic conic;
754 SkTSpan<SkDConic, SkDQuad> k1q2(conic, heap); k1q2.debugInit();
755 SkTSpan<SkDConic, SkDConic> k1k2(conic, heap); k1k2.debugInit();
756 SkTSpan<SkDConic, SkDCubic> k1c2(conic, heap); k1c2.debugInit();
757 SkDCubic cubic;
758 SkTSpan<SkDCubic, SkDQuad> c1q2(cubic, heap); c1q2.debugInit();
759 SkTSpan<SkDCubic, SkDConic> c1k2(cubic, heap); c1k2.debugInit();
760 SkTSpan<SkDCubic, SkDCubic> c1c2(cubic, heap); c1c2.debugInit();
761 DumpAll(&q1q2);
762 DumpAll(&q1k2);
763 DumpAll(&q1c2);
764 DumpAll(&k1q2);
765 DumpAll(&k1k2);
766 DumpAll(&k1c2);
767 DumpAll(&c1q2);
768 DumpAll(&c1k2);
769 DumpAll(&c1c2);
770#endif
771}
772
773template <typename TCurve, typename OppCurve>
774void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
caryclark26ad22a2015-10-16 09:03:38 -0700775 span->dumpBounded(0);
776}
777
Cary Clarkb2c7d842018-10-16 18:16:59 +0000778void DontCallDumpSpanBounded();
779void DontCallDumpSpanBounded() { // exists to instantiate the templates
780#if !PATH_OP_COMPILE_FOR_SIZE
781 SkArenaAlloc heap(0);
782 SkDQuad quad;
783 SkTSpan<SkDQuad, SkDQuad> q1q2(quad, heap); q1q2.debugInit();
784 SkTSpan<SkDQuad, SkDConic> q1k2(quad, heap); q1k2.debugInit();
785 SkTSpan<SkDQuad, SkDCubic> q1c2(quad, heap); q1c2.debugInit();
786 SkDConic conic;
787 SkTSpan<SkDConic, SkDQuad> k1q2(conic, heap); k1q2.debugInit();
788 SkTSpan<SkDConic, SkDConic> k1k2(conic, heap); k1k2.debugInit();
789 SkTSpan<SkDConic, SkDCubic> k1c2(conic, heap); k1c2.debugInit();
790 SkDCubic cubic;
791 SkTSpan<SkDCubic, SkDQuad> c1q2(cubic, heap); c1q2.debugInit();
792 SkTSpan<SkDCubic, SkDConic> c1k2(cubic, heap); c1k2.debugInit();
793 SkTSpan<SkDCubic, SkDCubic> c1c2(cubic, heap); c1c2.debugInit();
794 DumpBounded(&q1q2);
795 DumpBounded(&q1k2);
796 DumpBounded(&q1c2);
797 DumpBounded(&k1q2);
798 DumpBounded(&k1k2);
799 DumpBounded(&k1c2);
800 DumpBounded(&c1q2);
801 DumpBounded(&c1k2);
802 DumpBounded(&c1c2);
803#endif
804}
805
806template <typename TCurve, typename OppCurve>
807void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
caryclark1049f122015-04-20 08:31:59 -0700808 span->dumpCoin();
809}
810
Cary Clarkb2c7d842018-10-16 18:16:59 +0000811void DontCallDumpSpanCoin();
812void DontCallDumpSpanCoin() { // exists to instantiate the templates
813#if !PATH_OP_COMPILE_FOR_SIZE
814 SkArenaAlloc heap(0);
815 SkDQuad quad;
816 SkTSpan<SkDQuad, SkDQuad> q1q2(quad, heap); q1q2.debugInit();
817 SkTSpan<SkDQuad, SkDConic> q1k2(quad, heap); q1k2.debugInit();
818 SkTSpan<SkDQuad, SkDCubic> q1c2(quad, heap); q1c2.debugInit();
819 SkDConic conic;
820 SkTSpan<SkDConic, SkDQuad> k1q2(conic, heap); k1q2.debugInit();
821 SkTSpan<SkDConic, SkDConic> k1k2(conic, heap); k1k2.debugInit();
822 SkTSpan<SkDConic, SkDCubic> k1c2(conic, heap); k1c2.debugInit();
823 SkDCubic cubic;
824 SkTSpan<SkDCubic, SkDQuad> c1q2(cubic, heap); c1q2.debugInit();
825 SkTSpan<SkDCubic, SkDConic> c1k2(cubic, heap); c1k2.debugInit();
826 SkTSpan<SkDCubic, SkDCubic> c1c2(cubic, heap); c1c2.debugInit();
827 DumpCoin(&q1q2);
828 DumpCoin(&q1k2);
829 DumpCoin(&q1c2);
830 DumpCoin(&k1q2);
831 DumpCoin(&k1k2);
832 DumpCoin(&k1c2);
833 DumpCoin(&c1q2);
834 DumpCoin(&c1k2);
835 DumpCoin(&c1c2);
836#endif
837}
838
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000839static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700840 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
841 quad1.dumpInner();
842 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000843 quad2.dump();
844 SkDebugf("</div>\n\n");
845}
846
847static void dumpTestTrailer() {
848 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
849 SkDebugf(" var testDivs = [\n");
850}
851
852static void dumpTestList(int testNo, double min) {
853 SkDebugf(" quad%d,", testNo);
854 if (min > 0) {
855 SkDebugf(" // %1.9g", min);
856 }
857 SkDebugf("\n");
858}
859
860void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
861 SkDebugf("\n");
862 dumpTestCase(quad1, quad2, testNo);
863 dumpTestTrailer();
864 dumpTestList(testNo, 0);
865 SkDebugf("\n");
866}
867
868void DumpT(const SkDQuad& quad, double t) {
869 SkDLine line = {{quad.ptAtT(t), quad[0]}};
870 line.dump();
871}
caryclark54359292015-03-26 07:52:43 -0700872
873const SkOpAngle* SkOpAngle::debugAngle(int id) const {
874 return this->segment()->debugAngle(id);
875}
876
caryclark55888e42016-07-18 10:01:36 -0700877const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
878 return this->segment()->debugCoincidence();
879}
880
caryclark30b9fdd2016-08-31 14:36:29 -0700881SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700882 return this->segment()->debugContour(id);
883}
884
885const SkOpPtT* SkOpAngle::debugPtT(int id) const {
886 return this->segment()->debugPtT(id);
887}
888
889const SkOpSegment* SkOpAngle::debugSegment(int id) const {
890 return this->segment()->debugSegment(id);
891}
892
caryclark624637c2015-05-11 07:21:27 -0700893int SkOpAngle::debugSign() const {
894 SkASSERT(fStart->t() != fEnd->t());
895 return fStart->t() < fEnd->t() ? -1 : 1;
896}
897
caryclark54359292015-03-26 07:52:43 -0700898const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
899 return this->segment()->debugSpan(id);
900}
901
902void SkOpAngle::dump() const {
903 dumpOne(true);
904 SkDebugf("\n");
905}
906
907void SkOpAngle::dumpOne(bool functionHeader) const {
908// fSegment->debugValidate();
909 const SkOpSegment* segment = this->segment();
910 const SkOpSpan& mSpan = *fStart->starter(fEnd);
911 if (functionHeader) {
912 SkDebugf("%s ", __FUNCTION__);
913 }
914 SkDebugf("[%d", segment->debugID());
915 SkDebugf("/%d", debugID());
916 SkDebugf("] next=");
917 if (fNext) {
918 SkDebugf("%d", fNext->fStart->segment()->debugID());
919 SkDebugf("/%d", fNext->debugID());
920 } else {
921 SkDebugf("?");
922 }
923 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
924 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
925 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700926 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700927
928 SkDebugf(" windSum=");
929 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
930 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
931 SkDebugf(" oppVal=%d", mSpan.oppValue());
932 SkDebugf(" oppSum=");
933 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
934 }
935 if (mSpan.done()) {
936 SkDebugf(" done");
937 }
938 if (unorderable()) {
939 SkDebugf(" unorderable");
940 }
941 if (segment->operand()) {
942 SkDebugf(" operand");
943 }
caryclark54359292015-03-26 07:52:43 -0700944}
945
946void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
947 const SkOpAngle* first = this;
948 const SkOpAngle* next = this;
949 const char* indent = "";
950 do {
951 SkDebugf("%s", indent);
952 next->dumpOne(false);
953 if (segment == next->fStart->segment()) {
954 if (this == fNext) {
955 SkDebugf(" << from");
956 }
957 if (to == fNext) {
958 SkDebugf(" << to");
959 }
960 }
961 SkDebugf("\n");
962 indent = " ";
963 next = next->fNext;
964 } while (next && next != first);
965}
966
967void SkOpAngle::dumpCurves() const {
968 const SkOpAngle* first = this;
969 const SkOpAngle* next = this;
970 do {
caryclarkeed356d2016-09-14 07:18:20 -0700971 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700972 next = next->fNext;
973 } while (next && next != first);
974}
975
976void SkOpAngle::dumpLoop() const {
977 const SkOpAngle* first = this;
978 const SkOpAngle* next = this;
979 do {
980 next->dumpOne(false);
981 SkDebugf("\n");
982 next = next->fNext;
983 } while (next && next != first);
984}
985
986void SkOpAngle::dumpTest() const {
987 const SkOpAngle* first = this;
988 const SkOpAngle* next = this;
989 do {
990 SkDebugf("{ ");
991 SkOpSegment* segment = next->segment();
992 segment->dumpPts();
993 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
994 next->start()->t(), next->end()->t());
995 next = next->fNext;
996 } while (next && next != first);
997}
998
999bool SkOpPtT::debugMatchID(int id) const {
1000 int limit = this->debugLoopLimit(false);
1001 int loop = 0;
1002 const SkOpPtT* ptT = this;
1003 do {
1004 if (ptT->debugID() == id) {
1005 return true;
1006 }
1007 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
1008 return false;
1009}
1010
1011const SkOpAngle* SkOpPtT::debugAngle(int id) const {
1012 return this->span()->debugAngle(id);
1013}
1014
caryclark30b9fdd2016-08-31 14:36:29 -07001015SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001016 return this->span()->debugContour(id);
1017}
1018
caryclark55888e42016-07-18 10:01:36 -07001019const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
1020 return this->span()->debugCoincidence();
1021}
1022
caryclark54359292015-03-26 07:52:43 -07001023const SkOpPtT* SkOpPtT::debugPtT(int id) const {
1024 return this->span()->debugPtT(id);
1025}
1026
1027const SkOpSegment* SkOpPtT::debugSegment(int id) const {
1028 return this->span()->debugSegment(id);
1029}
1030
1031const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
1032 return this->span()->debugSpan(id);
1033}
1034
1035void SkOpPtT::dump() const {
1036 SkDebugf("seg=%d span=%d ptT=%d",
1037 this->segment()->debugID(), this->span()->debugID(), this->debugID());
1038 this->dumpBase();
1039 SkDebugf("\n");
1040}
1041
1042void SkOpPtT::dumpAll() const {
1043 contour()->indentDump();
1044 const SkOpPtT* next = this;
1045 int limit = debugLoopLimit(true);
1046 int loop = 0;
1047 do {
1048 SkDebugf("%.*s", contour()->debugIndent(), " ");
1049 SkDebugf("seg=%d span=%d ptT=%d",
1050 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1051 next->dumpBase();
1052 SkDebugf("\n");
1053 if (limit && ++loop >= limit) {
1054 SkDebugf("*** abort loop ***\n");
1055 break;
1056 }
1057 } while ((next = next->fNext) && next != this);
1058 contour()->outdentDump();
1059}
1060
1061void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001062 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1063 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001064 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1065}
1066
1067const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1068 return this->segment()->debugAngle(id);
1069}
1070
caryclark55888e42016-07-18 10:01:36 -07001071const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1072 return this->segment()->debugCoincidence();
1073}
1074
caryclark30b9fdd2016-08-31 14:36:29 -07001075SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001076 return this->segment()->debugContour(id);
1077}
1078
1079const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1080 return this->segment()->debugPtT(id);
1081}
1082
1083const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1084 return this->segment()->debugSegment(id);
1085}
1086
1087const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1088 return this->segment()->debugSpan(id);
1089}
1090
1091void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001092 this->dumpHead();
1093 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001094}
1095
caryclark55888e42016-07-18 10:01:36 -07001096void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001097 SkDebugf("%.*s", contour()->debugIndent(), " ");
1098 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1099 this->dumpBase();
1100 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001101}
1102
1103void SkOpSpanBase::dumpAll() const {
1104 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001105 this->fPtT.dumpAll();
1106}
1107
1108void SkOpSpanBase::dumpBase() const {
1109 if (this->fAligned) {
1110 SkDebugf(" aligned");
1111 }
1112 if (this->fChased) {
1113 SkDebugf(" chased");
1114 }
caryclark55888e42016-07-18 10:01:36 -07001115#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001116 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001117 SkDebugf(" deleted");
1118 }
1119#endif
caryclark54359292015-03-26 07:52:43 -07001120 if (!this->final()) {
1121 this->upCast()->dumpSpan();
1122 }
1123 const SkOpSpanBase* coin = this->coinEnd();
1124 if (this != coin) {
1125 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1126 } else if (this->final() || !this->upCast()->isCoincident()) {
1127 const SkOpPtT* oPt = this->ptT()->next();
1128 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1129 }
caryclark08bc8482015-04-24 09:08:57 -07001130 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001131}
1132
1133void SkOpSpanBase::dumpCoin() const {
1134 const SkOpSpan* span = this->upCastable();
1135 if (!span) {
1136 return;
1137 }
1138 if (!span->isCoincident()) {
1139 return;
1140 }
1141 span->dumpCoin();
1142}
1143
1144void SkOpSpan::dumpCoin() const {
1145 const SkOpSpan* coincident = fCoincident;
1146 bool ok = debugCoinLoopCheck();
1147 this->dump();
1148 int loop = 0;
1149 do {
1150 coincident->dump();
1151 if (!ok && ++loop > 10) {
1152 SkDebugf("*** abort loop ***\n");
1153 break;
1154 }
1155 } while ((coincident = coincident->fCoincident) != this);
1156}
1157
1158bool SkOpSpan::dumpSpan() const {
1159 SkOpSpan* coin = fCoincident;
1160 if (this != coin) {
1161 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1162 }
1163 SkDebugf(" windVal=%d", this->windValue());
1164 SkDebugf(" windSum=");
1165 SkPathOpsDebug::WindingPrintf(this->windSum());
1166 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1167 SkDebugf(" oppVal=%d", this->oppValue());
1168 SkDebugf(" oppSum=");
1169 SkPathOpsDebug::WindingPrintf(this->oppSum());
1170 }
1171 if (this->done()) {
1172 SkDebugf(" done");
1173 }
1174 return this != coin;
1175}
1176
1177const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1178 return this->contour()->debugAngle(id);
1179}
1180
Cary Clarkb2c7d842018-10-16 18:16:59 +00001181
caryclark55888e42016-07-18 10:01:36 -07001182const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1183 return this->contour()->debugCoincidence();
1184}
1185
caryclark30b9fdd2016-08-31 14:36:29 -07001186SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001187 return this->contour()->debugContour(id);
1188}
1189
1190const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1191 return this->contour()->debugPtT(id);
1192}
1193
1194const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1195 return this->contour()->debugSegment(id);
1196}
1197
1198const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1199 return this->contour()->debugSpan(id);
1200}
1201
1202void SkOpSegment::dump() const {
1203 SkDebugf("%.*s", contour()->debugIndent(), " ");
1204 this->dumpPts();
1205 const SkOpSpanBase* span = &fHead;
1206 contour()->indentDump();
1207 do {
1208 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1209 span->ptT()->dumpBase();
1210 span->dumpBase();
1211 SkDebugf("\n");
1212 } while (!span->final() && (span = span->upCast()->next()));
1213 contour()->outdentDump();
1214}
1215
1216void SkOpSegment::dumpAll() const {
1217 SkDebugf("%.*s", contour()->debugIndent(), " ");
1218 this->dumpPts();
1219 const SkOpSpanBase* span = &fHead;
1220 contour()->indentDump();
1221 do {
1222 span->dumpAll();
1223 } while (!span->final() && (span = span->upCast()->next()));
1224 contour()->outdentDump();
1225}
1226
1227void SkOpSegment::dumpAngles() const {
1228 SkDebugf("seg=%d\n", debugID());
1229 const SkOpSpanBase* span = &fHead;
1230 do {
1231 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001232 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001233 if (fAngle) {
1234 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1235 fAngle->dumpTo(this, tAngle);
1236 }
1237 if (tAngle) {
1238 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1239 tAngle->dumpTo(this, fAngle);
1240 }
1241 } while (!span->final() && (span = span->upCast()->next()));
1242}
1243
1244void SkOpSegment::dumpCoin() const {
1245 const SkOpSpan* span = &fHead;
1246 do {
1247 span->dumpCoin();
1248 } while ((span = span->next()->upCastable()));
1249}
1250
caryclark26ad22a2015-10-16 09:03:38 -07001251void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001252 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001253 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001254 if (fVerb == SkPath::kConic_Verb) {
1255 SkDebugf("{");
1256 }
caryclark54359292015-03-26 07:52:43 -07001257 int index = 0;
1258 do {
1259 SkDPoint::Dump(fPts[index]);
1260 SkDebugf(", ");
1261 } while (++index < last);
1262 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001263 SkDebugf("}}");
1264 if (fVerb == SkPath::kConic_Verb) {
1265 SkDebugf(", %1.9gf}", fWeight);
1266 }
caryclark624637c2015-05-11 07:21:27 -07001267}
1268
caryclark26ad22a2015-10-16 09:03:38 -07001269void SkOpSegment::dumpPts(const char* prefix) const {
1270 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001271 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001272}
1273
1274void SkCoincidentSpans::dump() const {
1275 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1276 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1277 fCoinPtTStart->dumpBase();
1278 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1279 fCoinPtTEnd->dumpBase();
1280 if (fCoinPtTStart->segment()->operand()) {
1281 SkDebugf(" operand");
1282 }
1283 if (fCoinPtTStart->segment()->isXor()) {
1284 SkDebugf(" xor");
1285 }
1286 SkDebugf("\n");
1287 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1288 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1289 fOppPtTStart->dumpBase();
1290 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1291 fOppPtTEnd->dumpBase();
1292 if (fOppPtTStart->segment()->operand()) {
1293 SkDebugf(" operand");
1294 }
1295 if (fOppPtTStart->segment()->isXor()) {
1296 SkDebugf(" xor");
1297 }
1298 SkDebugf("\n");
1299}
1300
1301void SkOpCoincidence::dump() const {
1302 SkCoincidentSpans* span = fHead;
1303 while (span) {
1304 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001305 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001306 }
caryclark26ad22a2015-10-16 09:03:38 -07001307 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001308 return;
1309 }
1310 SkDebugf("top:\n");
1311 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001312 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001313 while (span) {
1314 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001315 span = span->next();
1316 SkCoincidentSpans* check = fTop;
1317 ++count;
1318 for (int index = 0; index < count; ++index) {
1319 if (span == check) {
1320 SkDebugf("(loops to #%d)\n", index);
1321 return;
1322 }
1323 check = check->next();
1324 }
caryclark27c8eb82015-07-06 11:38:33 -07001325 }
caryclark54359292015-03-26 07:52:43 -07001326}
1327
caryclark624637c2015-05-11 07:21:27 -07001328void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001329 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001330 if (!fCount) {
1331 return;
1332 }
1333 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001334 SkDEBUGCODE(fDebugIndent = 0);
1335 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001336 do {
1337 segment->dump();
1338 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001339 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001340}
1341
caryclark624637c2015-05-11 07:21:27 -07001342void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001343 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001344 if (!fCount) {
1345 return;
1346 }
1347 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001348 SkDEBUGCODE(fDebugIndent = 0);
1349 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001350 do {
1351 segment->dumpAll();
1352 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001353 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001354}
1355
1356
1357void SkOpContour::dumpAngles() const {
1358 SkDebugf("contour=%d\n", this->debugID());
1359 const SkOpSegment* segment = &fHead;
1360 do {
1361 SkDebugf(" seg=%d ", segment->debugID());
1362 segment->dumpAngles();
1363 } while ((segment = segment->next()));
1364}
1365
1366void SkOpContour::dumpPt(int index) const {
1367 const SkOpSegment* segment = &fHead;
1368 do {
1369 if (segment->debugID() == index) {
1370 segment->dumpPts();
1371 }
1372 } while ((segment = segment->next()));
1373}
1374
caryclark26ad22a2015-10-16 09:03:38 -07001375void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001376 SkDebugf("contour=%d\n", this->debugID());
1377 const SkOpSegment* segment = &fHead;
1378 do {
caryclark26ad22a2015-10-16 09:03:38 -07001379 SkDebugf(" %s=%d ", prefix, segment->debugID());
1380 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001381 } while ((segment = segment->next()));
1382}
1383
caryclark26ad22a2015-10-16 09:03:38 -07001384void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001385 if (!this->fCount) {
1386 SkDebugf("<empty>\n");
1387 return;
1388 }
1389 const SkOpSegment* segment = &fHead;
1390 do {
caryclark26ad22a2015-10-16 09:03:38 -07001391 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001392 } while ((segment = segment->next()));
1393}
1394
1395void SkOpContour::dumpSegment(int index) const {
1396 debugSegment(index)->dump();
1397}
1398
caryclark26ad22a2015-10-16 09:03:38 -07001399void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001400 bool firstOp = false;
1401 const SkOpContour* c = this;
1402 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001403 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001404#if DEBUG_ACTIVE_OP
1405 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1406#endif
1407 firstOp = true;
1408 }
caryclark26ad22a2015-10-16 09:03:38 -07001409 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001410 } while ((c = c->next()));
1411}
1412
1413void SkOpContour::dumpSpan(int index) const {
1414 debugSpan(index)->dump();
1415}
1416
1417void SkOpContour::dumpSpans() const {
1418 SkDebugf("contour=%d\n", this->debugID());
1419 const SkOpSegment* segment = &fHead;
1420 do {
1421 SkDebugf(" seg=%d ", segment->debugID());
1422 segment->dump();
1423 } while ((segment = segment->next()));
1424}
1425
caryclark03b03ca2015-04-23 09:13:37 -07001426void SkOpCurve::dump() const {
1427 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1428 SkDebugf("{{");
1429 int index;
1430 for (index = 0; index <= count - 1; ++index) {
1431 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1432 }
1433 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1434}
1435
caryclark54359292015-03-26 07:52:43 -07001436#ifdef SK_DEBUG
1437const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001438 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001439 do {
1440 const SkOpSegment* segment = contour->first();
1441 while (segment) {
1442 const SkOpSpan* span = segment->head();
1443 do {
1444 SkOpAngle* angle = span->fromAngle();
1445 if (angle && angle->debugID() == id) {
1446 return angle;
1447 }
1448 angle = span->toAngle();
1449 if (angle && angle->debugID() == id) {
1450 return angle;
1451 }
1452 } while ((span = span->next()->upCastable()));
1453 const SkOpSpanBase* tail = segment->tail();
1454 SkOpAngle* angle = tail->fromAngle();
1455 if (angle && angle->debugID() == id) {
1456 return angle;
1457 }
1458 segment = segment->next();
1459 }
1460 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001461 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001462}
1463
caryclark30b9fdd2016-08-31 14:36:29 -07001464SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001465 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001466 do {
1467 if (contour->debugID() == id) {
1468 return contour;
1469 }
1470 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001471 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001472}
1473
1474const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001475 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001476 do {
1477 const SkOpSegment* segment = contour->first();
1478 while (segment) {
1479 const SkOpSpan* span = segment->head();
1480 do {
1481 const SkOpPtT* ptT = span->ptT();
1482 if (ptT->debugMatchID(id)) {
1483 return ptT;
1484 }
1485 } while ((span = span->next()->upCastable()));
1486 const SkOpSpanBase* tail = segment->tail();
1487 const SkOpPtT* ptT = tail->ptT();
1488 if (ptT->debugMatchID(id)) {
1489 return ptT;
1490 }
1491 segment = segment->next();
1492 }
1493 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001494 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001495}
1496
1497const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001498 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001499 do {
1500 const SkOpSegment* segment = contour->first();
1501 while (segment) {
1502 if (segment->debugID() == id) {
1503 return segment;
1504 }
1505 segment = segment->next();
1506 }
1507 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001508 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001509}
1510
1511const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001512 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001513 do {
1514 const SkOpSegment* segment = contour->first();
1515 while (segment) {
1516 const SkOpSpan* span = segment->head();
1517 do {
1518 if (span->debugID() == id) {
1519 return span;
1520 }
1521 } while ((span = span->next()->upCastable()));
1522 const SkOpSpanBase* tail = segment->tail();
1523 if (tail->debugID() == id) {
1524 return tail;
1525 }
1526 segment = segment->next();
1527 }
1528 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001529 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001530}
1531#endif
1532
caryclark54359292015-03-26 07:52:43 -07001533#if DEBUG_T_SECT_DUMP > 1
1534int gDumpTSectNum;
1535#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001536
1537// global path dumps for msvs Visual Studio 17 to use from Immediate Window
Cary Clarkb2c7d842018-10-16 18:16:59 +00001538namespace SkOpDebug {
Cary Clarkb8421ed2018-03-14 15:55:02 -04001539
Cary Clarkb2c7d842018-10-16 18:16:59 +00001540 void Dump(const SkOpContour& contour) {
1541 contour.dump();
1542 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001543
Cary Clarkb2c7d842018-10-16 18:16:59 +00001544 void DumpAll(const SkOpContour& contour) {
1545 contour.dumpAll();
1546 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001547
Cary Clarkb2c7d842018-10-16 18:16:59 +00001548 void DumpAngles(const SkOpContour& contour) {
1549 contour.dumpAngles();
1550 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001551
Cary Clarkb2c7d842018-10-16 18:16:59 +00001552 void DumpContours(const SkOpContour& contour) {
1553 contour.dumpContours();
1554 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001555
Cary Clarkb2c7d842018-10-16 18:16:59 +00001556 void DumpContoursAll(const SkOpContour& contour) {
1557 contour.dumpContoursAll();
1558 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001559
Cary Clarkb2c7d842018-10-16 18:16:59 +00001560 void DumpContoursAngles(const SkOpContour& contour) {
1561 contour.dumpContoursAngles();
1562 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001563
Cary Clarkb2c7d842018-10-16 18:16:59 +00001564 void DumpContoursPts(const SkOpContour& contour) {
1565 contour.dumpContoursPts();
1566 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001567
Cary Clarkb2c7d842018-10-16 18:16:59 +00001568 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1569 contour.dumpContoursPt(segmentID);
1570 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001571
Cary Clarkb2c7d842018-10-16 18:16:59 +00001572 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1573 contour.dumpContoursSegment(segmentID);
1574 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001575
Cary Clarkb2c7d842018-10-16 18:16:59 +00001576 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1577 contour.dumpContoursSpan(segmentID);
1578 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001579
Cary Clarkb2c7d842018-10-16 18:16:59 +00001580 void DumpContoursSpans(const SkOpContour& contour) {
1581 contour.dumpContoursSpans();
1582 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001583
Cary Clarkb2c7d842018-10-16 18:16:59 +00001584 void DumpPt(const SkOpContour& contour, int pt) {
1585 contour.dumpPt(pt);
1586 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001587
Cary Clarkb2c7d842018-10-16 18:16:59 +00001588 void DumpPts(const SkOpContour& contour, const char* prefix) {
1589 contour.dumpPts(prefix);
1590 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001591
Cary Clarkb2c7d842018-10-16 18:16:59 +00001592 void DumpSegment(const SkOpContour& contour, int seg) {
1593 contour.dumpSegment(seg);
1594 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001595
Cary Clarkb2c7d842018-10-16 18:16:59 +00001596 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1597 contour.dumpSegments(prefix, op);
1598 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001599
Cary Clarkb2c7d842018-10-16 18:16:59 +00001600 void DumpSpan(const SkOpContour& contour, int span) {
1601 contour.dumpSpan(span);
1602 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001603
Cary Clarkb2c7d842018-10-16 18:16:59 +00001604 void DumpSpans(const SkOpContour& contour ) {
1605 contour.dumpSpans();
1606 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001607
Cary Clarkb2c7d842018-10-16 18:16:59 +00001608 void Dump(const SkOpSegment& segment) {
1609 segment.dump();
1610 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001611
Cary Clarkb2c7d842018-10-16 18:16:59 +00001612 void DumpAll(const SkOpSegment& segment) {
1613 segment.dumpAll();
1614 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001615
Cary Clarkb2c7d842018-10-16 18:16:59 +00001616 void DumpAngles(const SkOpSegment& segment) {
1617 segment.dumpAngles();
1618 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001619
Cary Clarkb2c7d842018-10-16 18:16:59 +00001620 void DumpCoin(const SkOpSegment& segment) {
1621 segment.dumpCoin();
1622 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001623
Cary Clarkb2c7d842018-10-16 18:16:59 +00001624 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1625 segment.dumpPts(prefix);
1626 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001627
Cary Clarkb2c7d842018-10-16 18:16:59 +00001628 void Dump(const SkOpPtT& ptT) {
1629 ptT.dump();
1630 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001631
Cary Clarkb2c7d842018-10-16 18:16:59 +00001632 void DumpAll(const SkOpPtT& ptT) {
1633 ptT.dumpAll();
1634 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001635
Cary Clarkb2c7d842018-10-16 18:16:59 +00001636 void Dump(const SkOpSpanBase& spanBase) {
1637 spanBase.dump();
1638 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001639
Cary Clarkb2c7d842018-10-16 18:16:59 +00001640 void DumpCoin(const SkOpSpanBase& spanBase) {
1641 spanBase.dumpCoin();
1642 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001643
Cary Clarkb2c7d842018-10-16 18:16:59 +00001644 void DumpAll(const SkOpSpanBase& spanBase) {
1645 spanBase.dumpAll();
1646 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001647
Cary Clarkb2c7d842018-10-16 18:16:59 +00001648 void DumpCoin(const SkOpSpan& span) {
1649 span.dumpCoin();
1650 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001651
Cary Clarkb2c7d842018-10-16 18:16:59 +00001652 bool DumpSpan(const SkOpSpan& span) {
1653 return span.dumpSpan();
1654 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001655
Cary Clarkb2c7d842018-10-16 18:16:59 +00001656 void Dump(const SkDConic& conic) {
1657 conic.dump();
1658 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001659
Cary Clarkb2c7d842018-10-16 18:16:59 +00001660 void DumpID(const SkDConic& conic, int id) {
1661 conic.dumpID(id);
1662 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001663
Cary Clarkb2c7d842018-10-16 18:16:59 +00001664 void Dump(const SkDCubic& cubic) {
1665 cubic.dump();
1666 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001667
Cary Clarkb2c7d842018-10-16 18:16:59 +00001668 void DumpID(const SkDCubic& cubic, int id) {
1669 cubic.dumpID(id);
1670 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001671
Cary Clarkb2c7d842018-10-16 18:16:59 +00001672 void Dump(const SkDLine& line) {
1673 line.dump();
1674 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001675
Cary Clarkb2c7d842018-10-16 18:16:59 +00001676 void DumpID(const SkDLine& line, int id) {
1677 line.dumpID(id);
1678 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001679
Cary Clarkb2c7d842018-10-16 18:16:59 +00001680 void Dump(const SkDQuad& quad) {
1681 quad.dump();
1682 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001683
Cary Clarkb2c7d842018-10-16 18:16:59 +00001684 void DumpID(const SkDQuad& quad, int id) {
1685 quad.dumpID(id);
1686 }
Cary Clarkb8421ed2018-03-14 15:55:02 -04001687
Cary Clarkb2c7d842018-10-16 18:16:59 +00001688 void Dump(const SkDPoint& point) {
1689 point.dump();
1690 }
1691
1692 void Dump(const SkOpAngle& angle) {
1693 angle.dump();
1694 }
1695
1696// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1697#define DummyDefinitions(a, b) \
1698 \
1699 void Dump(const SkDebugTCoincident##a##b& curve) { \
1700 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1701 } \
1702 \
1703 void Dump(const SkDebugTSect##a##b& curve) { \
1704 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1705 } \
1706 \
1707 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1708 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1709 } \
1710 \
1711 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1712 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1713 } \
1714 \
1715 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1716 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1717 } \
1718 \
1719 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1720 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1721 } \
1722 \
1723 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1724 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1725 } \
1726 \
1727 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1728 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1729 } \
1730 \
1731 void Dump(const SkDebugTSpan##a##b& curve) { \
1732 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1733 } \
1734 \
1735 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1736 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1737 } \
1738 \
1739 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1740 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1741 } \
1742 \
1743 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1744 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1745 } \
1746 \
1747 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1748 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1749 }
1750
1751#if !PATH_OP_COMPILE_FOR_SIZE
1752 DummyDefinitions(Quad, Quad);
1753 DummyDefinitions(Conic, Quad);
1754 DummyDefinitions(Conic, Conic);
1755 DummyDefinitions(Cubic, Quad);
1756 DummyDefinitions(Cubic, Conic);
1757 DummyDefinitions(Cubic, Cubic);
1758#endif
1759
1760#undef DummyDefinitions
Cary Clarkb8421ed2018-03-14 15:55:02 -04001761}