blob: 942f99c7ae82866ba3cf39764375011ecdd72b29 [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
8#include "PathOpsTSectDebug.h"
9#include "SkOpCoincidence.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000010#include "SkOpContour.h"
11#include "SkIntersectionHelper.h"
caryclark1049f122015-04-20 08:31:59 -070012#include "SkMutex.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000013#include "SkOpSegment.h"
caryclark19eb3b22014-07-18 05:08:14 -070014#include "SkString.h"
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000015
16inline void DebugDumpDouble(double x) {
17 if (x == floor(x)) {
18 SkDebugf("%.0f", x);
19 } else {
20 SkDebugf("%1.19g", x);
21 }
22}
23
24inline void DebugDumpFloat(float x) {
25 if (x == floorf(x)) {
26 SkDebugf("%.0f", x);
27 } else {
28 SkDebugf("%1.9gf", x);
29 }
30}
31
caryclark65f55312014-11-13 06:58:52 -080032inline void DebugDumpHexFloat(float x) {
33 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
34}
caryclark19eb3b22014-07-18 05:08:14 -070035
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000036// if not defined by PathOpsDebug.cpp ...
37#if !defined SK_DEBUG && FORCE_RELEASE
38bool SkPathOpsDebug::ValidWind(int wind) {
39 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
40}
41
42void SkPathOpsDebug::WindingPrintf(int wind) {
43 if (wind == SK_MinS32) {
44 SkDebugf("?");
45 } else {
46 SkDebugf("%d", wind);
47 }
48}
49#endif
50
caryclark55888e42016-07-18 10:01:36 -070051static void DumpID(int id) {
52 SkDebugf("} ");
53 if (id >= 0) {
54 SkDebugf("id=%d", id);
55 }
56 SkDebugf("\n");
57}
58
caryclark1049f122015-04-20 08:31:59 -070059void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070060 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070061 SkDebugf("},\n");
62}
63
64void SkDConic::dumpID(int id) const {
65 dumpInner();
caryclark55888e42016-07-18 10:01:36 -070066 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -070067}
68
69void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070070 SkDebugf("{");
71 fPts.dumpInner();
72 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070073}
74
75void SkDCubic::dump() const {
76 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070077 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070078}
79
caryclark54359292015-03-26 07:52:43 -070080void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070081 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -070082 SkDebugf("}");
83 DumpID(id);
reed0dc4dd62015-03-24 13:55:33 -070084}
85
caryclark54359292015-03-26 07:52:43 -070086static inline bool double_is_NaN(double x) { return x != x; }
87
88void SkDCubic::dumpInner() const {
89 SkDebugf("{{");
90 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070091 do {
caryclark54359292015-03-26 07:52:43 -070092 if (index != 0) {
93 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
94 return;
reed0dc4dd62015-03-24 13:55:33 -070095 }
caryclark54359292015-03-26 07:52:43 -070096 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -070097 }
caryclark54359292015-03-26 07:52:43 -070098 fPts[index].dump();
99 } while (++index < 3);
100 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -0700101 return;
102 }
caryclark54359292015-03-26 07:52:43 -0700103 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700104 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000105}
106
caryclark55888e42016-07-18 10:01:36 -0700107void SkDCurve::dump() const {
108 dumpID(-1);
109}
110
caryclark1049f122015-04-20 08:31:59 -0700111void SkDCurve::dumpID(int id) const {
112#ifndef SK_RELEASE
113 switch(fVerb) {
114 case SkPath::kLine_Verb:
115 fLine.dumpID(id);
116 break;
117 case SkPath::kQuad_Verb:
118 fQuad.dumpID(id);
119 break;
120 case SkPath::kConic_Verb:
121 fConic.dumpID(id);
122 break;
123 case SkPath::kCubic_Verb:
124 fCubic.dumpID(id);
125 break;
126 default:
127 SkASSERT(0);
128 }
129#else
130 fCubic.dumpID(id);
131#endif
132}
133
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000134void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700135 this->dumpInner();
136 SkDebugf("}},\n");
137}
138
139void SkDLine::dumpID(int id) const {
140 this->dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700141 SkDebugf("}");
142 DumpID(id);
caryclark1049f122015-04-20 08:31:59 -0700143}
144
145void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000146 SkDebugf("{{");
147 fPts[0].dump();
148 SkDebugf(", ");
149 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000150}
151
152void SkDPoint::dump() const {
153 SkDebugf("{");
154 DebugDumpDouble(fX);
155 SkDebugf(", ");
156 DebugDumpDouble(fY);
157 SkDebugf("}");
158}
159
160void SkDPoint::Dump(const SkPoint& pt) {
161 SkDebugf("{");
162 DebugDumpFloat(pt.fX);
163 SkDebugf(", ");
164 DebugDumpFloat(pt.fY);
165 SkDebugf("}");
166}
167
caryclark65f55312014-11-13 06:58:52 -0800168void SkDPoint::DumpHex(const SkPoint& pt) {
169 SkDebugf("{");
170 DebugDumpHexFloat(pt.fX);
171 SkDebugf(", ");
172 DebugDumpHexFloat(pt.fY);
173 SkDebugf("}");
174}
175
176void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700177 dumpInner();
178 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800179}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000180
caryclark54359292015-03-26 07:52:43 -0700181void SkDQuad::dumpID(int id) const {
182 dumpInner();
caryclark55888e42016-07-18 10:01:36 -0700183 SkDebugf("}");
184 DumpID(id);
caryclark54359292015-03-26 07:52:43 -0700185}
186
187void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000188 SkDebugf("{{");
189 int index = 0;
190 do {
191 fPts[index].dump();
192 SkDebugf(", ");
193 } while (++index < 2);
194 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000195}
196
caryclark54359292015-03-26 07:52:43 -0700197void SkIntersections::dump() const {
198 SkDebugf("used=%d of %d", fUsed, fMax);
199 for (int index = 0; index < fUsed; ++index) {
200 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
201 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
202 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
203 fPt[index].fX, fPt[index].fY);
204 if (index < 2 && fNearlySame[index]) {
205 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000206 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000207 }
208 SkDebugf("\n");
209}
210
Cary Clarkb8421ed2018-03-14 15:55:02 -0400211namespace SkOpDebug {
212
213const ::SkOpAngle* AngleAngle(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700214 return angle->debugAngle(id);
215}
216
Cary Clarkb8421ed2018-03-14 15:55:02 -0400217::SkOpContour* AngleContour(::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700218 return angle->debugContour(id);
219}
220
Cary Clarkb8421ed2018-03-14 15:55:02 -0400221const ::SkOpPtT* AnglePtT(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700222 return angle->debugPtT(id);
223}
224
Cary Clarkb8421ed2018-03-14 15:55:02 -0400225const ::SkOpSegment* AngleSegment(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700226 return angle->debugSegment(id);
227}
228
Cary Clarkb8421ed2018-03-14 15:55:02 -0400229const ::SkOpSpanBase* AngleSpan(const ::SkOpAngle* angle, int id) {
caryclark54359292015-03-26 07:52:43 -0700230 return angle->debugSpan(id);
231}
232
Cary Clarkb8421ed2018-03-14 15:55:02 -0400233const ::SkOpAngle* ContourAngle(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700234 return contour->debugAngle(id);
235}
236
Cary Clarkb8421ed2018-03-14 15:55:02 -0400237::SkOpContour* ContourContour(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700238 return contour->debugContour(id);
239}
240
Cary Clarkb8421ed2018-03-14 15:55:02 -0400241const ::SkOpPtT* ContourPtT(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700242 return contour->debugPtT(id);
243}
244
Cary Clarkb8421ed2018-03-14 15:55:02 -0400245const ::SkOpSegment* ContourSegment(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700246 return contour->debugSegment(id);
247}
248
Cary Clarkb8421ed2018-03-14 15:55:02 -0400249const ::SkOpSpanBase* ContourSpan(::SkOpContour* contour, int id) {
caryclark54359292015-03-26 07:52:43 -0700250 return contour->debugSpan(id);
251}
252
Cary Clarkb8421ed2018-03-14 15:55:02 -0400253const ::SkOpAngle* CoincidenceAngle(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700254 return coin->debugAngle(id);
255}
256
Cary Clarkb8421ed2018-03-14 15:55:02 -0400257::SkOpContour* CoincidenceContour(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700258 return coin->debugContour(id);
259}
260
Cary Clarkb8421ed2018-03-14 15:55:02 -0400261const ::SkOpPtT* CoincidencePtT(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700262 return coin->debugPtT(id);
263}
264
Cary Clarkb8421ed2018-03-14 15:55:02 -0400265const ::SkOpSegment* CoincidenceSegment(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700266 return coin->debugSegment(id);
267}
268
Cary Clarkb8421ed2018-03-14 15:55:02 -0400269const ::SkOpSpanBase* CoincidenceSpan(::SkOpCoincidence* coin, int id) {
caryclark27c8eb82015-07-06 11:38:33 -0700270 return coin->debugSpan(id);
271}
272
Cary Clarkb8421ed2018-03-14 15:55:02 -0400273const ::SkOpAngle* PtTAngle(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700274 return ptT->debugAngle(id);
275}
276
Cary Clarkb8421ed2018-03-14 15:55:02 -0400277::SkOpContour* PtTContour(::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700278 return ptT->debugContour(id);
279}
280
Cary Clarkb8421ed2018-03-14 15:55:02 -0400281const ::SkOpPtT* PtTPtT(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700282 return ptT->debugPtT(id);
283}
284
Cary Clarkb8421ed2018-03-14 15:55:02 -0400285const ::SkOpSegment* PtTSegment(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700286 return ptT->debugSegment(id);
287}
288
Cary Clarkb8421ed2018-03-14 15:55:02 -0400289const ::SkOpSpanBase* PtTSpan(const ::SkOpPtT* ptT, int id) {
caryclark54359292015-03-26 07:52:43 -0700290 return ptT->debugSpan(id);
291}
292
Cary Clarkb8421ed2018-03-14 15:55:02 -0400293const ::SkOpAngle* SegmentAngle(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700294 return span->debugAngle(id);
295}
296
Cary Clarkb8421ed2018-03-14 15:55:02 -0400297::SkOpContour* SegmentContour(::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700298 return span->debugContour(id);
299}
300
Cary Clarkb8421ed2018-03-14 15:55:02 -0400301const ::SkOpPtT* SegmentPtT(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700302 return span->debugPtT(id);
303}
304
Cary Clarkb8421ed2018-03-14 15:55:02 -0400305const ::SkOpSegment* SegmentSegment(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700306 return span->debugSegment(id);
307}
308
Cary Clarkb8421ed2018-03-14 15:55:02 -0400309const ::SkOpSpanBase* SegmentSpan(const ::SkOpSegment* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700310 return span->debugSpan(id);
311}
312
Cary Clarkb8421ed2018-03-14 15:55:02 -0400313const ::SkOpAngle* SpanAngle(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700314 return span->debugAngle(id);
315}
316
Cary Clarkb8421ed2018-03-14 15:55:02 -0400317::SkOpContour* SpanContour(::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700318 return span->debugContour(id);
319}
320
Cary Clarkb8421ed2018-03-14 15:55:02 -0400321const ::SkOpPtT* SpanPtT(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700322 return span->debugPtT(id);
323}
324
Cary Clarkb8421ed2018-03-14 15:55:02 -0400325const ::SkOpSegment* SpanSegment(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700326 return span->debugSegment(id);
327}
328
Cary Clarkb8421ed2018-03-14 15:55:02 -0400329const ::SkOpSpanBase* SpanSpan(const ::SkOpSpanBase* span, int id) {
caryclark54359292015-03-26 07:52:43 -0700330 return span->debugSpan(id);
331}
332
Cary Clarkb8421ed2018-03-14 15:55:02 -0400333} // namespace SkPathOpsDebug
334
Cary Clarkab87d7a2016-10-04 10:01:04 -0400335#if DEBUG_COIN
336void SkPathOpsDebug::DumpCoinDict() {
Cary Clarkb8421ed2018-03-14 15:55:02 -0400337 SkPathOpsDebug::gCoinSumChangedDict.dump("unused coin algorithm", false);
338 SkPathOpsDebug::gCoinSumVisitedDict.dump("visited coin function", true);
Cary Clarkab87d7a2016-10-04 10:01:04 -0400339}
340
341void SkPathOpsDebug::CoinDict::dump(const char* str, bool visitCheck) const {
342 int count = fDict.count();
343 for (int index = 0; index < count; ++index) {
344 const auto& entry = fDict[index];
345 if (visitCheck || entry.fGlitchType == kUninitialized_Glitch) {
346 SkDebugf("%s %s : line %d iteration %d", str, entry.fFunctionName,
347 entry.fLineNumber, entry.fIteration);
348 DumpGlitchType(entry.fGlitchType);
349 SkDebugf("\n");
350 }
351 }
352}
353#endif
354
caryclark624637c2015-05-11 07:21:27 -0700355void SkOpContour::dumpContours() const {
356 SkOpContour* contour = this->globalState()->contourHead();
357 do {
358 contour->dump();
359 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000360}
361
caryclark624637c2015-05-11 07:21:27 -0700362void SkOpContour::dumpContoursAll() const {
363 SkOpContour* contour = this->globalState()->contourHead();
364 do {
365 contour->dumpAll();
366 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000367}
368
caryclark624637c2015-05-11 07:21:27 -0700369void SkOpContour::dumpContoursAngles() const {
370 SkOpContour* contour = this->globalState()->contourHead();
371 do {
372 contour->dumpAngles();
373 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000374}
375
caryclark624637c2015-05-11 07:21:27 -0700376void SkOpContour::dumpContoursPts() const {
377 SkOpContour* contour = this->globalState()->contourHead();
378 do {
379 contour->dumpPts();
380 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000381}
382
caryclark624637c2015-05-11 07:21:27 -0700383void SkOpContour::dumpContoursPt(int segmentID) const {
384 SkOpContour* contour = this->globalState()->contourHead();
385 do {
386 contour->dumpPt(segmentID);
387 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000388}
389
caryclark624637c2015-05-11 07:21:27 -0700390void SkOpContour::dumpContoursSegment(int segmentID) const {
391 SkOpContour* contour = this->globalState()->contourHead();
392 do {
393 contour->dumpSegment(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::dumpContoursSpan(int spanID) const {
398 SkOpContour* contour = this->globalState()->contourHead();
399 do {
400 contour->dumpSpan(spanID);
401 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000402}
403
caryclark624637c2015-05-11 07:21:27 -0700404void SkOpContour::dumpContoursSpans() const {
405 SkOpContour* contour = this->globalState()->contourHead();
406 do {
407 contour->dumpSpans();
408 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000409}
410
caryclark1049f122015-04-20 08:31:59 -0700411template <typename TCurve, typename OppCurve>
412const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700413 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000414}
415
caryclark1049f122015-04-20 08:31:59 -0700416void DontCallDebugSpan(int id);
417void DontCallDebugSpan(int id) { // exists to instantiate the templates
418 SkDQuad quad;
419 SkDConic conic;
420 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700421 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
422 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
423 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
424 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
425 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
426 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
427 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
428 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
429 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700430 DebugSpan(&q1q2, id);
431 DebugSpan(&q1k2, id);
432 DebugSpan(&q1c2, id);
433 DebugSpan(&k1q2, id);
434 DebugSpan(&k1k2, id);
435 DebugSpan(&k1c2, id);
436 DebugSpan(&c1q2, id);
437 DebugSpan(&c1k2, id);
438 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000439}
440
caryclark1049f122015-04-20 08:31:59 -0700441template <typename TCurve, typename OppCurve>
442const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700443 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000444}
445
caryclark1049f122015-04-20 08:31:59 -0700446void DontCallDebugT(double t);
447void DontCallDebugT(double t) { // exists to instantiate the templates
448 SkDQuad quad;
449 SkDConic conic;
450 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700451 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
452 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
453 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
454 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
455 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
456 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
457 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
458 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
459 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700460 DebugT(&q1q2, t);
461 DebugT(&q1k2, t);
462 DebugT(&q1c2, t);
463 DebugT(&k1q2, t);
464 DebugT(&k1k2, t);
465 DebugT(&k1c2, t);
466 DebugT(&c1q2, t);
467 DebugT(&c1k2, t);
468 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700469}
470
caryclark1049f122015-04-20 08:31:59 -0700471template <typename TCurve, typename OppCurve>
472void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700473 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000474}
475
caryclark1049f122015-04-20 08:31:59 -0700476void DontCallDumpTSect();
477void DontCallDumpTSect() { // exists to instantiate the templates
478 SkDQuad quad;
479 SkDConic conic;
480 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700481 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
482 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
483 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
484 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
485 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
486 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
487 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
488 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
489 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700490 Dump(&q1q2);
491 Dump(&q1k2);
492 Dump(&q1c2);
493 Dump(&k1q2);
494 Dump(&k1k2);
495 Dump(&k1c2);
496 Dump(&c1q2);
497 Dump(&c1k2);
498 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000499}
500
caryclark1049f122015-04-20 08:31:59 -0700501template <typename TCurve, typename OppCurve>
502void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700503 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700504}
505
caryclark1049f122015-04-20 08:31:59 -0700506void DontCallDumpBoth();
507void DontCallDumpBoth() { // exists to instantiate the templates
508 SkDQuad quad;
509 SkDConic conic;
510 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700511 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
512 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
513 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
514 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
515 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
516 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
517 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
518 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
519 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700520 DumpBoth(&q1q2, &q1q2);
521 DumpBoth(&q1k2, &k1q2);
522 DumpBoth(&q1c2, &c1q2);
523 DumpBoth(&k1q2, &q1k2);
524 DumpBoth(&k1k2, &k1k2);
525 DumpBoth(&k1c2, &c1k2);
526 DumpBoth(&c1q2, &q1c2);
527 DumpBoth(&c1k2, &k1c2);
528 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700529}
530
caryclark1049f122015-04-20 08:31:59 -0700531template <typename TCurve, typename OppCurve>
532void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
533 sect1->dumpBounded(id);
534}
535
536void DontCallDumpBounded();
537void DontCallDumpBounded() {
538 SkDQuad quad;
539 SkDConic conic;
540 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700541 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
542 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
543 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
544 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
545 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
546 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
547 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
548 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
549 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700550 DumpBounded(&q1q2, 0);
551 DumpBounded(&q1k2, 0);
552 DumpBounded(&q1c2, 0);
553 DumpBounded(&k1q2, 0);
554 DumpBounded(&k1k2, 0);
555 DumpBounded(&k1c2, 0);
556 DumpBounded(&c1q2, 0);
557 DumpBounded(&c1k2, 0);
558 DumpBounded(&c1c2, 0);
559}
560
561template <typename TCurve, typename OppCurve>
562void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
563 sect1->dumpBounds();
564}
565
566void DontCallDumpBounds();
567void DontCallDumpBounds() {
568 SkDQuad quad;
569 SkDConic conic;
570 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700571 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
572 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
573 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
574 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
575 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
576 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
577 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
578 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
579 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700580 DumpBounds(&q1q2);
581 DumpBounds(&q1k2);
582 DumpBounds(&q1c2);
583 DumpBounds(&k1q2);
584 DumpBounds(&k1k2);
585 DumpBounds(&k1c2);
586 DumpBounds(&c1q2);
587 DumpBounds(&c1k2);
588 DumpBounds(&c1c2);
589}
590
591template <typename TCurve, typename OppCurve>
592void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700593 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700594}
595
caryclark1049f122015-04-20 08:31:59 -0700596void DontCallDumpCoin();
597void DontCallDumpCoin() { // exists to instantiate the templates
598 SkDQuad quad;
599 SkDConic conic;
600 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700601 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
602 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
603 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
604 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
605 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
606 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
607 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
608 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
609 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700610 DumpCoin(&q1q2);
611 DumpCoin(&q1k2);
612 DumpCoin(&q1c2);
613 DumpCoin(&k1q2);
614 DumpCoin(&k1k2);
615 DumpCoin(&k1c2);
616 DumpCoin(&c1q2);
617 DumpCoin(&c1k2);
618 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000619}
620
caryclark1049f122015-04-20 08:31:59 -0700621template <typename TCurve, typename OppCurve>
622void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700623 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000624}
625
caryclark1049f122015-04-20 08:31:59 -0700626void DontCallDumpCoinCurves();
627void DontCallDumpCoinCurves() { // exists to instantiate the templates
628 SkDQuad quad;
629 SkDConic conic;
630 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700631 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
632 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
633 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
634 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
635 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
636 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
637 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
638 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
639 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700640 DumpCoinCurves(&q1q2);
641 DumpCoinCurves(&q1k2);
642 DumpCoinCurves(&q1c2);
643 DumpCoinCurves(&k1q2);
644 DumpCoinCurves(&k1k2);
645 DumpCoinCurves(&k1c2);
646 DumpCoinCurves(&c1q2);
647 DumpCoinCurves(&c1k2);
648 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000649}
650
caryclark1049f122015-04-20 08:31:59 -0700651template <typename TCurve, typename OppCurve>
652void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700653 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000654}
655
caryclark1049f122015-04-20 08:31:59 -0700656void DontCallDumpCurves();
657void DontCallDumpCurves() { // exists to instantiate the templates
658 SkDQuad quad;
659 SkDConic conic;
660 SkDCubic cubic;
caryclarke25a4f62016-07-26 09:26:29 -0700661 SkTSect<SkDQuad, SkDQuad> q1q2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
662 SkTSect<SkDQuad, SkDConic> q1k2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
663 SkTSect<SkDQuad, SkDCubic> q1c2(quad SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
664 SkTSect<SkDConic, SkDQuad> k1q2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
665 SkTSect<SkDConic, SkDConic> k1k2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
666 SkTSect<SkDConic, SkDCubic> k1c2(conic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
667 SkTSect<SkDCubic, SkDQuad> c1q2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
668 SkTSect<SkDCubic, SkDConic> c1k2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
669 SkTSect<SkDCubic, SkDCubic> c1c2(cubic SkDEBUGPARAMS(nullptr) PATH_OPS_DEBUG_T_SECT_PARAMS(1));
caryclark1049f122015-04-20 08:31:59 -0700670 DumpCurves(&q1q2);
671 DumpCurves(&q1k2);
672 DumpCurves(&q1c2);
673 DumpCurves(&k1q2);
674 DumpCurves(&k1k2);
675 DumpCurves(&k1c2);
676 DumpCurves(&c1q2);
677 DumpCurves(&c1k2);
678 DumpCurves(&c1c2);
679}
680
681template <typename TCurve, typename OppCurve>
682void Dump(const SkTSpan<TCurve, OppCurve>* span) {
683 span->dump();
684}
685
686void DontCallDumpTSpan();
687void DontCallDumpTSpan() { // exists to instantiate the templates
688 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
689 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
690 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
691 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
692 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
693 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
694 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
695 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
696 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
697 Dump(&q1q2);
698 Dump(&q1k2);
699 Dump(&q1c2);
700 Dump(&k1q2);
701 Dump(&k1k2);
702 Dump(&k1c2);
703 Dump(&c1q2);
704 Dump(&c1k2);
705 Dump(&c1c2);
706}
707
708template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700709void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
710 span->dumpAll();
711}
712
713void DontCallDumpSpanAll();
714void DontCallDumpSpanAll() { // exists to instantiate the templates
715 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
716 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
717 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
718 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
719 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
720 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
721 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
722 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
723 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
724 DumpAll(&q1q2);
725 DumpAll(&q1k2);
726 DumpAll(&q1c2);
727 DumpAll(&k1q2);
728 DumpAll(&k1k2);
729 DumpAll(&k1c2);
730 DumpAll(&c1q2);
731 DumpAll(&c1k2);
732 DumpAll(&c1c2);
733}
734
735template <typename TCurve, typename OppCurve>
736void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
737 span->dumpBounded(0);
738}
739
740void DontCallDumpSpanBounded();
741void DontCallDumpSpanBounded() { // exists to instantiate the templates
742 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
743 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
744 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
745 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
746 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
747 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
748 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
749 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
750 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
751 DumpBounded(&q1q2);
752 DumpBounded(&q1k2);
753 DumpBounded(&q1c2);
754 DumpBounded(&k1q2);
755 DumpBounded(&k1k2);
756 DumpBounded(&k1c2);
757 DumpBounded(&c1q2);
758 DumpBounded(&c1k2);
759 DumpBounded(&c1c2);
760}
761
762template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700763void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
764 span->dumpCoin();
765}
766
767void DontCallDumpSpanCoin();
768void DontCallDumpSpanCoin() { // exists to instantiate the templates
769 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
770 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
771 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
772 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
773 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
774 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
775 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
776 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
777 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
778 DumpCoin(&q1q2);
779 DumpCoin(&q1k2);
780 DumpCoin(&q1c2);
781 DumpCoin(&k1q2);
782 DumpCoin(&k1k2);
783 DumpCoin(&k1c2);
784 DumpCoin(&c1q2);
785 DumpCoin(&c1k2);
786 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700787}
788
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000789static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700790 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
791 quad1.dumpInner();
792 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000793 quad2.dump();
794 SkDebugf("</div>\n\n");
795}
796
797static void dumpTestTrailer() {
798 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
799 SkDebugf(" var testDivs = [\n");
800}
801
802static void dumpTestList(int testNo, double min) {
803 SkDebugf(" quad%d,", testNo);
804 if (min > 0) {
805 SkDebugf(" // %1.9g", min);
806 }
807 SkDebugf("\n");
808}
809
810void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
811 SkDebugf("\n");
812 dumpTestCase(quad1, quad2, testNo);
813 dumpTestTrailer();
814 dumpTestList(testNo, 0);
815 SkDebugf("\n");
816}
817
818void DumpT(const SkDQuad& quad, double t) {
819 SkDLine line = {{quad.ptAtT(t), quad[0]}};
820 line.dump();
821}
caryclark54359292015-03-26 07:52:43 -0700822
823const SkOpAngle* SkOpAngle::debugAngle(int id) const {
824 return this->segment()->debugAngle(id);
825}
826
caryclark55888e42016-07-18 10:01:36 -0700827const SkOpCoincidence* SkOpAngle::debugCoincidence() const {
828 return this->segment()->debugCoincidence();
829}
830
caryclark30b9fdd2016-08-31 14:36:29 -0700831SkOpContour* SkOpAngle::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700832 return this->segment()->debugContour(id);
833}
834
835const SkOpPtT* SkOpAngle::debugPtT(int id) const {
836 return this->segment()->debugPtT(id);
837}
838
839const SkOpSegment* SkOpAngle::debugSegment(int id) const {
840 return this->segment()->debugSegment(id);
841}
842
caryclark624637c2015-05-11 07:21:27 -0700843int SkOpAngle::debugSign() const {
844 SkASSERT(fStart->t() != fEnd->t());
845 return fStart->t() < fEnd->t() ? -1 : 1;
846}
847
caryclark54359292015-03-26 07:52:43 -0700848const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
849 return this->segment()->debugSpan(id);
850}
851
852void SkOpAngle::dump() const {
853 dumpOne(true);
854 SkDebugf("\n");
855}
856
857void SkOpAngle::dumpOne(bool functionHeader) const {
858// fSegment->debugValidate();
859 const SkOpSegment* segment = this->segment();
860 const SkOpSpan& mSpan = *fStart->starter(fEnd);
861 if (functionHeader) {
862 SkDebugf("%s ", __FUNCTION__);
863 }
864 SkDebugf("[%d", segment->debugID());
865 SkDebugf("/%d", debugID());
866 SkDebugf("] next=");
867 if (fNext) {
868 SkDebugf("%d", fNext->fStart->segment()->debugID());
869 SkDebugf("/%d", fNext->debugID());
870 } else {
871 SkDebugf("?");
872 }
873 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
874 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
875 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700876 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700877
878 SkDebugf(" windSum=");
879 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
880 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
881 SkDebugf(" oppVal=%d", mSpan.oppValue());
882 SkDebugf(" oppSum=");
883 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
884 }
885 if (mSpan.done()) {
886 SkDebugf(" done");
887 }
888 if (unorderable()) {
889 SkDebugf(" unorderable");
890 }
891 if (segment->operand()) {
892 SkDebugf(" operand");
893 }
caryclark54359292015-03-26 07:52:43 -0700894}
895
896void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
897 const SkOpAngle* first = this;
898 const SkOpAngle* next = this;
899 const char* indent = "";
900 do {
901 SkDebugf("%s", indent);
902 next->dumpOne(false);
903 if (segment == next->fStart->segment()) {
904 if (this == fNext) {
905 SkDebugf(" << from");
906 }
907 if (to == fNext) {
908 SkDebugf(" << to");
909 }
910 }
911 SkDebugf("\n");
912 indent = " ";
913 next = next->fNext;
914 } while (next && next != first);
915}
916
917void SkOpAngle::dumpCurves() const {
918 const SkOpAngle* first = this;
919 const SkOpAngle* next = this;
920 do {
caryclarkeed356d2016-09-14 07:18:20 -0700921 next->fPart.fCurve.dumpID(next->segment()->debugID());
caryclark54359292015-03-26 07:52:43 -0700922 next = next->fNext;
923 } while (next && next != first);
924}
925
926void SkOpAngle::dumpLoop() const {
927 const SkOpAngle* first = this;
928 const SkOpAngle* next = this;
929 do {
930 next->dumpOne(false);
931 SkDebugf("\n");
932 next = next->fNext;
933 } while (next && next != first);
934}
935
936void SkOpAngle::dumpTest() const {
937 const SkOpAngle* first = this;
938 const SkOpAngle* next = this;
939 do {
940 SkDebugf("{ ");
941 SkOpSegment* segment = next->segment();
942 segment->dumpPts();
943 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
944 next->start()->t(), next->end()->t());
945 next = next->fNext;
946 } while (next && next != first);
947}
948
949bool SkOpPtT::debugMatchID(int id) const {
950 int limit = this->debugLoopLimit(false);
951 int loop = 0;
952 const SkOpPtT* ptT = this;
953 do {
954 if (ptT->debugID() == id) {
955 return true;
956 }
957 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
958 return false;
959}
960
961const SkOpAngle* SkOpPtT::debugAngle(int id) const {
962 return this->span()->debugAngle(id);
963}
964
caryclark30b9fdd2016-08-31 14:36:29 -0700965SkOpContour* SkOpPtT::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -0700966 return this->span()->debugContour(id);
967}
968
caryclark55888e42016-07-18 10:01:36 -0700969const SkOpCoincidence* SkOpPtT::debugCoincidence() const {
970 return this->span()->debugCoincidence();
971}
972
caryclark54359292015-03-26 07:52:43 -0700973const SkOpPtT* SkOpPtT::debugPtT(int id) const {
974 return this->span()->debugPtT(id);
975}
976
977const SkOpSegment* SkOpPtT::debugSegment(int id) const {
978 return this->span()->debugSegment(id);
979}
980
981const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
982 return this->span()->debugSpan(id);
983}
984
985void SkOpPtT::dump() const {
986 SkDebugf("seg=%d span=%d ptT=%d",
987 this->segment()->debugID(), this->span()->debugID(), this->debugID());
988 this->dumpBase();
989 SkDebugf("\n");
990}
991
992void SkOpPtT::dumpAll() const {
993 contour()->indentDump();
994 const SkOpPtT* next = this;
995 int limit = debugLoopLimit(true);
996 int loop = 0;
997 do {
998 SkDebugf("%.*s", contour()->debugIndent(), " ");
999 SkDebugf("seg=%d span=%d ptT=%d",
1000 next->segment()->debugID(), next->span()->debugID(), next->debugID());
1001 next->dumpBase();
1002 SkDebugf("\n");
1003 if (limit && ++loop >= limit) {
1004 SkDebugf("*** abort loop ***\n");
1005 break;
1006 }
1007 } while ((next = next->fNext) && next != this);
1008 contour()->outdentDump();
1009}
1010
1011void SkOpPtT::dumpBase() const {
caryclark55888e42016-07-18 10:01:36 -07001012 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s%s", this->fT, this->fPt.fX, this->fPt.fY,
1013 this->fCoincident ? " coin" : "",
caryclark54359292015-03-26 07:52:43 -07001014 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
1015}
1016
1017const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
1018 return this->segment()->debugAngle(id);
1019}
1020
caryclark55888e42016-07-18 10:01:36 -07001021const SkOpCoincidence* SkOpSpanBase::debugCoincidence() const {
1022 return this->segment()->debugCoincidence();
1023}
1024
caryclark30b9fdd2016-08-31 14:36:29 -07001025SkOpContour* SkOpSpanBase::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001026 return this->segment()->debugContour(id);
1027}
1028
1029const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
1030 return this->segment()->debugPtT(id);
1031}
1032
1033const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
1034 return this->segment()->debugSegment(id);
1035}
1036
1037const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
1038 return this->segment()->debugSpan(id);
1039}
1040
1041void SkOpSpanBase::dump() const {
caryclark55888e42016-07-18 10:01:36 -07001042 this->dumpHead();
1043 this->fPtT.dump();
caryclark54359292015-03-26 07:52:43 -07001044}
1045
caryclark55888e42016-07-18 10:01:36 -07001046void SkOpSpanBase::dumpHead() const {
caryclark54359292015-03-26 07:52:43 -07001047 SkDebugf("%.*s", contour()->debugIndent(), " ");
1048 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
1049 this->dumpBase();
1050 SkDebugf("\n");
caryclark55888e42016-07-18 10:01:36 -07001051}
1052
1053void SkOpSpanBase::dumpAll() const {
1054 this->dumpHead();
caryclark54359292015-03-26 07:52:43 -07001055 this->fPtT.dumpAll();
1056}
1057
1058void SkOpSpanBase::dumpBase() const {
1059 if (this->fAligned) {
1060 SkDebugf(" aligned");
1061 }
1062 if (this->fChased) {
1063 SkDebugf(" chased");
1064 }
caryclark55888e42016-07-18 10:01:36 -07001065#ifdef SK_DEBUG
caryclark30b9fdd2016-08-31 14:36:29 -07001066 if (this->fDebugDeleted) {
caryclark55888e42016-07-18 10:01:36 -07001067 SkDebugf(" deleted");
1068 }
1069#endif
caryclark54359292015-03-26 07:52:43 -07001070 if (!this->final()) {
1071 this->upCast()->dumpSpan();
1072 }
1073 const SkOpSpanBase* coin = this->coinEnd();
1074 if (this != coin) {
1075 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1076 } else if (this->final() || !this->upCast()->isCoincident()) {
1077 const SkOpPtT* oPt = this->ptT()->next();
1078 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1079 }
caryclark08bc8482015-04-24 09:08:57 -07001080 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001081}
1082
1083void SkOpSpanBase::dumpCoin() const {
1084 const SkOpSpan* span = this->upCastable();
1085 if (!span) {
1086 return;
1087 }
1088 if (!span->isCoincident()) {
1089 return;
1090 }
1091 span->dumpCoin();
1092}
1093
1094void SkOpSpan::dumpCoin() const {
1095 const SkOpSpan* coincident = fCoincident;
1096 bool ok = debugCoinLoopCheck();
1097 this->dump();
1098 int loop = 0;
1099 do {
1100 coincident->dump();
1101 if (!ok && ++loop > 10) {
1102 SkDebugf("*** abort loop ***\n");
1103 break;
1104 }
1105 } while ((coincident = coincident->fCoincident) != this);
1106}
1107
1108bool SkOpSpan::dumpSpan() const {
1109 SkOpSpan* coin = fCoincident;
1110 if (this != coin) {
1111 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1112 }
1113 SkDebugf(" windVal=%d", this->windValue());
1114 SkDebugf(" windSum=");
1115 SkPathOpsDebug::WindingPrintf(this->windSum());
1116 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1117 SkDebugf(" oppVal=%d", this->oppValue());
1118 SkDebugf(" oppSum=");
1119 SkPathOpsDebug::WindingPrintf(this->oppSum());
1120 }
1121 if (this->done()) {
1122 SkDebugf(" done");
1123 }
1124 return this != coin;
1125}
1126
1127const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1128 return this->contour()->debugAngle(id);
1129}
1130
caryclark55888e42016-07-18 10:01:36 -07001131
1132const SkOpCoincidence* SkOpSegment::debugCoincidence() const {
1133 return this->contour()->debugCoincidence();
1134}
1135
caryclark30b9fdd2016-08-31 14:36:29 -07001136SkOpContour* SkOpSegment::debugContour(int id) const {
caryclark54359292015-03-26 07:52:43 -07001137 return this->contour()->debugContour(id);
1138}
1139
1140const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1141 return this->contour()->debugPtT(id);
1142}
1143
1144const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1145 return this->contour()->debugSegment(id);
1146}
1147
1148const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1149 return this->contour()->debugSpan(id);
1150}
1151
1152void SkOpSegment::dump() const {
1153 SkDebugf("%.*s", contour()->debugIndent(), " ");
1154 this->dumpPts();
1155 const SkOpSpanBase* span = &fHead;
1156 contour()->indentDump();
1157 do {
1158 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1159 span->ptT()->dumpBase();
1160 span->dumpBase();
1161 SkDebugf("\n");
1162 } while (!span->final() && (span = span->upCast()->next()));
1163 contour()->outdentDump();
1164}
1165
1166void SkOpSegment::dumpAll() const {
1167 SkDebugf("%.*s", contour()->debugIndent(), " ");
1168 this->dumpPts();
1169 const SkOpSpanBase* span = &fHead;
1170 contour()->indentDump();
1171 do {
1172 span->dumpAll();
1173 } while (!span->final() && (span = span->upCast()->next()));
1174 contour()->outdentDump();
1175}
1176
1177void SkOpSegment::dumpAngles() const {
1178 SkDebugf("seg=%d\n", debugID());
1179 const SkOpSpanBase* span = &fHead;
1180 do {
1181 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001182 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001183 if (fAngle) {
1184 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1185 fAngle->dumpTo(this, tAngle);
1186 }
1187 if (tAngle) {
1188 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1189 tAngle->dumpTo(this, fAngle);
1190 }
1191 } while (!span->final() && (span = span->upCast()->next()));
1192}
1193
1194void SkOpSegment::dumpCoin() const {
1195 const SkOpSpan* span = &fHead;
1196 do {
1197 span->dumpCoin();
1198 } while ((span = span->next()->upCastable()));
1199}
1200
caryclark26ad22a2015-10-16 09:03:38 -07001201void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001202 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001203 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001204 if (fVerb == SkPath::kConic_Verb) {
1205 SkDebugf("{");
1206 }
caryclark54359292015-03-26 07:52:43 -07001207 int index = 0;
1208 do {
1209 SkDPoint::Dump(fPts[index]);
1210 SkDebugf(", ");
1211 } while (++index < last);
1212 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001213 SkDebugf("}}");
1214 if (fVerb == SkPath::kConic_Verb) {
1215 SkDebugf(", %1.9gf}", fWeight);
1216 }
caryclark624637c2015-05-11 07:21:27 -07001217}
1218
caryclark26ad22a2015-10-16 09:03:38 -07001219void SkOpSegment::dumpPts(const char* prefix) const {
1220 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001221 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001222}
1223
1224void SkCoincidentSpans::dump() const {
1225 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1226 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1227 fCoinPtTStart->dumpBase();
1228 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1229 fCoinPtTEnd->dumpBase();
1230 if (fCoinPtTStart->segment()->operand()) {
1231 SkDebugf(" operand");
1232 }
1233 if (fCoinPtTStart->segment()->isXor()) {
1234 SkDebugf(" xor");
1235 }
1236 SkDebugf("\n");
1237 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1238 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1239 fOppPtTStart->dumpBase();
1240 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1241 fOppPtTEnd->dumpBase();
1242 if (fOppPtTStart->segment()->operand()) {
1243 SkDebugf(" operand");
1244 }
1245 if (fOppPtTStart->segment()->isXor()) {
1246 SkDebugf(" xor");
1247 }
1248 SkDebugf("\n");
1249}
1250
1251void SkOpCoincidence::dump() const {
1252 SkCoincidentSpans* span = fHead;
1253 while (span) {
1254 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001255 span = span->next();
caryclark54359292015-03-26 07:52:43 -07001256 }
caryclark26ad22a2015-10-16 09:03:38 -07001257 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001258 return;
1259 }
1260 SkDebugf("top:\n");
1261 span = fTop;
caryclark55888e42016-07-18 10:01:36 -07001262 int count = 0;
caryclark27c8eb82015-07-06 11:38:33 -07001263 while (span) {
1264 span->dump();
caryclark55888e42016-07-18 10:01:36 -07001265 span = span->next();
1266 SkCoincidentSpans* check = fTop;
1267 ++count;
1268 for (int index = 0; index < count; ++index) {
1269 if (span == check) {
1270 SkDebugf("(loops to #%d)\n", index);
1271 return;
1272 }
1273 check = check->next();
1274 }
caryclark27c8eb82015-07-06 11:38:33 -07001275 }
caryclark54359292015-03-26 07:52:43 -07001276}
1277
caryclark624637c2015-05-11 07:21:27 -07001278void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001279 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001280 if (!fCount) {
1281 return;
1282 }
1283 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001284 SkDEBUGCODE(fDebugIndent = 0);
1285 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001286 do {
1287 segment->dump();
1288 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001289 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001290}
1291
caryclark624637c2015-05-11 07:21:27 -07001292void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001293 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001294 if (!fCount) {
1295 return;
1296 }
1297 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001298 SkDEBUGCODE(fDebugIndent = 0);
1299 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001300 do {
1301 segment->dumpAll();
1302 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001303 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001304}
1305
1306
1307void SkOpContour::dumpAngles() const {
1308 SkDebugf("contour=%d\n", this->debugID());
1309 const SkOpSegment* segment = &fHead;
1310 do {
1311 SkDebugf(" seg=%d ", segment->debugID());
1312 segment->dumpAngles();
1313 } while ((segment = segment->next()));
1314}
1315
1316void SkOpContour::dumpPt(int index) const {
1317 const SkOpSegment* segment = &fHead;
1318 do {
1319 if (segment->debugID() == index) {
1320 segment->dumpPts();
1321 }
1322 } while ((segment = segment->next()));
1323}
1324
caryclark26ad22a2015-10-16 09:03:38 -07001325void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001326 SkDebugf("contour=%d\n", this->debugID());
1327 const SkOpSegment* segment = &fHead;
1328 do {
caryclark26ad22a2015-10-16 09:03:38 -07001329 SkDebugf(" %s=%d ", prefix, segment->debugID());
1330 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001331 } while ((segment = segment->next()));
1332}
1333
caryclark26ad22a2015-10-16 09:03:38 -07001334void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001335 if (!this->fCount) {
1336 SkDebugf("<empty>\n");
1337 return;
1338 }
1339 const SkOpSegment* segment = &fHead;
1340 do {
caryclark26ad22a2015-10-16 09:03:38 -07001341 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001342 } while ((segment = segment->next()));
1343}
1344
1345void SkOpContour::dumpSegment(int index) const {
1346 debugSegment(index)->dump();
1347}
1348
caryclark26ad22a2015-10-16 09:03:38 -07001349void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001350 bool firstOp = false;
1351 const SkOpContour* c = this;
1352 do {
Ben Wagner3f985522017-10-09 10:47:47 -04001353 if (!firstOp && c->operand()) {
caryclark54359292015-03-26 07:52:43 -07001354#if DEBUG_ACTIVE_OP
1355 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1356#endif
1357 firstOp = true;
1358 }
caryclark26ad22a2015-10-16 09:03:38 -07001359 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001360 } while ((c = c->next()));
1361}
1362
1363void SkOpContour::dumpSpan(int index) const {
1364 debugSpan(index)->dump();
1365}
1366
1367void SkOpContour::dumpSpans() const {
1368 SkDebugf("contour=%d\n", this->debugID());
1369 const SkOpSegment* segment = &fHead;
1370 do {
1371 SkDebugf(" seg=%d ", segment->debugID());
1372 segment->dump();
1373 } while ((segment = segment->next()));
1374}
1375
caryclark03b03ca2015-04-23 09:13:37 -07001376void SkOpCurve::dump() const {
1377 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1378 SkDebugf("{{");
1379 int index;
1380 for (index = 0; index <= count - 1; ++index) {
1381 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1382 }
1383 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1384}
1385
caryclark54359292015-03-26 07:52:43 -07001386#ifdef SK_DEBUG
1387const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001388 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001389 do {
1390 const SkOpSegment* segment = contour->first();
1391 while (segment) {
1392 const SkOpSpan* span = segment->head();
1393 do {
1394 SkOpAngle* angle = span->fromAngle();
1395 if (angle && angle->debugID() == id) {
1396 return angle;
1397 }
1398 angle = span->toAngle();
1399 if (angle && angle->debugID() == id) {
1400 return angle;
1401 }
1402 } while ((span = span->next()->upCastable()));
1403 const SkOpSpanBase* tail = segment->tail();
1404 SkOpAngle* angle = tail->fromAngle();
1405 if (angle && angle->debugID() == id) {
1406 return angle;
1407 }
1408 segment = segment->next();
1409 }
1410 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001411 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001412}
1413
caryclark30b9fdd2016-08-31 14:36:29 -07001414SkOpContour* SkOpGlobalState::debugContour(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001415 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001416 do {
1417 if (contour->debugID() == id) {
1418 return contour;
1419 }
1420 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001421 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001422}
1423
1424const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001425 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001426 do {
1427 const SkOpSegment* segment = contour->first();
1428 while (segment) {
1429 const SkOpSpan* span = segment->head();
1430 do {
1431 const SkOpPtT* ptT = span->ptT();
1432 if (ptT->debugMatchID(id)) {
1433 return ptT;
1434 }
1435 } while ((span = span->next()->upCastable()));
1436 const SkOpSpanBase* tail = segment->tail();
1437 const SkOpPtT* ptT = tail->ptT();
1438 if (ptT->debugMatchID(id)) {
1439 return ptT;
1440 }
1441 segment = segment->next();
1442 }
1443 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001444 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001445}
1446
1447const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001448 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001449 do {
1450 const SkOpSegment* segment = contour->first();
1451 while (segment) {
1452 if (segment->debugID() == id) {
1453 return segment;
1454 }
1455 segment = segment->next();
1456 }
1457 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001458 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001459}
1460
1461const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001462 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001463 do {
1464 const SkOpSegment* segment = contour->first();
1465 while (segment) {
1466 const SkOpSpan* span = segment->head();
1467 do {
1468 if (span->debugID() == id) {
1469 return span;
1470 }
1471 } while ((span = span->next()->upCastable()));
1472 const SkOpSpanBase* tail = segment->tail();
1473 if (tail->debugID() == id) {
1474 return tail;
1475 }
1476 segment = segment->next();
1477 }
1478 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001479 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001480}
1481#endif
1482
caryclark54359292015-03-26 07:52:43 -07001483#if DEBUG_T_SECT_DUMP > 1
1484int gDumpTSectNum;
1485#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -04001486
1487// global path dumps for msvs Visual Studio 17 to use from Immediate Window
1488namespace SkOpDebug {
1489
1490 void Dump(const SkOpContour& contour) {
1491 contour.dump();
1492 }
1493
1494 void DumpAll(const SkOpContour& contour) {
1495 contour.dumpAll();
1496 }
1497
1498 void DumpAngles(const SkOpContour& contour) {
1499 contour.dumpAngles();
1500 }
1501
1502 void DumpContours(const SkOpContour& contour) {
1503 contour.dumpContours();
1504 }
1505
1506 void DumpContoursAll(const SkOpContour& contour) {
1507 contour.dumpContoursAll();
1508 }
1509
1510 void DumpContoursAngles(const SkOpContour& contour) {
1511 contour.dumpContoursAngles();
1512 }
1513
1514 void DumpContoursPts(const SkOpContour& contour) {
1515 contour.dumpContoursPts();
1516 }
1517
1518 void DumpContoursPt(const SkOpContour& contour, int segmentID) {
1519 contour.dumpContoursPt(segmentID);
1520 }
1521
1522 void DumpContoursSegment(const SkOpContour& contour, int segmentID) {
1523 contour.dumpContoursSegment(segmentID);
1524 }
1525
1526 void DumpContoursSpan(const SkOpContour& contour, int segmentID) {
1527 contour.dumpContoursSpan(segmentID);
1528 }
1529
1530 void DumpContoursSpans(const SkOpContour& contour) {
1531 contour.dumpContoursSpans();
1532 }
1533
1534 void DumpPt(const SkOpContour& contour, int pt) {
1535 contour.dumpPt(pt);
1536 }
1537
1538 void DumpPts(const SkOpContour& contour, const char* prefix) {
1539 contour.dumpPts(prefix);
1540 }
1541
1542 void DumpSegment(const SkOpContour& contour, int seg) {
1543 contour.dumpSegment(seg);
1544 }
1545
1546 void DumpSegments(const SkOpContour& contour, const char* prefix, SkPathOp op) {
1547 contour.dumpSegments(prefix, op);
1548 }
1549
1550 void DumpSpan(const SkOpContour& contour, int span) {
1551 contour.dumpSpan(span);
1552 }
1553
1554 void DumpSpans(const SkOpContour& contour ) {
1555 contour.dumpSpans();
1556 }
1557
1558 void Dump(const SkOpSegment& segment) {
1559 segment.dump();
1560 }
1561
1562 void DumpAll(const SkOpSegment& segment) {
1563 segment.dumpAll();
1564 }
1565
1566 void DumpAngles(const SkOpSegment& segment) {
1567 segment.dumpAngles();
1568 }
1569
1570 void DumpCoin(const SkOpSegment& segment) {
1571 segment.dumpCoin();
1572 }
1573
1574 void DumpPts(const SkOpSegment& segment, const char* prefix) {
1575 segment.dumpPts(prefix);
1576 }
1577
1578 void Dump(const SkOpPtT& ptT) {
1579 ptT.dump();
1580 }
1581
1582 void DumpAll(const SkOpPtT& ptT) {
1583 ptT.dumpAll();
1584 }
1585
1586 void Dump(const SkOpSpanBase& spanBase) {
1587 spanBase.dump();
1588 }
1589
1590 void DumpCoin(const SkOpSpanBase& spanBase) {
1591 spanBase.dumpCoin();
1592 }
1593
1594 void DumpAll(const SkOpSpanBase& spanBase) {
1595 spanBase.dumpAll();
1596 }
1597
1598 void DumpCoin(const SkOpSpan& span) {
1599 span.dumpCoin();
1600 }
1601
1602 bool DumpSpan(const SkOpSpan& span) {
1603 return span.dumpSpan();
1604 }
1605
1606 void Dump(const SkDConic& conic) {
1607 conic.dump();
1608 }
1609
1610 void DumpID(const SkDConic& conic, int id) {
1611 conic.dumpID(id);
1612 }
1613
1614 void Dump(const SkDCubic& cubic) {
1615 cubic.dump();
1616 }
1617
1618 void DumpID(const SkDCubic& cubic, int id) {
1619 cubic.dumpID(id);
1620 }
1621
1622 void Dump(const SkDLine& line) {
1623 line.dump();
1624 }
1625
1626 void DumpID(const SkDLine& line, int id) {
1627 line.dumpID(id);
1628 }
1629
1630 void Dump(const SkDQuad& quad) {
1631 quad.dump();
1632 }
1633
1634 void DumpID(const SkDQuad& quad, int id) {
1635 quad.dumpID(id);
1636 }
1637
1638 void Dump(const SkDPoint& point) {
1639 point.dump();
1640 }
1641
1642// dummy definitions to fool msvs Visual Studio 2018 Immediate Window
1643#define DummyDefinitions(a, b) \
1644 \
1645 void Dump(const SkDebugTCoincident##a##b& curve) { \
1646 ((const SkTCoincident<SkD##a, SkD##b>& ) curve).dump(); \
1647 } \
1648 \
1649 void Dump(const SkDebugTSect##a##b& curve) { \
1650 ((const SkTSect<SkD##a, SkD##b>& ) curve).dump(); \
1651 } \
1652 \
1653 void DumpBoth(const SkDebugTSect##a##b& curve, SkDebugTSect##a##b* opp) { \
1654 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBoth((SkTSect<SkD##b, SkD##a>* ) opp); \
1655 } \
1656 \
1657 void DumpBounded(const SkDebugTSect##a##b& curve, int id) { \
1658 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1659 } \
1660 \
1661 void DumpBounds(const SkDebugTSect##a##b& curve) { \
1662 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1663 } \
1664 \
1665 void DumpCoin(const SkDebugTSect##a##b& curve) { \
1666 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1667 } \
1668 \
1669 void DumpCoinCurves(const SkDebugTSect##a##b& curve) { \
1670 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCoinCurves(); \
1671 } \
1672 \
1673 void DumpCurves(const SkDebugTSect##a##b& curve) { \
1674 ((const SkTSect<SkD##a, SkD##b>& ) curve).dumpCurves(); \
1675 } \
1676 \
1677 void Dump(const SkDebugTSpan##a##b& curve) { \
1678 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dump(); \
1679 } \
1680 \
1681 void DumpAll(const SkDebugTSpan##a##b& curve) { \
1682 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpAll(); \
1683 } \
1684 \
1685 void DumpBounded(const SkDebugTSpan##a##b& curve, int id) { \
1686 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounded(id); \
1687 } \
1688 \
1689 void DumpBounds(const SkDebugTSpan##a##b& curve) { \
1690 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpBounds(); \
1691 } \
1692 \
1693 void DumpCoin(const SkDebugTSpan##a##b& curve) { \
1694 ((const SkTSpan<SkD##a, SkD##b>& ) curve).dumpCoin(); \
1695 }
1696
1697 DummyDefinitions(Quad, Quad);
1698 DummyDefinitions(Conic, Quad);
1699 DummyDefinitions(Conic, Conic);
1700 DummyDefinitions(Cubic, Quad);
1701 DummyDefinitions(Cubic, Conic);
1702 DummyDefinitions(Cubic, Cubic);
1703
1704#undef DummyDefinitions
1705}