blob: 969ed85dbaa6c75a53eac37142085e19643d5221 [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;
19FILE* PathOpsDebug::gOut;
20
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000021inline void DebugDumpDouble(double x) {
22 if (x == floor(x)) {
23 SkDebugf("%.0f", x);
24 } else {
25 SkDebugf("%1.19g", x);
26 }
27}
28
29inline void DebugDumpFloat(float x) {
30 if (x == floorf(x)) {
31 SkDebugf("%.0f", x);
32 } else {
33 SkDebugf("%1.9gf", x);
34 }
35}
36
caryclark65f55312014-11-13 06:58:52 -080037inline void DebugDumpHexFloat(float x) {
38 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
39}
caryclark19eb3b22014-07-18 05:08:14 -070040
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000041// if not defined by PathOpsDebug.cpp ...
42#if !defined SK_DEBUG && FORCE_RELEASE
43bool SkPathOpsDebug::ValidWind(int wind) {
44 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
45}
46
47void SkPathOpsDebug::WindingPrintf(int wind) {
48 if (wind == SK_MinS32) {
49 SkDebugf("?");
50 } else {
51 SkDebugf("%d", wind);
52 }
53}
54#endif
55
caryclark55888e42016-07-18 10:01:36 -070056static void DumpID(int id) {
57 SkDebugf("} ");
58 if (id >= 0) {
59 SkDebugf("id=%d", id);
60 }
61 SkDebugf("\n");
62}
63
caryclark1049f122015-04-20 08:31:59 -070064void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070065 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070066 SkDebugf("},\n");
67}
68
69void SkDConic::dumpID(int id) const {
70 dumpInner();
caryclark55888e42016-07-18 10:01:36 -070071 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -070072}
73
74void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070075 SkDebugf("{");
76 fPts.dumpInner();
77 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070078}
79
80void SkDCubic::dump() const {
81 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070082 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070083}
84
caryclark54359292015-03-26 07:52:43 -070085void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070086 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -070087 SkDebugf("}");
88 DumpID(id);
reed0dc4dd62015-03-24 13:55:33 -070089}
90
caryclark54359292015-03-26 07:52:43 -070091static inline bool double_is_NaN(double x) { return x != x; }
92
93void SkDCubic::dumpInner() const {
94 SkDebugf("{{");
95 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070096 do {
caryclark54359292015-03-26 07:52:43 -070097 if (index != 0) {
98 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
99 return;
reed0dc4dd62015-03-24 13:55:33 -0700100 }
caryclark54359292015-03-26 07:52:43 -0700101 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700102 }
caryclark54359292015-03-26 07:52:43 -0700103 fPts[index].dump();
104 } while (++index < 3);
105 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -0700106 return;
107 }
caryclark54359292015-03-26 07:52:43 -0700108 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700109 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000110}
111
caryclark55888e42016-07-18 10:01:36 -0700112void SkDCurve::dump() const {
113 dumpID(-1);
114}
115
caryclark1049f122015-04-20 08:31:59 -0700116void SkDCurve::dumpID(int id) const {
117#ifndef SK_RELEASE
118 switch(fVerb) {
119 case SkPath::kLine_Verb:
120 fLine.dumpID(id);
121 break;
122 case SkPath::kQuad_Verb:
123 fQuad.dumpID(id);
124 break;
125 case SkPath::kConic_Verb:
126 fConic.dumpID(id);
127 break;
128 case SkPath::kCubic_Verb:
129 fCubic.dumpID(id);
130 break;
131 default:
132 SkASSERT(0);
133 }
134#else
135 fCubic.dumpID(id);
136#endif
137}
138
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000139void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700140 this->dumpInner();
141 SkDebugf("}},\n");
142}
143
144void SkDLine::dumpID(int id) const {
145 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700146 SkDebugf("}");
147 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -0700148}
149
150void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000151 SkDebugf("{{");
152 fPts[0].dump();
153 SkDebugf(", ");
154 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000155}
156
157void SkDPoint::dump() const {
158 SkDebugf("{");
159 DebugDumpDouble(fX);
160 SkDebugf(", ");
161 DebugDumpDouble(fY);
162 SkDebugf("}");
163}
164
165void SkDPoint::Dump(const SkPoint& pt) {
166 SkDebugf("{");
167 DebugDumpFloat(pt.fX);
168 SkDebugf(", ");
169 DebugDumpFloat(pt.fY);
170 SkDebugf("}");
171}
172
caryclark65f55312014-11-13 06:58:52 -0800173void SkDPoint::DumpHex(const SkPoint& pt) {
174 SkDebugf("{");
175 DebugDumpHexFloat(pt.fX);
176 SkDebugf(", ");
177 DebugDumpHexFloat(pt.fY);
178 SkDebugf("}");
179}
180
181void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700182 dumpInner();
183 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800184}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000185
caryclark54359292015-03-26 07:52:43 -0700186void SkDQuad::dumpID(int id) const {
187 dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700188 SkDebugf("}");
189 DumpID(id);
caryclark54359292015-03-26 07:52:43 -0700190}
191
192void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000193 SkDebugf("{{");
194 int index = 0;
195 do {
196 fPts[index].dump();
197 SkDebugf(", ");
198 } while (++index < 2);
199 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000200}
201
caryclark54359292015-03-26 07:52:43 -0700202void SkIntersections::dump() const {
203 SkDebugf("used=%d of %d", fUsed, fMax);
204 for (int index = 0; index < fUsed; ++index) {
205 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
206 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
207 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
208 fPt[index].fX, fPt[index].fY);
209 if (index < 2 && fNearlySame[index]) {
210 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000211 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000212 }
213 SkDebugf("\n");
214}
215
Cary Clarkb8421ed2018-03-14 15:55:02 -0400216namespace SkOpDebug {
217
218const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700219 return angle->debugAngle(id);
220}
221
Cary Clarkb8421ed2018-03-14 15:55:02 -0400222::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700223 return angle->debugContour(id);
224}
225
Cary Clarkb8421ed2018-03-14 15:55:02 -0400226const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700227 return angle->debugPtT(id);
228}
229
Cary Clarkb8421ed2018-03-14 15:55:02 -0400230const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700231 return angle->debugSegment(id);
232}
233
Cary Clarkb8421ed2018-03-14 15:55:02 -0400234const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700235 return angle->debugSpan(id);
236}
237
Cary Clarkb8421ed2018-03-14 15:55:02 -0400238const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700239 return contour->debugAngle(id);
240}
241
Cary Clarkb8421ed2018-03-14 15:55:02 -0400242::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700243 return contour->debugContour(id);
244}
245
Cary Clarkb8421ed2018-03-14 15:55:02 -0400246const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700247 return contour->debugPtT(id);
248}
249
Cary Clarkb8421ed2018-03-14 15:55:02 -0400250const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700251 return contour->debugSegment(id);
252}
253
Cary Clarkb8421ed2018-03-14 15:55:02 -0400254const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700255 return contour->debugSpan(id);
256}
257
Cary Clarkb8421ed2018-03-14 15:55:02 -0400258const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700259 return coin->debugAngle(id);
260}
261
Cary Clarkb8421ed2018-03-14 15:55:02 -0400262::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700263 return coin->debugContour(id);
264}
265
Cary Clarkb8421ed2018-03-14 15:55:02 -0400266const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700267 return coin->debugPtT(id);
268}
269
Cary Clarkb8421ed2018-03-14 15:55:02 -0400270const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700271 return coin->debugSegment(id);
272}
273
Cary Clarkb8421ed2018-03-14 15:55:02 -0400274const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700275 return coin->debugSpan(id);
276}
277
Cary Clarkb8421ed2018-03-14 15:55:02 -0400278const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700279 return ptT->debugAngle(id);
280}
281
Cary Clarkb8421ed2018-03-14 15:55:02 -0400282::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700283 return ptT->debugContour(id);
284}
285
Cary Clarkb8421ed2018-03-14 15:55:02 -0400286const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700287 return ptT->debugPtT(id);
288}
289
Cary Clarkb8421ed2018-03-14 15:55:02 -0400290const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700291 return ptT->debugSegment(id);
292}
293
Cary Clarkb8421ed2018-03-14 15:55:02 -0400294const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700295 return ptT->debugSpan(id);
296}
297
Cary Clarkb8421ed2018-03-14 15:55:02 -0400298const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700299 return span->debugAngle(id);
300}
301
Cary Clarkb8421ed2018-03-14 15:55:02 -0400302::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700303 return span->debugContour(id);
304}
305
Cary Clarkb8421ed2018-03-14 15:55:02 -0400306const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700307 return span->debugPtT(id);
308}
309
Cary Clarkb8421ed2018-03-14 15:55:02 -0400310const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700311 return span->debugSegment(id);
312}
313
Cary Clarkb8421ed2018-03-14 15:55:02 -0400314const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700315 return span->debugSpan(id);
316}
317
Cary Clarkb8421ed2018-03-14 15:55:02 -0400318const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700319 return span->debugAngle(id);
320}
321
Cary Clarkb8421ed2018-03-14 15:55:02 -0400322::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700323 return span->debugContour(id);
324}
325
Cary Clarkb8421ed2018-03-14 15:55:02 -0400326const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700327 return span->debugPtT(id);
328}
329
Cary Clarkb8421ed2018-03-14 15:55:02 -0400330const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700331 return span->debugSegment(id);
332}
333
Cary Clarkb8421ed2018-03-14 15:55:02 -0400334const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700335 return span->debugSpan(id);
336}
337
Cary Clarkb8421ed2018-03-14 15:55:02 -0400338} // namespace SkPathOpsDebug
339
Cary Clarkab87d7a2016-10-04 10:01:04 -0400340#if DEBUG_COIN
341void SkPathOpsDebug::DumpCoinDict() {
Cary Clarkb8421ed2018-03-14 15:55:02 -0400342 SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false);
343 SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true);
Cary Clarkab87d7a2016-10-04 10:01:04 -0400344}
345
346void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const {
347 int count = fDict.count();
348 for (int index = 0; index < count; ++index) {
349 const auto& entry = fDict[index];
350 if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) {
351 SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName,
352 entry.fLineNumber, entry.fIteration);
353 DumpGlitchType(entry.fGlitchType);
354 SkDebugf("\n");
355 }
356 }
357}
358#endif
359
caryclark624637c2015-05-11 07:21:27 -0700360void SkOpContour::dumpContours() const {
361 SkOpContour* contour = this->globalState()->contourHead();
362 do {
363 contour->dump();
364 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000365}
366
caryclark624637c2015-05-11 07:21:27 -0700367void SkOpContour::dumpContoursAll() const {
368 SkOpContour* contour = this->globalState()->contourHead();
369 do {
370 contour->dumpAll();
371 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000372}
373
caryclark624637c2015-05-11 07:21:27 -0700374void SkOpContour::dumpContoursAngles() const {
375 SkOpContour* contour = this->globalState()->contourHead();
376 do {
377 contour->dumpAngles();
378 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000379}
380
caryclark624637c2015-05-11 07:21:27 -0700381void SkOpContour::dumpContoursPts() const {
382 SkOpContour* contour = this->globalState()->contourHead();
383 do {
384 contour->dumpPts();
385 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000386}
387
caryclark624637c2015-05-11 07:21:27 -0700388void SkOpContour::dumpContoursPt(int segmentID) const {
389 SkOpContour* contour = this->globalState()->contourHead();
390 do {
391 contour->dumpPt(segmentID);
392 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000393}
394
caryclark624637c2015-05-11 07:21:27 -0700395void SkOpContour::dumpContoursSegment(int segmentID) const {
396 SkOpContour* contour = this->globalState()->contourHead();
397 do {
398 contour->dumpSegment(segmentID);
399 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000400}
401
caryclark624637c2015-05-11 07:21:27 -0700402void SkOpContour::dumpContoursSpan(int spanID) const {
403 SkOpContour* contour = this->globalState()->contourHead();
404 do {
405 contour->dumpSpan(spanID);
406 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000407}
408
caryclark624637c2015-05-11 07:21:27 -0700409void SkOpContour::dumpContoursSpans() const {
410 SkOpContour* contour = this->globalState()->contourHead();
411 do {
412 contour->dumpSpans();
413 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000414}
415
caryclark1049f122015-04-20 08:31:59 -0700416template <typename TCurve, typename OppCurve>
417const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700418 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000419}
420
caryclark1049f122015-04-20 08:31:59 -0700421void DontCallDebugSpan(int id);
422void DontCallDebugSpan(int id) { // exists to instantiate the templates
423 SkDQuad quad;
424 SkDConic conic;
425 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700426 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
427 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
428 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
429 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
430 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700435 DebugSpan(&q1q2, id);
436 DebugSpan(&q1k2, id);
437 DebugSpan(&q1c2, id);
438 DebugSpan(&k1q2, id);
439 DebugSpan(&k1k2, id);
440 DebugSpan(&k1c2, id);
441 DebugSpan(&c1q2, id);
442 DebugSpan(&c1k2, id);
443 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000444}
445
caryclark1049f122015-04-20 08:31:59 -0700446template <typename TCurve, typename OppCurve>
447const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700448 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000449}
450
caryclark1049f122015-04-20 08:31:59 -0700451void DontCallDebugT(double t);
452void DontCallDebugT(double t) { // exists to instantiate the templates
453 SkDQuad quad;
454 SkDConic conic;
455 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700456 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
457 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
458 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700465 DebugT(&q1q2, t);
466 DebugT(&q1k2, t);
467 DebugT(&q1c2, t);
468 DebugT(&k1q2, t);
469 DebugT(&k1k2, t);
470 DebugT(&k1c2, t);
471 DebugT(&c1q2, t);
472 DebugT(&c1k2, t);
473 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700474}
475
caryclark1049f122015-04-20 08:31:59 -0700476template <typename TCurve, typename OppCurve>
477void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700478 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000479}
480
caryclark1049f122015-04-20 08:31:59 -0700481void DontCallDumpTSect();
482void DontCallDumpTSect() { // exists to instantiate the templates
483 SkDQuad quad;
484 SkDConic conic;
485 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700486 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
487 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
488 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
489 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
490 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
491 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
492 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
493 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
494 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700495 Dump(&q1q2);
496 Dump(&q1k2);
497 Dump(&q1c2);
498 Dump(&k1q2);
499 Dump(&k1k2);
500 Dump(&k1c2);
501 Dump(&c1q2);
502 Dump(&c1k2);
503 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000504}
505
caryclark1049f122015-04-20 08:31:59 -0700506template <typename TCurve, typename OppCurve>
507void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700508 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700509}
510
caryclark1049f122015-04-20 08:31:59 -0700511void DontCallDumpBoth();
512void DontCallDumpBoth() { // exists to instantiate the templates
513 SkDQuad quad;
514 SkDConic conic;
515 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700516 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
517 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
518 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
519 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
520 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
521 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
522 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
523 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
524 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700525 DumpBoth(&q1q2, &q1q2);
526 DumpBoth(&q1k2, &k1q2);
527 DumpBoth(&q1c2, &c1q2);
528 DumpBoth(&k1q2, &q1k2);
529 DumpBoth(&k1k2, &k1k2);
530 DumpBoth(&k1c2, &c1k2);
531 DumpBoth(&c1q2, &q1c2);
532 DumpBoth(&c1k2, &k1c2);
533 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700534}
535
caryclark1049f122015-04-20 08:31:59 -0700536template <typename TCurve, typename OppCurve>
537void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
538 sect1->dumpBounded(id);
539}
540
541void DontCallDumpBounded();
542void DontCallDumpBounded() {
543 SkDQuad quad;
544 SkDConic conic;
545 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700546 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
547 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
548 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
549 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
550 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
551 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
552 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
553 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
554 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700555 DumpBounded(&q1q2, 0);
556 DumpBounded(&q1k2, 0);
557 DumpBounded(&q1c2, 0);
558 DumpBounded(&k1q2, 0);
559 DumpBounded(&k1k2, 0);
560 DumpBounded(&k1c2, 0);
561 DumpBounded(&c1q2, 0);
562 DumpBounded(&c1k2, 0);
563 DumpBounded(&c1c2, 0);
564}
565
566template <typename TCurve, typename OppCurve>
567void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
568 sect1->dumpBounds();
569}
570
571void DontCallDumpBounds();
572void DontCallDumpBounds() {
573 SkDQuad quad;
574 SkDConic conic;
575 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700576 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
577 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
578 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
579 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
580 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
581 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
582 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
583 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
584 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700585 DumpBounds(&q1q2);
586 DumpBounds(&q1k2);
587 DumpBounds(&q1c2);
588 DumpBounds(&k1q2);
589 DumpBounds(&k1k2);
590 DumpBounds(&k1c2);
591 DumpBounds(&c1q2);
592 DumpBounds(&c1k2);
593 DumpBounds(&c1c2);
594}
595
596template <typename TCurve, typename OppCurve>
597void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700598 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700599}
600
caryclark1049f122015-04-20 08:31:59 -0700601void DontCallDumpCoin();
602void DontCallDumpCoin() { // exists to instantiate the templates
603 SkDQuad quad;
604 SkDConic conic;
605 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700606 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
607 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
608 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
609 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
610 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
611 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
612 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
613 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
614 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700615 DumpCoin(&q1q2);
616 DumpCoin(&q1k2);
617 DumpCoin(&q1c2);
618 DumpCoin(&k1q2);
619 DumpCoin(&k1k2);
620 DumpCoin(&k1c2);
621 DumpCoin(&c1q2);
622 DumpCoin(&c1k2);
623 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000624}
625
caryclark1049f122015-04-20 08:31:59 -0700626template <typename TCurve, typename OppCurve>
627void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700628 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000629}
630
caryclark1049f122015-04-20 08:31:59 -0700631void DontCallDumpCoinCurves();
632void DontCallDumpCoinCurves() { // exists to instantiate the templates
633 SkDQuad quad;
634 SkDConic conic;
635 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700636 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
637 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
638 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
639 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
640 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
641 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
642 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
643 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
644 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700645 DumpCoinCurves(&q1q2);
646 DumpCoinCurves(&q1k2);
647 DumpCoinCurves(&q1c2);
648 DumpCoinCurves(&k1q2);
649 DumpCoinCurves(&k1k2);
650 DumpCoinCurves(&k1c2);
651 DumpCoinCurves(&c1q2);
652 DumpCoinCurves(&c1k2);
653 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000654}
655
caryclark1049f122015-04-20 08:31:59 -0700656template <typename TCurve, typename OppCurve>
657void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700658 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000659}
660
caryclark1049f122015-04-20 08:31:59 -0700661void DontCallDumpCurves();
662void DontCallDumpCurves() { // exists to instantiate the templates
663 SkDQuad quad;
664 SkDConic conic;
665 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700666 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
667 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
668 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
669 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
670 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
671 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
672 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
673 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
674 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700675 DumpCurves(&q1q2);
676 DumpCurves(&q1k2);
677 DumpCurves(&q1c2);
678 DumpCurves(&k1q2);
679 DumpCurves(&k1k2);
680 DumpCurves(&k1c2);
681 DumpCurves(&c1q2);
682 DumpCurves(&c1k2);
683 DumpCurves(&c1c2);
684}
685
686template <typename TCurve, typename OppCurve>
687void Dump(const SkTSpan<TCurve, OppCurve>* span) {
688 span->dump();
689}
690
691void DontCallDumpTSpan();
692void DontCallDumpTSpan() { // exists to instantiate the templates
693 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
694 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
695 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
696 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
697 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
698 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
699 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
700 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
701 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
702 Dump(&q1q2);
703 Dump(&q1k2);
704 Dump(&q1c2);
705 Dump(&k1q2);
706 Dump(&k1k2);
707 Dump(&k1c2);
708 Dump(&c1q2);
709 Dump(&c1k2);
710 Dump(&c1c2);
711}
712
713template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700714void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
715 span->dumpAll();
716}
717
718void DontCallDumpSpanAll();
719void DontCallDumpSpanAll() { // exists to instantiate the templates
720 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
721 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
722 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
723 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
724 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
725 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
726 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
727 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
728 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
729 DumpAll(&q1q2);
730 DumpAll(&q1k2);
731 DumpAll(&q1c2);
732 DumpAll(&k1q2);
733 DumpAll(&k1k2);
734 DumpAll(&k1c2);
735 DumpAll(&c1q2);
736 DumpAll(&c1k2);
737 DumpAll(&c1c2);
738}
739
740template <typename TCurve, typename OppCurve>
741void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
742 span->dumpBounded(0);
743}
744
745void DontCallDumpSpanBounded();
746void DontCallDumpSpanBounded() { // exists to instantiate the templates
747 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
748 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
749 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
750 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
751 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
752 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
753 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
754 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
755 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
756 DumpBounded(&q1q2);
757 DumpBounded(&q1k2);
758 DumpBounded(&q1c2);
759 DumpBounded(&k1q2);
760 DumpBounded(&k1k2);
761 DumpBounded(&k1c2);
762 DumpBounded(&c1q2);
763 DumpBounded(&c1k2);
764 DumpBounded(&c1c2);
765}
766
767template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700768void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
769 span->dumpCoin();
770}
771
772void DontCallDumpSpanCoin();
773void DontCallDumpSpanCoin() { // exists to instantiate the templates
774 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
775 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
776 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
777 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
778 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
779 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
780 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
781 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
782 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
783 DumpCoin(&q1q2);
784 DumpCoin(&q1k2);
785 DumpCoin(&q1c2);
786 DumpCoin(&k1q2);
787 DumpCoin(&k1k2);
788 DumpCoin(&k1c2);
789 DumpCoin(&c1q2);
790 DumpCoin(&c1k2);
791 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700792}
793
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000794static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700795 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
796 quad1.dumpInner();
797 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000798 quad2.dump();
799 SkDebugf("</div>\n\n");
800}
801
802static void dumpTestTrailer() {
803 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
804 SkDebugf(" var testDivs = [\n");
805}
806
807static void dumpTestList(int testNo, double min) {
808 SkDebugf(" quad%d,", testNo);
809 if (min > 0) {
810 SkDebugf(" // %1.9g", min);
811 }
812 SkDebugf("\n");
813}
814
815void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
816 SkDebugf("\n");
817 dumpTestCase(quad1, quad2, testNo);
818 dumpTestTrailer();
819 dumpTestList(testNo, 0);
820 SkDebugf("\n");
821}
822
823void DumpT(const SkDQuad& quad, double t) {
824 SkDLine line = {{quad.ptAtT(t), quad[0]}};
825 line.dump();
826}
caryclark54359292015-03-26 07:52:43 -0700827
828const SkOpAngle* SkOpAngle::debugAngle(int id) const {
829 return this->segment()->debugAngle(id);
830}
831
caryclark55888e42016-07-18 10:01:36 -0700832const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
833 return this->segment()->debugCoincidence();
834}
835
caryclark30b9fdd2016-08-31 14:36:29 -0700836SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700837 return this->segment()->debugContour(id);
838}
839
840const SkOpPtT* SkOpAngle::debugPtT(int id) const {
841 return this->segment()->debugPtT(id);
842}
843
844const SkOpSegment* SkOpAngle::debugSegment(int id) const {
845 return this->segment()->debugSegment(id);
846}
847
caryclark624637c2015-05-11 07:21:27 -0700848int SkOpAngle::debugSign() const {
849 SkASSERT(fStart->t() != fEnd->t());
850 return fStart->t() < fEnd->t() ? -1 : 1;
851}
852
caryclark54359292015-03-26 07:52:43 -0700853const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
854 return this->segment()->debugSpan(id);
855}
856
857void SkOpAngle::dump() const {
858 dumpOne(true);
859 SkDebugf("\n");
860}
861
862void SkOpAngle::dumpOne(bool functionHeader) const {
863// fSegment->debugValidate();
864 const SkOpSegment* segment = this->segment();
865 const SkOpSpan& mSpan = *fStart->starter(fEnd);
866 if (functionHeader) {
867 SkDebugf("%s ", __FUNCTION__);
868 }
869 SkDebugf("[%d", segment->debugID());
870 SkDebugf("/%d", debugID());
871 SkDebugf("] next=");
872 if (fNext) {
873 SkDebugf("%d", fNext->fStart->segment()->debugID());
874 SkDebugf("/%d", fNext->debugID());
875 } else {
876 SkDebugf("?");
877 }
878 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
879 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
880 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700881 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700882
883 SkDebugf(" windSum=");
884 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
885 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
886 SkDebugf(" oppVal=%d", mSpan.oppValue());
887 SkDebugf(" oppSum=");
888 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
889 }
890 if (mSpan.done()) {
891 SkDebugf(" done");
892 }
893 if (unorderable()) {
894 SkDebugf(" unorderable");
895 }
896 if (segment->operand()) {
897 SkDebugf(" operand");
898 }
caryclark54359292015-03-26 07:52:43 -0700899}
900
901void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
902 const SkOpAngle* first = this;
903 const SkOpAngle* next = this;
904 const char* indent = "";
905 do {
906 SkDebugf("%s", indent);
907 next->dumpOne(false);
908 if (segment == next->fStart->segment()) {
909 if (this == fNext) {
910 SkDebugf(" << from");
911 }
912 if (to == fNext) {
913 SkDebugf(" << to");
914 }
915 }
916 SkDebugf("\n");
917 indent = " ";
918 next = next->fNext;
919 } while (next && next != first);
920}
921
922void SkOpAngle::dumpCurves() const {
923 const SkOpAngle* first = this;
924 const SkOpAngle* next = this;
925 do {
caryclarkeed356d2016-09-14 07:18:20 -0700926 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700927 next = next->fNext;
928 } while (next && next != first);
929}
930
931void SkOpAngle::dumpLoop() const {
932 const SkOpAngle* first = this;
933 const SkOpAngle* next = this;
934 do {
935 next->dumpOne(false);
936 SkDebugf("\n");
937 next = next->fNext;
938 } while (next && next != first);
939}
940
941void SkOpAngle::dumpTest() const {
942 const SkOpAngle* first = this;
943 const SkOpAngle* next = this;
944 do {
945 SkDebugf("{ ");
946 SkOpSegment* segment = next->segment();
947 segment->dumpPts();
948 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
949 next->start()->t(), next->end()->t());
950 next = next->fNext;
951 } while (next && next != first);
952}
953
954bool SkOpPtT::debugMatchID(int id) const {
955 int limit = this->debugLoopLimit(false);
956 int loop = 0;
957 const SkOpPtT* ptT = this;
958 do {
959 if (ptT->debugID() == id) {
960 return true;
961 }
962 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
963 return false;
964}
965
966const SkOpAngle* SkOpPtT::debugAngle(int id) const {
967 return this->span()->debugAngle(id);
968}
969
caryclark30b9fdd2016-08-31 14:36:29 -0700970SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700971 return this->span()->debugContour(id);
972}
973
caryclark55888e42016-07-18 10:01:36 -0700974const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
975 return this->span()->debugCoincidence();
976}
977
caryclark54359292015-03-26 07:52:43 -0700978const SkOpPtT* SkOpPtT::debugPtT(int id) const {
979 return this->span()->debugPtT(id);
980}
981
982const SkOpSegment* SkOpPtT::debugSegment(int id) const {
983 return this->span()->debugSegment(id);
984}
985
986const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
987 return this->span()->debugSpan(id);
988}
989
990void SkOpPtT::dump() const {
991 SkDebugf("seg=%d span=%d ptT=%d",
992 this->segment()->debugID(), this->span()->debugID(), this->debugID());
993 this->dumpBase();
994 SkDebugf("\n");
995}
996
997void SkOpPtT::dumpAll() const {
998 contour()->indentDump();
999 const SkOpPtT* next = this;
1000 int limit = debugLoopLimit(true);
1001 int loop = 0;
1002 do {
1003 SkDebugf("%.*s", contour()->debugIndent(), " ");
1004 SkDebugf("seg=%d span=%d ptT=%d",
1005 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1006 next->dumpBase();
1007 SkDebugf("\n");
1008 if (limit && ++loop >= limit) {
1009 SkDebugf("*** abort loop ***\n");
1010 break;
1011 }
1012 } while ((next = next->fNext) && next != this);
1013 contour()->outdentDump();
1014}
1015
1016void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001017 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1018 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001019 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1020}
1021
1022const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1023 return this->segment()->debugAngle(id);
1024}
1025
caryclark55888e42016-07-18 10:01:36 -07001026const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1027 return this->segment()->debugCoincidence();
1028}
1029
caryclark30b9fdd2016-08-31 14:36:29 -07001030SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001031 return this->segment()->debugContour(id);
1032}
1033
1034const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1035 return this->segment()->debugPtT(id);
1036}
1037
1038const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1039 return this->segment()->debugSegment(id);
1040}
1041
1042const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1043 return this->segment()->debugSpan(id);
1044}
1045
1046void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001047 this->dumpHead();
1048 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001049}
1050
caryclark55888e42016-07-18 10:01:36 -07001051void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001052 SkDebugf("%.*s", contour()->debugIndent(), " ");
1053 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1054 this->dumpBase();
1055 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001056}
1057
1058void SkOpSpanBase::dumpAll() const {
1059 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001060 this->fPtT.dumpAll();
1061}
1062
1063void SkOpSpanBase::dumpBase() const {
1064 if (this->fAligned) {
1065 SkDebugf(" aligned");
1066 }
1067 if (this->fChased) {
1068 SkDebugf(" chased");
1069 }
caryclark55888e42016-07-18 10:01:36 -07001070#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001071 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001072 SkDebugf(" deleted");
1073 }
1074#endif
caryclark54359292015-03-26 07:52:43 -07001075 if (!this->final()) {
1076 this->upCast()->dumpSpan();
1077 }
1078 const SkOpSpanBase* coin = this->coinEnd();
1079 if (this != coin) {
1080 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1081 } else if (this->final() || !this->upCast()->isCoincident()) {
1082 const SkOpPtT* oPt = this->ptT()->next();
1083 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1084 }
caryclark08bc8482015-04-24 09:08:57 -07001085 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001086}
1087
1088void SkOpSpanBase::dumpCoin() const {
1089 const SkOpSpan* span = this->upCastable();
1090 if (!span) {
1091 return;
1092 }
1093 if (!span->isCoincident()) {
1094 return;
1095 }
1096 span->dumpCoin();
1097}
1098
1099void SkOpSpan::dumpCoin() const {
1100 const SkOpSpan* coincident = fCoincident;
1101 bool ok = debugCoinLoopCheck();
1102 this->dump();
1103 int loop = 0;
1104 do {
1105 coincident->dump();
1106 if (!ok && ++loop > 10) {
1107 SkDebugf("*** abort loop ***\n");
1108 break;
1109 }
1110 } while ((coincident = coincident->fCoincident) != this);
1111}
1112
1113bool SkOpSpan::dumpSpan() const {
1114 SkOpSpan* coin = fCoincident;
1115 if (this != coin) {
1116 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1117 }
1118 SkDebugf(" windVal=%d", this->windValue());
1119 SkDebugf(" windSum=");
1120 SkPathOpsDebug::WindingPrintf(this->windSum());
1121 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1122 SkDebugf(" oppVal=%d", this->oppValue());
1123 SkDebugf(" oppSum=");
1124 SkPathOpsDebug::WindingPrintf(this->oppSum());
1125 }
1126 if (this->done()) {
1127 SkDebugf(" done");
1128 }
1129 return this != coin;
1130}
1131
1132const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1133 return this->contour()->debugAngle(id);
1134}
1135
caryclark55888e42016-07-18 10:01:36 -07001136
1137const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1138 return this->contour()->debugCoincidence();
1139}
1140
caryclark30b9fdd2016-08-31 14:36:29 -07001141SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001142 return this->contour()->debugContour(id);
1143}
1144
1145const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1146 return this->contour()->debugPtT(id);
1147}
1148
1149const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1150 return this->contour()->debugSegment(id);
1151}
1152
1153const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1154 return this->contour()->debugSpan(id);
1155}
1156
1157void SkOpSegment::dump() const {
1158 SkDebugf("%.*s", contour()->debugIndent(), " ");
1159 this->dumpPts();
1160 const SkOpSpanBase* span = &fHead;
1161 contour()->indentDump();
1162 do {
1163 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1164 span->ptT()->dumpBase();
1165 span->dumpBase();
1166 SkDebugf("\n");
1167 } while (!span->final() && (span = span->upCast()->next()));
1168 contour()->outdentDump();
1169}
1170
1171void SkOpSegment::dumpAll() const {
1172 SkDebugf("%.*s", contour()->debugIndent(), " ");
1173 this->dumpPts();
1174 const SkOpSpanBase* span = &fHead;
1175 contour()->indentDump();
1176 do {
1177 span->dumpAll();
1178 } while (!span->final() && (span = span->upCast()->next()));
1179 contour()->outdentDump();
1180}
1181
1182void SkOpSegment::dumpAngles() const {
1183 SkDebugf("seg=%d\n", debugID());
1184 const SkOpSpanBase* span = &fHead;
1185 do {
1186 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001187 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001188 if (fAngle) {
1189 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1190 fAngle->dumpTo(this, tAngle);
1191 }
1192 if (tAngle) {
1193 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1194 tAngle->dumpTo(this, fAngle);
1195 }
1196 } while (!span->final() && (span = span->upCast()->next()));
1197}
1198
1199void SkOpSegment::dumpCoin() const {
1200 const SkOpSpan* span = &fHead;
1201 do {
1202 span->dumpCoin();
1203 } while ((span = span->next()->upCastable()));
1204}
1205
caryclark26ad22a2015-10-16 09:03:38 -07001206void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001207 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001208 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001209 if (fVerb == SkPath::kConic_Verb) {
1210 SkDebugf("{");
1211 }
caryclark54359292015-03-26 07:52:43 -07001212 int index = 0;
1213 do {
1214 SkDPoint::Dump(fPts[index]);
1215 SkDebugf(", ");
1216 } while (++index < last);
1217 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001218 SkDebugf("}}");
1219 if (fVerb == SkPath::kConic_Verb) {
1220 SkDebugf(", %1.9gf}", fWeight);
1221 }
caryclark624637c2015-05-11 07:21:27 -07001222}
1223
caryclark26ad22a2015-10-16 09:03:38 -07001224void SkOpSegment::dumpPts(const char* prefix) const {
1225 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001226 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001227}
1228
1229void SkCoincidentSpans::dump() const {
1230 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1231 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1232 fCoinPtTStart->dumpBase();
1233 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1234 fCoinPtTEnd->dumpBase();
1235 if (fCoinPtTStart->segment()->operand()) {
1236 SkDebugf(" operand");
1237 }
1238 if (fCoinPtTStart->segment()->isXor()) {
1239 SkDebugf(" xor");
1240 }
1241 SkDebugf("\n");
1242 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1243 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1244 fOppPtTStart->dumpBase();
1245 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1246 fOppPtTEnd->dumpBase();
1247 if (fOppPtTStart->segment()->operand()) {
1248 SkDebugf(" operand");
1249 }
1250 if (fOppPtTStart->segment()->isXor()) {
1251 SkDebugf(" xor");
1252 }
1253 SkDebugf("\n");
1254}
1255
1256void SkOpCoincidence::dump() const {
1257 SkCoincidentSpans* span = fHead;
1258 while (span) {
1259 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001260 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001261 }
caryclark26ad22a2015-10-16 09:03:38 -07001262 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001263 return;
1264 }
1265 SkDebugf("top:\n");
1266 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001267 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001268 while (span) {
1269 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001270 span = span->next();
1271 SkCoincidentSpans* check = fTop;
1272 ++count;
1273 for (int index = 0; index < count; ++index) {
1274 if (span == check) {
1275 SkDebugf("(loops to #%d)\n", index);
1276 return;
1277 }
1278 check = check->next();
1279 }
caryclark27c8eb82015-07-06 11:38:33 -07001280 }
caryclark54359292015-03-26 07:52:43 -07001281}
1282
caryclark624637c2015-05-11 07:21:27 -07001283void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001284 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001285 if (!fCount) {
1286 return;
1287 }
1288 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001289 SkDEBUGCODE(fDebugIndent = 0);
1290 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001291 do {
1292 segment->dump();
1293 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001294 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001295}
1296
caryclark624637c2015-05-11 07:21:27 -07001297void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001298 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001299 if (!fCount) {
1300 return;
1301 }
1302 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001303 SkDEBUGCODE(fDebugIndent = 0);
1304 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001305 do {
1306 segment->dumpAll();
1307 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001308 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001309}
1310
1311
1312void SkOpContour::dumpAngles() const {
1313 SkDebugf("contour=%d\n", this->debugID());
1314 const SkOpSegment* segment = &fHead;
1315 do {
1316 SkDebugf(" seg=%d ", segment->debugID());
1317 segment->dumpAngles();
1318 } while ((segment = segment->next()));
1319}
1320
1321void SkOpContour::dumpPt(int index) const {
1322 const SkOpSegment* segment = &fHead;
1323 do {
1324 if (segment->debugID() == index) {
1325 segment->dumpPts();
1326 }
1327 } while ((segment = segment->next()));
1328}
1329
caryclark26ad22a2015-10-16 09:03:38 -07001330void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001331 SkDebugf("contour=%d\n", this->debugID());
1332 const SkOpSegment* segment = &fHead;
1333 do {
caryclark26ad22a2015-10-16 09:03:38 -07001334 SkDebugf(" %s=%d ", prefix, segment->debugID());
1335 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001336 } while ((segment = segment->next()));
1337}
1338
caryclark26ad22a2015-10-16 09:03:38 -07001339void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001340 if (!this->fCount) {
1341 SkDebugf("<empty>\n");
1342 return;
1343 }
1344 const SkOpSegment* segment = &fHead;
1345 do {
caryclark26ad22a2015-10-16 09:03:38 -07001346 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001347 } while ((segment = segment->next()));
1348}
1349
1350void SkOpContour::dumpSegment(int index) const {
1351 debugSegment(index)->dump();
1352}
1353
caryclark26ad22a2015-10-16 09:03:38 -07001354void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001355 bool firstOp = false;
1356 const SkOpContour* c = this;
1357 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001358 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001359#if DEBUG_ACTIVE_OP
1360 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1361#endif
1362 firstOp = true;
1363 }
caryclark26ad22a2015-10-16 09:03:38 -07001364 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001365 } while ((c = c->next()));
1366}
1367
1368void SkOpContour::dumpSpan(int index) const {
1369 debugSpan(index)->dump();
1370}
1371
1372void SkOpContour::dumpSpans() const {
1373 SkDebugf("contour=%d\n", this->debugID());
1374 const SkOpSegment* segment = &fHead;
1375 do {
1376 SkDebugf(" seg=%d ", segment->debugID());
1377 segment->dump();
1378 } while ((segment = segment->next()));
1379}
1380
caryclark03b03ca2015-04-23 09:13:37 -07001381void SkOpCurve::dump() const {
1382 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1383 SkDebugf("{{");
1384 int index;
1385 for (index = 0; index <= count - 1; ++index) {
1386 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1387 }
1388 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1389}
1390
caryclark54359292015-03-26 07:52:43 -07001391#ifdef SK_DEBUG
1392const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001393 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001394 do {
1395 const SkOpSegment* segment = contour->first();
1396 while (segment) {
1397 const SkOpSpan* span = segment->head();
1398 do {
1399 SkOpAngle* angle = span->fromAngle();
1400 if (angle && angle->debugID() == id) {
1401 return angle;
1402 }
1403 angle = span->toAngle();
1404 if (angle && angle->debugID() == id) {
1405 return angle;
1406 }
1407 } while ((span = span->next()->upCastable()));
1408 const SkOpSpanBase* tail = segment->tail();
1409 SkOpAngle* angle = tail->fromAngle();
1410 if (angle && angle->debugID() == id) {
1411 return angle;
1412 }
1413 segment = segment->next();
1414 }
1415 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001416 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001417}
1418
caryclark30b9fdd2016-08-31 14:36:29 -07001419SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001420 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001421 do {
1422 if (contour->debugID() == id) {
1423 return contour;
1424 }
1425 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001426 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001427}
1428
1429const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001430 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001431 do {
1432 const SkOpSegment* segment = contour->first();
1433 while (segment) {
1434 const SkOpSpan* span = segment->head();
1435 do {
1436 const SkOpPtT* ptT = span->ptT();
1437 if (ptT->debugMatchID(id)) {
1438 return ptT;
1439 }
1440 } while ((span = span->next()->upCastable()));
1441 const SkOpSpanBase* tail = segment->tail();
1442 const SkOpPtT* ptT = tail->ptT();
1443 if (ptT->debugMatchID(id)) {
1444 return ptT;
1445 }
1446 segment = segment->next();
1447 }
1448 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001449 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001450}
1451
1452const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001453 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001454 do {
1455 const SkOpSegment* segment = contour->first();
1456 while (segment) {
1457 if (segment->debugID() == id) {
1458 return segment;
1459 }
1460 segment = segment->next();
1461 }
1462 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001463 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001464}
1465
1466const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001467 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001468 do {
1469 const SkOpSegment* segment = contour->first();
1470 while (segment) {
1471 const SkOpSpan* span = segment->head();
1472 do {
1473 if (span->debugID() == id) {
1474 return span;
1475 }
1476 } while ((span = span->next()->upCastable()));
1477 const SkOpSpanBase* tail = segment->tail();
1478 if (tail->debugID() == id) {
1479 return tail;
1480 }
1481 segment = segment->next();
1482 }
1483 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001484 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001485}
1486#endif
1487
caryclark54359292015-03-26 07:52:43 -07001488#if DEBUG_T_SECT_DUMP > 1
1489int gDumpTSectNum;
1490#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001491
1492// global path dumps for msvs Visual Studio 17 to use from Immediate Window
1493namespace SkOpDebug {
1494
1495 void Dump(const SkOpContour& contour) {
1496 contour.dump();
1497 }
1498
1499 void DumpAll(const SkOpContour& contour) {
1500 contour.dumpAll();
1501 }
1502
1503 void DumpAngles(const SkOpContour& contour) {
1504 contour.dumpAngles();
1505 }
1506
1507 void DumpContours(const SkOpContour& contour) {
1508 contour.dumpContours();
1509 }
1510
1511 void DumpContoursAll(const SkOpContour& contour) {
1512 contour.dumpContoursAll();
1513 }
1514
1515 void DumpContoursAngles(const SkOpContour& contour) {
1516 contour.dumpContoursAngles();
1517 }
1518
1519 void DumpContoursPts(const SkOpContour& contour) {
1520 contour.dumpContoursPts();
1521 }
1522
1523 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1524 contour.dumpContoursPt(segmentID);
1525 }
1526
1527 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1528 contour.dumpContoursSegment(segmentID);
1529 }
1530
1531 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1532 contour.dumpContoursSpan(segmentID);
1533 }
1534
1535 void DumpContoursSpans(const SkOpContour& contour) {
1536 contour.dumpContoursSpans();
1537 }
1538
1539 void DumpPt(const SkOpContour& contour, int pt) {
1540 contour.dumpPt(pt);
1541 }
1542
1543 void DumpPts(const SkOpContour& contour, const char* prefix) {
1544 contour.dumpPts(prefix);
1545 }
1546
1547 void DumpSegment(const SkOpContour& contour, int seg) {
1548 contour.dumpSegment(seg);
1549 }
1550
1551 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1552 contour.dumpSegments(prefix, op);
1553 }
1554
1555 void DumpSpan(const SkOpContour& contour, int span) {
1556 contour.dumpSpan(span);
1557 }
1558
1559 void DumpSpans(const SkOpContour& contour ) {
1560 contour.dumpSpans();
1561 }
1562
1563 void Dump(const SkOpSegment& segment) {
1564 segment.dump();
1565 }
1566
1567 void DumpAll(const SkOpSegment& segment) {
1568 segment.dumpAll();
1569 }
1570
1571 void DumpAngles(const SkOpSegment& segment) {
1572 segment.dumpAngles();
1573 }
1574
1575 void DumpCoin(const SkOpSegment& segment) {
1576 segment.dumpCoin();
1577 }
1578
1579 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1580 segment.dumpPts(prefix);
1581 }
1582
1583 void Dump(const SkOpPtT& ptT) {
1584 ptT.dump();
1585 }
1586
1587 void DumpAll(const SkOpPtT& ptT) {
1588 ptT.dumpAll();
1589 }
1590
1591 void Dump(const SkOpSpanBase& spanBase) {
1592 spanBase.dump();
1593 }
1594
1595 void DumpCoin(const SkOpSpanBase& spanBase) {
1596 spanBase.dumpCoin();
1597 }
1598
1599 void DumpAll(const SkOpSpanBase& spanBase) {
1600 spanBase.dumpAll();
1601 }
1602
1603 void DumpCoin(const SkOpSpan& span) {
1604 span.dumpCoin();
1605 }
1606
1607 bool DumpSpan(const SkOpSpan& span) {
1608 return span.dumpSpan();
1609 }
1610
1611 void Dump(const SkDConic& conic) {
1612 conic.dump();
1613 }
1614
1615 void DumpID(const SkDConic& conic, int id) {
1616 conic.dumpID(id);
1617 }
1618
1619 void Dump(const SkDCubic& cubic) {
1620 cubic.dump();
1621 }
1622
1623 void DumpID(const SkDCubic& cubic, int id) {
1624 cubic.dumpID(id);
1625 }
1626
1627 void Dump(const SkDLine& line) {
1628 line.dump();
1629 }
1630
1631 void DumpID(const SkDLine& line, int id) {
1632 line.dumpID(id);
1633 }
1634
1635 void Dump(const SkDQuad& quad) {
1636 quad.dump();
1637 }
1638
1639 void DumpID(const SkDQuad& quad, int id) {
1640 quad.dumpID(id);
1641 }
1642
1643 void Dump(const SkDPoint& point) {
1644 point.dump();
1645 }
1646
Cary Clark1857ddb2018-07-11 11:01:43 -04001647 void Dump(const SkOpAngle& angle) {
1648 angle.dump();
1649 }
1650
Cary Clarkb8421ed2018-03-14 15:55:02 -04001651// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1652#define DummyDefinitions(a, b) \
1653 \
1654 void Dump(const SkDebugTCoincident##a##b& curve) { \
1655 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1656 } \
1657 \
1658 void Dump(const SkDebugTSect##a##b& curve) { \
1659 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1660 } \
1661 \
1662 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1663 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1664 } \
1665 \
1666 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1667 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1668 } \
1669 \
1670 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1671 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1672 } \
1673 \
1674 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1675 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1676 } \
1677 \
1678 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1679 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1680 } \
1681 \
1682 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1683 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1684 } \
1685 \
1686 void Dump(const SkDebugTSpan##a##b& curve) { \
1687 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1688 } \
1689 \
1690 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1691 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1692 } \
1693 \
1694 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1695 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1696 } \
1697 \
1698 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1699 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1700 } \
1701 \
1702 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1703 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1704 }
1705
1706 DummyDefinitions(Quad, Quad);
1707 DummyDefinitions(Conic, Quad);
1708 DummyDefinitions(Conic, Conic);
1709 DummyDefinitions(Cubic, Quad);
1710 DummyDefinitions(Cubic, Conic);
1711 DummyDefinitions(Cubic, Cubic);
1712
1713#undef DummyDefinitions
1714}