blob: 0f96ef4f885b317a84ac918985e211f809b7a274 [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
caryclark27c8eb82015-07-06 11:38:33 -070016extern bool FLAGS_runFail;
17
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000018inline void DebugDumpDouble(double x) {
19 if (x == floor(x)) {
20 SkDebugf("%.0f", x);
21 } else {
22 SkDebugf("%1.19g", x);
23 }
24}
25
26inline void DebugDumpFloat(float x) {
27 if (x == floorf(x)) {
28 SkDebugf("%.0f", x);
29 } else {
30 SkDebugf("%1.9gf", x);
31 }
32}
33
caryclark65f55312014-11-13 06:58:52 -080034inline void DebugDumpHexFloat(float x) {
35 SkDebugf("SkBits2Float(0x%08x)", SkFloat2Bits(x));
36}
caryclark19eb3b22014-07-18 05:08:14 -070037
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000038// if not defined by PathOpsDebug.cpp ...
39#if !defined SK_DEBUG && FORCE_RELEASE
40bool SkPathOpsDebug::ValidWind(int wind) {
41 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
42}
43
44void SkPathOpsDebug::WindingPrintf(int wind) {
45 if (wind == SK_MinS32) {
46 SkDebugf("?");
47 } else {
48 SkDebugf("%d", wind);
49 }
50}
51#endif
52
caryclark1049f122015-04-20 08:31:59 -070053void SkDConic::dump() const {
caryclark54359292015-03-26 07:52:43 -070054 dumpInner();
caryclark1049f122015-04-20 08:31:59 -070055 SkDebugf("},\n");
56}
57
58void SkDConic::dumpID(int id) const {
59 dumpInner();
60 SkDebugf("} id=%d\n", id);
61}
62
63void SkDConic::dumpInner() const {
caryclark26ad22a2015-10-16 09:03:38 -070064 SkDebugf("{");
65 fPts.dumpInner();
66 SkDebugf("}}, %1.9gf", fWeight);
caryclark1049f122015-04-20 08:31:59 -070067}
68
69void SkDCubic::dump() const {
70 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070071 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070072}
73
caryclark54359292015-03-26 07:52:43 -070074void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070075 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070076 SkDebugf("}} id=%d\n", id);
reed0dc4dd62015-03-24 13:55:33 -070077}
78
caryclark54359292015-03-26 07:52:43 -070079static inline bool double_is_NaN(double x) { return x != x; }
80
81void SkDCubic::dumpInner() const {
82 SkDebugf("{{");
83 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070084 do {
caryclark54359292015-03-26 07:52:43 -070085 if (index != 0) {
86 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
87 return;
reed0dc4dd62015-03-24 13:55:33 -070088 }
caryclark54359292015-03-26 07:52:43 -070089 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -070090 }
caryclark54359292015-03-26 07:52:43 -070091 fPts[index].dump();
92 } while (++index < 3);
93 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -070094 return;
95 }
caryclark54359292015-03-26 07:52:43 -070096 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -070097 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000098}
99
caryclark1049f122015-04-20 08:31:59 -0700100void SkDCurve::dumpID(int id) const {
101#ifndef SK_RELEASE
102 switch(fVerb) {
103 case SkPath::kLine_Verb:
104 fLine.dumpID(id);
105 break;
106 case SkPath::kQuad_Verb:
107 fQuad.dumpID(id);
108 break;
109 case SkPath::kConic_Verb:
110 fConic.dumpID(id);
111 break;
112 case SkPath::kCubic_Verb:
113 fCubic.dumpID(id);
114 break;
115 default:
116 SkASSERT(0);
117 }
118#else
119 fCubic.dumpID(id);
120#endif
121}
122
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000123void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700124 this->dumpInner();
125 SkDebugf("}},\n");
126}
127
128void SkDLine::dumpID(int id) const {
129 this->dumpInner();
130 SkDebugf("}} id=%d\n", id);
131}
132
133void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000134 SkDebugf("{{");
135 fPts[0].dump();
136 SkDebugf(", ");
137 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000138}
139
140void SkDPoint::dump() const {
141 SkDebugf("{");
142 DebugDumpDouble(fX);
143 SkDebugf(", ");
144 DebugDumpDouble(fY);
145 SkDebugf("}");
146}
147
148void SkDPoint::Dump(const SkPoint& pt) {
149 SkDebugf("{");
150 DebugDumpFloat(pt.fX);
151 SkDebugf(", ");
152 DebugDumpFloat(pt.fY);
153 SkDebugf("}");
154}
155
caryclark65f55312014-11-13 06:58:52 -0800156void SkDPoint::DumpHex(const SkPoint& pt) {
157 SkDebugf("{");
158 DebugDumpHexFloat(pt.fX);
159 SkDebugf(", ");
160 DebugDumpHexFloat(pt.fY);
161 SkDebugf("}");
162}
163
164void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700165 dumpInner();
166 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800167}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000168
caryclark54359292015-03-26 07:52:43 -0700169void SkDQuad::dumpID(int id) const {
170 dumpInner();
171 SkDebugf("}} id=%d\n", id);
172}
173
174void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000175 SkDebugf("{{");
176 int index = 0;
177 do {
178 fPts[index].dump();
179 SkDebugf(", ");
180 } while (++index < 2);
181 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000182}
183
caryclark54359292015-03-26 07:52:43 -0700184void SkIntersections::dump() const {
185 SkDebugf("used=%d of %d", fUsed, fMax);
186 for (int index = 0; index < fUsed; ++index) {
187 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
188 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
189 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
190 fPt[index].fX, fPt[index].fY);
191 if (index < 2 && fNearlySame[index]) {
192 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000193 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000194 }
195 SkDebugf("\n");
196}
197
caryclark54359292015-03-26 07:52:43 -0700198const SkOpAngle* SkPathOpsDebug::DebugAngleAngle(const SkOpAngle* angle, int id) {
199 return angle->debugAngle(id);
200}
201
202SkOpContour* SkPathOpsDebug::DebugAngleContour(SkOpAngle* angle, int id) {
203 return angle->debugContour(id);
204}
205
206const SkOpPtT* SkPathOpsDebug::DebugAnglePtT(const SkOpAngle* angle, int id) {
207 return angle->debugPtT(id);
208}
209
210const SkOpSegment* SkPathOpsDebug::DebugAngleSegment(const SkOpAngle* angle, int id) {
211 return angle->debugSegment(id);
212}
213
214const SkOpSpanBase* SkPathOpsDebug::DebugAngleSpan(const SkOpAngle* angle, int id) {
215 return angle->debugSpan(id);
216}
217
218const SkOpAngle* SkPathOpsDebug::DebugContourAngle(SkOpContour* contour, int id) {
219 return contour->debugAngle(id);
220}
221
222SkOpContour* SkPathOpsDebug::DebugContourContour(SkOpContour* contour, int id) {
223 return contour->debugContour(id);
224}
225
226const SkOpPtT* SkPathOpsDebug::DebugContourPtT(SkOpContour* contour, int id) {
227 return contour->debugPtT(id);
228}
229
230const SkOpSegment* SkPathOpsDebug::DebugContourSegment(SkOpContour* contour, int id) {
231 return contour->debugSegment(id);
232}
233
234const SkOpSpanBase* SkPathOpsDebug::DebugContourSpan(SkOpContour* contour, int id) {
235 return contour->debugSpan(id);
236}
237
caryclark27c8eb82015-07-06 11:38:33 -0700238const SkOpAngle* SkPathOpsDebug::DebugCoincidenceAngle(SkOpCoincidence* coin, int id) {
239 return coin->debugAngle(id);
240}
241
242SkOpContour* SkPathOpsDebug::DebugCoincidenceContour(SkOpCoincidence* coin, int id) {
243 return coin->debugContour(id);
244}
245
246const SkOpPtT* SkPathOpsDebug::DebugCoincidencePtT(SkOpCoincidence* coin, int id) {
247 return coin->debugPtT(id);
248}
249
250const SkOpSegment* SkPathOpsDebug::DebugCoincidenceSegment(SkOpCoincidence* coin, int id) {
251 return coin->debugSegment(id);
252}
253
254const SkOpSpanBase* SkPathOpsDebug::DebugCoincidenceSpan(SkOpCoincidence* coin, int id) {
255 return coin->debugSpan(id);
256}
257
caryclark54359292015-03-26 07:52:43 -0700258const SkOpAngle* SkPathOpsDebug::DebugPtTAngle(const SkOpPtT* ptT, int id) {
259 return ptT->debugAngle(id);
260}
261
262SkOpContour* SkPathOpsDebug::DebugPtTContour(SkOpPtT* ptT, int id) {
263 return ptT->debugContour(id);
264}
265
266const SkOpPtT* SkPathOpsDebug::DebugPtTPtT(const SkOpPtT* ptT, int id) {
267 return ptT->debugPtT(id);
268}
269
270const SkOpSegment* SkPathOpsDebug::DebugPtTSegment(const SkOpPtT* ptT, int id) {
271 return ptT->debugSegment(id);
272}
273
274const SkOpSpanBase* SkPathOpsDebug::DebugPtTSpan(const SkOpPtT* ptT, int id) {
275 return ptT->debugSpan(id);
276}
277
278const SkOpAngle* SkPathOpsDebug::DebugSegmentAngle(const SkOpSegment* span, int id) {
279 return span->debugAngle(id);
280}
281
282SkOpContour* SkPathOpsDebug::DebugSegmentContour(SkOpSegment* span, int id) {
283 return span->debugContour(id);
284}
285
286const SkOpPtT* SkPathOpsDebug::DebugSegmentPtT(const SkOpSegment* span, int id) {
287 return span->debugPtT(id);
288}
289
290const SkOpSegment* SkPathOpsDebug::DebugSegmentSegment(const SkOpSegment* span, int id) {
291 return span->debugSegment(id);
292}
293
294const SkOpSpanBase* SkPathOpsDebug::DebugSegmentSpan(const SkOpSegment* span, int id) {
295 return span->debugSpan(id);
296}
297
298const SkOpAngle* SkPathOpsDebug::DebugSpanAngle(const SkOpSpanBase* span, int id) {
299 return span->debugAngle(id);
300}
301
302SkOpContour* SkPathOpsDebug::DebugSpanContour(SkOpSpanBase* span, int id) {
303 return span->debugContour(id);
304}
305
306const SkOpPtT* SkPathOpsDebug::DebugSpanPtT(const SkOpSpanBase* span, int id) {
307 return span->debugPtT(id);
308}
309
310const SkOpSegment* SkPathOpsDebug::DebugSpanSegment(const SkOpSpanBase* span, int id) {
311 return span->debugSegment(id);
312}
313
314const SkOpSpanBase* SkPathOpsDebug::DebugSpanSpan(const SkOpSpanBase* span, int id) {
315 return span->debugSpan(id);
316}
317
caryclark624637c2015-05-11 07:21:27 -0700318void SkOpContour::dumpContours() const {
319 SkOpContour* contour = this->globalState()->contourHead();
320 do {
321 contour->dump();
322 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000323}
324
caryclark624637c2015-05-11 07:21:27 -0700325void SkOpContour::dumpContoursAll() const {
326 SkOpContour* contour = this->globalState()->contourHead();
327 do {
328 contour->dumpAll();
329 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000330}
331
caryclark624637c2015-05-11 07:21:27 -0700332void SkOpContour::dumpContoursAngles() const {
333 SkOpContour* contour = this->globalState()->contourHead();
334 do {
335 contour->dumpAngles();
336 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000337}
338
caryclark624637c2015-05-11 07:21:27 -0700339void SkOpContour::dumpContoursPts() const {
340 SkOpContour* contour = this->globalState()->contourHead();
341 do {
342 contour->dumpPts();
343 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000344}
345
caryclark624637c2015-05-11 07:21:27 -0700346void SkOpContour::dumpContoursPt(int segmentID) const {
347 SkOpContour* contour = this->globalState()->contourHead();
348 do {
349 contour->dumpPt(segmentID);
350 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000351}
352
caryclark624637c2015-05-11 07:21:27 -0700353void SkOpContour::dumpContoursSegment(int segmentID) const {
354 SkOpContour* contour = this->globalState()->contourHead();
355 do {
356 contour->dumpSegment(segmentID);
357 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000358}
359
caryclark624637c2015-05-11 07:21:27 -0700360void SkOpContour::dumpContoursSpan(int spanID) const {
361 SkOpContour* contour = this->globalState()->contourHead();
362 do {
363 contour->dumpSpan(spanID);
364 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000365}
366
caryclark624637c2015-05-11 07:21:27 -0700367void SkOpContour::dumpContoursSpans() const {
368 SkOpContour* contour = this->globalState()->contourHead();
369 do {
370 contour->dumpSpans();
371 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000372}
373
caryclark1049f122015-04-20 08:31:59 -0700374template <typename TCurve, typename OppCurve>
375const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700376 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000377}
378
caryclark1049f122015-04-20 08:31:59 -0700379void DontCallDebugSpan(int id);
380void DontCallDebugSpan(int id) { // exists to instantiate the templates
381 SkDQuad quad;
382 SkDConic conic;
383 SkDCubic cubic;
384 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
385 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
386 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
387 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
388 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
389 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
390 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
391 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
392 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
393 DebugSpan(&q1q2, id);
394 DebugSpan(&q1k2, id);
395 DebugSpan(&q1c2, id);
396 DebugSpan(&k1q2, id);
397 DebugSpan(&k1k2, id);
398 DebugSpan(&k1c2, id);
399 DebugSpan(&c1q2, id);
400 DebugSpan(&c1k2, id);
401 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000402}
403
caryclark1049f122015-04-20 08:31:59 -0700404template <typename TCurve, typename OppCurve>
405const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700406 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000407}
408
caryclark1049f122015-04-20 08:31:59 -0700409void DontCallDebugT(double t);
410void DontCallDebugT(double t) { // exists to instantiate the templates
411 SkDQuad quad;
412 SkDConic conic;
413 SkDCubic cubic;
414 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
415 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
416 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
417 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
418 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
419 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
420 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
421 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
422 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
423 DebugT(&q1q2, t);
424 DebugT(&q1k2, t);
425 DebugT(&q1c2, t);
426 DebugT(&k1q2, t);
427 DebugT(&k1k2, t);
428 DebugT(&k1c2, t);
429 DebugT(&c1q2, t);
430 DebugT(&c1k2, t);
431 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700432}
433
caryclark1049f122015-04-20 08:31:59 -0700434template <typename TCurve, typename OppCurve>
435void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700436 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000437}
438
caryclark1049f122015-04-20 08:31:59 -0700439void DontCallDumpTSect();
440void DontCallDumpTSect() { // exists to instantiate the templates
441 SkDQuad quad;
442 SkDConic conic;
443 SkDCubic cubic;
444 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
445 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
446 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
447 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
448 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
449 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
450 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
451 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
452 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
453 Dump(&q1q2);
454 Dump(&q1k2);
455 Dump(&q1c2);
456 Dump(&k1q2);
457 Dump(&k1k2);
458 Dump(&k1c2);
459 Dump(&c1q2);
460 Dump(&c1k2);
461 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000462}
463
caryclark1049f122015-04-20 08:31:59 -0700464template <typename TCurve, typename OppCurve>
465void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700466 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700467}
468
caryclark1049f122015-04-20 08:31:59 -0700469void DontCallDumpBoth();
470void DontCallDumpBoth() { // exists to instantiate the templates
471 SkDQuad quad;
472 SkDConic conic;
473 SkDCubic cubic;
474 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
475 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
476 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
477 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
478 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
479 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
480 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
481 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
482 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
483 DumpBoth(&q1q2, &q1q2);
484 DumpBoth(&q1k2, &k1q2);
485 DumpBoth(&q1c2, &c1q2);
486 DumpBoth(&k1q2, &q1k2);
487 DumpBoth(&k1k2, &k1k2);
488 DumpBoth(&k1c2, &c1k2);
489 DumpBoth(&c1q2, &q1c2);
490 DumpBoth(&c1k2, &k1c2);
491 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700492}
493
caryclark1049f122015-04-20 08:31:59 -0700494template <typename TCurve, typename OppCurve>
495void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
496 sect1->dumpBounded(id);
497}
498
499void DontCallDumpBounded();
500void DontCallDumpBounded() {
501 SkDQuad quad;
502 SkDConic conic;
503 SkDCubic cubic;
504 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
505 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
506 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
507 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
508 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
509 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
510 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
511 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
512 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
513 DumpBounded(&q1q2, 0);
514 DumpBounded(&q1k2, 0);
515 DumpBounded(&q1c2, 0);
516 DumpBounded(&k1q2, 0);
517 DumpBounded(&k1k2, 0);
518 DumpBounded(&k1c2, 0);
519 DumpBounded(&c1q2, 0);
520 DumpBounded(&c1k2, 0);
521 DumpBounded(&c1c2, 0);
522}
523
524template <typename TCurve, typename OppCurve>
525void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
526 sect1->dumpBounds();
527}
528
529void DontCallDumpBounds();
530void DontCallDumpBounds() {
531 SkDQuad quad;
532 SkDConic conic;
533 SkDCubic cubic;
534 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
535 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
536 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
537 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
538 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
539 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
540 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
541 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
542 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
543 DumpBounds(&q1q2);
544 DumpBounds(&q1k2);
545 DumpBounds(&q1c2);
546 DumpBounds(&k1q2);
547 DumpBounds(&k1k2);
548 DumpBounds(&k1c2);
549 DumpBounds(&c1q2);
550 DumpBounds(&c1k2);
551 DumpBounds(&c1c2);
552}
553
554template <typename TCurve, typename OppCurve>
555void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700556 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700557}
558
caryclark1049f122015-04-20 08:31:59 -0700559void DontCallDumpCoin();
560void DontCallDumpCoin() { // exists to instantiate the templates
561 SkDQuad quad;
562 SkDConic conic;
563 SkDCubic cubic;
564 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
565 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
566 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
567 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
568 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
569 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
570 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
571 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
572 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
573 DumpCoin(&q1q2);
574 DumpCoin(&q1k2);
575 DumpCoin(&q1c2);
576 DumpCoin(&k1q2);
577 DumpCoin(&k1k2);
578 DumpCoin(&k1c2);
579 DumpCoin(&c1q2);
580 DumpCoin(&c1k2);
581 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000582}
583
caryclark1049f122015-04-20 08:31:59 -0700584template <typename TCurve, typename OppCurve>
585void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700586 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000587}
588
caryclark1049f122015-04-20 08:31:59 -0700589void DontCallDumpCoinCurves();
590void DontCallDumpCoinCurves() { // exists to instantiate the templates
591 SkDQuad quad;
592 SkDConic conic;
593 SkDCubic cubic;
594 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
595 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
596 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
597 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
598 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
599 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
600 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
601 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
602 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
603 DumpCoinCurves(&q1q2);
604 DumpCoinCurves(&q1k2);
605 DumpCoinCurves(&q1c2);
606 DumpCoinCurves(&k1q2);
607 DumpCoinCurves(&k1k2);
608 DumpCoinCurves(&k1c2);
609 DumpCoinCurves(&c1q2);
610 DumpCoinCurves(&c1k2);
611 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000612}
613
caryclark1049f122015-04-20 08:31:59 -0700614template <typename TCurve, typename OppCurve>
615void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700616 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000617}
618
caryclark1049f122015-04-20 08:31:59 -0700619void DontCallDumpCurves();
620void DontCallDumpCurves() { // exists to instantiate the templates
621 SkDQuad quad;
622 SkDConic conic;
623 SkDCubic cubic;
624 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
625 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
626 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
627 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
628 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
629 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
630 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
631 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
632 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
633 DumpCurves(&q1q2);
634 DumpCurves(&q1k2);
635 DumpCurves(&q1c2);
636 DumpCurves(&k1q2);
637 DumpCurves(&k1k2);
638 DumpCurves(&k1c2);
639 DumpCurves(&c1q2);
640 DumpCurves(&c1k2);
641 DumpCurves(&c1c2);
642}
643
644template <typename TCurve, typename OppCurve>
645void Dump(const SkTSpan<TCurve, OppCurve>* span) {
646 span->dump();
647}
648
649void DontCallDumpTSpan();
650void DontCallDumpTSpan() { // exists to instantiate the templates
651 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
652 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
653 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
654 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
655 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
656 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
657 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
658 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
659 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
660 Dump(&q1q2);
661 Dump(&q1k2);
662 Dump(&q1c2);
663 Dump(&k1q2);
664 Dump(&k1k2);
665 Dump(&k1c2);
666 Dump(&c1q2);
667 Dump(&c1k2);
668 Dump(&c1c2);
669}
670
671template <typename TCurve, typename OppCurve>
caryclark26ad22a2015-10-16 09:03:38 -0700672void DumpAll(const SkTSpan<TCurve, OppCurve>* span) {
673 span->dumpAll();
674}
675
676void DontCallDumpSpanAll();
677void DontCallDumpSpanAll() { // exists to instantiate the templates
678 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
679 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
680 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
681 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
682 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
683 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
684 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
685 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
686 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
687 DumpAll(&q1q2);
688 DumpAll(&q1k2);
689 DumpAll(&q1c2);
690 DumpAll(&k1q2);
691 DumpAll(&k1k2);
692 DumpAll(&k1c2);
693 DumpAll(&c1q2);
694 DumpAll(&c1k2);
695 DumpAll(&c1c2);
696}
697
698template <typename TCurve, typename OppCurve>
699void DumpBounded(const SkTSpan<TCurve, OppCurve>* span) {
700 span->dumpBounded(0);
701}
702
703void DontCallDumpSpanBounded();
704void DontCallDumpSpanBounded() { // exists to instantiate the templates
705 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
706 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
707 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
708 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
709 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
710 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
711 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
712 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
713 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
714 DumpBounded(&q1q2);
715 DumpBounded(&q1k2);
716 DumpBounded(&q1c2);
717 DumpBounded(&k1q2);
718 DumpBounded(&k1k2);
719 DumpBounded(&k1c2);
720 DumpBounded(&c1q2);
721 DumpBounded(&c1k2);
722 DumpBounded(&c1c2);
723}
724
725template <typename TCurve, typename OppCurve>
caryclark1049f122015-04-20 08:31:59 -0700726void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
727 span->dumpCoin();
728}
729
730void DontCallDumpSpanCoin();
731void DontCallDumpSpanCoin() { // exists to instantiate the templates
732 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
733 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
734 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
735 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
736 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
737 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
738 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
739 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
740 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
741 DumpCoin(&q1q2);
742 DumpCoin(&q1k2);
743 DumpCoin(&q1c2);
744 DumpCoin(&k1q2);
745 DumpCoin(&k1k2);
746 DumpCoin(&k1c2);
747 DumpCoin(&c1q2);
748 DumpCoin(&c1k2);
749 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700750}
751
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000752static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700753 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
754 quad1.dumpInner();
755 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000756 quad2.dump();
757 SkDebugf("</div>\n\n");
758}
759
760static void dumpTestTrailer() {
761 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
762 SkDebugf(" var testDivs = [\n");
763}
764
765static void dumpTestList(int testNo, double min) {
766 SkDebugf(" quad%d,", testNo);
767 if (min > 0) {
768 SkDebugf(" // %1.9g", min);
769 }
770 SkDebugf("\n");
771}
772
773void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
774 SkDebugf("\n");
775 dumpTestCase(quad1, quad2, testNo);
776 dumpTestTrailer();
777 dumpTestList(testNo, 0);
778 SkDebugf("\n");
779}
780
781void DumpT(const SkDQuad& quad, double t) {
782 SkDLine line = {{quad.ptAtT(t), quad[0]}};
783 line.dump();
784}
caryclark54359292015-03-26 07:52:43 -0700785
786const SkOpAngle* SkOpAngle::debugAngle(int id) const {
787 return this->segment()->debugAngle(id);
788}
789
790SkOpContour* SkOpAngle::debugContour(int id) {
791 return this->segment()->debugContour(id);
792}
793
794const SkOpPtT* SkOpAngle::debugPtT(int id) const {
795 return this->segment()->debugPtT(id);
796}
797
798const SkOpSegment* SkOpAngle::debugSegment(int id) const {
799 return this->segment()->debugSegment(id);
800}
801
caryclark624637c2015-05-11 07:21:27 -0700802int SkOpAngle::debugSign() const {
803 SkASSERT(fStart->t() != fEnd->t());
804 return fStart->t() < fEnd->t() ? -1 : 1;
805}
806
caryclark54359292015-03-26 07:52:43 -0700807const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
808 return this->segment()->debugSpan(id);
809}
810
811void SkOpAngle::dump() const {
812 dumpOne(true);
813 SkDebugf("\n");
814}
815
816void SkOpAngle::dumpOne(bool functionHeader) const {
817// fSegment->debugValidate();
818 const SkOpSegment* segment = this->segment();
819 const SkOpSpan& mSpan = *fStart->starter(fEnd);
820 if (functionHeader) {
821 SkDebugf("%s ", __FUNCTION__);
822 }
823 SkDebugf("[%d", segment->debugID());
824 SkDebugf("/%d", debugID());
825 SkDebugf("] next=");
826 if (fNext) {
827 SkDebugf("%d", fNext->fStart->segment()->debugID());
828 SkDebugf("/%d", fNext->debugID());
829 } else {
830 SkDebugf("?");
831 }
832 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
833 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
834 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700835 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700836
837 SkDebugf(" windSum=");
838 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
839 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
840 SkDebugf(" oppVal=%d", mSpan.oppValue());
841 SkDebugf(" oppSum=");
842 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
843 }
844 if (mSpan.done()) {
845 SkDebugf(" done");
846 }
847 if (unorderable()) {
848 SkDebugf(" unorderable");
849 }
850 if (segment->operand()) {
851 SkDebugf(" operand");
852 }
caryclark54359292015-03-26 07:52:43 -0700853}
854
855void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
856 const SkOpAngle* first = this;
857 const SkOpAngle* next = this;
858 const char* indent = "";
859 do {
860 SkDebugf("%s", indent);
861 next->dumpOne(false);
862 if (segment == next->fStart->segment()) {
863 if (this == fNext) {
864 SkDebugf(" << from");
865 }
866 if (to == fNext) {
867 SkDebugf(" << to");
868 }
869 }
870 SkDebugf("\n");
871 indent = " ";
872 next = next->fNext;
873 } while (next && next != first);
874}
875
876void SkOpAngle::dumpCurves() const {
877 const SkOpAngle* first = this;
878 const SkOpAngle* next = this;
879 do {
880 next->fCurvePart.dumpID(next->segment()->debugID());
881 next = next->fNext;
882 } while (next && next != first);
883}
884
885void SkOpAngle::dumpLoop() const {
886 const SkOpAngle* first = this;
887 const SkOpAngle* next = this;
888 do {
889 next->dumpOne(false);
890 SkDebugf("\n");
891 next = next->fNext;
892 } while (next && next != first);
893}
894
895void SkOpAngle::dumpTest() const {
896 const SkOpAngle* first = this;
897 const SkOpAngle* next = this;
898 do {
899 SkDebugf("{ ");
900 SkOpSegment* segment = next->segment();
901 segment->dumpPts();
902 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
903 next->start()->t(), next->end()->t());
904 next = next->fNext;
905 } while (next && next != first);
906}
907
908bool SkOpPtT::debugMatchID(int id) const {
909 int limit = this->debugLoopLimit(false);
910 int loop = 0;
911 const SkOpPtT* ptT = this;
912 do {
913 if (ptT->debugID() == id) {
914 return true;
915 }
916 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
917 return false;
918}
919
920const SkOpAngle* SkOpPtT::debugAngle(int id) const {
921 return this->span()->debugAngle(id);
922}
923
924SkOpContour* SkOpPtT::debugContour(int id) {
925 return this->span()->debugContour(id);
926}
927
928const SkOpPtT* SkOpPtT::debugPtT(int id) const {
929 return this->span()->debugPtT(id);
930}
931
932const SkOpSegment* SkOpPtT::debugSegment(int id) const {
933 return this->span()->debugSegment(id);
934}
935
936const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
937 return this->span()->debugSpan(id);
938}
939
940void SkOpPtT::dump() const {
941 SkDebugf("seg=%d span=%d ptT=%d",
942 this->segment()->debugID(), this->span()->debugID(), this->debugID());
943 this->dumpBase();
944 SkDebugf("\n");
945}
946
947void SkOpPtT::dumpAll() const {
948 contour()->indentDump();
949 const SkOpPtT* next = this;
950 int limit = debugLoopLimit(true);
951 int loop = 0;
952 do {
953 SkDebugf("%.*s", contour()->debugIndent(), " ");
954 SkDebugf("seg=%d span=%d ptT=%d",
955 next->segment()->debugID(), next->span()->debugID(), next->debugID());
956 next->dumpBase();
957 SkDebugf("\n");
958 if (limit && ++loop >= limit) {
959 SkDebugf("*** abort loop ***\n");
960 break;
961 }
962 } while ((next = next->fNext) && next != this);
963 contour()->outdentDump();
964}
965
966void SkOpPtT::dumpBase() const {
967 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s", this->fT, this->fPt.fX, this->fPt.fY,
968 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
969}
970
971const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
972 return this->segment()->debugAngle(id);
973}
974
975SkOpContour* SkOpSpanBase::debugContour(int id) {
976 return this->segment()->debugContour(id);
977}
978
979const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
980 return this->segment()->debugPtT(id);
981}
982
983const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
984 return this->segment()->debugSegment(id);
985}
986
987const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
988 return this->segment()->debugSpan(id);
989}
990
991void SkOpSpanBase::dump() const {
992 this->dumpAll();
993 SkDebugf("\n");
994}
995
996void SkOpSpanBase::dumpAll() const {
997 SkDebugf("%.*s", contour()->debugIndent(), " ");
998 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
999 this->dumpBase();
1000 SkDebugf("\n");
1001 this->fPtT.dumpAll();
1002}
1003
1004void SkOpSpanBase::dumpBase() const {
1005 if (this->fAligned) {
1006 SkDebugf(" aligned");
1007 }
1008 if (this->fChased) {
1009 SkDebugf(" chased");
1010 }
1011 if (!this->final()) {
1012 this->upCast()->dumpSpan();
1013 }
1014 const SkOpSpanBase* coin = this->coinEnd();
1015 if (this != coin) {
1016 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1017 } else if (this->final() || !this->upCast()->isCoincident()) {
1018 const SkOpPtT* oPt = this->ptT()->next();
1019 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
1020 }
caryclark08bc8482015-04-24 09:08:57 -07001021 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -07001022}
1023
1024void SkOpSpanBase::dumpCoin() const {
1025 const SkOpSpan* span = this->upCastable();
1026 if (!span) {
1027 return;
1028 }
1029 if (!span->isCoincident()) {
1030 return;
1031 }
1032 span->dumpCoin();
1033}
1034
1035void SkOpSpan::dumpCoin() const {
1036 const SkOpSpan* coincident = fCoincident;
1037 bool ok = debugCoinLoopCheck();
1038 this->dump();
1039 int loop = 0;
1040 do {
1041 coincident->dump();
1042 if (!ok && ++loop > 10) {
1043 SkDebugf("*** abort loop ***\n");
1044 break;
1045 }
1046 } while ((coincident = coincident->fCoincident) != this);
1047}
1048
1049bool SkOpSpan::dumpSpan() const {
1050 SkOpSpan* coin = fCoincident;
1051 if (this != coin) {
1052 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1053 }
1054 SkDebugf(" windVal=%d", this->windValue());
1055 SkDebugf(" windSum=");
1056 SkPathOpsDebug::WindingPrintf(this->windSum());
1057 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1058 SkDebugf(" oppVal=%d", this->oppValue());
1059 SkDebugf(" oppSum=");
1060 SkPathOpsDebug::WindingPrintf(this->oppSum());
1061 }
1062 if (this->done()) {
1063 SkDebugf(" done");
1064 }
1065 return this != coin;
1066}
1067
1068const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1069 return this->contour()->debugAngle(id);
1070}
1071
1072SkOpContour* SkOpSegment::debugContour(int id) {
1073 return this->contour()->debugContour(id);
1074}
1075
1076const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1077 return this->contour()->debugPtT(id);
1078}
1079
1080const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1081 return this->contour()->debugSegment(id);
1082}
1083
1084const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1085 return this->contour()->debugSpan(id);
1086}
1087
1088void SkOpSegment::dump() const {
1089 SkDebugf("%.*s", contour()->debugIndent(), " ");
1090 this->dumpPts();
1091 const SkOpSpanBase* span = &fHead;
1092 contour()->indentDump();
1093 do {
1094 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1095 span->ptT()->dumpBase();
1096 span->dumpBase();
1097 SkDebugf("\n");
1098 } while (!span->final() && (span = span->upCast()->next()));
1099 contour()->outdentDump();
1100}
1101
1102void SkOpSegment::dumpAll() const {
1103 SkDebugf("%.*s", contour()->debugIndent(), " ");
1104 this->dumpPts();
1105 const SkOpSpanBase* span = &fHead;
1106 contour()->indentDump();
1107 do {
1108 span->dumpAll();
1109 } while (!span->final() && (span = span->upCast()->next()));
1110 contour()->outdentDump();
1111}
1112
1113void SkOpSegment::dumpAngles() const {
1114 SkDebugf("seg=%d\n", debugID());
1115 const SkOpSpanBase* span = &fHead;
1116 do {
1117 const SkOpAngle* fAngle = span->fromAngle();
halcanary96fcdcc2015-08-27 07:41:13 -07001118 const SkOpAngle* tAngle = span->final() ? nullptr : span->upCast()->toAngle();
caryclark54359292015-03-26 07:52:43 -07001119 if (fAngle) {
1120 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1121 fAngle->dumpTo(this, tAngle);
1122 }
1123 if (tAngle) {
1124 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1125 tAngle->dumpTo(this, fAngle);
1126 }
1127 } while (!span->final() && (span = span->upCast()->next()));
1128}
1129
1130void SkOpSegment::dumpCoin() const {
1131 const SkOpSpan* span = &fHead;
1132 do {
1133 span->dumpCoin();
1134 } while ((span = span->next()->upCastable()));
1135}
1136
caryclark26ad22a2015-10-16 09:03:38 -07001137void SkOpSegment::dumpPtsInner(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001138 int last = SkPathOpsVerbToPoints(fVerb);
caryclark26ad22a2015-10-16 09:03:38 -07001139 SkDebugf("%s=%d {{", prefix, this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001140 if (fVerb == SkPath::kConic_Verb) {
1141 SkDebugf("{");
1142 }
caryclark54359292015-03-26 07:52:43 -07001143 int index = 0;
1144 do {
1145 SkDPoint::Dump(fPts[index]);
1146 SkDebugf(", ");
1147 } while (++index < last);
1148 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001149 SkDebugf("}}");
1150 if (fVerb == SkPath::kConic_Verb) {
1151 SkDebugf(", %1.9gf}", fWeight);
1152 }
caryclark624637c2015-05-11 07:21:27 -07001153}
1154
caryclark26ad22a2015-10-16 09:03:38 -07001155void SkOpSegment::dumpPts(const char* prefix) const {
1156 dumpPtsInner(prefix);
caryclark1049f122015-04-20 08:31:59 -07001157 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001158}
1159
1160void SkCoincidentSpans::dump() const {
1161 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1162 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1163 fCoinPtTStart->dumpBase();
1164 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1165 fCoinPtTEnd->dumpBase();
1166 if (fCoinPtTStart->segment()->operand()) {
1167 SkDebugf(" operand");
1168 }
1169 if (fCoinPtTStart->segment()->isXor()) {
1170 SkDebugf(" xor");
1171 }
1172 SkDebugf("\n");
1173 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1174 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1175 fOppPtTStart->dumpBase();
1176 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1177 fOppPtTEnd->dumpBase();
1178 if (fOppPtTStart->segment()->operand()) {
1179 SkDebugf(" operand");
1180 }
1181 if (fOppPtTStart->segment()->isXor()) {
1182 SkDebugf(" xor");
1183 }
1184 SkDebugf("\n");
1185}
1186
1187void SkOpCoincidence::dump() const {
1188 SkCoincidentSpans* span = fHead;
1189 while (span) {
1190 span->dump();
1191 span = span->fNext;
1192 }
caryclark26ad22a2015-10-16 09:03:38 -07001193 if (!fTop || fHead == fTop) {
caryclark27c8eb82015-07-06 11:38:33 -07001194 return;
1195 }
1196 SkDebugf("top:\n");
1197 span = fTop;
caryclark26ad22a2015-10-16 09:03:38 -07001198 if (fHead) {
1199 span->dump();
1200 return;
1201 }
caryclark27c8eb82015-07-06 11:38:33 -07001202 while (span) {
1203 span->dump();
1204 span = span->fNext;
1205 }
caryclark54359292015-03-26 07:52:43 -07001206}
1207
caryclark624637c2015-05-11 07:21:27 -07001208void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001209 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001210 if (!fCount) {
1211 return;
1212 }
1213 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001214 SkDEBUGCODE(fDebugIndent = 0);
1215 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001216 do {
1217 segment->dump();
1218 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001219 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001220}
1221
caryclark624637c2015-05-11 07:21:27 -07001222void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001223 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001224 if (!fCount) {
1225 return;
1226 }
1227 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001228 SkDEBUGCODE(fDebugIndent = 0);
1229 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001230 do {
1231 segment->dumpAll();
1232 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001233 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001234}
1235
1236
1237void SkOpContour::dumpAngles() const {
1238 SkDebugf("contour=%d\n", this->debugID());
1239 const SkOpSegment* segment = &fHead;
1240 do {
1241 SkDebugf(" seg=%d ", segment->debugID());
1242 segment->dumpAngles();
1243 } while ((segment = segment->next()));
1244}
1245
1246void SkOpContour::dumpPt(int index) const {
1247 const SkOpSegment* segment = &fHead;
1248 do {
1249 if (segment->debugID() == index) {
1250 segment->dumpPts();
1251 }
1252 } while ((segment = segment->next()));
1253}
1254
caryclark26ad22a2015-10-16 09:03:38 -07001255void SkOpContour::dumpPts(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001256 SkDebugf("contour=%d\n", this->debugID());
1257 const SkOpSegment* segment = &fHead;
1258 do {
caryclark26ad22a2015-10-16 09:03:38 -07001259 SkDebugf(" %s=%d ", prefix, segment->debugID());
1260 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001261 } while ((segment = segment->next()));
1262}
1263
caryclark26ad22a2015-10-16 09:03:38 -07001264void SkOpContour::dumpPtsX(const char* prefix) const {
caryclark54359292015-03-26 07:52:43 -07001265 if (!this->fCount) {
1266 SkDebugf("<empty>\n");
1267 return;
1268 }
1269 const SkOpSegment* segment = &fHead;
1270 do {
caryclark26ad22a2015-10-16 09:03:38 -07001271 segment->dumpPts(prefix);
caryclark54359292015-03-26 07:52:43 -07001272 } while ((segment = segment->next()));
1273}
1274
1275void SkOpContour::dumpSegment(int index) const {
1276 debugSegment(index)->dump();
1277}
1278
caryclark26ad22a2015-10-16 09:03:38 -07001279void SkOpContour::dumpSegments(const char* prefix, SkPathOp op) const {
caryclark54359292015-03-26 07:52:43 -07001280 bool firstOp = false;
1281 const SkOpContour* c = this;
1282 do {
caryclark26ad22a2015-10-16 09:03:38 -07001283 if (!firstOp && c->operand() && op >= 0) {
caryclark54359292015-03-26 07:52:43 -07001284#if DEBUG_ACTIVE_OP
1285 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1286#endif
1287 firstOp = true;
1288 }
caryclark26ad22a2015-10-16 09:03:38 -07001289 c->dumpPtsX(prefix);
caryclark54359292015-03-26 07:52:43 -07001290 } while ((c = c->next()));
1291}
1292
1293void SkOpContour::dumpSpan(int index) const {
1294 debugSpan(index)->dump();
1295}
1296
1297void SkOpContour::dumpSpans() const {
1298 SkDebugf("contour=%d\n", this->debugID());
1299 const SkOpSegment* segment = &fHead;
1300 do {
1301 SkDebugf(" seg=%d ", segment->debugID());
1302 segment->dump();
1303 } while ((segment = segment->next()));
1304}
1305
caryclark03b03ca2015-04-23 09:13:37 -07001306void SkOpCurve::dump() const {
1307 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1308 SkDebugf("{{");
1309 int index;
1310 for (index = 0; index <= count - 1; ++index) {
1311 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1312 }
1313 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1314}
1315
caryclark54359292015-03-26 07:52:43 -07001316#ifdef SK_DEBUG
1317const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001318 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001319 do {
1320 const SkOpSegment* segment = contour->first();
1321 while (segment) {
1322 const SkOpSpan* span = segment->head();
1323 do {
1324 SkOpAngle* angle = span->fromAngle();
1325 if (angle && angle->debugID() == id) {
1326 return angle;
1327 }
1328 angle = span->toAngle();
1329 if (angle && angle->debugID() == id) {
1330 return angle;
1331 }
1332 } while ((span = span->next()->upCastable()));
1333 const SkOpSpanBase* tail = segment->tail();
1334 SkOpAngle* angle = tail->fromAngle();
1335 if (angle && angle->debugID() == id) {
1336 return angle;
1337 }
1338 segment = segment->next();
1339 }
1340 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001341 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001342}
1343
1344SkOpContour* SkOpGlobalState::debugContour(int id) {
caryclark624637c2015-05-11 07:21:27 -07001345 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001346 do {
1347 if (contour->debugID() == id) {
1348 return contour;
1349 }
1350 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001351 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001352}
1353
1354const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001355 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001356 do {
1357 const SkOpSegment* segment = contour->first();
1358 while (segment) {
1359 const SkOpSpan* span = segment->head();
1360 do {
1361 const SkOpPtT* ptT = span->ptT();
1362 if (ptT->debugMatchID(id)) {
1363 return ptT;
1364 }
1365 } while ((span = span->next()->upCastable()));
1366 const SkOpSpanBase* tail = segment->tail();
1367 const SkOpPtT* ptT = tail->ptT();
1368 if (ptT->debugMatchID(id)) {
1369 return ptT;
1370 }
1371 segment = segment->next();
1372 }
1373 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001374 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001375}
1376
1377const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001378 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001379 do {
1380 const SkOpSegment* segment = contour->first();
1381 while (segment) {
1382 if (segment->debugID() == id) {
1383 return segment;
1384 }
1385 segment = segment->next();
1386 }
1387 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001388 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001389}
1390
1391const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001392 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001393 do {
1394 const SkOpSegment* segment = contour->first();
1395 while (segment) {
1396 const SkOpSpan* span = segment->head();
1397 do {
1398 if (span->debugID() == id) {
1399 return span;
1400 }
1401 } while ((span = span->next()->upCastable()));
1402 const SkOpSpanBase* tail = segment->tail();
1403 if (tail->debugID() == id) {
1404 return tail;
1405 }
1406 segment = segment->next();
1407 }
1408 } while ((contour = contour->next()));
halcanary96fcdcc2015-08-27 07:41:13 -07001409 return nullptr;
caryclark54359292015-03-26 07:52:43 -07001410}
1411#endif
1412
caryclark54359292015-03-26 07:52:43 -07001413#if DEBUG_T_SECT_DUMP > 1
1414int gDumpTSectNum;
1415#endif