blob: 507d86592687184ed363025d5f4fce3db39a958c [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 {
64 SkDebugf("{{");
65 int index = 0;
66 do {
67 fPts[index].dump();
68 SkDebugf(", ");
69 } while (++index < 2);
70 fPts[index].dump();
71 SkDebugf("}, %1.9g", fWeight);
72}
73
74void SkDCubic::dump() const {
75 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070076 SkDebugf("}},\n");
reed0dc4dd62015-03-24 13:55:33 -070077}
78
caryclark54359292015-03-26 07:52:43 -070079void SkDCubic::dumpID(int id) const {
caryclark1049f122015-04-20 08:31:59 -070080 this->dumpInner();
caryclark54359292015-03-26 07:52:43 -070081 SkDebugf("}} id=%d\n", id);
reed0dc4dd62015-03-24 13:55:33 -070082}
83
caryclark54359292015-03-26 07:52:43 -070084static inline bool double_is_NaN(double x) { return x != x; }
85
86void SkDCubic::dumpInner() const {
87 SkDebugf("{{");
88 int index = 0;
reed0dc4dd62015-03-24 13:55:33 -070089 do {
caryclark54359292015-03-26 07:52:43 -070090 if (index != 0) {
91 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
92 return;
reed0dc4dd62015-03-24 13:55:33 -070093 }
caryclark54359292015-03-26 07:52:43 -070094 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -070095 }
caryclark54359292015-03-26 07:52:43 -070096 fPts[index].dump();
97 } while (++index < 3);
98 if (double_is_NaN(fPts[index].fX) && double_is_NaN(fPts[index].fY)) {
reed0dc4dd62015-03-24 13:55:33 -070099 return;
100 }
caryclark54359292015-03-26 07:52:43 -0700101 SkDebugf(", ");
reed0dc4dd62015-03-24 13:55:33 -0700102 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000103}
104
caryclark1049f122015-04-20 08:31:59 -0700105void SkDCurve::dumpID(int id) const {
106#ifndef SK_RELEASE
107 switch(fVerb) {
108 case SkPath::kLine_Verb:
109 fLine.dumpID(id);
110 break;
111 case SkPath::kQuad_Verb:
112 fQuad.dumpID(id);
113 break;
114 case SkPath::kConic_Verb:
115 fConic.dumpID(id);
116 break;
117 case SkPath::kCubic_Verb:
118 fCubic.dumpID(id);
119 break;
120 default:
121 SkASSERT(0);
122 }
123#else
124 fCubic.dumpID(id);
125#endif
126}
127
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000128void SkDLine::dump() const {
caryclark1049f122015-04-20 08:31:59 -0700129 this->dumpInner();
130 SkDebugf("}},\n");
131}
132
133void SkDLine::dumpID(int id) const {
134 this->dumpInner();
135 SkDebugf("}} id=%d\n", id);
136}
137
138void SkDLine::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000139 SkDebugf("{{");
140 fPts[0].dump();
141 SkDebugf(", ");
142 fPts[1].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000143}
144
145void SkDPoint::dump() const {
146 SkDebugf("{");
147 DebugDumpDouble(fX);
148 SkDebugf(", ");
149 DebugDumpDouble(fY);
150 SkDebugf("}");
151}
152
153void SkDPoint::Dump(const SkPoint& pt) {
154 SkDebugf("{");
155 DebugDumpFloat(pt.fX);
156 SkDebugf(", ");
157 DebugDumpFloat(pt.fY);
158 SkDebugf("}");
159}
160
caryclark65f55312014-11-13 06:58:52 -0800161void SkDPoint::DumpHex(const SkPoint& pt) {
162 SkDebugf("{");
163 DebugDumpHexFloat(pt.fX);
164 SkDebugf(", ");
165 DebugDumpHexFloat(pt.fY);
166 SkDebugf("}");
167}
168
169void SkDQuad::dump() const {
caryclark54359292015-03-26 07:52:43 -0700170 dumpInner();
171 SkDebugf("}},\n");
caryclark65f55312014-11-13 06:58:52 -0800172}
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000173
caryclark54359292015-03-26 07:52:43 -0700174void SkDQuad::dumpID(int id) const {
175 dumpInner();
176 SkDebugf("}} id=%d\n", id);
177}
178
179void SkDQuad::dumpInner() const {
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000180 SkDebugf("{{");
181 int index = 0;
182 do {
183 fPts[index].dump();
184 SkDebugf(", ");
185 } while (++index < 2);
186 fPts[index].dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000187}
188
caryclark54359292015-03-26 07:52:43 -0700189void SkIntersections::dump() const {
190 SkDebugf("used=%d of %d", fUsed, fMax);
191 for (int index = 0; index < fUsed; ++index) {
192 SkDebugf(" t=(%s%1.9g,%s%1.9g) pt=(%1.9g,%1.9g)",
193 fIsCoincident[0] & (1 << index) ? "*" : "", fT[0][index],
194 fIsCoincident[1] & (1 << index) ? "*" : "", fT[1][index],
195 fPt[index].fX, fPt[index].fY);
196 if (index < 2 && fNearlySame[index]) {
197 SkDebugf(" pt2=(%1.9g,%1.9g)",fPt2[index].fX, fPt2[index].fY);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000198 }
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000199 }
200 SkDebugf("\n");
201}
202
caryclark54359292015-03-26 07:52:43 -0700203const SkOpAngle* SkPathOpsDebug::DebugAngleAngle(const SkOpAngle* angle, int id) {
204 return angle->debugAngle(id);
205}
206
207SkOpContour* SkPathOpsDebug::DebugAngleContour(SkOpAngle* angle, int id) {
208 return angle->debugContour(id);
209}
210
211const SkOpPtT* SkPathOpsDebug::DebugAnglePtT(const SkOpAngle* angle, int id) {
212 return angle->debugPtT(id);
213}
214
215const SkOpSegment* SkPathOpsDebug::DebugAngleSegment(const SkOpAngle* angle, int id) {
216 return angle->debugSegment(id);
217}
218
219const SkOpSpanBase* SkPathOpsDebug::DebugAngleSpan(const SkOpAngle* angle, int id) {
220 return angle->debugSpan(id);
221}
222
223const SkOpAngle* SkPathOpsDebug::DebugContourAngle(SkOpContour* contour, int id) {
224 return contour->debugAngle(id);
225}
226
227SkOpContour* SkPathOpsDebug::DebugContourContour(SkOpContour* contour, int id) {
228 return contour->debugContour(id);
229}
230
231const SkOpPtT* SkPathOpsDebug::DebugContourPtT(SkOpContour* contour, int id) {
232 return contour->debugPtT(id);
233}
234
235const SkOpSegment* SkPathOpsDebug::DebugContourSegment(SkOpContour* contour, int id) {
236 return contour->debugSegment(id);
237}
238
239const SkOpSpanBase* SkPathOpsDebug::DebugContourSpan(SkOpContour* contour, int id) {
240 return contour->debugSpan(id);
241}
242
caryclark27c8eb82015-07-06 11:38:33 -0700243const SkOpAngle* SkPathOpsDebug::DebugCoincidenceAngle(SkOpCoincidence* coin, int id) {
244 return coin->debugAngle(id);
245}
246
247SkOpContour* SkPathOpsDebug::DebugCoincidenceContour(SkOpCoincidence* coin, int id) {
248 return coin->debugContour(id);
249}
250
251const SkOpPtT* SkPathOpsDebug::DebugCoincidencePtT(SkOpCoincidence* coin, int id) {
252 return coin->debugPtT(id);
253}
254
255const SkOpSegment* SkPathOpsDebug::DebugCoincidenceSegment(SkOpCoincidence* coin, int id) {
256 return coin->debugSegment(id);
257}
258
259const SkOpSpanBase* SkPathOpsDebug::DebugCoincidenceSpan(SkOpCoincidence* coin, int id) {
260 return coin->debugSpan(id);
261}
262
caryclark54359292015-03-26 07:52:43 -0700263const SkOpAngle* SkPathOpsDebug::DebugPtTAngle(const SkOpPtT* ptT, int id) {
264 return ptT->debugAngle(id);
265}
266
267SkOpContour* SkPathOpsDebug::DebugPtTContour(SkOpPtT* ptT, int id) {
268 return ptT->debugContour(id);
269}
270
271const SkOpPtT* SkPathOpsDebug::DebugPtTPtT(const SkOpPtT* ptT, int id) {
272 return ptT->debugPtT(id);
273}
274
275const SkOpSegment* SkPathOpsDebug::DebugPtTSegment(const SkOpPtT* ptT, int id) {
276 return ptT->debugSegment(id);
277}
278
279const SkOpSpanBase* SkPathOpsDebug::DebugPtTSpan(const SkOpPtT* ptT, int id) {
280 return ptT->debugSpan(id);
281}
282
283const SkOpAngle* SkPathOpsDebug::DebugSegmentAngle(const SkOpSegment* span, int id) {
284 return span->debugAngle(id);
285}
286
287SkOpContour* SkPathOpsDebug::DebugSegmentContour(SkOpSegment* span, int id) {
288 return span->debugContour(id);
289}
290
291const SkOpPtT* SkPathOpsDebug::DebugSegmentPtT(const SkOpSegment* span, int id) {
292 return span->debugPtT(id);
293}
294
295const SkOpSegment* SkPathOpsDebug::DebugSegmentSegment(const SkOpSegment* span, int id) {
296 return span->debugSegment(id);
297}
298
299const SkOpSpanBase* SkPathOpsDebug::DebugSegmentSpan(const SkOpSegment* span, int id) {
300 return span->debugSpan(id);
301}
302
303const SkOpAngle* SkPathOpsDebug::DebugSpanAngle(const SkOpSpanBase* span, int id) {
304 return span->debugAngle(id);
305}
306
307SkOpContour* SkPathOpsDebug::DebugSpanContour(SkOpSpanBase* span, int id) {
308 return span->debugContour(id);
309}
310
311const SkOpPtT* SkPathOpsDebug::DebugSpanPtT(const SkOpSpanBase* span, int id) {
312 return span->debugPtT(id);
313}
314
315const SkOpSegment* SkPathOpsDebug::DebugSpanSegment(const SkOpSpanBase* span, int id) {
316 return span->debugSegment(id);
317}
318
319const SkOpSpanBase* SkPathOpsDebug::DebugSpanSpan(const SkOpSpanBase* span, int id) {
320 return span->debugSpan(id);
321}
322
caryclark624637c2015-05-11 07:21:27 -0700323void SkOpContour::dumpContours() const {
324 SkOpContour* contour = this->globalState()->contourHead();
325 do {
326 contour->dump();
327 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000328}
329
caryclark624637c2015-05-11 07:21:27 -0700330void SkOpContour::dumpContoursAll() const {
331 SkOpContour* contour = this->globalState()->contourHead();
332 do {
333 contour->dumpAll();
334 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000335}
336
caryclark624637c2015-05-11 07:21:27 -0700337void SkOpContour::dumpContoursAngles() const {
338 SkOpContour* contour = this->globalState()->contourHead();
339 do {
340 contour->dumpAngles();
341 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000342}
343
caryclark624637c2015-05-11 07:21:27 -0700344void SkOpContour::dumpContoursPts() const {
345 SkOpContour* contour = this->globalState()->contourHead();
346 do {
347 contour->dumpPts();
348 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000349}
350
caryclark624637c2015-05-11 07:21:27 -0700351void SkOpContour::dumpContoursPt(int segmentID) const {
352 SkOpContour* contour = this->globalState()->contourHead();
353 do {
354 contour->dumpPt(segmentID);
355 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000356}
357
caryclark624637c2015-05-11 07:21:27 -0700358void SkOpContour::dumpContoursSegment(int segmentID) const {
359 SkOpContour* contour = this->globalState()->contourHead();
360 do {
361 contour->dumpSegment(segmentID);
362 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000363}
364
caryclark624637c2015-05-11 07:21:27 -0700365void SkOpContour::dumpContoursSpan(int spanID) const {
366 SkOpContour* contour = this->globalState()->contourHead();
367 do {
368 contour->dumpSpan(spanID);
369 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000370}
371
caryclark624637c2015-05-11 07:21:27 -0700372void SkOpContour::dumpContoursSpans() const {
373 SkOpContour* contour = this->globalState()->contourHead();
374 do {
375 contour->dumpSpans();
376 } while ((contour = contour->next()));
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000377}
378
caryclark1049f122015-04-20 08:31:59 -0700379template <typename TCurve, typename OppCurve>
380const SkTSpan<TCurve, OppCurve>* DebugSpan(const SkTSect<TCurve, OppCurve>* sect, int id) {
caryclark54359292015-03-26 07:52:43 -0700381 return sect->debugSpan(id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000382}
383
caryclark1049f122015-04-20 08:31:59 -0700384void DontCallDebugSpan(int id);
385void DontCallDebugSpan(int id) { // exists to instantiate the templates
386 SkDQuad quad;
387 SkDConic conic;
388 SkDCubic cubic;
389 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
390 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
391 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
392 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
393 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
394 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
395 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
396 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
397 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
398 DebugSpan(&q1q2, id);
399 DebugSpan(&q1k2, id);
400 DebugSpan(&q1c2, id);
401 DebugSpan(&k1q2, id);
402 DebugSpan(&k1k2, id);
403 DebugSpan(&k1c2, id);
404 DebugSpan(&c1q2, id);
405 DebugSpan(&c1k2, id);
406 DebugSpan(&c1c2, id);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000407}
408
caryclark1049f122015-04-20 08:31:59 -0700409template <typename TCurve, typename OppCurve>
410const SkTSpan<TCurve, OppCurve>* DebugT(const SkTSect<TCurve, OppCurve>* sect, double t) {
caryclark54359292015-03-26 07:52:43 -0700411 return sect->debugT(t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000412}
413
caryclark1049f122015-04-20 08:31:59 -0700414void DontCallDebugT(double t);
415void DontCallDebugT(double t) { // exists to instantiate the templates
416 SkDQuad quad;
417 SkDConic conic;
418 SkDCubic cubic;
419 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
420 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
421 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
422 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
423 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
424 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
425 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
426 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
427 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
428 DebugT(&q1q2, t);
429 DebugT(&q1k2, t);
430 DebugT(&q1c2, t);
431 DebugT(&k1q2, t);
432 DebugT(&k1k2, t);
433 DebugT(&k1c2, t);
434 DebugT(&c1q2, t);
435 DebugT(&c1k2, t);
436 DebugT(&c1c2, t);
caryclarkdac1d172014-06-17 05:15:38 -0700437}
438
caryclark1049f122015-04-20 08:31:59 -0700439template <typename TCurve, typename OppCurve>
440void Dump(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700441 sect->dump();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000442}
443
caryclark1049f122015-04-20 08:31:59 -0700444void DontCallDumpTSect();
445void DontCallDumpTSect() { // exists to instantiate the templates
446 SkDQuad quad;
447 SkDConic conic;
448 SkDCubic cubic;
449 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
450 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
451 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
452 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
453 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
454 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
455 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
456 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
457 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
458 Dump(&q1q2);
459 Dump(&q1k2);
460 Dump(&q1c2);
461 Dump(&k1q2);
462 Dump(&k1k2);
463 Dump(&k1c2);
464 Dump(&c1q2);
465 Dump(&c1k2);
466 Dump(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000467}
468
caryclark1049f122015-04-20 08:31:59 -0700469template <typename TCurve, typename OppCurve>
470void DumpBoth(SkTSect<TCurve, OppCurve>* sect1, SkTSect<OppCurve, TCurve>* sect2) {
caryclark54359292015-03-26 07:52:43 -0700471 sect1->dumpBoth(sect2);
caryclarkdac1d172014-06-17 05:15:38 -0700472}
473
caryclark1049f122015-04-20 08:31:59 -0700474void DontCallDumpBoth();
475void DontCallDumpBoth() { // exists to instantiate the templates
476 SkDQuad quad;
477 SkDConic conic;
478 SkDCubic cubic;
479 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
480 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
481 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
482 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
483 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
484 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
485 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
486 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
487 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
488 DumpBoth(&q1q2, &q1q2);
489 DumpBoth(&q1k2, &k1q2);
490 DumpBoth(&q1c2, &c1q2);
491 DumpBoth(&k1q2, &q1k2);
492 DumpBoth(&k1k2, &k1k2);
493 DumpBoth(&k1c2, &c1k2);
494 DumpBoth(&c1q2, &q1c2);
495 DumpBoth(&c1k2, &k1c2);
496 DumpBoth(&c1c2, &c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700497}
498
caryclark1049f122015-04-20 08:31:59 -0700499template <typename TCurve, typename OppCurve>
500void DumpBounded(SkTSect<TCurve, OppCurve>* sect1, int id) {
501 sect1->dumpBounded(id);
502}
503
504void DontCallDumpBounded();
505void DontCallDumpBounded() {
506 SkDQuad quad;
507 SkDConic conic;
508 SkDCubic cubic;
509 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
510 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
511 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
512 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
513 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
514 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
515 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
516 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
517 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
518 DumpBounded(&q1q2, 0);
519 DumpBounded(&q1k2, 0);
520 DumpBounded(&q1c2, 0);
521 DumpBounded(&k1q2, 0);
522 DumpBounded(&k1k2, 0);
523 DumpBounded(&k1c2, 0);
524 DumpBounded(&c1q2, 0);
525 DumpBounded(&c1k2, 0);
526 DumpBounded(&c1c2, 0);
527}
528
529template <typename TCurve, typename OppCurve>
530void DumpBounds(SkTSect<TCurve, OppCurve>* sect1) {
531 sect1->dumpBounds();
532}
533
534void DontCallDumpBounds();
535void DontCallDumpBounds() {
536 SkDQuad quad;
537 SkDConic conic;
538 SkDCubic cubic;
539 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
540 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
541 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
542 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
543 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
544 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
545 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
546 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
547 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
548 DumpBounds(&q1q2);
549 DumpBounds(&q1k2);
550 DumpBounds(&q1c2);
551 DumpBounds(&k1q2);
552 DumpBounds(&k1k2);
553 DumpBounds(&k1c2);
554 DumpBounds(&c1q2);
555 DumpBounds(&c1k2);
556 DumpBounds(&c1c2);
557}
558
559template <typename TCurve, typename OppCurve>
560void DumpCoin(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700561 sect1->dumpCoin();
caryclarkdac1d172014-06-17 05:15:38 -0700562}
563
caryclark1049f122015-04-20 08:31:59 -0700564void DontCallDumpCoin();
565void DontCallDumpCoin() { // exists to instantiate the templates
566 SkDQuad quad;
567 SkDConic conic;
568 SkDCubic cubic;
569 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
570 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
571 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
572 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
573 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
574 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
575 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
576 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
577 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
578 DumpCoin(&q1q2);
579 DumpCoin(&q1k2);
580 DumpCoin(&q1c2);
581 DumpCoin(&k1q2);
582 DumpCoin(&k1k2);
583 DumpCoin(&k1c2);
584 DumpCoin(&c1q2);
585 DumpCoin(&c1k2);
586 DumpCoin(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000587}
588
caryclark1049f122015-04-20 08:31:59 -0700589template <typename TCurve, typename OppCurve>
590void DumpCoinCurves(SkTSect<TCurve, OppCurve>* sect1) {
caryclark54359292015-03-26 07:52:43 -0700591 sect1->dumpCoinCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000592}
593
caryclark1049f122015-04-20 08:31:59 -0700594void DontCallDumpCoinCurves();
595void DontCallDumpCoinCurves() { // exists to instantiate the templates
596 SkDQuad quad;
597 SkDConic conic;
598 SkDCubic cubic;
599 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
600 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
601 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
602 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
603 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
604 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
605 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
606 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
607 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
608 DumpCoinCurves(&q1q2);
609 DumpCoinCurves(&q1k2);
610 DumpCoinCurves(&q1c2);
611 DumpCoinCurves(&k1q2);
612 DumpCoinCurves(&k1k2);
613 DumpCoinCurves(&k1c2);
614 DumpCoinCurves(&c1q2);
615 DumpCoinCurves(&c1k2);
616 DumpCoinCurves(&c1c2);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000617}
618
caryclark1049f122015-04-20 08:31:59 -0700619template <typename TCurve, typename OppCurve>
620void DumpCurves(const SkTSect<TCurve, OppCurve>* sect) {
caryclark54359292015-03-26 07:52:43 -0700621 sect->dumpCurves();
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000622}
623
caryclark1049f122015-04-20 08:31:59 -0700624void DontCallDumpCurves();
625void DontCallDumpCurves() { // exists to instantiate the templates
626 SkDQuad quad;
627 SkDConic conic;
628 SkDCubic cubic;
629 SkTSect<SkDQuad, SkDQuad> q1q2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
630 SkTSect<SkDQuad, SkDConic> q1k2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
631 SkTSect<SkDQuad, SkDCubic> q1c2(quad PATH_OPS_DEBUG_T_SECT_PARAMS(1));
632 SkTSect<SkDConic, SkDQuad> k1q2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
633 SkTSect<SkDConic, SkDConic> k1k2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
634 SkTSect<SkDConic, SkDCubic> k1c2(conic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
635 SkTSect<SkDCubic, SkDQuad> c1q2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
636 SkTSect<SkDCubic, SkDConic> c1k2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
637 SkTSect<SkDCubic, SkDCubic> c1c2(cubic PATH_OPS_DEBUG_T_SECT_PARAMS(1));
638 DumpCurves(&q1q2);
639 DumpCurves(&q1k2);
640 DumpCurves(&q1c2);
641 DumpCurves(&k1q2);
642 DumpCurves(&k1k2);
643 DumpCurves(&k1c2);
644 DumpCurves(&c1q2);
645 DumpCurves(&c1k2);
646 DumpCurves(&c1c2);
647}
648
649template <typename TCurve, typename OppCurve>
650void Dump(const SkTSpan<TCurve, OppCurve>* span) {
651 span->dump();
652}
653
654void DontCallDumpTSpan();
655void DontCallDumpTSpan() { // exists to instantiate the templates
656 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
657 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
658 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
659 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
660 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
661 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
662 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
663 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
664 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
665 Dump(&q1q2);
666 Dump(&q1k2);
667 Dump(&q1c2);
668 Dump(&k1q2);
669 Dump(&k1k2);
670 Dump(&k1c2);
671 Dump(&c1q2);
672 Dump(&c1k2);
673 Dump(&c1c2);
674}
675
676template <typename TCurve, typename OppCurve>
677void DumpCoin(const SkTSpan<TCurve, OppCurve>* span) {
678 span->dumpCoin();
679}
680
681void DontCallDumpSpanCoin();
682void DontCallDumpSpanCoin() { // exists to instantiate the templates
683 SkTSpan<SkDQuad, SkDQuad> q1q2; q1q2.debugInit();
684 SkTSpan<SkDQuad, SkDConic> q1k2; q1k2.debugInit();
685 SkTSpan<SkDQuad, SkDCubic> q1c2; q1c2.debugInit();
686 SkTSpan<SkDConic, SkDQuad> k1q2; k1q2.debugInit();
687 SkTSpan<SkDConic, SkDConic> k1k2; k1k2.debugInit();
688 SkTSpan<SkDConic, SkDCubic> k1c2; k1c2.debugInit();
689 SkTSpan<SkDCubic, SkDQuad> c1q2; c1q2.debugInit();
690 SkTSpan<SkDCubic, SkDConic> c1k2; c1k2.debugInit();
691 SkTSpan<SkDCubic, SkDCubic> c1c2; c1c2.debugInit();
692 DumpCoin(&q1q2);
693 DumpCoin(&q1k2);
694 DumpCoin(&q1c2);
695 DumpCoin(&k1q2);
696 DumpCoin(&k1k2);
697 DumpCoin(&k1c2);
698 DumpCoin(&c1q2);
699 DumpCoin(&c1k2);
700 DumpCoin(&c1c2);
caryclarkdac1d172014-06-17 05:15:38 -0700701}
702
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000703static void dumpTestCase(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
caryclark54359292015-03-26 07:52:43 -0700704 SkDebugf("\n<div id=\"quad%d\">\n", testNo);
705 quad1.dumpInner();
706 SkDebugf("}}, ");
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000707 quad2.dump();
708 SkDebugf("</div>\n\n");
709}
710
711static void dumpTestTrailer() {
712 SkDebugf("</div>\n\n<script type=\"text/javascript\">\n\n");
713 SkDebugf(" var testDivs = [\n");
714}
715
716static void dumpTestList(int testNo, double min) {
717 SkDebugf(" quad%d,", testNo);
718 if (min > 0) {
719 SkDebugf(" // %1.9g", min);
720 }
721 SkDebugf("\n");
722}
723
724void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo) {
725 SkDebugf("\n");
726 dumpTestCase(quad1, quad2, testNo);
727 dumpTestTrailer();
728 dumpTestList(testNo, 0);
729 SkDebugf("\n");
730}
731
732void DumpT(const SkDQuad& quad, double t) {
733 SkDLine line = {{quad.ptAtT(t), quad[0]}};
734 line.dump();
735}
caryclark54359292015-03-26 07:52:43 -0700736
737const SkOpAngle* SkOpAngle::debugAngle(int id) const {
738 return this->segment()->debugAngle(id);
739}
740
741SkOpContour* SkOpAngle::debugContour(int id) {
742 return this->segment()->debugContour(id);
743}
744
745const SkOpPtT* SkOpAngle::debugPtT(int id) const {
746 return this->segment()->debugPtT(id);
747}
748
749const SkOpSegment* SkOpAngle::debugSegment(int id) const {
750 return this->segment()->debugSegment(id);
751}
752
caryclark624637c2015-05-11 07:21:27 -0700753int SkOpAngle::debugSign() const {
754 SkASSERT(fStart->t() != fEnd->t());
755 return fStart->t() < fEnd->t() ? -1 : 1;
756}
757
caryclark54359292015-03-26 07:52:43 -0700758const SkOpSpanBase* SkOpAngle::debugSpan(int id) const {
759 return this->segment()->debugSpan(id);
760}
761
762void SkOpAngle::dump() const {
763 dumpOne(true);
764 SkDebugf("\n");
765}
766
767void SkOpAngle::dumpOne(bool functionHeader) const {
768// fSegment->debugValidate();
769 const SkOpSegment* segment = this->segment();
770 const SkOpSpan& mSpan = *fStart->starter(fEnd);
771 if (functionHeader) {
772 SkDebugf("%s ", __FUNCTION__);
773 }
774 SkDebugf("[%d", segment->debugID());
775 SkDebugf("/%d", debugID());
776 SkDebugf("] next=");
777 if (fNext) {
778 SkDebugf("%d", fNext->fStart->segment()->debugID());
779 SkDebugf("/%d", fNext->debugID());
780 } else {
781 SkDebugf("?");
782 }
783 SkDebugf(" sect=%d/%d ", fSectorStart, fSectorEnd);
784 SkDebugf(" s=%1.9g [%d] e=%1.9g [%d]", fStart->t(), fStart->debugID(),
785 fEnd->t(), fEnd->debugID());
caryclark624637c2015-05-11 07:21:27 -0700786 SkDebugf(" sgn=%d windVal=%d", this->debugSign(), mSpan.windValue());
caryclark54359292015-03-26 07:52:43 -0700787
788 SkDebugf(" windSum=");
789 SkPathOpsDebug::WindingPrintf(mSpan.windSum());
790 if (mSpan.oppValue() != 0 || mSpan.oppSum() != SK_MinS32) {
791 SkDebugf(" oppVal=%d", mSpan.oppValue());
792 SkDebugf(" oppSum=");
793 SkPathOpsDebug::WindingPrintf(mSpan.oppSum());
794 }
795 if (mSpan.done()) {
796 SkDebugf(" done");
797 }
798 if (unorderable()) {
799 SkDebugf(" unorderable");
800 }
801 if (segment->operand()) {
802 SkDebugf(" operand");
803 }
caryclark54359292015-03-26 07:52:43 -0700804}
805
806void SkOpAngle::dumpTo(const SkOpSegment* segment, const SkOpAngle* to) const {
807 const SkOpAngle* first = this;
808 const SkOpAngle* next = this;
809 const char* indent = "";
810 do {
811 SkDebugf("%s", indent);
812 next->dumpOne(false);
813 if (segment == next->fStart->segment()) {
814 if (this == fNext) {
815 SkDebugf(" << from");
816 }
817 if (to == fNext) {
818 SkDebugf(" << to");
819 }
820 }
821 SkDebugf("\n");
822 indent = " ";
823 next = next->fNext;
824 } while (next && next != first);
825}
826
827void SkOpAngle::dumpCurves() const {
828 const SkOpAngle* first = this;
829 const SkOpAngle* next = this;
830 do {
831 next->fCurvePart.dumpID(next->segment()->debugID());
832 next = next->fNext;
833 } while (next && next != first);
834}
835
836void SkOpAngle::dumpLoop() const {
837 const SkOpAngle* first = this;
838 const SkOpAngle* next = this;
839 do {
840 next->dumpOne(false);
841 SkDebugf("\n");
842 next = next->fNext;
843 } while (next && next != first);
844}
845
846void SkOpAngle::dumpTest() const {
847 const SkOpAngle* first = this;
848 const SkOpAngle* next = this;
849 do {
850 SkDebugf("{ ");
851 SkOpSegment* segment = next->segment();
852 segment->dumpPts();
853 SkDebugf(", %d, %1.9g, %1.9g, {} },\n", SkPathOpsVerbToPoints(segment->verb()) + 1,
854 next->start()->t(), next->end()->t());
855 next = next->fNext;
856 } while (next && next != first);
857}
858
859bool SkOpPtT::debugMatchID(int id) const {
860 int limit = this->debugLoopLimit(false);
861 int loop = 0;
862 const SkOpPtT* ptT = this;
863 do {
864 if (ptT->debugID() == id) {
865 return true;
866 }
867 } while ((!limit || ++loop <= limit) && (ptT = ptT->next()) && ptT != this);
868 return false;
869}
870
871const SkOpAngle* SkOpPtT::debugAngle(int id) const {
872 return this->span()->debugAngle(id);
873}
874
875SkOpContour* SkOpPtT::debugContour(int id) {
876 return this->span()->debugContour(id);
877}
878
879const SkOpPtT* SkOpPtT::debugPtT(int id) const {
880 return this->span()->debugPtT(id);
881}
882
883const SkOpSegment* SkOpPtT::debugSegment(int id) const {
884 return this->span()->debugSegment(id);
885}
886
887const SkOpSpanBase* SkOpPtT::debugSpan(int id) const {
888 return this->span()->debugSpan(id);
889}
890
891void SkOpPtT::dump() const {
892 SkDebugf("seg=%d span=%d ptT=%d",
893 this->segment()->debugID(), this->span()->debugID(), this->debugID());
894 this->dumpBase();
895 SkDebugf("\n");
896}
897
898void SkOpPtT::dumpAll() const {
899 contour()->indentDump();
900 const SkOpPtT* next = this;
901 int limit = debugLoopLimit(true);
902 int loop = 0;
903 do {
904 SkDebugf("%.*s", contour()->debugIndent(), " ");
905 SkDebugf("seg=%d span=%d ptT=%d",
906 next->segment()->debugID(), next->span()->debugID(), next->debugID());
907 next->dumpBase();
908 SkDebugf("\n");
909 if (limit && ++loop >= limit) {
910 SkDebugf("*** abort loop ***\n");
911 break;
912 }
913 } while ((next = next->fNext) && next != this);
914 contour()->outdentDump();
915}
916
917void SkOpPtT::dumpBase() const {
918 SkDebugf(" t=%1.9g pt=(%1.9g,%1.9g)%s%s", this->fT, this->fPt.fX, this->fPt.fY,
919 this->fDuplicatePt ? " dup" : "", this->fDeleted ? " deleted" : "");
920}
921
922const SkOpAngle* SkOpSpanBase::debugAngle(int id) const {
923 return this->segment()->debugAngle(id);
924}
925
926SkOpContour* SkOpSpanBase::debugContour(int id) {
927 return this->segment()->debugContour(id);
928}
929
930const SkOpPtT* SkOpSpanBase::debugPtT(int id) const {
931 return this->segment()->debugPtT(id);
932}
933
934const SkOpSegment* SkOpSpanBase::debugSegment(int id) const {
935 return this->segment()->debugSegment(id);
936}
937
938const SkOpSpanBase* SkOpSpanBase::debugSpan(int id) const {
939 return this->segment()->debugSpan(id);
940}
941
942void SkOpSpanBase::dump() const {
943 this->dumpAll();
944 SkDebugf("\n");
945}
946
947void SkOpSpanBase::dumpAll() const {
948 SkDebugf("%.*s", contour()->debugIndent(), " ");
949 SkDebugf("seg=%d span=%d", this->segment()->debugID(), this->debugID());
950 this->dumpBase();
951 SkDebugf("\n");
952 this->fPtT.dumpAll();
953}
954
955void SkOpSpanBase::dumpBase() const {
956 if (this->fAligned) {
957 SkDebugf(" aligned");
958 }
959 if (this->fChased) {
960 SkDebugf(" chased");
961 }
962 if (!this->final()) {
963 this->upCast()->dumpSpan();
964 }
965 const SkOpSpanBase* coin = this->coinEnd();
966 if (this != coin) {
967 SkDebugf(" coinEnd seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
968 } else if (this->final() || !this->upCast()->isCoincident()) {
969 const SkOpPtT* oPt = this->ptT()->next();
970 SkDebugf(" seg/span=%d/%d", oPt->segment()->debugID(), oPt->span()->debugID());
971 }
caryclark08bc8482015-04-24 09:08:57 -0700972 SkDebugf(" adds=%d", fSpanAdds);
caryclark54359292015-03-26 07:52:43 -0700973}
974
975void SkOpSpanBase::dumpCoin() const {
976 const SkOpSpan* span = this->upCastable();
977 if (!span) {
978 return;
979 }
980 if (!span->isCoincident()) {
981 return;
982 }
983 span->dumpCoin();
984}
985
986void SkOpSpan::dumpCoin() const {
987 const SkOpSpan* coincident = fCoincident;
988 bool ok = debugCoinLoopCheck();
989 this->dump();
990 int loop = 0;
991 do {
992 coincident->dump();
993 if (!ok && ++loop > 10) {
994 SkDebugf("*** abort loop ***\n");
995 break;
996 }
997 } while ((coincident = coincident->fCoincident) != this);
998}
999
1000bool SkOpSpan::dumpSpan() const {
1001 SkOpSpan* coin = fCoincident;
1002 if (this != coin) {
1003 SkDebugf(" coinStart seg/span=%d/%d", coin->segment()->debugID(), coin->debugID());
1004 }
1005 SkDebugf(" windVal=%d", this->windValue());
1006 SkDebugf(" windSum=");
1007 SkPathOpsDebug::WindingPrintf(this->windSum());
1008 if (this->oppValue() != 0 || this->oppSum() != SK_MinS32) {
1009 SkDebugf(" oppVal=%d", this->oppValue());
1010 SkDebugf(" oppSum=");
1011 SkPathOpsDebug::WindingPrintf(this->oppSum());
1012 }
1013 if (this->done()) {
1014 SkDebugf(" done");
1015 }
1016 return this != coin;
1017}
1018
1019const SkOpAngle* SkOpSegment::debugAngle(int id) const {
1020 return this->contour()->debugAngle(id);
1021}
1022
1023SkOpContour* SkOpSegment::debugContour(int id) {
1024 return this->contour()->debugContour(id);
1025}
1026
1027const SkOpPtT* SkOpSegment::debugPtT(int id) const {
1028 return this->contour()->debugPtT(id);
1029}
1030
1031const SkOpSegment* SkOpSegment::debugSegment(int id) const {
1032 return this->contour()->debugSegment(id);
1033}
1034
1035const SkOpSpanBase* SkOpSegment::debugSpan(int id) const {
1036 return this->contour()->debugSpan(id);
1037}
1038
1039void SkOpSegment::dump() const {
1040 SkDebugf("%.*s", contour()->debugIndent(), " ");
1041 this->dumpPts();
1042 const SkOpSpanBase* span = &fHead;
1043 contour()->indentDump();
1044 do {
1045 SkDebugf("%.*s span=%d ", contour()->debugIndent(), " ", span->debugID());
1046 span->ptT()->dumpBase();
1047 span->dumpBase();
1048 SkDebugf("\n");
1049 } while (!span->final() && (span = span->upCast()->next()));
1050 contour()->outdentDump();
1051}
1052
1053void SkOpSegment::dumpAll() const {
1054 SkDebugf("%.*s", contour()->debugIndent(), " ");
1055 this->dumpPts();
1056 const SkOpSpanBase* span = &fHead;
1057 contour()->indentDump();
1058 do {
1059 span->dumpAll();
1060 } while (!span->final() && (span = span->upCast()->next()));
1061 contour()->outdentDump();
1062}
1063
1064void SkOpSegment::dumpAngles() const {
1065 SkDebugf("seg=%d\n", debugID());
1066 const SkOpSpanBase* span = &fHead;
1067 do {
1068 const SkOpAngle* fAngle = span->fromAngle();
1069 const SkOpAngle* tAngle = span->final() ? NULL : span->upCast()->toAngle();
1070 if (fAngle) {
1071 SkDebugf(" span=%d from=%d ", span->debugID(), fAngle->debugID());
1072 fAngle->dumpTo(this, tAngle);
1073 }
1074 if (tAngle) {
1075 SkDebugf(" span=%d to=%d ", span->debugID(), tAngle->debugID());
1076 tAngle->dumpTo(this, fAngle);
1077 }
1078 } while (!span->final() && (span = span->upCast()->next()));
1079}
1080
1081void SkOpSegment::dumpCoin() const {
1082 const SkOpSpan* span = &fHead;
1083 do {
1084 span->dumpCoin();
1085 } while ((span = span->next()->upCastable()));
1086}
1087
caryclark624637c2015-05-11 07:21:27 -07001088void SkOpSegment::dumpPtsInner() const {
caryclark54359292015-03-26 07:52:43 -07001089 int last = SkPathOpsVerbToPoints(fVerb);
1090 SkDebugf("seg=%d {{", this->debugID());
caryclark1049f122015-04-20 08:31:59 -07001091 if (fVerb == SkPath::kConic_Verb) {
1092 SkDebugf("{");
1093 }
caryclark54359292015-03-26 07:52:43 -07001094 int index = 0;
1095 do {
1096 SkDPoint::Dump(fPts[index]);
1097 SkDebugf(", ");
1098 } while (++index < last);
1099 SkDPoint::Dump(fPts[index]);
caryclark1049f122015-04-20 08:31:59 -07001100 SkDebugf("}}");
1101 if (fVerb == SkPath::kConic_Verb) {
1102 SkDebugf(", %1.9gf}", fWeight);
1103 }
caryclark624637c2015-05-11 07:21:27 -07001104}
1105
1106void SkOpSegment::dumpPts() const {
1107 dumpPtsInner();
caryclark1049f122015-04-20 08:31:59 -07001108 SkDebugf("\n");
caryclark54359292015-03-26 07:52:43 -07001109}
1110
1111void SkCoincidentSpans::dump() const {
1112 SkDebugf("- seg=%d span=%d ptT=%d ", fCoinPtTStart->segment()->debugID(),
1113 fCoinPtTStart->span()->debugID(), fCoinPtTStart->debugID());
1114 fCoinPtTStart->dumpBase();
1115 SkDebugf(" span=%d ptT=%d ", fCoinPtTEnd->span()->debugID(), fCoinPtTEnd->debugID());
1116 fCoinPtTEnd->dumpBase();
1117 if (fCoinPtTStart->segment()->operand()) {
1118 SkDebugf(" operand");
1119 }
1120 if (fCoinPtTStart->segment()->isXor()) {
1121 SkDebugf(" xor");
1122 }
1123 SkDebugf("\n");
1124 SkDebugf("+ seg=%d span=%d ptT=%d ", fOppPtTStart->segment()->debugID(),
1125 fOppPtTStart->span()->debugID(), fOppPtTStart->debugID());
1126 fOppPtTStart->dumpBase();
1127 SkDebugf(" span=%d ptT=%d ", fOppPtTEnd->span()->debugID(), fOppPtTEnd->debugID());
1128 fOppPtTEnd->dumpBase();
1129 if (fOppPtTStart->segment()->operand()) {
1130 SkDebugf(" operand");
1131 }
1132 if (fOppPtTStart->segment()->isXor()) {
1133 SkDebugf(" xor");
1134 }
1135 SkDebugf("\n");
1136}
1137
1138void SkOpCoincidence::dump() const {
1139 SkCoincidentSpans* span = fHead;
1140 while (span) {
1141 span->dump();
1142 span = span->fNext;
1143 }
caryclark27c8eb82015-07-06 11:38:33 -07001144 if (!fTop) {
1145 return;
1146 }
1147 SkDebugf("top:\n");
1148 span = fTop;
1149 while (span) {
1150 span->dump();
1151 span = span->fNext;
1152 }
caryclark54359292015-03-26 07:52:43 -07001153}
1154
caryclark624637c2015-05-11 07:21:27 -07001155void SkOpContour::dump() const {
caryclark1049f122015-04-20 08:31:59 -07001156 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001157 if (!fCount) {
1158 return;
1159 }
1160 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001161 SkDEBUGCODE(fDebugIndent = 0);
1162 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001163 do {
1164 segment->dump();
1165 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001166 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001167}
1168
caryclark624637c2015-05-11 07:21:27 -07001169void SkOpContour::dumpAll() const {
caryclark1049f122015-04-20 08:31:59 -07001170 SkDebugf("contour=%d count=%d op=%d xor=%d\n", this->debugID(), fCount, fOperand, fXor);
caryclark54359292015-03-26 07:52:43 -07001171 if (!fCount) {
1172 return;
1173 }
1174 const SkOpSegment* segment = &fHead;
caryclark624637c2015-05-11 07:21:27 -07001175 SkDEBUGCODE(fDebugIndent = 0);
1176 this->indentDump();
caryclark54359292015-03-26 07:52:43 -07001177 do {
1178 segment->dumpAll();
1179 } while ((segment = segment->next()));
caryclark624637c2015-05-11 07:21:27 -07001180 this->outdentDump();
caryclark54359292015-03-26 07:52:43 -07001181}
1182
1183
1184void SkOpContour::dumpAngles() const {
1185 SkDebugf("contour=%d\n", this->debugID());
1186 const SkOpSegment* segment = &fHead;
1187 do {
1188 SkDebugf(" seg=%d ", segment->debugID());
1189 segment->dumpAngles();
1190 } while ((segment = segment->next()));
1191}
1192
1193void SkOpContour::dumpPt(int index) const {
1194 const SkOpSegment* segment = &fHead;
1195 do {
1196 if (segment->debugID() == index) {
1197 segment->dumpPts();
1198 }
1199 } while ((segment = segment->next()));
1200}
1201
1202void SkOpContour::dumpPts() const {
1203 SkDebugf("contour=%d\n", this->debugID());
1204 const SkOpSegment* segment = &fHead;
1205 do {
1206 SkDebugf(" seg=%d ", segment->debugID());
1207 segment->dumpPts();
1208 } while ((segment = segment->next()));
1209}
1210
1211void SkOpContour::dumpPtsX() const {
1212 if (!this->fCount) {
1213 SkDebugf("<empty>\n");
1214 return;
1215 }
1216 const SkOpSegment* segment = &fHead;
1217 do {
1218 segment->dumpPts();
1219 } while ((segment = segment->next()));
1220}
1221
1222void SkOpContour::dumpSegment(int index) const {
1223 debugSegment(index)->dump();
1224}
1225
1226void SkOpContour::dumpSegments(SkPathOp op) const {
1227 bool firstOp = false;
1228 const SkOpContour* c = this;
1229 do {
1230 if (!firstOp && c->operand()) {
1231#if DEBUG_ACTIVE_OP
1232 SkDebugf("op %s\n", SkPathOpsDebug::kPathOpStr[op]);
1233#endif
1234 firstOp = true;
1235 }
1236 c->dumpPtsX();
1237 } while ((c = c->next()));
1238}
1239
1240void SkOpContour::dumpSpan(int index) const {
1241 debugSpan(index)->dump();
1242}
1243
1244void SkOpContour::dumpSpans() const {
1245 SkDebugf("contour=%d\n", this->debugID());
1246 const SkOpSegment* segment = &fHead;
1247 do {
1248 SkDebugf(" seg=%d ", segment->debugID());
1249 segment->dump();
1250 } while ((segment = segment->next()));
1251}
1252
caryclark03b03ca2015-04-23 09:13:37 -07001253void SkOpCurve::dump() const {
1254 int count = SkPathOpsVerbToPoints(SkDEBUGRELEASE(fVerb, SkPath::kCubic_Verb));
1255 SkDebugf("{{");
1256 int index;
1257 for (index = 0; index <= count - 1; ++index) {
1258 SkDebugf("{%1.9gf,%1.9gf}, ", fPts[index].fX, fPts[index].fY);
1259 }
1260 SkDebugf("{%1.9gf,%1.9gf}}}\n", fPts[index].fX, fPts[index].fY);
1261}
1262
caryclark54359292015-03-26 07:52:43 -07001263#ifdef SK_DEBUG
1264const SkOpAngle* SkOpGlobalState::debugAngle(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001265 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001266 do {
1267 const SkOpSegment* segment = contour->first();
1268 while (segment) {
1269 const SkOpSpan* span = segment->head();
1270 do {
1271 SkOpAngle* angle = span->fromAngle();
1272 if (angle && angle->debugID() == id) {
1273 return angle;
1274 }
1275 angle = span->toAngle();
1276 if (angle && angle->debugID() == id) {
1277 return angle;
1278 }
1279 } while ((span = span->next()->upCastable()));
1280 const SkOpSpanBase* tail = segment->tail();
1281 SkOpAngle* angle = tail->fromAngle();
1282 if (angle && angle->debugID() == id) {
1283 return angle;
1284 }
1285 segment = segment->next();
1286 }
1287 } while ((contour = contour->next()));
1288 return NULL;
1289}
1290
1291SkOpContour* SkOpGlobalState::debugContour(int id) {
caryclark624637c2015-05-11 07:21:27 -07001292 SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001293 do {
1294 if (contour->debugID() == id) {
1295 return contour;
1296 }
1297 } while ((contour = contour->next()));
1298 return NULL;
1299}
1300
1301const SkOpPtT* SkOpGlobalState::debugPtT(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001302 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001303 do {
1304 const SkOpSegment* segment = contour->first();
1305 while (segment) {
1306 const SkOpSpan* span = segment->head();
1307 do {
1308 const SkOpPtT* ptT = span->ptT();
1309 if (ptT->debugMatchID(id)) {
1310 return ptT;
1311 }
1312 } while ((span = span->next()->upCastable()));
1313 const SkOpSpanBase* tail = segment->tail();
1314 const SkOpPtT* ptT = tail->ptT();
1315 if (ptT->debugMatchID(id)) {
1316 return ptT;
1317 }
1318 segment = segment->next();
1319 }
1320 } while ((contour = contour->next()));
1321 return NULL;
1322}
1323
1324const SkOpSegment* SkOpGlobalState::debugSegment(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001325 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001326 do {
1327 const SkOpSegment* segment = contour->first();
1328 while (segment) {
1329 if (segment->debugID() == id) {
1330 return segment;
1331 }
1332 segment = segment->next();
1333 }
1334 } while ((contour = contour->next()));
1335 return NULL;
1336}
1337
1338const SkOpSpanBase* SkOpGlobalState::debugSpan(int id) const {
caryclark624637c2015-05-11 07:21:27 -07001339 const SkOpContour* contour = fContourHead;
caryclark54359292015-03-26 07:52:43 -07001340 do {
1341 const SkOpSegment* segment = contour->first();
1342 while (segment) {
1343 const SkOpSpan* span = segment->head();
1344 do {
1345 if (span->debugID() == id) {
1346 return span;
1347 }
1348 } while ((span = span->next()->upCastable()));
1349 const SkOpSpanBase* tail = segment->tail();
1350 if (tail->debugID() == id) {
1351 return tail;
1352 }
1353 segment = segment->next();
1354 }
1355 } while ((contour = contour->next()));
1356 return NULL;
1357}
1358#endif
1359
caryclark54359292015-03-26 07:52:43 -07001360#if DEBUG_T_SECT_DUMP > 1
1361int gDumpTSectNum;
1362#endif