blob: 09579065a6644495688b93d8f00613f166aad6f2 [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;
18bool PathOpsDebug::gOutFirst;
Cary Clark4533f3d2018-08-08 09:48:09 -040019bool PathOpsDebug::gCheckForDuplicateNames;
Cary Clarkf3949122018-08-07 16:38:21 -040020FILE* PathOpsDebug::gOut;
21
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000022inline void DebugDumpDouble(double x) {
23 if (x == floor(x)) {
24 SkDebugf("%.0f", x);
25 } else {
26 SkDebugf("%1.19g", x);
27 }
28}
29
30inline void DebugDumpFloat(float x) {
31 if (x == floorf(x)) {
32 SkDebugf("%.0f", x);
33 } else {
34 SkDebugf("%1.9gf", x);
35 }
36}
37
caryclark65f55312014-11-13 06:58:52 -080038inline void DebugDumpHexFloat(float x) {
39 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
40}
caryclark19eb3b22014-07-18 05:08:14 -070041
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000042// if not defined by PathOpsDebug.cpp ...
43#if !defined SK_DEBUG && FORCE_RELEASE
44bool SkPathOpsDebug::ValidWind(int wind) {
45 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
46}
47
48void SkPathOpsDebug::WindingPrintf(int wind) {
49 if (wind == SK_MinS32) {
50 SkDebugf("?");
51 } else {
52 SkDebugf("%d", wind);
53 }
54}
55#endif
56
caryclark55888e42016-07-18 10:01:36 -070057static void DumpID(int id) {
58 SkDebugf("} ");
59 if (id >= 0) {
60 SkDebugf("id=%d", id);
61 }
62 SkDebugf("\n");
63}
64
caryclark1049f122015-04-20 08:31:59 -070065void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070066 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070067 SkDebugf("},\n");
68}
69
70void SkDConic::dumpID(int id) const {
71 dumpInner();
caryclark55888e42016-07-18 10:01:36 -070072 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -070073}
74
75void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070076 SkDebugf("{");
77 fPts.dumpInner();
78 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070079}
80
81void SkDCubic::dump() const {
82 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070083 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070084}
85
caryclark54359292015-03-26 07:52:43 -070086void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070087 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -070088 SkDebugf("}");
89 DumpID(id);
reed0dc4dd62015-03-24 13:55:33 -070090}
91
caryclark54359292015-03-26 07:52:43 -070092static inline bool double_is_NaN(double x) { return x != x; }
93
94void SkDCubic::dumpInner() const {
95 SkDebugf("{{");
96 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070097 do {
caryclark54359292015-03-26 07:52:43 -070098 if (index != 0) {
99 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
100 return;
reed0dc4dd62015-03-24 13:55:33 -0700101 }
caryclark54359292015-03-26 07:52:43 -0700102 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700103 }
caryclark54359292015-03-26 07:52:43 -0700104 fPts[index].dump();
105 } while (++index < 3);
106 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -0700107 return;
108 }
caryclark54359292015-03-26 07:52:43 -0700109 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700110 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000111}
112
caryclark55888e42016-07-18 10:01:36 -0700113void SkDCurve::dump() const {
114 dumpID(-1);
115}
116
caryclark1049f122015-04-20 08:31:59 -0700117void SkDCurve::dumpID(int id) const {
118#ifndef SK_RELEASE
119 switch(fVerb) {
120 case SkPath::kLine_Verb:
121 fLine.dumpID(id);
122 break;
123 case SkPath::kQuad_Verb:
124 fQuad.dumpID(id);
125 break;
126 case SkPath::kConic_Verb:
127 fConic.dumpID(id);
128 break;
129 case SkPath::kCubic_Verb:
130 fCubic.dumpID(id);
131 break;
132 default:
133 SkASSERT(0);
134 }
135#else
136 fCubic.dumpID(id);
137#endif
138}
139
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000140void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700141 this->dumpInner();
142 SkDebugf("}},\n");
143}
144
145void SkDLine::dumpID(int id) const {
146 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700147 SkDebugf("}");
148 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -0700149}
150
151void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000152 SkDebugf("{{");
153 fPts[0].dump();
154 SkDebugf(", ");
155 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000156}
157
158void SkDPoint::dump() const {
159 SkDebugf("{");
160 DebugDumpDouble(fX);
161 SkDebugf(", ");
162 DebugDumpDouble(fY);
163 SkDebugf("}");
164}
165
166void SkDPoint::Dump(const SkPoint& pt) {
167 SkDebugf("{");
168 DebugDumpFloat(pt.fX);
169 SkDebugf(", ");
170 DebugDumpFloat(pt.fY);
171 SkDebugf("}");
172}
173
caryclark65f55312014-11-13 06:58:52 -0800174void SkDPoint::DumpHex(const SkPoint& pt) {
175 SkDebugf("{");
176 DebugDumpHexFloat(pt.fX);
177 SkDebugf(", ");
178 DebugDumpHexFloat(pt.fY);
179 SkDebugf("}");
180}
181
182void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700183 dumpInner();
184 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800185}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000186
caryclark54359292015-03-26 07:52:43 -0700187void SkDQuad::dumpID(int id) const {
188 dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700189 SkDebugf("}");
190 DumpID(id);
caryclark54359292015-03-26 07:52:43 -0700191}
192
193void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000194 SkDebugf("{{");
195 int index = 0;
196 do {
197 fPts[index].dump();
198 SkDebugf(", ");
199 } while (++index < 2);
200 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000201}
202
caryclark54359292015-03-26 07:52:43 -0700203void SkIntersections::dump() const {
204 SkDebugf("used=%d of %d", fUsed, fMax);
205 for (int index = 0; index < fUsed; ++index) {
206 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
207 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
208 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
209 fPt[index].fX, fPt[index].fY);
210 if (index < 2 && fNearlySame[index]) {
211 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000212 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000213 }
214 SkDebugf("\n");
215}
216
Cary Clarkb8421ed2018-03-14 15:55:02 -0400217namespace SkOpDebug {
218
219const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700220 return angle->debugAngle(id);
221}
222
Cary Clarkb8421ed2018-03-14 15:55:02 -0400223::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700224 return angle->debugContour(id);
225}
226
Cary Clarkb8421ed2018-03-14 15:55:02 -0400227const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700228 return angle->debugPtT(id);
229}
230
Cary Clarkb8421ed2018-03-14 15:55:02 -0400231const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700232 return angle->debugSegment(id);
233}
234
Cary Clarkb8421ed2018-03-14 15:55:02 -0400235const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700236 return angle->debugSpan(id);
237}
238
Cary Clarkb8421ed2018-03-14 15:55:02 -0400239const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700240 return contour->debugAngle(id);
241}
242
Cary Clarkb8421ed2018-03-14 15:55:02 -0400243::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700244 return contour->debugContour(id);
245}
246
Cary Clarkb8421ed2018-03-14 15:55:02 -0400247const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700248 return contour->debugPtT(id);
249}
250
Cary Clarkb8421ed2018-03-14 15:55:02 -0400251const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700252 return contour->debugSegment(id);
253}
254
Cary Clarkb8421ed2018-03-14 15:55:02 -0400255const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700256 return contour->debugSpan(id);
257}
258
Cary Clarkb8421ed2018-03-14 15:55:02 -0400259const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700260 return coin->debugAngle(id);
261}
262
Cary Clarkb8421ed2018-03-14 15:55:02 -0400263::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700264 return coin->debugContour(id);
265}
266
Cary Clarkb8421ed2018-03-14 15:55:02 -0400267const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700268 return coin->debugPtT(id);
269}
270
Cary Clarkb8421ed2018-03-14 15:55:02 -0400271const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700272 return coin->debugSegment(id);
273}
274
Cary Clarkb8421ed2018-03-14 15:55:02 -0400275const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700276 return coin->debugSpan(id);
277}
278
Cary Clarkb8421ed2018-03-14 15:55:02 -0400279const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700280 return ptT->debugAngle(id);
281}
282
Cary Clarkb8421ed2018-03-14 15:55:02 -0400283::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700284 return ptT->debugContour(id);
285}
286
Cary Clarkb8421ed2018-03-14 15:55:02 -0400287const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700288 return ptT->debugPtT(id);
289}
290
Cary Clarkb8421ed2018-03-14 15:55:02 -0400291const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700292 return ptT->debugSegment(id);
293}
294
Cary Clarkb8421ed2018-03-14 15:55:02 -0400295const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700296 return ptT->debugSpan(id);
297}
298
Cary Clarkb8421ed2018-03-14 15:55:02 -0400299const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700300 return span->debugAngle(id);
301}
302
Cary Clarkb8421ed2018-03-14 15:55:02 -0400303::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700304 return span->debugContour(id);
305}
306
Cary Clarkb8421ed2018-03-14 15:55:02 -0400307const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700308 return span->debugPtT(id);
309}
310
Cary Clarkb8421ed2018-03-14 15:55:02 -0400311const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700312 return span->debugSegment(id);
313}
314
Cary Clarkb8421ed2018-03-14 15:55:02 -0400315const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700316 return span->debugSpan(id);
317}
318
Cary Clarkb8421ed2018-03-14 15:55:02 -0400319const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700320 return span->debugAngle(id);
321}
322
Cary Clarkb8421ed2018-03-14 15:55:02 -0400323::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700324 return span->debugContour(id);
325}
326
Cary Clarkb8421ed2018-03-14 15:55:02 -0400327const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700328 return span->debugPtT(id);
329}
330
Cary Clarkb8421ed2018-03-14 15:55:02 -0400331const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700332 return span->debugSegment(id);
333}
334
Cary Clarkb8421ed2018-03-14 15:55:02 -0400335const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700336 return span->debugSpan(id);
337}
338
Cary Clarkb8421ed2018-03-14 15:55:02 -0400339} // namespace SkPathOpsDebug
340
Cary Clarkab87d7a2016-10-04 10:01:04 -0400341#if DEBUG_COIN
342void SkPathOpsDebug::DumpCoinDict() {
Cary Clarkb8421ed2018-03-14 15:55:02 -0400343 SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false);
344 SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true);
Cary Clarkab87d7a2016-10-04 10:01:04 -0400345}
346
347void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const {
348 int count = fDict.count();
349 for (int index = 0; index < count; ++index) {
350 const auto& entry = fDict[index];
351 if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) {
352 SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName,
353 entry.fLineNumber, entry.fIteration);
354 DumpGlitchType(entry.fGlitchType);
355 SkDebugf("\n");
356 }
357 }
358}
359#endif
360
caryclark624637c2015-05-11 07:21:27 -0700361void SkOpContour::dumpContours() const {
362 SkOpContour* contour = this->globalState()->contourHead();
363 do {
364 contour->dump();
365 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000366}
367
caryclark624637c2015-05-11 07:21:27 -0700368void SkOpContour::dumpContoursAll() const {
369 SkOpContour* contour = this->globalState()->contourHead();
370 do {
371 contour->dumpAll();
372 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000373}
374
caryclark624637c2015-05-11 07:21:27 -0700375void SkOpContour::dumpContoursAngles() const {
376 SkOpContour* contour = this->globalState()->contourHead();
377 do {
378 contour->dumpAngles();
379 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000380}
381
caryclark624637c2015-05-11 07:21:27 -0700382void SkOpContour::dumpContoursPts() const {
383 SkOpContour* contour = this->globalState()->contourHead();
384 do {
385 contour->dumpPts();
386 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000387}
388
caryclark624637c2015-05-11 07:21:27 -0700389void SkOpContour::dumpContoursPt(int segmentID) const {
390 SkOpContour* contour = this->globalState()->contourHead();
391 do {
392 contour->dumpPt(segmentID);
393 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000394}
395
caryclark624637c2015-05-11 07:21:27 -0700396void SkOpContour::dumpContoursSegment(int segmentID) const {
397 SkOpContour* contour = this->globalState()->contourHead();
398 do {
399 contour->dumpSegment(segmentID);
400 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000401}
402
caryclark624637c2015-05-11 07:21:27 -0700403void SkOpContour::dumpContoursSpan(int spanID) const {
404 SkOpContour* contour = this->globalState()->contourHead();
405 do {
406 contour->dumpSpan(spanID);
407 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000408}
409
caryclark624637c2015-05-11 07:21:27 -0700410void SkOpContour::dumpContoursSpans() const {
411 SkOpContour* contour = this->globalState()->contourHead();
412 do {
413 contour->dumpSpans();
414 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000415}
416
caryclark1049f122015-04-20 08:31:59 -0700417template <typename TCurve, typename OppCurve>
418const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700419 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000420}
421
caryclark1049f122015-04-20 08:31:59 -0700422void DontCallDebugSpan(int id);
423void DontCallDebugSpan(int id) { // exists to instantiate the templates
424 SkDQuad quad;
425 SkDConic conic;
426 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700427 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
428 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
429 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
430 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
435 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700436 DebugSpan(&q1q2, id);
437 DebugSpan(&q1k2, id);
438 DebugSpan(&q1c2, id);
439 DebugSpan(&k1q2, id);
440 DebugSpan(&k1k2, id);
441 DebugSpan(&k1c2, id);
442 DebugSpan(&c1q2, id);
443 DebugSpan(&c1k2, id);
444 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000445}
446
caryclark1049f122015-04-20 08:31:59 -0700447template <typename TCurve, typename OppCurve>
448const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700449 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000450}
451
caryclark1049f122015-04-20 08:31:59 -0700452void DontCallDebugT(double t);
453void DontCallDebugT(double t) { // exists to instantiate the templates
454 SkDQuad quad;
455 SkDConic conic;
456 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700457 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
458 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700466 DebugT(&q1q2, t);
467 DebugT(&q1k2, t);
468 DebugT(&q1c2, t);
469 DebugT(&k1q2, t);
470 DebugT(&k1k2, t);
471 DebugT(&k1c2, t);
472 DebugT(&c1q2, t);
473 DebugT(&c1k2, t);
474 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700475}
476
caryclark1049f122015-04-20 08:31:59 -0700477template <typename TCurve, typename OppCurve>
478void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700479 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000480}
481
caryclark1049f122015-04-20 08:31:59 -0700482void DontCallDumpTSect();
483void DontCallDumpTSect() { // exists to instantiate the templates
484 SkDQuad quad;
485 SkDConic conic;
486 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700487 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
488 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
489 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
490 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
491 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
492 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
493 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
494 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
495 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700496 Dump(&q1q2);
497 Dump(&q1k2);
498 Dump(&q1c2);
499 Dump(&k1q2);
500 Dump(&k1k2);
501 Dump(&k1c2);
502 Dump(&c1q2);
503 Dump(&c1k2);
504 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000505}
506
caryclark1049f122015-04-20 08:31:59 -0700507template <typename TCurve, typename OppCurve>
508void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700509 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700510}
511
caryclark1049f122015-04-20 08:31:59 -0700512void DontCallDumpBoth();
513void DontCallDumpBoth() { // exists to instantiate the templates
514 SkDQuad quad;
515 SkDConic conic;
516 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700517 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
518 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
519 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
520 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
521 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
522 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
523 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
524 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
525 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700526 DumpBoth(&q1q2, &q1q2);
527 DumpBoth(&q1k2, &k1q2);
528 DumpBoth(&q1c2, &c1q2);
529 DumpBoth(&k1q2, &q1k2);
530 DumpBoth(&k1k2, &k1k2);
531 DumpBoth(&k1c2, &c1k2);
532 DumpBoth(&c1q2, &q1c2);
533 DumpBoth(&c1k2, &k1c2);
534 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700535}
536
caryclark1049f122015-04-20 08:31:59 -0700537template <typename TCurve, typename OppCurve>
538void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
539 sect1->dumpBounded(id);
540}
541
542void DontCallDumpBounded();
543void DontCallDumpBounded() {
544 SkDQuad quad;
545 SkDConic conic;
546 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700547 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
548 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
549 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
550 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
551 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
552 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
553 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
554 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
555 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700556 DumpBounded(&q1q2, 0);
557 DumpBounded(&q1k2, 0);
558 DumpBounded(&q1c2, 0);
559 DumpBounded(&k1q2, 0);
560 DumpBounded(&k1k2, 0);
561 DumpBounded(&k1c2, 0);
562 DumpBounded(&c1q2, 0);
563 DumpBounded(&c1k2, 0);
564 DumpBounded(&c1c2, 0);
565}
566
567template <typename TCurve, typename OppCurve>
568void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
569 sect1->dumpBounds();
570}
571
572void DontCallDumpBounds();
573void DontCallDumpBounds() {
574 SkDQuad quad;
575 SkDConic conic;
576 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700577 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
578 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
579 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
580 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
581 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
582 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
583 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
584 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
585 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700586 DumpBounds(&q1q2);
587 DumpBounds(&q1k2);
588 DumpBounds(&q1c2);
589 DumpBounds(&k1q2);
590 DumpBounds(&k1k2);
591 DumpBounds(&k1c2);
592 DumpBounds(&c1q2);
593 DumpBounds(&c1k2);
594 DumpBounds(&c1c2);
595}
596
597template <typename TCurve, typename OppCurve>
598void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700599 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700600}
601
caryclark1049f122015-04-20 08:31:59 -0700602void DontCallDumpCoin();
603void DontCallDumpCoin() { // exists to instantiate the templates
604 SkDQuad quad;
605 SkDConic conic;
606 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700607 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
608 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
609 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
610 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
611 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
612 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
613 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
614 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
615 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700616 DumpCoin(&q1q2);
617 DumpCoin(&q1k2);
618 DumpCoin(&q1c2);
619 DumpCoin(&k1q2);
620 DumpCoin(&k1k2);
621 DumpCoin(&k1c2);
622 DumpCoin(&c1q2);
623 DumpCoin(&c1k2);
624 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000625}
626
caryclark1049f122015-04-20 08:31:59 -0700627template <typename TCurve, typename OppCurve>
628void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700629 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000630}
631
caryclark1049f122015-04-20 08:31:59 -0700632void DontCallDumpCoinCurves();
633void DontCallDumpCoinCurves() { // exists to instantiate the templates
634 SkDQuad quad;
635 SkDConic conic;
636 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700637 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
638 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
639 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
640 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
641 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
642 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
643 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
644 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
645 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700646 DumpCoinCurves(&q1q2);
647 DumpCoinCurves(&q1k2);
648 DumpCoinCurves(&q1c2);
649 DumpCoinCurves(&k1q2);
650 DumpCoinCurves(&k1k2);
651 DumpCoinCurves(&k1c2);
652 DumpCoinCurves(&c1q2);
653 DumpCoinCurves(&c1k2);
654 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000655}
656
caryclark1049f122015-04-20 08:31:59 -0700657template <typename TCurve, typename OppCurve>
658void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700659 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000660}
661
caryclark1049f122015-04-20 08:31:59 -0700662void DontCallDumpCurves();
663void DontCallDumpCurves() { // exists to instantiate the templates
664 SkDQuad quad;
665 SkDConic conic;
666 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700667 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
668 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
669 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
670 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
671 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
672 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
673 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
674 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
675 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700676 DumpCurves(&q1q2);
677 DumpCurves(&q1k2);
678 DumpCurves(&q1c2);
679 DumpCurves(&k1q2);
680 DumpCurves(&k1k2);
681 DumpCurves(&k1c2);
682 DumpCurves(&c1q2);
683 DumpCurves(&c1k2);
684 DumpCurves(&c1c2);
685}
686
687template <typename TCurve, typename OppCurve>
688void Dump(const SkTSpan<TCurve, OppCurve>* span) {
689 span->dump();
690}
691
692void DontCallDumpTSpan();
693void DontCallDumpTSpan() { // exists to instantiate the templates
694 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
695 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
696 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
697 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
698 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
699 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
700 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
701 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
702 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
703 Dump(&q1q2);
704 Dump(&q1k2);
705 Dump(&q1c2);
706 Dump(&k1q2);
707 Dump(&k1k2);
708 Dump(&k1c2);
709 Dump(&c1q2);
710 Dump(&c1k2);
711 Dump(&c1c2);
712}
713
714template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700715void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
716 span->dumpAll();
717}
718
719void DontCallDumpSpanAll();
720void DontCallDumpSpanAll() { // exists to instantiate the templates
721 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
722 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
723 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
724 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
725 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
726 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
727 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
728 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
729 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
730 DumpAll(&q1q2);
731 DumpAll(&q1k2);
732 DumpAll(&q1c2);
733 DumpAll(&k1q2);
734 DumpAll(&k1k2);
735 DumpAll(&k1c2);
736 DumpAll(&c1q2);
737 DumpAll(&c1k2);
738 DumpAll(&c1c2);
739}
740
741template <typename TCurve, typename OppCurve>
742void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
743 span->dumpBounded(0);
744}
745
746void DontCallDumpSpanBounded();
747void DontCallDumpSpanBounded() { // exists to instantiate the templates
748 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
749 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
750 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
751 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
752 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
753 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
754 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
755 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
756 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
757 DumpBounded(&q1q2);
758 DumpBounded(&q1k2);
759 DumpBounded(&q1c2);
760 DumpBounded(&k1q2);
761 DumpBounded(&k1k2);
762 DumpBounded(&k1c2);
763 DumpBounded(&c1q2);
764 DumpBounded(&c1k2);
765 DumpBounded(&c1c2);
766}
767
768template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700769void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
770 span->dumpCoin();
771}
772
773void DontCallDumpSpanCoin();
774void DontCallDumpSpanCoin() { // exists to instantiate the templates
775 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
776 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
777 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
778 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
779 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
780 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
781 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
782 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
783 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
784 DumpCoin(&q1q2);
785 DumpCoin(&q1k2);
786 DumpCoin(&q1c2);
787 DumpCoin(&k1q2);
788 DumpCoin(&k1k2);
789 DumpCoin(&k1c2);
790 DumpCoin(&c1q2);
791 DumpCoin(&c1k2);
792 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700793}
794
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000795static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700796 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
797 quad1.dumpInner();
798 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000799 quad2.dump();
800 SkDebugf("</div>\n\n");
801}
802
803static void dumpTestTrailer() {
804 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
805 SkDebugf(" var testDivs = [\n");
806}
807
808static void dumpTestList(int testNo, double min) {
809 SkDebugf(" quad%d,", testNo);
810 if (min > 0) {
811 SkDebugf(" // %1.9g", min);
812 }
813 SkDebugf("\n");
814}
815
816void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
817 SkDebugf("\n");
818 dumpTestCase(quad1, quad2, testNo);
819 dumpTestTrailer();
820 dumpTestList(testNo, 0);
821 SkDebugf("\n");
822}
823
824void DumpT(const SkDQuad& quad, double t) {
825 SkDLine line = {{quad.ptAtT(t), quad[0]}};
826 line.dump();
827}
caryclark54359292015-03-26 07:52:43 -0700828
829const SkOpAngle* SkOpAngle::debugAngle(int id) const {
830 return this->segment()->debugAngle(id);
831}
832
caryclark55888e42016-07-18 10:01:36 -0700833const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
834 return this->segment()->debugCoincidence();
835}
836
caryclark30b9fdd2016-08-31 14:36:29 -0700837SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700838 return this->segment()->debugContour(id);
839}
840
841const SkOpPtT* SkOpAngle::debugPtT(int id) const {
842 return this->segment()->debugPtT(id);
843}
844
845const SkOpSegment* SkOpAngle::debugSegment(int id) const {
846 return this->segment()->debugSegment(id);
847}
848
caryclark624637c2015-05-11 07:21:27 -0700849int SkOpAngle::debugSign() const {
850 SkASSERT(fStart->t() != fEnd->t());
851 return fStart->t() < fEnd->t() ? -1 : 1;
852}
853
caryclark54359292015-03-26 07:52:43 -0700854const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
855 return this->segment()->debugSpan(id);
856}
857
858void SkOpAngle::dump() const {
859 dumpOne(true);
860 SkDebugf("\n");
861}
862
863void SkOpAngle::dumpOne(bool functionHeader) const {
864// fSegment->debugValidate();
865 const SkOpSegment* segment = this->segment();
866 const SkOpSpan& mSpan = *fStart->starter(fEnd);
867 if (functionHeader) {
868 SkDebugf("%s ", __FUNCTION__);
869 }
870 SkDebugf("[%d", segment->debugID());
871 SkDebugf("/%d", debugID());
872 SkDebugf("] next=");
873 if (fNext) {
874 SkDebugf("%d", fNext->fStart->segment()->debugID());
875 SkDebugf("/%d", fNext->debugID());
876 } else {
877 SkDebugf("?");
878 }
879 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
880 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
881 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700882 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700883
884 SkDebugf(" windSum=");
885 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
886 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
887 SkDebugf(" oppVal=%d", mSpan.oppValue());
888 SkDebugf(" oppSum=");
889 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
890 }
891 if (mSpan.done()) {
892 SkDebugf(" done");
893 }
894 if (unorderable()) {
895 SkDebugf(" unorderable");
896 }
897 if (segment->operand()) {
898 SkDebugf(" operand");
899 }
caryclark54359292015-03-26 07:52:43 -0700900}
901
902void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
903 const SkOpAngle* first = this;
904 const SkOpAngle* next = this;
905 const char* indent = "";
906 do {
907 SkDebugf("%s", indent);
908 next->dumpOne(false);
909 if (segment == next->fStart->segment()) {
910 if (this == fNext) {
911 SkDebugf(" << from");
912 }
913 if (to == fNext) {
914 SkDebugf(" << to");
915 }
916 }
917 SkDebugf("\n");
918 indent = " ";
919 next = next->fNext;
920 } while (next && next != first);
921}
922
923void SkOpAngle::dumpCurves() const {
924 const SkOpAngle* first = this;
925 const SkOpAngle* next = this;
926 do {
caryclarkeed356d2016-09-14 07:18:20 -0700927 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700928 next = next->fNext;
929 } while (next && next != first);
930}
931
932void SkOpAngle::dumpLoop() const {
933 const SkOpAngle* first = this;
934 const SkOpAngle* next = this;
935 do {
936 next->dumpOne(false);
937 SkDebugf("\n");
938 next = next->fNext;
939 } while (next && next != first);
940}
941
942void SkOpAngle::dumpTest() const {
943 const SkOpAngle* first = this;
944 const SkOpAngle* next = this;
945 do {
946 SkDebugf("{ ");
947 SkOpSegment* segment = next->segment();
948 segment->dumpPts();
949 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
950 next->start()->t(), next->end()->t());
951 next = next->fNext;
952 } while (next && next != first);
953}
954
955bool SkOpPtT::debugMatchID(int id) const {
956 int limit = this->debugLoopLimit(false);
957 int loop = 0;
958 const SkOpPtT* ptT = this;
959 do {
960 if (ptT->debugID() == id) {
961 return true;
962 }
963 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
964 return false;
965}
966
967const SkOpAngle* SkOpPtT::debugAngle(int id) const {
968 return this->span()->debugAngle(id);
969}
970
caryclark30b9fdd2016-08-31 14:36:29 -0700971SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700972 return this->span()->debugContour(id);
973}
974
caryclark55888e42016-07-18 10:01:36 -0700975const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
976 return this->span()->debugCoincidence();
977}
978
caryclark54359292015-03-26 07:52:43 -0700979const SkOpPtT* SkOpPtT::debugPtT(int id) const {
980 return this->span()->debugPtT(id);
981}
982
983const SkOpSegment* SkOpPtT::debugSegment(int id) const {
984 return this->span()->debugSegment(id);
985}
986
987const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
988 return this->span()->debugSpan(id);
989}
990
991void SkOpPtT::dump() const {
992 SkDebugf("seg=%d span=%d ptT=%d",
993 this->segment()->debugID(), this->span()->debugID(), this->debugID());
994 this->dumpBase();
995 SkDebugf("\n");
996}
997
998void SkOpPtT::dumpAll() const {
999 contour()->indentDump();
1000 const SkOpPtT* next = this;
1001 int limit = debugLoopLimit(true);
1002 int loop = 0;
1003 do {
1004 SkDebugf("%.*s", contour()->debugIndent(), " ");
1005 SkDebugf("seg=%d span=%d ptT=%d",
1006 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1007 next->dumpBase();
1008 SkDebugf("\n");
1009 if (limit && ++loop >= limit) {
1010 SkDebugf("*** abort loop ***\n");
1011 break;
1012 }
1013 } while ((next = next->fNext) && next != this);
1014 contour()->outdentDump();
1015}
1016
1017void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001018 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1019 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001020 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1021}
1022
1023const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1024 return this->segment()->debugAngle(id);
1025}
1026
caryclark55888e42016-07-18 10:01:36 -07001027const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1028 return this->segment()->debugCoincidence();
1029}
1030
caryclark30b9fdd2016-08-31 14:36:29 -07001031SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001032 return this->segment()->debugContour(id);
1033}
1034
1035const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1036 return this->segment()->debugPtT(id);
1037}
1038
1039const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1040 return this->segment()->debugSegment(id);
1041}
1042
1043const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1044 return this->segment()->debugSpan(id);
1045}
1046
1047void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001048 this->dumpHead();
1049 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001050}
1051
caryclark55888e42016-07-18 10:01:36 -07001052void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001053 SkDebugf("%.*s", contour()->debugIndent(), " ");
1054 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1055 this->dumpBase();
1056 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001057}
1058
1059void SkOpSpanBase::dumpAll() const {
1060 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001061 this->fPtT.dumpAll();
1062}
1063
1064void SkOpSpanBase::dumpBase() const {
1065 if (this->fAligned) {
1066 SkDebugf(" aligned");
1067 }
1068 if (this->fChased) {
1069 SkDebugf(" chased");
1070 }
caryclark55888e42016-07-18 10:01:36 -07001071#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001072 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001073 SkDebugf(" deleted");
1074 }
1075#endif
caryclark54359292015-03-26 07:52:43 -07001076 if (!this->final()) {
1077 this->upCast()->dumpSpan();
1078 }
1079 const SkOpSpanBase* coin = this->coinEnd();
1080 if (this != coin) {
1081 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1082 } else if (this->final() || !this->upCast()->isCoincident()) {
1083 const SkOpPtT* oPt = this->ptT()->next();
1084 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1085 }
caryclark08bc8482015-04-24 09:08:57 -07001086 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001087}
1088
1089void SkOpSpanBase::dumpCoin() const {
1090 const SkOpSpan* span = this->upCastable();
1091 if (!span) {
1092 return;
1093 }
1094 if (!span->isCoincident()) {
1095 return;
1096 }
1097 span->dumpCoin();
1098}
1099
1100void SkOpSpan::dumpCoin() const {
1101 const SkOpSpan* coincident = fCoincident;
1102 bool ok = debugCoinLoopCheck();
1103 this->dump();
1104 int loop = 0;
1105 do {
1106 coincident->dump();
1107 if (!ok && ++loop > 10) {
1108 SkDebugf("*** abort loop ***\n");
1109 break;
1110 }
1111 } while ((coincident = coincident->fCoincident) != this);
1112}
1113
1114bool SkOpSpan::dumpSpan() const {
1115 SkOpSpan* coin = fCoincident;
1116 if (this != coin) {
1117 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1118 }
1119 SkDebugf(" windVal=%d", this->windValue());
1120 SkDebugf(" windSum=");
1121 SkPathOpsDebug::WindingPrintf(this->windSum());
1122 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1123 SkDebugf(" oppVal=%d", this->oppValue());
1124 SkDebugf(" oppSum=");
1125 SkPathOpsDebug::WindingPrintf(this->oppSum());
1126 }
1127 if (this->done()) {
1128 SkDebugf(" done");
1129 }
1130 return this != coin;
1131}
1132
1133const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1134 return this->contour()->debugAngle(id);
1135}
1136
caryclark55888e42016-07-18 10:01:36 -07001137
1138const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1139 return this->contour()->debugCoincidence();
1140}
1141
caryclark30b9fdd2016-08-31 14:36:29 -07001142SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001143 return this->contour()->debugContour(id);
1144}
1145
1146const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1147 return this->contour()->debugPtT(id);
1148}
1149
1150const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1151 return this->contour()->debugSegment(id);
1152}
1153
1154const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1155 return this->contour()->debugSpan(id);
1156}
1157
1158void SkOpSegment::dump() const {
1159 SkDebugf("%.*s", contour()->debugIndent(), " ");
1160 this->dumpPts();
1161 const SkOpSpanBase* span = &fHead;
1162 contour()->indentDump();
1163 do {
1164 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1165 span->ptT()->dumpBase();
1166 span->dumpBase();
1167 SkDebugf("\n");
1168 } while (!span->final() && (span = span->upCast()->next()));
1169 contour()->outdentDump();
1170}
1171
1172void SkOpSegment::dumpAll() const {
1173 SkDebugf("%.*s", contour()->debugIndent(), " ");
1174 this->dumpPts();
1175 const SkOpSpanBase* span = &fHead;
1176 contour()->indentDump();
1177 do {
1178 span->dumpAll();
1179 } while (!span->final() && (span = span->upCast()->next()));
1180 contour()->outdentDump();
1181}
1182
1183void SkOpSegment::dumpAngles() const {
1184 SkDebugf("seg=%d\n", debugID());
1185 const SkOpSpanBase* span = &fHead;
1186 do {
1187 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001188 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001189 if (fAngle) {
1190 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1191 fAngle->dumpTo(this, tAngle);
1192 }
1193 if (tAngle) {
1194 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1195 tAngle->dumpTo(this, fAngle);
1196 }
1197 } while (!span->final() && (span = span->upCast()->next()));
1198}
1199
1200void SkOpSegment::dumpCoin() const {
1201 const SkOpSpan* span = &fHead;
1202 do {
1203 span->dumpCoin();
1204 } while ((span = span->next()->upCastable()));
1205}
1206
caryclark26ad22a2015-10-16 09:03:38 -07001207void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001208 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001209 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001210 if (fVerb == SkPath::kConic_Verb) {
1211 SkDebugf("{");
1212 }
caryclark54359292015-03-26 07:52:43 -07001213 int index = 0;
1214 do {
1215 SkDPoint::Dump(fPts[index]);
1216 SkDebugf(", ");
1217 } while (++index < last);
1218 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001219 SkDebugf("}}");
1220 if (fVerb == SkPath::kConic_Verb) {
1221 SkDebugf(", %1.9gf}", fWeight);
1222 }
caryclark624637c2015-05-11 07:21:27 -07001223}
1224
caryclark26ad22a2015-10-16 09:03:38 -07001225void SkOpSegment::dumpPts(const char* prefix) const {
1226 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001227 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001228}
1229
1230void SkCoincidentSpans::dump() const {
1231 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1232 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1233 fCoinPtTStart->dumpBase();
1234 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1235 fCoinPtTEnd->dumpBase();
1236 if (fCoinPtTStart->segment()->operand()) {
1237 SkDebugf(" operand");
1238 }
1239 if (fCoinPtTStart->segment()->isXor()) {
1240 SkDebugf(" xor");
1241 }
1242 SkDebugf("\n");
1243 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1244 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1245 fOppPtTStart->dumpBase();
1246 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1247 fOppPtTEnd->dumpBase();
1248 if (fOppPtTStart->segment()->operand()) {
1249 SkDebugf(" operand");
1250 }
1251 if (fOppPtTStart->segment()->isXor()) {
1252 SkDebugf(" xor");
1253 }
1254 SkDebugf("\n");
1255}
1256
1257void SkOpCoincidence::dump() const {
1258 SkCoincidentSpans* span = fHead;
1259 while (span) {
1260 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001261 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001262 }
caryclark26ad22a2015-10-16 09:03:38 -07001263 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001264 return;
1265 }
1266 SkDebugf("top:\n");
1267 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001268 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001269 while (span) {
1270 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001271 span = span->next();
1272 SkCoincidentSpans* check = fTop;
1273 ++count;
1274 for (int index = 0; index < count; ++index) {
1275 if (span == check) {
1276 SkDebugf("(loops to #%d)\n", index);
1277 return;
1278 }
1279 check = check->next();
1280 }
caryclark27c8eb82015-07-06 11:38:33 -07001281 }
caryclark54359292015-03-26 07:52:43 -07001282}
1283
caryclark624637c2015-05-11 07:21:27 -07001284void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001285 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001286 if (!fCount) {
1287 return;
1288 }
1289 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001290 SkDEBUGCODE(fDebugIndent = 0);
1291 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001292 do {
1293 segment->dump();
1294 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001295 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001296}
1297
caryclark624637c2015-05-11 07:21:27 -07001298void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001299 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001300 if (!fCount) {
1301 return;
1302 }
1303 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001304 SkDEBUGCODE(fDebugIndent = 0);
1305 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001306 do {
1307 segment->dumpAll();
1308 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001309 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001310}
1311
1312
1313void SkOpContour::dumpAngles() const {
1314 SkDebugf("contour=%d\n", this->debugID());
1315 const SkOpSegment* segment = &fHead;
1316 do {
1317 SkDebugf(" seg=%d ", segment->debugID());
1318 segment->dumpAngles();
1319 } while ((segment = segment->next()));
1320}
1321
1322void SkOpContour::dumpPt(int index) const {
1323 const SkOpSegment* segment = &fHead;
1324 do {
1325 if (segment->debugID() == index) {
1326 segment->dumpPts();
1327 }
1328 } while ((segment = segment->next()));
1329}
1330
caryclark26ad22a2015-10-16 09:03:38 -07001331void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001332 SkDebugf("contour=%d\n", this->debugID());
1333 const SkOpSegment* segment = &fHead;
1334 do {
caryclark26ad22a2015-10-16 09:03:38 -07001335 SkDebugf(" %s=%d ", prefix, segment->debugID());
1336 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001337 } while ((segment = segment->next()));
1338}
1339
caryclark26ad22a2015-10-16 09:03:38 -07001340void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001341 if (!this->fCount) {
1342 SkDebugf("<empty>\n");
1343 return;
1344 }
1345 const SkOpSegment* segment = &fHead;
1346 do {
caryclark26ad22a2015-10-16 09:03:38 -07001347 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001348 } while ((segment = segment->next()));
1349}
1350
1351void SkOpContour::dumpSegment(int index) const {
1352 debugSegment(index)->dump();
1353}
1354
caryclark26ad22a2015-10-16 09:03:38 -07001355void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001356 bool firstOp = false;
1357 const SkOpContour* c = this;
1358 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001359 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001360#if DEBUG_ACTIVE_OP
1361 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1362#endif
1363 firstOp = true;
1364 }
caryclark26ad22a2015-10-16 09:03:38 -07001365 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001366 } while ((c = c->next()));
1367}
1368
1369void SkOpContour::dumpSpan(int index) const {
1370 debugSpan(index)->dump();
1371}
1372
1373void SkOpContour::dumpSpans() const {
1374 SkDebugf("contour=%d\n", this->debugID());
1375 const SkOpSegment* segment = &fHead;
1376 do {
1377 SkDebugf(" seg=%d ", segment->debugID());
1378 segment->dump();
1379 } while ((segment = segment->next()));
1380}
1381
caryclark03b03ca2015-04-23 09:13:37 -07001382void SkOpCurve::dump() const {
1383 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1384 SkDebugf("{{");
1385 int index;
1386 for (index = 0; index <= count - 1; ++index) {
1387 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1388 }
1389 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1390}
1391
caryclark54359292015-03-26 07:52:43 -07001392#ifdef SK_DEBUG
1393const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001394 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001395 do {
1396 const SkOpSegment* segment = contour->first();
1397 while (segment) {
1398 const SkOpSpan* span = segment->head();
1399 do {
1400 SkOpAngle* angle = span->fromAngle();
1401 if (angle && angle->debugID() == id) {
1402 return angle;
1403 }
1404 angle = span->toAngle();
1405 if (angle && angle->debugID() == id) {
1406 return angle;
1407 }
1408 } while ((span = span->next()->upCastable()));
1409 const SkOpSpanBase* tail = segment->tail();
1410 SkOpAngle* angle = tail->fromAngle();
1411 if (angle && angle->debugID() == id) {
1412 return angle;
1413 }
1414 segment = segment->next();
1415 }
1416 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001417 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001418}
1419
caryclark30b9fdd2016-08-31 14:36:29 -07001420SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001421 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001422 do {
1423 if (contour->debugID() == id) {
1424 return contour;
1425 }
1426 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001427 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001428}
1429
1430const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001431 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001432 do {
1433 const SkOpSegment* segment = contour->first();
1434 while (segment) {
1435 const SkOpSpan* span = segment->head();
1436 do {
1437 const SkOpPtT* ptT = span->ptT();
1438 if (ptT->debugMatchID(id)) {
1439 return ptT;
1440 }
1441 } while ((span = span->next()->upCastable()));
1442 const SkOpSpanBase* tail = segment->tail();
1443 const SkOpPtT* ptT = tail->ptT();
1444 if (ptT->debugMatchID(id)) {
1445 return ptT;
1446 }
1447 segment = segment->next();
1448 }
1449 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001450 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001451}
1452
1453const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001454 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001455 do {
1456 const SkOpSegment* segment = contour->first();
1457 while (segment) {
1458 if (segment->debugID() == id) {
1459 return segment;
1460 }
1461 segment = segment->next();
1462 }
1463 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001464 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001465}
1466
1467const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001468 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001469 do {
1470 const SkOpSegment* segment = contour->first();
1471 while (segment) {
1472 const SkOpSpan* span = segment->head();
1473 do {
1474 if (span->debugID() == id) {
1475 return span;
1476 }
1477 } while ((span = span->next()->upCastable()));
1478 const SkOpSpanBase* tail = segment->tail();
1479 if (tail->debugID() == id) {
1480 return tail;
1481 }
1482 segment = segment->next();
1483 }
1484 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001485 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001486}
1487#endif
1488
caryclark54359292015-03-26 07:52:43 -07001489#if DEBUG_T_SECT_DUMP > 1
1490int gDumpTSectNum;
1491#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001492
1493// global path dumps for msvs Visual Studio 17 to use from Immediate Window
1494namespace SkOpDebug {
1495
1496 void Dump(const SkOpContour& contour) {
1497 contour.dump();
1498 }
1499
1500 void DumpAll(const SkOpContour& contour) {
1501 contour.dumpAll();
1502 }
1503
1504 void DumpAngles(const SkOpContour& contour) {
1505 contour.dumpAngles();
1506 }
1507
1508 void DumpContours(const SkOpContour& contour) {
1509 contour.dumpContours();
1510 }
1511
1512 void DumpContoursAll(const SkOpContour& contour) {
1513 contour.dumpContoursAll();
1514 }
1515
1516 void DumpContoursAngles(const SkOpContour& contour) {
1517 contour.dumpContoursAngles();
1518 }
1519
1520 void DumpContoursPts(const SkOpContour& contour) {
1521 contour.dumpContoursPts();
1522 }
1523
1524 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1525 contour.dumpContoursPt(segmentID);
1526 }
1527
1528 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1529 contour.dumpContoursSegment(segmentID);
1530 }
1531
1532 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1533 contour.dumpContoursSpan(segmentID);
1534 }
1535
1536 void DumpContoursSpans(const SkOpContour& contour) {
1537 contour.dumpContoursSpans();
1538 }
1539
1540 void DumpPt(const SkOpContour& contour, int pt) {
1541 contour.dumpPt(pt);
1542 }
1543
1544 void DumpPts(const SkOpContour& contour, const char* prefix) {
1545 contour.dumpPts(prefix);
1546 }
1547
1548 void DumpSegment(const SkOpContour& contour, int seg) {
1549 contour.dumpSegment(seg);
1550 }
1551
1552 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1553 contour.dumpSegments(prefix, op);
1554 }
1555
1556 void DumpSpan(const SkOpContour& contour, int span) {
1557 contour.dumpSpan(span);
1558 }
1559
1560 void DumpSpans(const SkOpContour& contour ) {
1561 contour.dumpSpans();
1562 }
1563
1564 void Dump(const SkOpSegment& segment) {
1565 segment.dump();
1566 }
1567
1568 void DumpAll(const SkOpSegment& segment) {
1569 segment.dumpAll();
1570 }
1571
1572 void DumpAngles(const SkOpSegment& segment) {
1573 segment.dumpAngles();
1574 }
1575
1576 void DumpCoin(const SkOpSegment& segment) {
1577 segment.dumpCoin();
1578 }
1579
1580 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1581 segment.dumpPts(prefix);
1582 }
1583
1584 void Dump(const SkOpPtT& ptT) {
1585 ptT.dump();
1586 }
1587
1588 void DumpAll(const SkOpPtT& ptT) {
1589 ptT.dumpAll();
1590 }
1591
1592 void Dump(const SkOpSpanBase& spanBase) {
1593 spanBase.dump();
1594 }
1595
1596 void DumpCoin(const SkOpSpanBase& spanBase) {
1597 spanBase.dumpCoin();
1598 }
1599
1600 void DumpAll(const SkOpSpanBase& spanBase) {
1601 spanBase.dumpAll();
1602 }
1603
1604 void DumpCoin(const SkOpSpan& span) {
1605 span.dumpCoin();
1606 }
1607
1608 bool DumpSpan(const SkOpSpan& span) {
1609 return span.dumpSpan();
1610 }
1611
1612 void Dump(const SkDConic& conic) {
1613 conic.dump();
1614 }
1615
1616 void DumpID(const SkDConic& conic, int id) {
1617 conic.dumpID(id);
1618 }
1619
1620 void Dump(const SkDCubic& cubic) {
1621 cubic.dump();
1622 }
1623
1624 void DumpID(const SkDCubic& cubic, int id) {
1625 cubic.dumpID(id);
1626 }
1627
1628 void Dump(const SkDLine& line) {
1629 line.dump();
1630 }
1631
1632 void DumpID(const SkDLine& line, int id) {
1633 line.dumpID(id);
1634 }
1635
1636 void Dump(const SkDQuad& quad) {
1637 quad.dump();
1638 }
1639
1640 void DumpID(const SkDQuad& quad, int id) {
1641 quad.dumpID(id);
1642 }
1643
1644 void Dump(const SkDPoint& point) {
1645 point.dump();
1646 }
1647
Cary Clark1857ddb2018-07-11 11:01:43 -04001648 void Dump(const SkOpAngle& angle) {
1649 angle.dump();
1650 }
1651
Cary Clarkb8421ed2018-03-14 15:55:02 -04001652// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1653#define DummyDefinitions(a, b) \
1654 \
1655 void Dump(const SkDebugTCoincident##a##b& curve) { \
1656 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1657 } \
1658 \
1659 void Dump(const SkDebugTSect##a##b& curve) { \
1660 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1661 } \
1662 \
1663 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1664 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1665 } \
1666 \
1667 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1668 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1669 } \
1670 \
1671 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1672 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1673 } \
1674 \
1675 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1676 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1677 } \
1678 \
1679 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1680 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1681 } \
1682 \
1683 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1684 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1685 } \
1686 \
1687 void Dump(const SkDebugTSpan##a##b& curve) { \
1688 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1689 } \
1690 \
1691 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1692 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1693 } \
1694 \
1695 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1696 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1697 } \
1698 \
1699 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1700 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1701 } \
1702 \
1703 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1704 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1705 }
1706
1707 DummyDefinitions(Quad, Quad);
1708 DummyDefinitions(Conic, Quad);
1709 DummyDefinitions(Conic, Conic);
1710 DummyDefinitions(Cubic, Quad);
1711 DummyDefinitions(Cubic, Conic);
1712 DummyDefinitions(Cubic, Cubic);
1713
1714#undef DummyDefinitions
1715}