blob: 41f912ee11272e11136c77c49f52c0f35db53e14 [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 Clarkb8421ed2018-03-14 15:55:02 -0400219namespace SkOpDebug {
220
221const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700222 return angle->debugAngle(id);
223}
224
Cary Clarkb8421ed2018-03-14 15:55:02 -0400225::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700226 return angle->debugContour(id);
227}
228
Cary Clarkb8421ed2018-03-14 15:55:02 -0400229const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700230 return angle->debugPtT(id);
231}
232
Cary Clarkb8421ed2018-03-14 15:55:02 -0400233const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700234 return angle->debugSegment(id);
235}
236
Cary Clarkb8421ed2018-03-14 15:55:02 -0400237const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700238 return angle->debugSpan(id);
239}
240
Cary Clarkb8421ed2018-03-14 15:55:02 -0400241const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700242 return contour->debugAngle(id);
243}
244
Cary Clarkb8421ed2018-03-14 15:55:02 -0400245::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700246 return contour->debugContour(id);
247}
248
Cary Clarkb8421ed2018-03-14 15:55:02 -0400249const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700250 return contour->debugPtT(id);
251}
252
Cary Clarkb8421ed2018-03-14 15:55:02 -0400253const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700254 return contour->debugSegment(id);
255}
256
Cary Clarkb8421ed2018-03-14 15:55:02 -0400257const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700258 return contour->debugSpan(id);
259}
260
Cary Clarkb8421ed2018-03-14 15:55:02 -0400261const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700262 return coin->debugAngle(id);
263}
264
Cary Clarkb8421ed2018-03-14 15:55:02 -0400265::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700266 return coin->debugContour(id);
267}
268
Cary Clarkb8421ed2018-03-14 15:55:02 -0400269const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700270 return coin->debugPtT(id);
271}
272
Cary Clarkb8421ed2018-03-14 15:55:02 -0400273const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700274 return coin->debugSegment(id);
275}
276
Cary Clarkb8421ed2018-03-14 15:55:02 -0400277const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700278 return coin->debugSpan(id);
279}
280
Cary Clarkb8421ed2018-03-14 15:55:02 -0400281const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700282 return ptT->debugAngle(id);
283}
284
Cary Clarkb8421ed2018-03-14 15:55:02 -0400285::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700286 return ptT->debugContour(id);
287}
288
Cary Clarkb8421ed2018-03-14 15:55:02 -0400289const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700290 return ptT->debugPtT(id);
291}
292
Cary Clarkb8421ed2018-03-14 15:55:02 -0400293const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700294 return ptT->debugSegment(id);
295}
296
Cary Clarkb8421ed2018-03-14 15:55:02 -0400297const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700298 return ptT->debugSpan(id);
299}
300
Cary Clarkb8421ed2018-03-14 15:55:02 -0400301const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700302 return span->debugAngle(id);
303}
304
Cary Clarkb8421ed2018-03-14 15:55:02 -0400305::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700306 return span->debugContour(id);
307}
308
Cary Clarkb8421ed2018-03-14 15:55:02 -0400309const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700310 return span->debugPtT(id);
311}
312
Cary Clarkb8421ed2018-03-14 15:55:02 -0400313const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700314 return span->debugSegment(id);
315}
316
Cary Clarkb8421ed2018-03-14 15:55:02 -0400317const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700318 return span->debugSpan(id);
319}
320
Cary Clarkb8421ed2018-03-14 15:55:02 -0400321const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700322 return span->debugAngle(id);
323}
324
Cary Clarkb8421ed2018-03-14 15:55:02 -0400325::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700326 return span->debugContour(id);
327}
328
Cary Clarkb8421ed2018-03-14 15:55:02 -0400329const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700330 return span->debugPtT(id);
331}
332
Cary Clarkb8421ed2018-03-14 15:55:02 -0400333const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700334 return span->debugSegment(id);
335}
336
Cary Clarkb8421ed2018-03-14 15:55:02 -0400337const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700338 return span->debugSpan(id);
339}
340
Cary Clarkb8421ed2018-03-14 15:55:02 -0400341} // 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
caryclark1049f122015-04-20 08:31:59 -0700419template <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
caryclark1049f122015-04-20 08:31:59 -0700424void DontCallDebugSpan(int id);
425void DontCallDebugSpan(int id) { // exists to instantiate the templates
426 SkDQuad quad;
427 SkDConic conic;
428 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700429 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
430 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
435 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
436 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
437 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700438 DebugSpan(&q1q2, id);
439 DebugSpan(&q1k2, id);
440 DebugSpan(&q1c2, id);
441 DebugSpan(&k1q2, id);
442 DebugSpan(&k1k2, id);
443 DebugSpan(&k1c2, id);
444 DebugSpan(&c1q2, id);
445 DebugSpan(&c1k2, id);
446 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000447}
448
caryclark1049f122015-04-20 08:31:59 -0700449template <typename TCurve, typename OppCurve>
450const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700451 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000452}
453
caryclark1049f122015-04-20 08:31:59 -0700454void DontCallDebugT(double t);
455void DontCallDebugT(double t) { // exists to instantiate the templates
456 SkDQuad quad;
457 SkDConic conic;
458 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700459 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
466 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
467 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700468 DebugT(&q1q2, t);
469 DebugT(&q1k2, t);
470 DebugT(&q1c2, t);
471 DebugT(&k1q2, t);
472 DebugT(&k1k2, t);
473 DebugT(&k1c2, t);
474 DebugT(&c1q2, t);
475 DebugT(&c1k2, t);
476 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700477}
478
caryclark1049f122015-04-20 08:31:59 -0700479template <typename TCurve, typename OppCurve>
480void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700481 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000482}
483
caryclark1049f122015-04-20 08:31:59 -0700484void DontCallDumpTSect();
485void DontCallDumpTSect() { // exists to instantiate the templates
486 SkDQuad quad;
487 SkDConic conic;
488 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700489 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
490 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
491 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
492 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
493 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
494 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
495 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
496 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
497 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700498 Dump(&q1q2);
499 Dump(&q1k2);
500 Dump(&q1c2);
501 Dump(&k1q2);
502 Dump(&k1k2);
503 Dump(&k1c2);
504 Dump(&c1q2);
505 Dump(&c1k2);
506 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000507}
508
caryclark1049f122015-04-20 08:31:59 -0700509template <typename TCurve, typename OppCurve>
510void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700511 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700512}
513
caryclark1049f122015-04-20 08:31:59 -0700514void DontCallDumpBoth();
515void DontCallDumpBoth() { // exists to instantiate the templates
516 SkDQuad quad;
517 SkDConic conic;
518 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700519 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
520 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
521 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
522 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
523 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
524 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
525 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
526 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
527 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700528 DumpBoth(&q1q2, &q1q2);
529 DumpBoth(&q1k2, &k1q2);
530 DumpBoth(&q1c2, &c1q2);
531 DumpBoth(&k1q2, &q1k2);
532 DumpBoth(&k1k2, &k1k2);
533 DumpBoth(&k1c2, &c1k2);
534 DumpBoth(&c1q2, &q1c2);
535 DumpBoth(&c1k2, &k1c2);
536 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700537}
538
caryclark1049f122015-04-20 08:31:59 -0700539template <typename TCurve, typename OppCurve>
540void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
541 sect1->dumpBounded(id);
542}
543
544void DontCallDumpBounded();
545void DontCallDumpBounded() {
546 SkDQuad quad;
547 SkDConic conic;
548 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700549 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
550 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
551 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
552 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
553 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
554 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
555 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
556 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
557 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700558 DumpBounded(&q1q2, 0);
559 DumpBounded(&q1k2, 0);
560 DumpBounded(&q1c2, 0);
561 DumpBounded(&k1q2, 0);
562 DumpBounded(&k1k2, 0);
563 DumpBounded(&k1c2, 0);
564 DumpBounded(&c1q2, 0);
565 DumpBounded(&c1k2, 0);
566 DumpBounded(&c1c2, 0);
567}
568
569template <typename TCurve, typename OppCurve>
570void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
571 sect1->dumpBounds();
572}
573
574void DontCallDumpBounds();
575void DontCallDumpBounds() {
576 SkDQuad quad;
577 SkDConic conic;
578 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700579 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
580 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
581 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
582 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
583 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
584 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
585 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
586 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
587 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700588 DumpBounds(&q1q2);
589 DumpBounds(&q1k2);
590 DumpBounds(&q1c2);
591 DumpBounds(&k1q2);
592 DumpBounds(&k1k2);
593 DumpBounds(&k1c2);
594 DumpBounds(&c1q2);
595 DumpBounds(&c1k2);
596 DumpBounds(&c1c2);
597}
598
599template <typename TCurve, typename OppCurve>
600void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700601 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700602}
603
caryclark1049f122015-04-20 08:31:59 -0700604void DontCallDumpCoin();
605void DontCallDumpCoin() { // exists to instantiate the templates
606 SkDQuad quad;
607 SkDConic conic;
608 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700609 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
610 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
611 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
612 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
613 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
614 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
615 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
616 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
617 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700618 DumpCoin(&q1q2);
619 DumpCoin(&q1k2);
620 DumpCoin(&q1c2);
621 DumpCoin(&k1q2);
622 DumpCoin(&k1k2);
623 DumpCoin(&k1c2);
624 DumpCoin(&c1q2);
625 DumpCoin(&c1k2);
626 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000627}
628
caryclark1049f122015-04-20 08:31:59 -0700629template <typename TCurve, typename OppCurve>
630void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700631 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000632}
633
caryclark1049f122015-04-20 08:31:59 -0700634void DontCallDumpCoinCurves();
635void DontCallDumpCoinCurves() { // exists to instantiate the templates
636 SkDQuad quad;
637 SkDConic conic;
638 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700639 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
640 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
641 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
642 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
643 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
644 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
645 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
646 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
647 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700648 DumpCoinCurves(&q1q2);
649 DumpCoinCurves(&q1k2);
650 DumpCoinCurves(&q1c2);
651 DumpCoinCurves(&k1q2);
652 DumpCoinCurves(&k1k2);
653 DumpCoinCurves(&k1c2);
654 DumpCoinCurves(&c1q2);
655 DumpCoinCurves(&c1k2);
656 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000657}
658
caryclark1049f122015-04-20 08:31:59 -0700659template <typename TCurve, typename OppCurve>
660void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700661 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000662}
663
caryclark1049f122015-04-20 08:31:59 -0700664void DontCallDumpCurves();
665void DontCallDumpCurves() { // exists to instantiate the templates
666 SkDQuad quad;
667 SkDConic conic;
668 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700669 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
670 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
671 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
672 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
673 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
674 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
675 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
676 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
677 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700678 DumpCurves(&q1q2);
679 DumpCurves(&q1k2);
680 DumpCurves(&q1c2);
681 DumpCurves(&k1q2);
682 DumpCurves(&k1k2);
683 DumpCurves(&k1c2);
684 DumpCurves(&c1q2);
685 DumpCurves(&c1k2);
686 DumpCurves(&c1c2);
687}
688
689template <typename TCurve, typename OppCurve>
690void Dump(const SkTSpan<TCurve, OppCurve>* span) {
691 span->dump();
692}
693
694void DontCallDumpTSpan();
695void DontCallDumpTSpan() { // exists to instantiate the templates
696 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
697 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
698 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
699 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
700 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
701 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
702 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
703 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
704 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
705 Dump(&q1q2);
706 Dump(&q1k2);
707 Dump(&q1c2);
708 Dump(&k1q2);
709 Dump(&k1k2);
710 Dump(&k1c2);
711 Dump(&c1q2);
712 Dump(&c1k2);
713 Dump(&c1c2);
714}
715
716template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700717void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
718 span->dumpAll();
719}
720
721void DontCallDumpSpanAll();
722void DontCallDumpSpanAll() { // exists to instantiate the templates
723 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
724 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
725 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
726 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
727 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
728 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
729 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
730 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
731 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
732 DumpAll(&q1q2);
733 DumpAll(&q1k2);
734 DumpAll(&q1c2);
735 DumpAll(&k1q2);
736 DumpAll(&k1k2);
737 DumpAll(&k1c2);
738 DumpAll(&c1q2);
739 DumpAll(&c1k2);
740 DumpAll(&c1c2);
741}
742
743template <typename TCurve, typename OppCurve>
744void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
745 span->dumpBounded(0);
746}
747
748void DontCallDumpSpanBounded();
749void DontCallDumpSpanBounded() { // exists to instantiate the templates
750 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
751 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
752 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
753 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
754 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
755 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
756 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
757 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
758 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
759 DumpBounded(&q1q2);
760 DumpBounded(&q1k2);
761 DumpBounded(&q1c2);
762 DumpBounded(&k1q2);
763 DumpBounded(&k1k2);
764 DumpBounded(&k1c2);
765 DumpBounded(&c1q2);
766 DumpBounded(&c1k2);
767 DumpBounded(&c1c2);
768}
769
770template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700771void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
772 span->dumpCoin();
773}
774
775void DontCallDumpSpanCoin();
776void DontCallDumpSpanCoin() { // exists to instantiate the templates
777 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
778 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
779 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
780 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
781 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
782 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
783 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
784 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
785 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
786 DumpCoin(&q1q2);
787 DumpCoin(&q1k2);
788 DumpCoin(&q1c2);
789 DumpCoin(&k1q2);
790 DumpCoin(&k1k2);
791 DumpCoin(&k1c2);
792 DumpCoin(&c1q2);
793 DumpCoin(&c1k2);
794 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700795}
796
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000797static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700798 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
799 quad1.dumpInner();
800 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000801 quad2.dump();
802 SkDebugf("</div>\n\n");
803}
804
805static void dumpTestTrailer() {
806 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
807 SkDebugf(" var testDivs = [\n");
808}
809
810static void dumpTestList(int testNo, double min) {
811 SkDebugf(" quad%d,", testNo);
812 if (min > 0) {
813 SkDebugf(" // %1.9g", min);
814 }
815 SkDebugf("\n");
816}
817
818void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
819 SkDebugf("\n");
820 dumpTestCase(quad1, quad2, testNo);
821 dumpTestTrailer();
822 dumpTestList(testNo, 0);
823 SkDebugf("\n");
824}
825
826void DumpT(const SkDQuad& quad, double t) {
827 SkDLine line = {{quad.ptAtT(t), quad[0]}};
828 line.dump();
829}
caryclark54359292015-03-26 07:52:43 -0700830
831const SkOpAngle* SkOpAngle::debugAngle(int id) const {
832 return this->segment()->debugAngle(id);
833}
834
caryclark55888e42016-07-18 10:01:36 -0700835const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
836 return this->segment()->debugCoincidence();
837}
838
caryclark30b9fdd2016-08-31 14:36:29 -0700839SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700840 return this->segment()->debugContour(id);
841}
842
843const SkOpPtT* SkOpAngle::debugPtT(int id) const {
844 return this->segment()->debugPtT(id);
845}
846
847const SkOpSegment* SkOpAngle::debugSegment(int id) const {
848 return this->segment()->debugSegment(id);
849}
850
caryclark624637c2015-05-11 07:21:27 -0700851int SkOpAngle::debugSign() const {
852 SkASSERT(fStart->t() != fEnd->t());
853 return fStart->t() < fEnd->t() ? -1 : 1;
854}
855
caryclark54359292015-03-26 07:52:43 -0700856const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
857 return this->segment()->debugSpan(id);
858}
859
860void SkOpAngle::dump() const {
861 dumpOne(true);
862 SkDebugf("\n");
863}
864
865void SkOpAngle::dumpOne(bool functionHeader) const {
866// fSegment->debugValidate();
867 const SkOpSegment* segment = this->segment();
868 const SkOpSpan& mSpan = *fStart->starter(fEnd);
869 if (functionHeader) {
870 SkDebugf("%s ", __FUNCTION__);
871 }
872 SkDebugf("[%d", segment->debugID());
873 SkDebugf("/%d", debugID());
874 SkDebugf("] next=");
875 if (fNext) {
876 SkDebugf("%d", fNext->fStart->segment()->debugID());
877 SkDebugf("/%d", fNext->debugID());
878 } else {
879 SkDebugf("?");
880 }
881 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
882 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
883 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700884 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700885
886 SkDebugf(" windSum=");
887 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
888 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
889 SkDebugf(" oppVal=%d", mSpan.oppValue());
890 SkDebugf(" oppSum=");
891 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
892 }
893 if (mSpan.done()) {
894 SkDebugf(" done");
895 }
896 if (unorderable()) {
897 SkDebugf(" unorderable");
898 }
899 if (segment->operand()) {
900 SkDebugf(" operand");
901 }
caryclark54359292015-03-26 07:52:43 -0700902}
903
904void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
905 const SkOpAngle* first = this;
906 const SkOpAngle* next = this;
907 const char* indent = "";
908 do {
909 SkDebugf("%s", indent);
910 next->dumpOne(false);
911 if (segment == next->fStart->segment()) {
912 if (this == fNext) {
913 SkDebugf(" << from");
914 }
915 if (to == fNext) {
916 SkDebugf(" << to");
917 }
918 }
919 SkDebugf("\n");
920 indent = " ";
921 next = next->fNext;
922 } while (next && next != first);
923}
924
925void SkOpAngle::dumpCurves() const {
926 const SkOpAngle* first = this;
927 const SkOpAngle* next = this;
928 do {
caryclarkeed356d2016-09-14 07:18:20 -0700929 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700930 next = next->fNext;
931 } while (next && next != first);
932}
933
934void SkOpAngle::dumpLoop() const {
935 const SkOpAngle* first = this;
936 const SkOpAngle* next = this;
937 do {
938 next->dumpOne(false);
939 SkDebugf("\n");
940 next = next->fNext;
941 } while (next && next != first);
942}
943
944void SkOpAngle::dumpTest() const {
945 const SkOpAngle* first = this;
946 const SkOpAngle* next = this;
947 do {
948 SkDebugf("{ ");
949 SkOpSegment* segment = next->segment();
950 segment->dumpPts();
951 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
952 next->start()->t(), next->end()->t());
953 next = next->fNext;
954 } while (next && next != first);
955}
956
957bool SkOpPtT::debugMatchID(int id) const {
958 int limit = this->debugLoopLimit(false);
959 int loop = 0;
960 const SkOpPtT* ptT = this;
961 do {
962 if (ptT->debugID() == id) {
963 return true;
964 }
965 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
966 return false;
967}
968
969const SkOpAngle* SkOpPtT::debugAngle(int id) const {
970 return this->span()->debugAngle(id);
971}
972
caryclark30b9fdd2016-08-31 14:36:29 -0700973SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700974 return this->span()->debugContour(id);
975}
976
caryclark55888e42016-07-18 10:01:36 -0700977const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
978 return this->span()->debugCoincidence();
979}
980
caryclark54359292015-03-26 07:52:43 -0700981const SkOpPtT* SkOpPtT::debugPtT(int id) const {
982 return this->span()->debugPtT(id);
983}
984
985const SkOpSegment* SkOpPtT::debugSegment(int id) const {
986 return this->span()->debugSegment(id);
987}
988
989const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
990 return this->span()->debugSpan(id);
991}
992
993void SkOpPtT::dump() const {
994 SkDebugf("seg=%d span=%d ptT=%d",
995 this->segment()->debugID(), this->span()->debugID(), this->debugID());
996 this->dumpBase();
997 SkDebugf("\n");
998}
999
1000void SkOpPtT::dumpAll() const {
1001 contour()->indentDump();
1002 const SkOpPtT* next = this;
1003 int limit = debugLoopLimit(true);
1004 int loop = 0;
1005 do {
1006 SkDebugf("%.*s", contour()->debugIndent(), " ");
1007 SkDebugf("seg=%d span=%d ptT=%d",
1008 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1009 next->dumpBase();
1010 SkDebugf("\n");
1011 if (limit && ++loop >= limit) {
1012 SkDebugf("*** abort loop ***\n");
1013 break;
1014 }
1015 } while ((next = next->fNext) && next != this);
1016 contour()->outdentDump();
1017}
1018
1019void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001020 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1021 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001022 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1023}
1024
1025const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1026 return this->segment()->debugAngle(id);
1027}
1028
caryclark55888e42016-07-18 10:01:36 -07001029const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1030 return this->segment()->debugCoincidence();
1031}
1032
caryclark30b9fdd2016-08-31 14:36:29 -07001033SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001034 return this->segment()->debugContour(id);
1035}
1036
1037const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1038 return this->segment()->debugPtT(id);
1039}
1040
1041const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1042 return this->segment()->debugSegment(id);
1043}
1044
1045const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1046 return this->segment()->debugSpan(id);
1047}
1048
1049void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001050 this->dumpHead();
1051 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001052}
1053
caryclark55888e42016-07-18 10:01:36 -07001054void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001055 SkDebugf("%.*s", contour()->debugIndent(), " ");
1056 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1057 this->dumpBase();
1058 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001059}
1060
1061void SkOpSpanBase::dumpAll() const {
1062 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001063 this->fPtT.dumpAll();
1064}
1065
1066void SkOpSpanBase::dumpBase() const {
1067 if (this->fAligned) {
1068 SkDebugf(" aligned");
1069 }
1070 if (this->fChased) {
1071 SkDebugf(" chased");
1072 }
caryclark55888e42016-07-18 10:01:36 -07001073#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001074 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001075 SkDebugf(" deleted");
1076 }
1077#endif
caryclark54359292015-03-26 07:52:43 -07001078 if (!this->final()) {
1079 this->upCast()->dumpSpan();
1080 }
1081 const SkOpSpanBase* coin = this->coinEnd();
1082 if (this != coin) {
1083 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1084 } else if (this->final() || !this->upCast()->isCoincident()) {
1085 const SkOpPtT* oPt = this->ptT()->next();
1086 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1087 }
caryclark08bc8482015-04-24 09:08:57 -07001088 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001089}
1090
1091void SkOpSpanBase::dumpCoin() const {
1092 const SkOpSpan* span = this->upCastable();
1093 if (!span) {
1094 return;
1095 }
1096 if (!span->isCoincident()) {
1097 return;
1098 }
1099 span->dumpCoin();
1100}
1101
1102void SkOpSpan::dumpCoin() const {
1103 const SkOpSpan* coincident = fCoincident;
1104 bool ok = debugCoinLoopCheck();
1105 this->dump();
1106 int loop = 0;
1107 do {
1108 coincident->dump();
1109 if (!ok && ++loop > 10) {
1110 SkDebugf("*** abort loop ***\n");
1111 break;
1112 }
1113 } while ((coincident = coincident->fCoincident) != this);
1114}
1115
1116bool SkOpSpan::dumpSpan() const {
1117 SkOpSpan* coin = fCoincident;
1118 if (this != coin) {
1119 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1120 }
1121 SkDebugf(" windVal=%d", this->windValue());
1122 SkDebugf(" windSum=");
1123 SkPathOpsDebug::WindingPrintf(this->windSum());
1124 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1125 SkDebugf(" oppVal=%d", this->oppValue());
1126 SkDebugf(" oppSum=");
1127 SkPathOpsDebug::WindingPrintf(this->oppSum());
1128 }
1129 if (this->done()) {
1130 SkDebugf(" done");
1131 }
1132 return this != coin;
1133}
1134
1135const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1136 return this->contour()->debugAngle(id);
1137}
1138
caryclark55888e42016-07-18 10:01:36 -07001139
1140const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1141 return this->contour()->debugCoincidence();
1142}
1143
caryclark30b9fdd2016-08-31 14:36:29 -07001144SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001145 return this->contour()->debugContour(id);
1146}
1147
1148const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1149 return this->contour()->debugPtT(id);
1150}
1151
1152const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1153 return this->contour()->debugSegment(id);
1154}
1155
1156const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1157 return this->contour()->debugSpan(id);
1158}
1159
1160void SkOpSegment::dump() const {
1161 SkDebugf("%.*s", contour()->debugIndent(), " ");
1162 this->dumpPts();
1163 const SkOpSpanBase* span = &fHead;
1164 contour()->indentDump();
1165 do {
1166 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1167 span->ptT()->dumpBase();
1168 span->dumpBase();
1169 SkDebugf("\n");
1170 } while (!span->final() && (span = span->upCast()->next()));
1171 contour()->outdentDump();
1172}
1173
1174void SkOpSegment::dumpAll() const {
1175 SkDebugf("%.*s", contour()->debugIndent(), " ");
1176 this->dumpPts();
1177 const SkOpSpanBase* span = &fHead;
1178 contour()->indentDump();
1179 do {
1180 span->dumpAll();
1181 } while (!span->final() && (span = span->upCast()->next()));
1182 contour()->outdentDump();
1183}
1184
1185void SkOpSegment::dumpAngles() const {
1186 SkDebugf("seg=%d\n", debugID());
1187 const SkOpSpanBase* span = &fHead;
1188 do {
1189 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001190 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001191 if (fAngle) {
1192 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1193 fAngle->dumpTo(this, tAngle);
1194 }
1195 if (tAngle) {
1196 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1197 tAngle->dumpTo(this, fAngle);
1198 }
1199 } while (!span->final() && (span = span->upCast()->next()));
1200}
1201
1202void SkOpSegment::dumpCoin() const {
1203 const SkOpSpan* span = &fHead;
1204 do {
1205 span->dumpCoin();
1206 } while ((span = span->next()->upCastable()));
1207}
1208
caryclark26ad22a2015-10-16 09:03:38 -07001209void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001210 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001211 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001212 if (fVerb == SkPath::kConic_Verb) {
1213 SkDebugf("{");
1214 }
caryclark54359292015-03-26 07:52:43 -07001215 int index = 0;
1216 do {
1217 SkDPoint::Dump(fPts[index]);
1218 SkDebugf(", ");
1219 } while (++index < last);
1220 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001221 SkDebugf("}}");
1222 if (fVerb == SkPath::kConic_Verb) {
1223 SkDebugf(", %1.9gf}", fWeight);
1224 }
caryclark624637c2015-05-11 07:21:27 -07001225}
1226
caryclark26ad22a2015-10-16 09:03:38 -07001227void SkOpSegment::dumpPts(const char* prefix) const {
1228 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001229 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001230}
1231
1232void SkCoincidentSpans::dump() const {
1233 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1234 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1235 fCoinPtTStart->dumpBase();
1236 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1237 fCoinPtTEnd->dumpBase();
1238 if (fCoinPtTStart->segment()->operand()) {
1239 SkDebugf(" operand");
1240 }
1241 if (fCoinPtTStart->segment()->isXor()) {
1242 SkDebugf(" xor");
1243 }
1244 SkDebugf("\n");
1245 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1246 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1247 fOppPtTStart->dumpBase();
1248 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1249 fOppPtTEnd->dumpBase();
1250 if (fOppPtTStart->segment()->operand()) {
1251 SkDebugf(" operand");
1252 }
1253 if (fOppPtTStart->segment()->isXor()) {
1254 SkDebugf(" xor");
1255 }
1256 SkDebugf("\n");
1257}
1258
1259void SkOpCoincidence::dump() const {
1260 SkCoincidentSpans* span = fHead;
1261 while (span) {
1262 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001263 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001264 }
caryclark26ad22a2015-10-16 09:03:38 -07001265 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001266 return;
1267 }
1268 SkDebugf("top:\n");
1269 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001270 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001271 while (span) {
1272 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001273 span = span->next();
1274 SkCoincidentSpans* check = fTop;
1275 ++count;
1276 for (int index = 0; index < count; ++index) {
1277 if (span == check) {
1278 SkDebugf("(loops to #%d)\n", index);
1279 return;
1280 }
1281 check = check->next();
1282 }
caryclark27c8eb82015-07-06 11:38:33 -07001283 }
caryclark54359292015-03-26 07:52:43 -07001284}
1285
caryclark624637c2015-05-11 07:21:27 -07001286void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001287 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001288 if (!fCount) {
1289 return;
1290 }
1291 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001292 SkDEBUGCODE(fDebugIndent = 0);
1293 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001294 do {
1295 segment->dump();
1296 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001297 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001298}
1299
caryclark624637c2015-05-11 07:21:27 -07001300void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001301 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001302 if (!fCount) {
1303 return;
1304 }
1305 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001306 SkDEBUGCODE(fDebugIndent = 0);
1307 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001308 do {
1309 segment->dumpAll();
1310 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001311 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001312}
1313
1314
1315void SkOpContour::dumpAngles() const {
1316 SkDebugf("contour=%d\n", this->debugID());
1317 const SkOpSegment* segment = &fHead;
1318 do {
1319 SkDebugf(" seg=%d ", segment->debugID());
1320 segment->dumpAngles();
1321 } while ((segment = segment->next()));
1322}
1323
1324void SkOpContour::dumpPt(int index) const {
1325 const SkOpSegment* segment = &fHead;
1326 do {
1327 if (segment->debugID() == index) {
1328 segment->dumpPts();
1329 }
1330 } while ((segment = segment->next()));
1331}
1332
caryclark26ad22a2015-10-16 09:03:38 -07001333void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001334 SkDebugf("contour=%d\n", this->debugID());
1335 const SkOpSegment* segment = &fHead;
1336 do {
caryclark26ad22a2015-10-16 09:03:38 -07001337 SkDebugf(" %s=%d ", prefix, segment->debugID());
1338 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001339 } while ((segment = segment->next()));
1340}
1341
caryclark26ad22a2015-10-16 09:03:38 -07001342void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001343 if (!this->fCount) {
1344 SkDebugf("<empty>\n");
1345 return;
1346 }
1347 const SkOpSegment* segment = &fHead;
1348 do {
caryclark26ad22a2015-10-16 09:03:38 -07001349 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001350 } while ((segment = segment->next()));
1351}
1352
1353void SkOpContour::dumpSegment(int index) const {
1354 debugSegment(index)->dump();
1355}
1356
caryclark26ad22a2015-10-16 09:03:38 -07001357void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001358 bool firstOp = false;
1359 const SkOpContour* c = this;
1360 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001361 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001362#if DEBUG_ACTIVE_OP
1363 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1364#endif
1365 firstOp = true;
1366 }
caryclark26ad22a2015-10-16 09:03:38 -07001367 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001368 } while ((c = c->next()));
1369}
1370
1371void SkOpContour::dumpSpan(int index) const {
1372 debugSpan(index)->dump();
1373}
1374
1375void SkOpContour::dumpSpans() const {
1376 SkDebugf("contour=%d\n", this->debugID());
1377 const SkOpSegment* segment = &fHead;
1378 do {
1379 SkDebugf(" seg=%d ", segment->debugID());
1380 segment->dump();
1381 } while ((segment = segment->next()));
1382}
1383
caryclark03b03ca2015-04-23 09:13:37 -07001384void SkOpCurve::dump() const {
1385 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1386 SkDebugf("{{");
1387 int index;
1388 for (index = 0; index <= count - 1; ++index) {
1389 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1390 }
1391 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1392}
1393
caryclark54359292015-03-26 07:52:43 -07001394#ifdef SK_DEBUG
1395const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001396 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001397 do {
1398 const SkOpSegment* segment = contour->first();
1399 while (segment) {
1400 const SkOpSpan* span = segment->head();
1401 do {
1402 SkOpAngle* angle = span->fromAngle();
1403 if (angle && angle->debugID() == id) {
1404 return angle;
1405 }
1406 angle = span->toAngle();
1407 if (angle && angle->debugID() == id) {
1408 return angle;
1409 }
1410 } while ((span = span->next()->upCastable()));
1411 const SkOpSpanBase* tail = segment->tail();
1412 SkOpAngle* angle = tail->fromAngle();
1413 if (angle && angle->debugID() == id) {
1414 return angle;
1415 }
1416 segment = segment->next();
1417 }
1418 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001419 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001420}
1421
caryclark30b9fdd2016-08-31 14:36:29 -07001422SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001423 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001424 do {
1425 if (contour->debugID() == id) {
1426 return contour;
1427 }
1428 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001429 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001430}
1431
1432const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001433 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001434 do {
1435 const SkOpSegment* segment = contour->first();
1436 while (segment) {
1437 const SkOpSpan* span = segment->head();
1438 do {
1439 const SkOpPtT* ptT = span->ptT();
1440 if (ptT->debugMatchID(id)) {
1441 return ptT;
1442 }
1443 } while ((span = span->next()->upCastable()));
1444 const SkOpSpanBase* tail = segment->tail();
1445 const SkOpPtT* ptT = tail->ptT();
1446 if (ptT->debugMatchID(id)) {
1447 return ptT;
1448 }
1449 segment = segment->next();
1450 }
1451 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001452 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001453}
1454
1455const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001456 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001457 do {
1458 const SkOpSegment* segment = contour->first();
1459 while (segment) {
1460 if (segment->debugID() == id) {
1461 return segment;
1462 }
1463 segment = segment->next();
1464 }
1465 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001466 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001467}
1468
1469const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001470 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001471 do {
1472 const SkOpSegment* segment = contour->first();
1473 while (segment) {
1474 const SkOpSpan* span = segment->head();
1475 do {
1476 if (span->debugID() == id) {
1477 return span;
1478 }
1479 } while ((span = span->next()->upCastable()));
1480 const SkOpSpanBase* tail = segment->tail();
1481 if (tail->debugID() == id) {
1482 return tail;
1483 }
1484 segment = segment->next();
1485 }
1486 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001487 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001488}
1489#endif
1490
caryclark54359292015-03-26 07:52:43 -07001491#if DEBUG_T_SECT_DUMP > 1
1492int gDumpTSectNum;
1493#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001494
1495// global path dumps for msvs Visual Studio 17 to use from Immediate Window
1496namespace SkOpDebug {
1497
1498 void Dump(const SkOpContour& contour) {
1499 contour.dump();
1500 }
1501
1502 void DumpAll(const SkOpContour& contour) {
1503 contour.dumpAll();
1504 }
1505
1506 void DumpAngles(const SkOpContour& contour) {
1507 contour.dumpAngles();
1508 }
1509
1510 void DumpContours(const SkOpContour& contour) {
1511 contour.dumpContours();
1512 }
1513
1514 void DumpContoursAll(const SkOpContour& contour) {
1515 contour.dumpContoursAll();
1516 }
1517
1518 void DumpContoursAngles(const SkOpContour& contour) {
1519 contour.dumpContoursAngles();
1520 }
1521
1522 void DumpContoursPts(const SkOpContour& contour) {
1523 contour.dumpContoursPts();
1524 }
1525
1526 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1527 contour.dumpContoursPt(segmentID);
1528 }
1529
1530 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1531 contour.dumpContoursSegment(segmentID);
1532 }
1533
1534 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1535 contour.dumpContoursSpan(segmentID);
1536 }
1537
1538 void DumpContoursSpans(const SkOpContour& contour) {
1539 contour.dumpContoursSpans();
1540 }
1541
1542 void DumpPt(const SkOpContour& contour, int pt) {
1543 contour.dumpPt(pt);
1544 }
1545
1546 void DumpPts(const SkOpContour& contour, const char* prefix) {
1547 contour.dumpPts(prefix);
1548 }
1549
1550 void DumpSegment(const SkOpContour& contour, int seg) {
1551 contour.dumpSegment(seg);
1552 }
1553
1554 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1555 contour.dumpSegments(prefix, op);
1556 }
1557
1558 void DumpSpan(const SkOpContour& contour, int span) {
1559 contour.dumpSpan(span);
1560 }
1561
1562 void DumpSpans(const SkOpContour& contour ) {
1563 contour.dumpSpans();
1564 }
1565
1566 void Dump(const SkOpSegment& segment) {
1567 segment.dump();
1568 }
1569
1570 void DumpAll(const SkOpSegment& segment) {
1571 segment.dumpAll();
1572 }
1573
1574 void DumpAngles(const SkOpSegment& segment) {
1575 segment.dumpAngles();
1576 }
1577
1578 void DumpCoin(const SkOpSegment& segment) {
1579 segment.dumpCoin();
1580 }
1581
1582 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1583 segment.dumpPts(prefix);
1584 }
1585
1586 void Dump(const SkOpPtT& ptT) {
1587 ptT.dump();
1588 }
1589
1590 void DumpAll(const SkOpPtT& ptT) {
1591 ptT.dumpAll();
1592 }
1593
1594 void Dump(const SkOpSpanBase& spanBase) {
1595 spanBase.dump();
1596 }
1597
1598 void DumpCoin(const SkOpSpanBase& spanBase) {
1599 spanBase.dumpCoin();
1600 }
1601
1602 void DumpAll(const SkOpSpanBase& spanBase) {
1603 spanBase.dumpAll();
1604 }
1605
1606 void DumpCoin(const SkOpSpan& span) {
1607 span.dumpCoin();
1608 }
1609
1610 bool DumpSpan(const SkOpSpan& span) {
1611 return span.dumpSpan();
1612 }
1613
1614 void Dump(const SkDConic& conic) {
1615 conic.dump();
1616 }
1617
1618 void DumpID(const SkDConic& conic, int id) {
1619 conic.dumpID(id);
1620 }
1621
1622 void Dump(const SkDCubic& cubic) {
1623 cubic.dump();
1624 }
1625
1626 void DumpID(const SkDCubic& cubic, int id) {
1627 cubic.dumpID(id);
1628 }
1629
1630 void Dump(const SkDLine& line) {
1631 line.dump();
1632 }
1633
1634 void DumpID(const SkDLine& line, int id) {
1635 line.dumpID(id);
1636 }
1637
1638 void Dump(const SkDQuad& quad) {
1639 quad.dump();
1640 }
1641
1642 void DumpID(const SkDQuad& quad, int id) {
1643 quad.dumpID(id);
1644 }
1645
1646 void Dump(const SkDPoint& point) {
1647 point.dump();
1648 }
1649
Cary Clark1857ddb2018-07-11 11:01:43 -04001650 void Dump(const SkOpAngle& angle) {
1651 angle.dump();
1652 }
1653
Cary Clarkb8421ed2018-03-14 15:55:02 -04001654// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1655#define DummyDefinitions(a, b) \
1656 \
1657 void Dump(const SkDebugTCoincident##a##b& curve) { \
1658 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1659 } \
1660 \
1661 void Dump(const SkDebugTSect##a##b& curve) { \
1662 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1663 } \
1664 \
1665 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1666 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1667 } \
1668 \
1669 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1670 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1671 } \
1672 \
1673 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1674 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1675 } \
1676 \
1677 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1678 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1679 } \
1680 \
1681 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1682 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1683 } \
1684 \
1685 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1686 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1687 } \
1688 \
1689 void Dump(const SkDebugTSpan##a##b& curve) { \
1690 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1691 } \
1692 \
1693 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1694 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1695 } \
1696 \
1697 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1698 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1699 } \
1700 \
1701 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1702 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1703 } \
1704 \
1705 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1706 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1707 }
1708
1709 DummyDefinitions(Quad, Quad);
1710 DummyDefinitions(Conic, Quad);
1711 DummyDefinitions(Conic, Conic);
1712 DummyDefinitions(Cubic, Quad);
1713 DummyDefinitions(Cubic, Conic);
1714 DummyDefinitions(Cubic, Cubic);
1715
1716#undef DummyDefinitions
1717}