blob: 059ecaa0d45282ebbc196595d03ed2d72045342e [file] [log] [blame]
caryclark54359292015-03-26 07:52:43 -07001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
Cary Clarkf3949122018-08-07 16:38:21 -04008#include "PathOpsDebug.h"
caryclark54359292015-03-26 07:52:43 -07009#include "PathOpsTSectDebug.h"
10#include "SkOpCoincidence.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000011#include "SkOpContour.h"
12#include "SkIntersectionHelper.h"
caryclark1049f122015-04-20 08:31:59 -070013#include "SkMutex.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000014#include "SkOpSegment.h"
caryclark19eb3b22014-07-18 05:08:14 -070015#include "SkString.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000016
Cary Clarkf3949122018-08-07 16:38:21 -040017bool PathOpsDebug::gJson;
18bool PathOpsDebug::gOutFirst;
Cary Clark4533f3d2018-08-08 09:48:09 -040019bool PathOpsDebug::gCheckForDuplicateNames;
Cary Clark9c9611f2018-08-08 13:17:25 -040020bool PathOpsDebug::gOutputSVG;
Cary Clarkf3949122018-08-07 16:38:21 -040021FILE* PathOpsDebug::gOut;
22
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000023inline void DebugDumpDouble(double x) {
24 if (x == floor(x)) {
25 SkDebugf("%.0f", x);
26 } else {
27 SkDebugf("%1.19g", x);
28 }
29}
30
31inline void DebugDumpFloat(float x) {
32 if (x == floorf(x)) {
33 SkDebugf("%.0f", x);
34 } else {
35 SkDebugf("%1.9gf", x);
36 }
37}
38
caryclark65f55312014-11-13 06:58:52 -080039inline void DebugDumpHexFloat(float x) {
40 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
41}
caryclark19eb3b22014-07-18 05:08:14 -070042
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000043// if not defined by PathOpsDebug.cpp ...
44#if !defined SK_DEBUG && FORCE_RELEASE
45bool SkPathOpsDebug::ValidWind(int wind) {
46 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
47}
48
49void SkPathOpsDebug::WindingPrintf(int wind) {
50 if (wind == SK_MinS32) {
51 SkDebugf("?");
52 } else {
53 SkDebugf("%d", wind);
54 }
55}
56#endif
57
caryclark55888e42016-07-18 10:01:36 -070058static void DumpID(int id) {
59 SkDebugf("} ");
60 if (id >= 0) {
61 SkDebugf("id=%d", id);
62 }
63 SkDebugf("\n");
64}
65
caryclark1049f122015-04-20 08:31:59 -070066void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070067 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070068 SkDebugf("},\n");
69}
70
71void SkDConic::dumpID(int id) const {
72 dumpInner();
caryclark55888e42016-07-18 10:01:36 -070073 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -070074}
75
76void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070077 SkDebugf("{");
78 fPts.dumpInner();
79 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070080}
81
82void SkDCubic::dump() const {
83 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070084 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070085}
86
caryclark54359292015-03-26 07:52:43 -070087void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070088 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -070089 SkDebugf("}");
90 DumpID(id);
reed0dc4dd62015-03-24 13:55:33 -070091}
92
caryclark54359292015-03-26 07:52:43 -070093static inline bool double_is_NaN(double x) { return x != x; }
94
95void SkDCubic::dumpInner() const {
96 SkDebugf("{{");
97 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070098 do {
caryclark54359292015-03-26 07:52:43 -070099 if (index != 0) {
100 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
101 return;
reed0dc4dd62015-03-24 13:55:33 -0700102 }
caryclark54359292015-03-26 07:52:43 -0700103 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700104 }
caryclark54359292015-03-26 07:52:43 -0700105 fPts[index].dump();
106 } while (++index < 3);
107 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -0700108 return;
109 }
caryclark54359292015-03-26 07:52:43 -0700110 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700111 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000112}
113
caryclark55888e42016-07-18 10:01:36 -0700114void SkDCurve::dump() const {
115 dumpID(-1);
116}
117
caryclark1049f122015-04-20 08:31:59 -0700118void SkDCurve::dumpID(int id) const {
119#ifndef SK_RELEASE
120 switch(fVerb) {
121 case SkPath::kLine_Verb:
122 fLine.dumpID(id);
123 break;
124 case SkPath::kQuad_Verb:
125 fQuad.dumpID(id);
126 break;
127 case SkPath::kConic_Verb:
128 fConic.dumpID(id);
129 break;
130 case SkPath::kCubic_Verb:
131 fCubic.dumpID(id);
132 break;
133 default:
134 SkASSERT(0);
135 }
136#else
137 fCubic.dumpID(id);
138#endif
139}
140
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000141void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700142 this->dumpInner();
143 SkDebugf("}},\n");
144}
145
146void SkDLine::dumpID(int id) const {
147 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700148 SkDebugf("}");
149 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -0700150}
151
152void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000153 SkDebugf("{{");
154 fPts[0].dump();
155 SkDebugf(", ");
156 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000157}
158
159void SkDPoint::dump() const {
160 SkDebugf("{");
161 DebugDumpDouble(fX);
162 SkDebugf(", ");
163 DebugDumpDouble(fY);
164 SkDebugf("}");
165}
166
167void SkDPoint::Dump(const SkPoint& pt) {
168 SkDebugf("{");
169 DebugDumpFloat(pt.fX);
170 SkDebugf(", ");
171 DebugDumpFloat(pt.fY);
172 SkDebugf("}");
173}
174
caryclark65f55312014-11-13 06:58:52 -0800175void SkDPoint::DumpHex(const SkPoint& pt) {
176 SkDebugf("{");
177 DebugDumpHexFloat(pt.fX);
178 SkDebugf(", ");
179 DebugDumpHexFloat(pt.fY);
180 SkDebugf("}");
181}
182
183void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700184 dumpInner();
185 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800186}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000187
caryclark54359292015-03-26 07:52:43 -0700188void SkDQuad::dumpID(int id) const {
189 dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700190 SkDebugf("}");
191 DumpID(id);
caryclark54359292015-03-26 07:52:43 -0700192}
193
194void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000195 SkDebugf("{{");
196 int index = 0;
197 do {
198 fPts[index].dump();
199 SkDebugf(", ");
200 } while (++index < 2);
201 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000202}
203
caryclark54359292015-03-26 07:52:43 -0700204void SkIntersections::dump() const {
205 SkDebugf("used=%d of %d", fUsed, fMax);
206 for (int index = 0; index < fUsed; ++index) {
207 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
208 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
209 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
210 fPt[index].fX, fPt[index].fY);
211 if (index < 2 && fNearlySame[index]) {
212 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000213 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000214 }
215 SkDebugf("\n");
216}
217
Cary Clarkb8421ed2018-03-14 15:55:02 -0400218namespace SkOpDebug {
219
220const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700221 return angle->debugAngle(id);
222}
223
Cary Clarkb8421ed2018-03-14 15:55:02 -0400224::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700225 return angle->debugContour(id);
226}
227
Cary Clarkb8421ed2018-03-14 15:55:02 -0400228const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700229 return angle->debugPtT(id);
230}
231
Cary Clarkb8421ed2018-03-14 15:55:02 -0400232const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700233 return angle->debugSegment(id);
234}
235
Cary Clarkb8421ed2018-03-14 15:55:02 -0400236const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700237 return angle->debugSpan(id);
238}
239
Cary Clarkb8421ed2018-03-14 15:55:02 -0400240const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700241 return contour->debugAngle(id);
242}
243
Cary Clarkb8421ed2018-03-14 15:55:02 -0400244::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700245 return contour->debugContour(id);
246}
247
Cary Clarkb8421ed2018-03-14 15:55:02 -0400248const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700249 return contour->debugPtT(id);
250}
251
Cary Clarkb8421ed2018-03-14 15:55:02 -0400252const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700253 return contour->debugSegment(id);
254}
255
Cary Clarkb8421ed2018-03-14 15:55:02 -0400256const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700257 return contour->debugSpan(id);
258}
259
Cary Clarkb8421ed2018-03-14 15:55:02 -0400260const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700261 return coin->debugAngle(id);
262}
263
Cary Clarkb8421ed2018-03-14 15:55:02 -0400264::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700265 return coin->debugContour(id);
266}
267
Cary Clarkb8421ed2018-03-14 15:55:02 -0400268const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700269 return coin->debugPtT(id);
270}
271
Cary Clarkb8421ed2018-03-14 15:55:02 -0400272const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700273 return coin->debugSegment(id);
274}
275
Cary Clarkb8421ed2018-03-14 15:55:02 -0400276const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700277 return coin->debugSpan(id);
278}
279
Cary Clarkb8421ed2018-03-14 15:55:02 -0400280const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700281 return ptT->debugAngle(id);
282}
283
Cary Clarkb8421ed2018-03-14 15:55:02 -0400284::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700285 return ptT->debugContour(id);
286}
287
Cary Clarkb8421ed2018-03-14 15:55:02 -0400288const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700289 return ptT->debugPtT(id);
290}
291
Cary Clarkb8421ed2018-03-14 15:55:02 -0400292const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700293 return ptT->debugSegment(id);
294}
295
Cary Clarkb8421ed2018-03-14 15:55:02 -0400296const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700297 return ptT->debugSpan(id);
298}
299
Cary Clarkb8421ed2018-03-14 15:55:02 -0400300const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700301 return span->debugAngle(id);
302}
303
Cary Clarkb8421ed2018-03-14 15:55:02 -0400304::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700305 return span->debugContour(id);
306}
307
Cary Clarkb8421ed2018-03-14 15:55:02 -0400308const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700309 return span->debugPtT(id);
310}
311
Cary Clarkb8421ed2018-03-14 15:55:02 -0400312const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700313 return span->debugSegment(id);
314}
315
Cary Clarkb8421ed2018-03-14 15:55:02 -0400316const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700317 return span->debugSpan(id);
318}
319
Cary Clarkb8421ed2018-03-14 15:55:02 -0400320const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700321 return span->debugAngle(id);
322}
323
Cary Clarkb8421ed2018-03-14 15:55:02 -0400324::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700325 return span->debugContour(id);
326}
327
Cary Clarkb8421ed2018-03-14 15:55:02 -0400328const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700329 return span->debugPtT(id);
330}
331
Cary Clarkb8421ed2018-03-14 15:55:02 -0400332const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700333 return span->debugSegment(id);
334}
335
Cary Clarkb8421ed2018-03-14 15:55:02 -0400336const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700337 return span->debugSpan(id);
338}
339
Cary Clarkb8421ed2018-03-14 15:55:02 -0400340} // namespace SkPathOpsDebug
341
Cary Clarkab87d7a2016-10-04 10:01:04 -0400342#if DEBUG_COIN
343void SkPathOpsDebug::DumpCoinDict() {
Cary Clarkb8421ed2018-03-14 15:55:02 -0400344 SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false);
345 SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true);
Cary Clarkab87d7a2016-10-04 10:01:04 -0400346}
347
348void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const {
349 int count = fDict.count();
350 for (int index = 0; index < count; ++index) {
351 const auto& entry = fDict[index];
352 if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) {
353 SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName,
354 entry.fLineNumber, entry.fIteration);
355 DumpGlitchType(entry.fGlitchType);
356 SkDebugf("\n");
357 }
358 }
359}
360#endif
361
caryclark624637c2015-05-11 07:21:27 -0700362void SkOpContour::dumpContours() const {
363 SkOpContour* contour = this->globalState()->contourHead();
364 do {
365 contour->dump();
366 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000367}
368
caryclark624637c2015-05-11 07:21:27 -0700369void SkOpContour::dumpContoursAll() const {
370 SkOpContour* contour = this->globalState()->contourHead();
371 do {
372 contour->dumpAll();
373 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000374}
375
caryclark624637c2015-05-11 07:21:27 -0700376void SkOpContour::dumpContoursAngles() const {
377 SkOpContour* contour = this->globalState()->contourHead();
378 do {
379 contour->dumpAngles();
380 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000381}
382
caryclark624637c2015-05-11 07:21:27 -0700383void SkOpContour::dumpContoursPts() const {
384 SkOpContour* contour = this->globalState()->contourHead();
385 do {
386 contour->dumpPts();
387 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000388}
389
caryclark624637c2015-05-11 07:21:27 -0700390void SkOpContour::dumpContoursPt(int segmentID) const {
391 SkOpContour* contour = this->globalState()->contourHead();
392 do {
393 contour->dumpPt(segmentID);
394 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000395}
396
caryclark624637c2015-05-11 07:21:27 -0700397void SkOpContour::dumpContoursSegment(int segmentID) const {
398 SkOpContour* contour = this->globalState()->contourHead();
399 do {
400 contour->dumpSegment(segmentID);
401 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000402}
403
caryclark624637c2015-05-11 07:21:27 -0700404void SkOpContour::dumpContoursSpan(int spanID) const {
405 SkOpContour* contour = this->globalState()->contourHead();
406 do {
407 contour->dumpSpan(spanID);
408 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000409}
410
caryclark624637c2015-05-11 07:21:27 -0700411void SkOpContour::dumpContoursSpans() const {
412 SkOpContour* contour = this->globalState()->contourHead();
413 do {
414 contour->dumpSpans();
415 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000416}
417
caryclark1049f122015-04-20 08:31:59 -0700418template <typename TCurve, typename OppCurve>
419const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700420 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000421}
422
caryclark1049f122015-04-20 08:31:59 -0700423void DontCallDebugSpan(int id);
424void DontCallDebugSpan(int id) { // exists to instantiate the templates
425 SkDQuad quad;
426 SkDConic conic;
427 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700428 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
429 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
430 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
431 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
432 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
433 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
434 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
435 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
436 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700437 DebugSpan(&q1q2, id);
438 DebugSpan(&q1k2, id);
439 DebugSpan(&q1c2, id);
440 DebugSpan(&k1q2, id);
441 DebugSpan(&k1k2, id);
442 DebugSpan(&k1c2, id);
443 DebugSpan(&c1q2, id);
444 DebugSpan(&c1k2, id);
445 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000446}
447
caryclark1049f122015-04-20 08:31:59 -0700448template <typename TCurve, typename OppCurve>
449const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700450 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000451}
452
caryclark1049f122015-04-20 08:31:59 -0700453void DontCallDebugT(double t);
454void DontCallDebugT(double t) { // exists to instantiate the templates
455 SkDQuad quad;
456 SkDConic conic;
457 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700458 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
460 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
461 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
462 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
463 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
464 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
465 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
466 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700467 DebugT(&q1q2, t);
468 DebugT(&q1k2, t);
469 DebugT(&q1c2, t);
470 DebugT(&k1q2, t);
471 DebugT(&k1k2, t);
472 DebugT(&k1c2, t);
473 DebugT(&c1q2, t);
474 DebugT(&c1k2, t);
475 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700476}
477
caryclark1049f122015-04-20 08:31:59 -0700478template <typename TCurve, typename OppCurve>
479void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700480 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000481}
482
caryclark1049f122015-04-20 08:31:59 -0700483void DontCallDumpTSect();
484void DontCallDumpTSect() { // exists to instantiate the templates
485 SkDQuad quad;
486 SkDConic conic;
487 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700488 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
489 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
490 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
491 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
492 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
493 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
494 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
495 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
496 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700497 Dump(&q1q2);
498 Dump(&q1k2);
499 Dump(&q1c2);
500 Dump(&k1q2);
501 Dump(&k1k2);
502 Dump(&k1c2);
503 Dump(&c1q2);
504 Dump(&c1k2);
505 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000506}
507
caryclark1049f122015-04-20 08:31:59 -0700508template <typename TCurve, typename OppCurve>
509void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700510 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700511}
512
caryclark1049f122015-04-20 08:31:59 -0700513void DontCallDumpBoth();
514void DontCallDumpBoth() { // exists to instantiate the templates
515 SkDQuad quad;
516 SkDConic conic;
517 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700518 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
519 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
520 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
521 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
522 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
523 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
524 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
525 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
526 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700527 DumpBoth(&q1q2, &q1q2);
528 DumpBoth(&q1k2, &k1q2);
529 DumpBoth(&q1c2, &c1q2);
530 DumpBoth(&k1q2, &q1k2);
531 DumpBoth(&k1k2, &k1k2);
532 DumpBoth(&k1c2, &c1k2);
533 DumpBoth(&c1q2, &q1c2);
534 DumpBoth(&c1k2, &k1c2);
535 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700536}
537
caryclark1049f122015-04-20 08:31:59 -0700538template <typename TCurve, typename OppCurve>
539void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
540 sect1->dumpBounded(id);
541}
542
543void DontCallDumpBounded();
544void DontCallDumpBounded() {
545 SkDQuad quad;
546 SkDConic conic;
547 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700548 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
549 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
550 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
551 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
552 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
553 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
554 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
555 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
556 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700557 DumpBounded(&q1q2, 0);
558 DumpBounded(&q1k2, 0);
559 DumpBounded(&q1c2, 0);
560 DumpBounded(&k1q2, 0);
561 DumpBounded(&k1k2, 0);
562 DumpBounded(&k1c2, 0);
563 DumpBounded(&c1q2, 0);
564 DumpBounded(&c1k2, 0);
565 DumpBounded(&c1c2, 0);
566}
567
568template <typename TCurve, typename OppCurve>
569void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
570 sect1->dumpBounds();
571}
572
573void DontCallDumpBounds();
574void DontCallDumpBounds() {
575 SkDQuad quad;
576 SkDConic conic;
577 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700578 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
579 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
580 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
581 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
582 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
583 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
584 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
585 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
586 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700587 DumpBounds(&q1q2);
588 DumpBounds(&q1k2);
589 DumpBounds(&q1c2);
590 DumpBounds(&k1q2);
591 DumpBounds(&k1k2);
592 DumpBounds(&k1c2);
593 DumpBounds(&c1q2);
594 DumpBounds(&c1k2);
595 DumpBounds(&c1c2);
596}
597
598template <typename TCurve, typename OppCurve>
599void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700600 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700601}
602
caryclark1049f122015-04-20 08:31:59 -0700603void DontCallDumpCoin();
604void DontCallDumpCoin() { // exists to instantiate the templates
605 SkDQuad quad;
606 SkDConic conic;
607 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700608 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
609 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
610 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
611 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
612 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
613 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
614 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
615 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
616 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700617 DumpCoin(&q1q2);
618 DumpCoin(&q1k2);
619 DumpCoin(&q1c2);
620 DumpCoin(&k1q2);
621 DumpCoin(&k1k2);
622 DumpCoin(&k1c2);
623 DumpCoin(&c1q2);
624 DumpCoin(&c1k2);
625 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000626}
627
caryclark1049f122015-04-20 08:31:59 -0700628template <typename TCurve, typename OppCurve>
629void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700630 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000631}
632
caryclark1049f122015-04-20 08:31:59 -0700633void DontCallDumpCoinCurves();
634void DontCallDumpCoinCurves() { // exists to instantiate the templates
635 SkDQuad quad;
636 SkDConic conic;
637 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700638 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
639 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
640 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
641 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
642 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
643 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
644 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
645 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
646 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700647 DumpCoinCurves(&q1q2);
648 DumpCoinCurves(&q1k2);
649 DumpCoinCurves(&q1c2);
650 DumpCoinCurves(&k1q2);
651 DumpCoinCurves(&k1k2);
652 DumpCoinCurves(&k1c2);
653 DumpCoinCurves(&c1q2);
654 DumpCoinCurves(&c1k2);
655 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000656}
657
caryclark1049f122015-04-20 08:31:59 -0700658template <typename TCurve, typename OppCurve>
659void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700660 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000661}
662
caryclark1049f122015-04-20 08:31:59 -0700663void DontCallDumpCurves();
664void DontCallDumpCurves() { // exists to instantiate the templates
665 SkDQuad quad;
666 SkDConic conic;
667 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700668 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
669 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
670 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
671 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
672 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
673 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
674 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
675 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
676 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700677 DumpCurves(&q1q2);
678 DumpCurves(&q1k2);
679 DumpCurves(&q1c2);
680 DumpCurves(&k1q2);
681 DumpCurves(&k1k2);
682 DumpCurves(&k1c2);
683 DumpCurves(&c1q2);
684 DumpCurves(&c1k2);
685 DumpCurves(&c1c2);
686}
687
688template <typename TCurve, typename OppCurve>
689void Dump(const SkTSpan<TCurve, OppCurve>* span) {
690 span->dump();
691}
692
693void DontCallDumpTSpan();
694void DontCallDumpTSpan() { // exists to instantiate the templates
695 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
696 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
697 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
698 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
699 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
700 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
701 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
702 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
703 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
704 Dump(&q1q2);
705 Dump(&q1k2);
706 Dump(&q1c2);
707 Dump(&k1q2);
708 Dump(&k1k2);
709 Dump(&k1c2);
710 Dump(&c1q2);
711 Dump(&c1k2);
712 Dump(&c1c2);
713}
714
715template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700716void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
717 span->dumpAll();
718}
719
720void DontCallDumpSpanAll();
721void DontCallDumpSpanAll() { // exists to instantiate the templates
722 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
723 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
724 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
725 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
726 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
727 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
728 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
729 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
730 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
731 DumpAll(&q1q2);
732 DumpAll(&q1k2);
733 DumpAll(&q1c2);
734 DumpAll(&k1q2);
735 DumpAll(&k1k2);
736 DumpAll(&k1c2);
737 DumpAll(&c1q2);
738 DumpAll(&c1k2);
739 DumpAll(&c1c2);
740}
741
742template <typename TCurve, typename OppCurve>
743void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
744 span->dumpBounded(0);
745}
746
747void DontCallDumpSpanBounded();
748void DontCallDumpSpanBounded() { // exists to instantiate the templates
749 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
750 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
751 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
752 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
753 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
754 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
755 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
756 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
757 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
758 DumpBounded(&q1q2);
759 DumpBounded(&q1k2);
760 DumpBounded(&q1c2);
761 DumpBounded(&k1q2);
762 DumpBounded(&k1k2);
763 DumpBounded(&k1c2);
764 DumpBounded(&c1q2);
765 DumpBounded(&c1k2);
766 DumpBounded(&c1c2);
767}
768
769template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700770void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
771 span->dumpCoin();
772}
773
774void DontCallDumpSpanCoin();
775void DontCallDumpSpanCoin() { // exists to instantiate the templates
776 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
777 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
778 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
779 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
780 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
781 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
782 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
783 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
784 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
785 DumpCoin(&q1q2);
786 DumpCoin(&q1k2);
787 DumpCoin(&q1c2);
788 DumpCoin(&k1q2);
789 DumpCoin(&k1k2);
790 DumpCoin(&k1c2);
791 DumpCoin(&c1q2);
792 DumpCoin(&c1k2);
793 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700794}
795
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000796static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700797 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
798 quad1.dumpInner();
799 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000800 quad2.dump();
801 SkDebugf("</div>\n\n");
802}
803
804static void dumpTestTrailer() {
805 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
806 SkDebugf(" var testDivs = [\n");
807}
808
809static void dumpTestList(int testNo, double min) {
810 SkDebugf(" quad%d,", testNo);
811 if (min > 0) {
812 SkDebugf(" // %1.9g", min);
813 }
814 SkDebugf("\n");
815}
816
817void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
818 SkDebugf("\n");
819 dumpTestCase(quad1, quad2, testNo);
820 dumpTestTrailer();
821 dumpTestList(testNo, 0);
822 SkDebugf("\n");
823}
824
825void DumpT(const SkDQuad& quad, double t) {
826 SkDLine line = {{quad.ptAtT(t), quad[0]}};
827 line.dump();
828}
caryclark54359292015-03-26 07:52:43 -0700829
830const SkOpAngle* SkOpAngle::debugAngle(int id) const {
831 return this->segment()->debugAngle(id);
832}
833
caryclark55888e42016-07-18 10:01:36 -0700834const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
835 return this->segment()->debugCoincidence();
836}
837
caryclark30b9fdd2016-08-31 14:36:29 -0700838SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700839 return this->segment()->debugContour(id);
840}
841
842const SkOpPtT* SkOpAngle::debugPtT(int id) const {
843 return this->segment()->debugPtT(id);
844}
845
846const SkOpSegment* SkOpAngle::debugSegment(int id) const {
847 return this->segment()->debugSegment(id);
848}
849
caryclark624637c2015-05-11 07:21:27 -0700850int SkOpAngle::debugSign() const {
851 SkASSERT(fStart->t() != fEnd->t());
852 return fStart->t() < fEnd->t() ? -1 : 1;
853}
854
caryclark54359292015-03-26 07:52:43 -0700855const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
856 return this->segment()->debugSpan(id);
857}
858
859void SkOpAngle::dump() const {
860 dumpOne(true);
861 SkDebugf("\n");
862}
863
864void SkOpAngle::dumpOne(bool functionHeader) const {
865// fSegment->debugValidate();
866 const SkOpSegment* segment = this->segment();
867 const SkOpSpan& mSpan = *fStart->starter(fEnd);
868 if (functionHeader) {
869 SkDebugf("%s ", __FUNCTION__);
870 }
871 SkDebugf("[%d", segment->debugID());
872 SkDebugf("/%d", debugID());
873 SkDebugf("] next=");
874 if (fNext) {
875 SkDebugf("%d", fNext->fStart->segment()->debugID());
876 SkDebugf("/%d", fNext->debugID());
877 } else {
878 SkDebugf("?");
879 }
880 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
881 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
882 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700883 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700884
885 SkDebugf(" windSum=");
886 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
887 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
888 SkDebugf(" oppVal=%d", mSpan.oppValue());
889 SkDebugf(" oppSum=");
890 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
891 }
892 if (mSpan.done()) {
893 SkDebugf(" done");
894 }
895 if (unorderable()) {
896 SkDebugf(" unorderable");
897 }
898 if (segment->operand()) {
899 SkDebugf(" operand");
900 }
caryclark54359292015-03-26 07:52:43 -0700901}
902
903void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
904 const SkOpAngle* first = this;
905 const SkOpAngle* next = this;
906 const char* indent = "";
907 do {
908 SkDebugf("%s", indent);
909 next->dumpOne(false);
910 if (segment == next->fStart->segment()) {
911 if (this == fNext) {
912 SkDebugf(" << from");
913 }
914 if (to == fNext) {
915 SkDebugf(" << to");
916 }
917 }
918 SkDebugf("\n");
919 indent = " ";
920 next = next->fNext;
921 } while (next && next != first);
922}
923
924void SkOpAngle::dumpCurves() const {
925 const SkOpAngle* first = this;
926 const SkOpAngle* next = this;
927 do {
caryclarkeed356d2016-09-14 07:18:20 -0700928 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700929 next = next->fNext;
930 } while (next && next != first);
931}
932
933void SkOpAngle::dumpLoop() const {
934 const SkOpAngle* first = this;
935 const SkOpAngle* next = this;
936 do {
937 next->dumpOne(false);
938 SkDebugf("\n");
939 next = next->fNext;
940 } while (next && next != first);
941}
942
943void SkOpAngle::dumpTest() const {
944 const SkOpAngle* first = this;
945 const SkOpAngle* next = this;
946 do {
947 SkDebugf("{ ");
948 SkOpSegment* segment = next->segment();
949 segment->dumpPts();
950 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
951 next->start()->t(), next->end()->t());
952 next = next->fNext;
953 } while (next && next != first);
954}
955
956bool SkOpPtT::debugMatchID(int id) const {
957 int limit = this->debugLoopLimit(false);
958 int loop = 0;
959 const SkOpPtT* ptT = this;
960 do {
961 if (ptT->debugID() == id) {
962 return true;
963 }
964 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
965 return false;
966}
967
968const SkOpAngle* SkOpPtT::debugAngle(int id) const {
969 return this->span()->debugAngle(id);
970}
971
caryclark30b9fdd2016-08-31 14:36:29 -0700972SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700973 return this->span()->debugContour(id);
974}
975
caryclark55888e42016-07-18 10:01:36 -0700976const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
977 return this->span()->debugCoincidence();
978}
979
caryclark54359292015-03-26 07:52:43 -0700980const SkOpPtT* SkOpPtT::debugPtT(int id) const {
981 return this->span()->debugPtT(id);
982}
983
984const SkOpSegment* SkOpPtT::debugSegment(int id) const {
985 return this->span()->debugSegment(id);
986}
987
988const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
989 return this->span()->debugSpan(id);
990}
991
992void SkOpPtT::dump() const {
993 SkDebugf("seg=%d span=%d ptT=%d",
994 this->segment()->debugID(), this->span()->debugID(), this->debugID());
995 this->dumpBase();
996 SkDebugf("\n");
997}
998
999void SkOpPtT::dumpAll() const {
1000 contour()->indentDump();
1001 const SkOpPtT* next = this;
1002 int limit = debugLoopLimit(true);
1003 int loop = 0;
1004 do {
1005 SkDebugf("%.*s", contour()->debugIndent(), " ");
1006 SkDebugf("seg=%d span=%d ptT=%d",
1007 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1008 next->dumpBase();
1009 SkDebugf("\n");
1010 if (limit && ++loop >= limit) {
1011 SkDebugf("*** abort loop ***\n");
1012 break;
1013 }
1014 } while ((next = next->fNext) && next != this);
1015 contour()->outdentDump();
1016}
1017
1018void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001019 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1020 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001021 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1022}
1023
1024const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1025 return this->segment()->debugAngle(id);
1026}
1027
caryclark55888e42016-07-18 10:01:36 -07001028const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1029 return this->segment()->debugCoincidence();
1030}
1031
caryclark30b9fdd2016-08-31 14:36:29 -07001032SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001033 return this->segment()->debugContour(id);
1034}
1035
1036const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1037 return this->segment()->debugPtT(id);
1038}
1039
1040const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1041 return this->segment()->debugSegment(id);
1042}
1043
1044const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1045 return this->segment()->debugSpan(id);
1046}
1047
1048void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001049 this->dumpHead();
1050 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001051}
1052
caryclark55888e42016-07-18 10:01:36 -07001053void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001054 SkDebugf("%.*s", contour()->debugIndent(), " ");
1055 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1056 this->dumpBase();
1057 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001058}
1059
1060void SkOpSpanBase::dumpAll() const {
1061 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001062 this->fPtT.dumpAll();
1063}
1064
1065void SkOpSpanBase::dumpBase() const {
1066 if (this->fAligned) {
1067 SkDebugf(" aligned");
1068 }
1069 if (this->fChased) {
1070 SkDebugf(" chased");
1071 }
caryclark55888e42016-07-18 10:01:36 -07001072#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001073 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001074 SkDebugf(" deleted");
1075 }
1076#endif
caryclark54359292015-03-26 07:52:43 -07001077 if (!this->final()) {
1078 this->upCast()->dumpSpan();
1079 }
1080 const SkOpSpanBase* coin = this->coinEnd();
1081 if (this != coin) {
1082 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1083 } else if (this->final() || !this->upCast()->isCoincident()) {
1084 const SkOpPtT* oPt = this->ptT()->next();
1085 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1086 }
caryclark08bc8482015-04-24 09:08:57 -07001087 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001088}
1089
1090void SkOpSpanBase::dumpCoin() const {
1091 const SkOpSpan* span = this->upCastable();
1092 if (!span) {
1093 return;
1094 }
1095 if (!span->isCoincident()) {
1096 return;
1097 }
1098 span->dumpCoin();
1099}
1100
1101void SkOpSpan::dumpCoin() const {
1102 const SkOpSpan* coincident = fCoincident;
1103 bool ok = debugCoinLoopCheck();
1104 this->dump();
1105 int loop = 0;
1106 do {
1107 coincident->dump();
1108 if (!ok && ++loop > 10) {
1109 SkDebugf("*** abort loop ***\n");
1110 break;
1111 }
1112 } while ((coincident = coincident->fCoincident) != this);
1113}
1114
1115bool SkOpSpan::dumpSpan() const {
1116 SkOpSpan* coin = fCoincident;
1117 if (this != coin) {
1118 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1119 }
1120 SkDebugf(" windVal=%d", this->windValue());
1121 SkDebugf(" windSum=");
1122 SkPathOpsDebug::WindingPrintf(this->windSum());
1123 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1124 SkDebugf(" oppVal=%d", this->oppValue());
1125 SkDebugf(" oppSum=");
1126 SkPathOpsDebug::WindingPrintf(this->oppSum());
1127 }
1128 if (this->done()) {
1129 SkDebugf(" done");
1130 }
1131 return this != coin;
1132}
1133
1134const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1135 return this->contour()->debugAngle(id);
1136}
1137
caryclark55888e42016-07-18 10:01:36 -07001138
1139const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1140 return this->contour()->debugCoincidence();
1141}
1142
caryclark30b9fdd2016-08-31 14:36:29 -07001143SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001144 return this->contour()->debugContour(id);
1145}
1146
1147const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1148 return this->contour()->debugPtT(id);
1149}
1150
1151const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1152 return this->contour()->debugSegment(id);
1153}
1154
1155const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1156 return this->contour()->debugSpan(id);
1157}
1158
1159void SkOpSegment::dump() const {
1160 SkDebugf("%.*s", contour()->debugIndent(), " ");
1161 this->dumpPts();
1162 const SkOpSpanBase* span = &fHead;
1163 contour()->indentDump();
1164 do {
1165 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1166 span->ptT()->dumpBase();
1167 span->dumpBase();
1168 SkDebugf("\n");
1169 } while (!span->final() && (span = span->upCast()->next()));
1170 contour()->outdentDump();
1171}
1172
1173void SkOpSegment::dumpAll() const {
1174 SkDebugf("%.*s", contour()->debugIndent(), " ");
1175 this->dumpPts();
1176 const SkOpSpanBase* span = &fHead;
1177 contour()->indentDump();
1178 do {
1179 span->dumpAll();
1180 } while (!span->final() && (span = span->upCast()->next()));
1181 contour()->outdentDump();
1182}
1183
1184void SkOpSegment::dumpAngles() const {
1185 SkDebugf("seg=%d\n", debugID());
1186 const SkOpSpanBase* span = &fHead;
1187 do {
1188 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001189 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001190 if (fAngle) {
1191 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1192 fAngle->dumpTo(this, tAngle);
1193 }
1194 if (tAngle) {
1195 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1196 tAngle->dumpTo(this, fAngle);
1197 }
1198 } while (!span->final() && (span = span->upCast()->next()));
1199}
1200
1201void SkOpSegment::dumpCoin() const {
1202 const SkOpSpan* span = &fHead;
1203 do {
1204 span->dumpCoin();
1205 } while ((span = span->next()->upCastable()));
1206}
1207
caryclark26ad22a2015-10-16 09:03:38 -07001208void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001209 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001210 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001211 if (fVerb == SkPath::kConic_Verb) {
1212 SkDebugf("{");
1213 }
caryclark54359292015-03-26 07:52:43 -07001214 int index = 0;
1215 do {
1216 SkDPoint::Dump(fPts[index]);
1217 SkDebugf(", ");
1218 } while (++index < last);
1219 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001220 SkDebugf("}}");
1221 if (fVerb == SkPath::kConic_Verb) {
1222 SkDebugf(", %1.9gf}", fWeight);
1223 }
caryclark624637c2015-05-11 07:21:27 -07001224}
1225
caryclark26ad22a2015-10-16 09:03:38 -07001226void SkOpSegment::dumpPts(const char* prefix) const {
1227 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001228 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001229}
1230
1231void SkCoincidentSpans::dump() const {
1232 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1233 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1234 fCoinPtTStart->dumpBase();
1235 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1236 fCoinPtTEnd->dumpBase();
1237 if (fCoinPtTStart->segment()->operand()) {
1238 SkDebugf(" operand");
1239 }
1240 if (fCoinPtTStart->segment()->isXor()) {
1241 SkDebugf(" xor");
1242 }
1243 SkDebugf("\n");
1244 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1245 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1246 fOppPtTStart->dumpBase();
1247 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1248 fOppPtTEnd->dumpBase();
1249 if (fOppPtTStart->segment()->operand()) {
1250 SkDebugf(" operand");
1251 }
1252 if (fOppPtTStart->segment()->isXor()) {
1253 SkDebugf(" xor");
1254 }
1255 SkDebugf("\n");
1256}
1257
1258void SkOpCoincidence::dump() const {
1259 SkCoincidentSpans* span = fHead;
1260 while (span) {
1261 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001262 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001263 }
caryclark26ad22a2015-10-16 09:03:38 -07001264 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001265 return;
1266 }
1267 SkDebugf("top:\n");
1268 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001269 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001270 while (span) {
1271 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001272 span = span->next();
1273 SkCoincidentSpans* check = fTop;
1274 ++count;
1275 for (int index = 0; index < count; ++index) {
1276 if (span == check) {
1277 SkDebugf("(loops to #%d)\n", index);
1278 return;
1279 }
1280 check = check->next();
1281 }
caryclark27c8eb82015-07-06 11:38:33 -07001282 }
caryclark54359292015-03-26 07:52:43 -07001283}
1284
caryclark624637c2015-05-11 07:21:27 -07001285void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001286 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001287 if (!fCount) {
1288 return;
1289 }
1290 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001291 SkDEBUGCODE(fDebugIndent = 0);
1292 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001293 do {
1294 segment->dump();
1295 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001296 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001297}
1298
caryclark624637c2015-05-11 07:21:27 -07001299void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001300 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001301 if (!fCount) {
1302 return;
1303 }
1304 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001305 SkDEBUGCODE(fDebugIndent = 0);
1306 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001307 do {
1308 segment->dumpAll();
1309 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001310 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001311}
1312
1313
1314void SkOpContour::dumpAngles() const {
1315 SkDebugf("contour=%d\n", this->debugID());
1316 const SkOpSegment* segment = &fHead;
1317 do {
1318 SkDebugf(" seg=%d ", segment->debugID());
1319 segment->dumpAngles();
1320 } while ((segment = segment->next()));
1321}
1322
1323void SkOpContour::dumpPt(int index) const {
1324 const SkOpSegment* segment = &fHead;
1325 do {
1326 if (segment->debugID() == index) {
1327 segment->dumpPts();
1328 }
1329 } while ((segment = segment->next()));
1330}
1331
caryclark26ad22a2015-10-16 09:03:38 -07001332void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001333 SkDebugf("contour=%d\n", this->debugID());
1334 const SkOpSegment* segment = &fHead;
1335 do {
caryclark26ad22a2015-10-16 09:03:38 -07001336 SkDebugf(" %s=%d ", prefix, segment->debugID());
1337 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001338 } while ((segment = segment->next()));
1339}
1340
caryclark26ad22a2015-10-16 09:03:38 -07001341void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001342 if (!this->fCount) {
1343 SkDebugf("<empty>\n");
1344 return;
1345 }
1346 const SkOpSegment* segment = &fHead;
1347 do {
caryclark26ad22a2015-10-16 09:03:38 -07001348 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001349 } while ((segment = segment->next()));
1350}
1351
1352void SkOpContour::dumpSegment(int index) const {
1353 debugSegment(index)->dump();
1354}
1355
caryclark26ad22a2015-10-16 09:03:38 -07001356void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001357 bool firstOp = false;
1358 const SkOpContour* c = this;
1359 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001360 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001361#if DEBUG_ACTIVE_OP
1362 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1363#endif
1364 firstOp = true;
1365 }
caryclark26ad22a2015-10-16 09:03:38 -07001366 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001367 } while ((c = c->next()));
1368}
1369
1370void SkOpContour::dumpSpan(int index) const {
1371 debugSpan(index)->dump();
1372}
1373
1374void SkOpContour::dumpSpans() const {
1375 SkDebugf("contour=%d\n", this->debugID());
1376 const SkOpSegment* segment = &fHead;
1377 do {
1378 SkDebugf(" seg=%d ", segment->debugID());
1379 segment->dump();
1380 } while ((segment = segment->next()));
1381}
1382
caryclark03b03ca2015-04-23 09:13:37 -07001383void SkOpCurve::dump() const {
1384 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1385 SkDebugf("{{");
1386 int index;
1387 for (index = 0; index <= count - 1; ++index) {
1388 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1389 }
1390 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1391}
1392
caryclark54359292015-03-26 07:52:43 -07001393#ifdef SK_DEBUG
1394const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001395 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001396 do {
1397 const SkOpSegment* segment = contour->first();
1398 while (segment) {
1399 const SkOpSpan* span = segment->head();
1400 do {
1401 SkOpAngle* angle = span->fromAngle();
1402 if (angle && angle->debugID() == id) {
1403 return angle;
1404 }
1405 angle = span->toAngle();
1406 if (angle && angle->debugID() == id) {
1407 return angle;
1408 }
1409 } while ((span = span->next()->upCastable()));
1410 const SkOpSpanBase* tail = segment->tail();
1411 SkOpAngle* angle = tail->fromAngle();
1412 if (angle && angle->debugID() == id) {
1413 return angle;
1414 }
1415 segment = segment->next();
1416 }
1417 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001418 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001419}
1420
caryclark30b9fdd2016-08-31 14:36:29 -07001421SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001422 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001423 do {
1424 if (contour->debugID() == id) {
1425 return contour;
1426 }
1427 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001428 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001429}
1430
1431const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001432 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001433 do {
1434 const SkOpSegment* segment = contour->first();
1435 while (segment) {
1436 const SkOpSpan* span = segment->head();
1437 do {
1438 const SkOpPtT* ptT = span->ptT();
1439 if (ptT->debugMatchID(id)) {
1440 return ptT;
1441 }
1442 } while ((span = span->next()->upCastable()));
1443 const SkOpSpanBase* tail = segment->tail();
1444 const SkOpPtT* ptT = tail->ptT();
1445 if (ptT->debugMatchID(id)) {
1446 return ptT;
1447 }
1448 segment = segment->next();
1449 }
1450 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001451 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001452}
1453
1454const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001455 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001456 do {
1457 const SkOpSegment* segment = contour->first();
1458 while (segment) {
1459 if (segment->debugID() == id) {
1460 return segment;
1461 }
1462 segment = segment->next();
1463 }
1464 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001465 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001466}
1467
1468const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001469 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001470 do {
1471 const SkOpSegment* segment = contour->first();
1472 while (segment) {
1473 const SkOpSpan* span = segment->head();
1474 do {
1475 if (span->debugID() == id) {
1476 return span;
1477 }
1478 } while ((span = span->next()->upCastable()));
1479 const SkOpSpanBase* tail = segment->tail();
1480 if (tail->debugID() == id) {
1481 return tail;
1482 }
1483 segment = segment->next();
1484 }
1485 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001486 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001487}
1488#endif
1489
caryclark54359292015-03-26 07:52:43 -07001490#if DEBUG_T_SECT_DUMP > 1
1491int gDumpTSectNum;
1492#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001493
1494// global path dumps for msvs Visual Studio 17 to use from Immediate Window
1495namespace SkOpDebug {
1496
1497 void Dump(const SkOpContour& contour) {
1498 contour.dump();
1499 }
1500
1501 void DumpAll(const SkOpContour& contour) {
1502 contour.dumpAll();
1503 }
1504
1505 void DumpAngles(const SkOpContour& contour) {
1506 contour.dumpAngles();
1507 }
1508
1509 void DumpContours(const SkOpContour& contour) {
1510 contour.dumpContours();
1511 }
1512
1513 void DumpContoursAll(const SkOpContour& contour) {
1514 contour.dumpContoursAll();
1515 }
1516
1517 void DumpContoursAngles(const SkOpContour& contour) {
1518 contour.dumpContoursAngles();
1519 }
1520
1521 void DumpContoursPts(const SkOpContour& contour) {
1522 contour.dumpContoursPts();
1523 }
1524
1525 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1526 contour.dumpContoursPt(segmentID);
1527 }
1528
1529 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1530 contour.dumpContoursSegment(segmentID);
1531 }
1532
1533 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1534 contour.dumpContoursSpan(segmentID);
1535 }
1536
1537 void DumpContoursSpans(const SkOpContour& contour) {
1538 contour.dumpContoursSpans();
1539 }
1540
1541 void DumpPt(const SkOpContour& contour, int pt) {
1542 contour.dumpPt(pt);
1543 }
1544
1545 void DumpPts(const SkOpContour& contour, const char* prefix) {
1546 contour.dumpPts(prefix);
1547 }
1548
1549 void DumpSegment(const SkOpContour& contour, int seg) {
1550 contour.dumpSegment(seg);
1551 }
1552
1553 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1554 contour.dumpSegments(prefix, op);
1555 }
1556
1557 void DumpSpan(const SkOpContour& contour, int span) {
1558 contour.dumpSpan(span);
1559 }
1560
1561 void DumpSpans(const SkOpContour& contour ) {
1562 contour.dumpSpans();
1563 }
1564
1565 void Dump(const SkOpSegment& segment) {
1566 segment.dump();
1567 }
1568
1569 void DumpAll(const SkOpSegment& segment) {
1570 segment.dumpAll();
1571 }
1572
1573 void DumpAngles(const SkOpSegment& segment) {
1574 segment.dumpAngles();
1575 }
1576
1577 void DumpCoin(const SkOpSegment& segment) {
1578 segment.dumpCoin();
1579 }
1580
1581 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1582 segment.dumpPts(prefix);
1583 }
1584
1585 void Dump(const SkOpPtT& ptT) {
1586 ptT.dump();
1587 }
1588
1589 void DumpAll(const SkOpPtT& ptT) {
1590 ptT.dumpAll();
1591 }
1592
1593 void Dump(const SkOpSpanBase& spanBase) {
1594 spanBase.dump();
1595 }
1596
1597 void DumpCoin(const SkOpSpanBase& spanBase) {
1598 spanBase.dumpCoin();
1599 }
1600
1601 void DumpAll(const SkOpSpanBase& spanBase) {
1602 spanBase.dumpAll();
1603 }
1604
1605 void DumpCoin(const SkOpSpan& span) {
1606 span.dumpCoin();
1607 }
1608
1609 bool DumpSpan(const SkOpSpan& span) {
1610 return span.dumpSpan();
1611 }
1612
1613 void Dump(const SkDConic& conic) {
1614 conic.dump();
1615 }
1616
1617 void DumpID(const SkDConic& conic, int id) {
1618 conic.dumpID(id);
1619 }
1620
1621 void Dump(const SkDCubic& cubic) {
1622 cubic.dump();
1623 }
1624
1625 void DumpID(const SkDCubic& cubic, int id) {
1626 cubic.dumpID(id);
1627 }
1628
1629 void Dump(const SkDLine& line) {
1630 line.dump();
1631 }
1632
1633 void DumpID(const SkDLine& line, int id) {
1634 line.dumpID(id);
1635 }
1636
1637 void Dump(const SkDQuad& quad) {
1638 quad.dump();
1639 }
1640
1641 void DumpID(const SkDQuad& quad, int id) {
1642 quad.dumpID(id);
1643 }
1644
1645 void Dump(const SkDPoint& point) {
1646 point.dump();
1647 }
1648
Cary Clark1857ddb2018-07-11 11:01:43 -04001649 void Dump(const SkOpAngle& angle) {
1650 angle.dump();
1651 }
1652
Cary Clarkb8421ed2018-03-14 15:55:02 -04001653// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1654#define DummyDefinitions(a, b) \
1655 \
1656 void Dump(const SkDebugTCoincident##a##b& curve) { \
1657 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1658 } \
1659 \
1660 void Dump(const SkDebugTSect##a##b& curve) { \
1661 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1662 } \
1663 \
1664 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1665 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1666 } \
1667 \
1668 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1669 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1670 } \
1671 \
1672 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1673 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1674 } \
1675 \
1676 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1677 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1678 } \
1679 \
1680 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1681 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1682 } \
1683 \
1684 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1685 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1686 } \
1687 \
1688 void Dump(const SkDebugTSpan##a##b& curve) { \
1689 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1690 } \
1691 \
1692 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1693 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1694 } \
1695 \
1696 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1697 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1698 } \
1699 \
1700 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1701 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1702 } \
1703 \
1704 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1705 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1706 }
1707
1708 DummyDefinitions(Quad, Quad);
1709 DummyDefinitions(Conic, Quad);
1710 DummyDefinitions(Conic, Conic);
1711 DummyDefinitions(Cubic, Quad);
1712 DummyDefinitions(Cubic, Conic);
1713 DummyDefinitions(Cubic, Cubic);
1714
1715#undef DummyDefinitions
1716}