blob: 9aec715de1186ee4d6693679b6954a0f4e724f5d [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
2 * Copyright 2013 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#ifndef SkPathOpsDebug_DEFINED
8#define SkPathOpsDebug_DEFINED
9
caryclark@google.coma5e55922013-05-07 18:51:31 +000010#include "SkPathOps.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000011#include "SkTypes.h"
bungeman60e0fee2015-08-26 05:15:46 -070012
13#include <stdlib.h>
bungeman@google.comfab44db2013-10-11 18:50:45 +000014#include <stdio.h>
caryclark@google.com07393ca2013-04-08 11:47:37 +000015
Cary Clarkab87d7a2016-10-04 10:01:04 -040016enum class SkOpPhase : char;
Cary Clarkb8421ed2018-03-14 15:55:02 -040017struct SkDQuad;
18class SkOpAngle;
19class SkOpCoincidence;
20class SkOpContour;
Cary Clarkab87d7a2016-10-04 10:01:04 -040021class SkOpContourHead;
Cary Clarkb8421ed2018-03-14 15:55:02 -040022class SkOpPtT;
23class SkOpSegment;
24class SkOpSpan;
25class SkOpSpanBase;
26struct SkDPoint;
27struct SkDLine;
28struct SkDQuad;
29struct SkDConic;
30struct SkDCubic;
31template<typename TCurve, typename OppCurve> class SkTSect;
32
33// dummy classes to fool msvs Visual Studio 2018 Immediate Window
34#define DummyClasses(a, b) \
35class SkDebugTCoincident##a##b; \
36class SkDebugTSect##a##b; \
37class SkDebugTSpan##a##b
38
39DummyClasses(Quad, Quad);
40DummyClasses(Conic, Quad);
41DummyClasses(Conic, Conic);
42DummyClasses(Cubic, Quad);
43DummyClasses(Cubic, Conic);
44DummyClasses(Cubic, Cubic);
45
46#undef DummyClasses
Cary Clarkab87d7a2016-10-04 10:01:04 -040047
caryclark@google.com07393ca2013-04-08 11:47:37 +000048#ifdef SK_RELEASE
49#define FORCE_RELEASE 1
50#else
caryclark@google.comb3f09212013-04-17 15:49:16 +000051#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging
caryclark@google.com07393ca2013-04-08 11:47:37 +000052#endif
53
caryclarkb36a3cd2016-10-18 07:59:44 -070054#define DEBUG_UNDER_DEVELOPMENT 0
caryclark27c015d2016-09-23 05:47:20 -070055
caryclark@google.com07393ca2013-04-08 11:47:37 +000056#define ONE_OFF_DEBUG 0
57#define ONE_OFF_DEBUG_MATHEMATICA 0
58
caryclark@google.comdb60de72013-04-11 12:33:23 +000059#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_ANDROID)
caryclark@google.com07393ca2013-04-08 11:47:37 +000060 #define SK_RAND(seed) rand()
caryclark@google.com07393ca2013-04-08 11:47:37 +000061#else
62 #define SK_RAND(seed) rand_r(&seed)
caryclark@google.comdb60de72013-04-11 12:33:23 +000063#endif
64#ifdef SK_BUILD_FOR_WIN
65 #define SK_SNPRINTF _snprintf
66#else
skia.committer@gmail.com32840172013-04-09 07:01:27 +000067 #define SK_SNPRINTF snprintf
caryclark@google.com07393ca2013-04-08 11:47:37 +000068#endif
69
commit-bot@chromium.org4431e772014-04-14 17:08:59 +000070#define WIND_AS_STRING(x) char x##Str[12]; \
71 if (!SkPathOpsDebug::ValidWind(x)) strcpy(x##Str, "?"); \
72 else SK_SNPRINTF(x##Str, sizeof(x##Str), "%d", x)
73
caryclark@google.com07393ca2013-04-08 11:47:37 +000074#if FORCE_RELEASE
75
76#define DEBUG_ACTIVE_OP 0
77#define DEBUG_ACTIVE_SPANS 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000078#define DEBUG_ADD_INTERSECTING_TS 0
caryclark54359292015-03-26 07:52:43 -070079#define DEBUG_ADD_T 0
caryclark26ad22a2015-10-16 09:03:38 -070080#define DEBUG_ALIGNMENT 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000081#define DEBUG_ANGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000082#define DEBUG_ASSEMBLE 0
Cary Clarkab87d7a2016-10-04 10:01:04 -040083#define DEBUG_COINCIDENCE 0 // sanity checking
84#define DEBUG_COINCIDENCE_DUMP 0 // accumulate and dump which algorithms fired
85#define DEBUG_COINCIDENCE_ORDER 0 // for well behaved curves, check if pairs match up in t-order
86#define DEBUG_COINCIDENCE_VERBOSE 0 // usually whether the next function generates coincidence
commit-bot@chromium.org2db7fe72014-05-07 15:31:40 +000087#define DEBUG_CUBIC_BINARY_SEARCH 0
caryclark03b03ca2015-04-23 09:13:37 -070088#define DEBUG_CUBIC_SPLIT 0
caryclark624637c2015-05-11 07:21:27 -070089#define DEBUG_DUMP_SEGMENTS 0
Cary Clark918fb1f2016-11-15 13:22:25 -050090#define DEBUG_DUMP_VERIFY 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000091#define DEBUG_FLOW 0
commit-bot@chromium.org8cb1daa2014-04-25 12:59:11 +000092#define DEBUG_LIMIT_WIND_SUM 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000093#define DEBUG_MARK_DONE 0
94#define DEBUG_PATH_CONSTRUCTION 0
caryclark54359292015-03-26 07:52:43 -070095#define DEBUG_PERP 0
caryclark624637c2015-05-11 07:21:27 -070096#define DEBUG_SHOW_TEST_NAME 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000097#define DEBUG_SORT 0
caryclark54359292015-03-26 07:52:43 -070098#define DEBUG_T_SECT 0
99#define DEBUG_T_SECT_DUMP 0
caryclark26ad22a2015-10-16 09:03:38 -0700100#define DEBUG_T_SECT_LOOP_COUNT 0
caryclark@google.com4fdbb222013-07-23 15:27:41 +0000101#define DEBUG_VALIDATE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +0000102#define DEBUG_WINDING 0
103#define DEBUG_WINDING_AT_T 0
104
105#else
106
107#define DEBUG_ACTIVE_OP 1
108#define DEBUG_ACTIVE_SPANS 1
caryclark@google.com07393ca2013-04-08 11:47:37 +0000109#define DEBUG_ADD_INTERSECTING_TS 1
caryclark54359292015-03-26 07:52:43 -0700110#define DEBUG_ADD_T 1
caryclark26ad22a2015-10-16 09:03:38 -0700111#define DEBUG_ALIGNMENT 0
caryclark@google.com07393ca2013-04-08 11:47:37 +0000112#define DEBUG_ANGLE 1
caryclark@google.com07393ca2013-04-08 11:47:37 +0000113#define DEBUG_ASSEMBLE 1
Cary Clarkff114282016-12-14 11:56:16 -0500114#define DEBUG_COINCIDENCE 1
Cary Clarkab87d7a2016-10-04 10:01:04 -0400115#define DEBUG_COINCIDENCE_DUMP 0
caryclark81a478c2016-09-09 09:37:57 -0700116#define DEBUG_COINCIDENCE_ORDER 0 // tight arc quads may generate out-of-order coincdence spans
Cary Clarkff114282016-12-14 11:56:16 -0500117#define DEBUG_COINCIDENCE_VERBOSE 1
caryclark65b427c2014-09-18 10:32:57 -0700118#define DEBUG_CUBIC_BINARY_SEARCH 0
caryclark03b03ca2015-04-23 09:13:37 -0700119#define DEBUG_CUBIC_SPLIT 1
Cary Clark918fb1f2016-11-15 13:22:25 -0500120#define DEBUG_DUMP_VERIFY 0
caryclark03b03ca2015-04-23 09:13:37 -0700121#define DEBUG_DUMP_SEGMENTS 1
caryclark@google.com07393ca2013-04-08 11:47:37 +0000122#define DEBUG_FLOW 1
caryclark55888e42016-07-18 10:01:36 -0700123#define DEBUG_LIMIT_WIND_SUM 15
caryclark@google.com07393ca2013-04-08 11:47:37 +0000124#define DEBUG_MARK_DONE 1
125#define DEBUG_PATH_CONSTRUCTION 1
caryclark03b03ca2015-04-23 09:13:37 -0700126#define DEBUG_PERP 1
caryclark@google.com03610322013-04-18 15:58:21 +0000127#define DEBUG_SHOW_TEST_NAME 1
caryclark@google.com07393ca2013-04-08 11:47:37 +0000128#define DEBUG_SORT 1
Cary Clarkb8421ed2018-03-14 15:55:02 -0400129#define DEBUG_T_SECT 0 // enabling may trigger validate asserts even though op does not fail
caryclarke839e782016-09-15 07:48:18 -0700130#define DEBUG_T_SECT_DUMP 0 // Use 1 normally. Use 2 to number segments, 3 for script output
caryclarked0935a2015-10-22 07:23:52 -0700131#define DEBUG_T_SECT_LOOP_COUNT 0
caryclark54359292015-03-26 07:52:43 -0700132#define DEBUG_VALIDATE 1
caryclark@google.com07393ca2013-04-08 11:47:37 +0000133#define DEBUG_WINDING 1
134#define DEBUG_WINDING_AT_T 1
135
136#endif
137
caryclark54359292015-03-26 07:52:43 -0700138#ifdef SK_RELEASE
caryclark1049f122015-04-20 08:31:59 -0700139 #define SkDEBUGRELEASE(a, b) b
140 #define SkDEBUGPARAMS(...)
reed0dc4dd62015-03-24 13:55:33 -0700141#else
caryclark1049f122015-04-20 08:31:59 -0700142 #define SkDEBUGRELEASE(a, b) a
143 #define SkDEBUGPARAMS(...) , __VA_ARGS__
reed0dc4dd62015-03-24 13:55:33 -0700144#endif
caryclark54359292015-03-26 07:52:43 -0700145
caryclark27c8eb82015-07-06 11:38:33 -0700146#if DEBUG_VALIDATE == 0
147 #define PATH_OPS_DEBUG_VALIDATE_PARAMS(...)
148#else
149 #define PATH_OPS_DEBUG_VALIDATE_PARAMS(...) , __VA_ARGS__
150#endif
151
caryclark54359292015-03-26 07:52:43 -0700152#if DEBUG_T_SECT == 0
153 #define PATH_OPS_DEBUG_T_SECT_RELEASE(a, b) b
154 #define PATH_OPS_DEBUG_T_SECT_PARAMS(...)
155 #define PATH_OPS_DEBUG_T_SECT_CODE(...)
156#else
157 #define PATH_OPS_DEBUG_T_SECT_RELEASE(a, b) a
158 #define PATH_OPS_DEBUG_T_SECT_PARAMS(...) , __VA_ARGS__
159 #define PATH_OPS_DEBUG_T_SECT_CODE(...) __VA_ARGS__
160#endif
161
162#if DEBUG_T_SECT_DUMP > 1
163 extern int gDumpTSectNum;
164#endif
165
Ben Wagner63fd7602017-10-09 15:45:33 -0400166#if DEBUG_COINCIDENCE || DEBUG_COINCIDENCE_DUMP
Cary Clarkab87d7a2016-10-04 10:01:04 -0400167 #define DEBUG_COIN 1
caryclark26ad22a2015-10-16 09:03:38 -0700168#else
Cary Clarkab87d7a2016-10-04 10:01:04 -0400169 #define DEBUG_COIN 0
170#endif
171
172#if DEBUG_COIN
173 #define DEBUG_COIN_DECLARE_ONLY_PARAMS() \
174 int lineNo, SkOpPhase phase, int iteration
175 #define DEBUG_COIN_DECLARE_PARAMS() \
176 , DEBUG_COIN_DECLARE_ONLY_PARAMS()
177 #define DEBUG_COIN_ONLY_PARAMS() \
178 __LINE__, SkOpPhase::kNoChange, 0
179 #define DEBUG_COIN_PARAMS() \
180 , DEBUG_COIN_ONLY_PARAMS()
181 #define DEBUG_ITER_ONLY_PARAMS(iteration) \
182 __LINE__, SkOpPhase::kNoChange, iteration
183 #define DEBUG_ITER_PARAMS(iteration) \
184 , DEBUG_ITER_ONLY_PARAMS(iteration)
185 #define DEBUG_PHASE_ONLY_PARAMS(phase) \
186 __LINE__, SkOpPhase::phase, 0
187 #define DEBUG_PHASE_PARAMS(phase) \
188 , DEBUG_PHASE_ONLY_PARAMS(phase)
189 #define DEBUG_SET_PHASE() \
190 this->globalState()->debugSetPhase(__func__, lineNo, phase, iteration)
191 #define DEBUG_STATIC_SET_PHASE(obj) \
192 obj->globalState()->debugSetPhase(__func__, lineNo, phase, iteration)
193#elif DEBUG_VALIDATE
194 #define DEBUG_COIN_DECLARE_ONLY_PARAMS() \
195 SkOpPhase phase
196 #define DEBUG_COIN_DECLARE_PARAMS() \
197 , DEBUG_COIN_DECLARE_ONLY_PARAMS()
198 #define DEBUG_COIN_ONLY_PARAMS() \
199 SkOpPhase::kNoChange
200 #define DEBUG_COIN_PARAMS() \
201 , DEBUG_COIN_ONLY_PARAMS()
202 #define DEBUG_ITER_ONLY_PARAMS(iteration) \
203 SkOpPhase::kNoChange
204 #define DEBUG_ITER_PARAMS(iteration) \
205 , DEBUG_ITER_ONLY_PARAMS(iteration)
206 #define DEBUG_PHASE_ONLY_PARAMS(phase) \
207 SkOpPhase::phase
208 #define DEBUG_PHASE_PARAMS(phase) \
209 , DEBUG_PHASE_ONLY_PARAMS(phase)
210 #define DEBUG_SET_PHASE() \
211 this->globalState()->debugSetPhase(phase)
212 #define DEBUG_STATIC_SET_PHASE(obj) \
213 obj->globalState()->debugSetPhase(phase)
214#else
215 #define DEBUG_COIN_DECLARE_ONLY_PARAMS()
216 #define DEBUG_COIN_DECLARE_PARAMS()
217 #define DEBUG_COIN_ONLY_PARAMS()
218 #define DEBUG_COIN_PARAMS()
219 #define DEBUG_ITER_ONLY_PARAMS(iteration)
220 #define DEBUG_ITER_PARAMS(iteration)
221 #define DEBUG_PHASE_ONLY_PARAMS(phase)
222 #define DEBUG_PHASE_PARAMS(phase)
223 #define DEBUG_SET_PHASE()
224 #define DEBUG_STATIC_SET_PHASE(obj)
caryclark26ad22a2015-10-16 09:03:38 -0700225#endif
226
caryclark1049f122015-04-20 08:31:59 -0700227#define CUBIC_DEBUG_STR "{{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}}"
228#define CONIC_DEBUG_STR "{{{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}}, %1.9g}"
229#define QUAD_DEBUG_STR "{{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}}"
230#define LINE_DEBUG_STR "{{{%1.9g,%1.9g}, {%1.9g,%1.9g}}}"
caryclark54359292015-03-26 07:52:43 -0700231#define PT_DEBUG_STR "{{%1.9g,%1.9g}}"
232
caryclark@google.com07393ca2013-04-08 11:47:37 +0000233#define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g"
234#define TX_DEBUG_STR(t) #t "[%d]=%1.9g"
235#define CUBIC_DEBUG_DATA(c) c[0].fX, c[0].fY, c[1].fX, c[1].fY, c[2].fX, c[2].fY, c[3].fX, c[3].fY
caryclark1049f122015-04-20 08:31:59 -0700236#define CONIC_DEBUG_DATA(c, w) c[0].fX, c[0].fY, c[1].fX, c[1].fY, c[2].fX, c[2].fY, w
caryclark@google.com07393ca2013-04-08 11:47:37 +0000237#define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY
238#define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY
caryclarkdac1d172014-06-17 05:15:38 -0700239#define PT_DEBUG_DATA(i, n) i.pt(n).asSkPoint().fX, i.pt(n).asSkPoint().fY
caryclark@google.com07393ca2013-04-08 11:47:37 +0000240
caryclark@google.com07e97fc2013-07-08 17:17:02 +0000241#ifndef DEBUG_TEST
242#define DEBUG_TEST 0
caryclark@google.coma5e55922013-05-07 18:51:31 +0000243#endif
244
caryclark@google.com570863f2013-09-16 15:55:01 +0000245#if DEBUG_SHOW_TEST_NAME
246#include "SkTLS.h"
247#endif
248
caryclark29b25632016-08-25 11:27:17 -0700249// Tests with extreme numbers may fail, but all other tests should never fail.
250#define FAIL_IF(cond) \
251 do { bool fail = (cond); SkOPASSERT(!fail); if (fail) return false; } while (false)
caryclark025b11e2016-08-25 05:21:14 -0700252
caryclark29b25632016-08-25 11:27:17 -0700253#define FAIL_WITH_NULL_IF(cond) \
254 do { bool fail = (cond); SkOPASSERT(!fail); if (fail) return nullptr; } while (false)
255
256// Some functions serve two masters: one allows the function to fail, the other expects success
257// always. If abort is true, tests with normal numbers may not fail and assert if they do so.
258// If abort is false, both normal and extreme numbers may return false without asserting.
caryclark025b11e2016-08-25 05:21:14 -0700259#define RETURN_FALSE_IF(abort, cond) \
caryclark29b25632016-08-25 11:27:17 -0700260 do { bool fail = (cond); SkOPASSERT(!(abort) || !fail); if (fail) return false; \
261 } while (false)
caryclark025b11e2016-08-25 05:21:14 -0700262
caryclark@google.com570863f2013-09-16 15:55:01 +0000263class SkPathOpsDebug {
264public:
Cary Clarkab87d7a2016-10-04 10:01:04 -0400265#if DEBUG_COIN
caryclark26ad22a2015-10-16 09:03:38 -0700266 struct GlitchLog;
commit-bot@chromium.org8cb1daa2014-04-25 12:59:11 +0000267
Cary Clarkab87d7a2016-10-04 10:01:04 -0400268 enum GlitchType {
269 kUninitialized_Glitch,
270 kAddCorruptCoin_Glitch,
271 kAddExpandedCoin_Glitch,
272 kAddExpandedFail_Glitch,
273 kAddIfCollapsed_Glitch,
274 kAddIfMissingCoin_Glitch,
275 kAddMissingCoin_Glitch,
276 kAddMissingExtend_Glitch,
277 kAddOrOverlap_Glitch,
278 kCollapsedCoin_Glitch,
279 kCollapsedDone_Glitch,
280 kCollapsedOppValue_Glitch,
281 kCollapsedSpan_Glitch,
282 kCollapsedWindValue_Glitch,
283 kCorrectEnd_Glitch,
284 kDeletedCoin_Glitch,
285 kExpandCoin_Glitch,
286 kFail_Glitch,
287 kMarkCoinEnd_Glitch,
288 kMarkCoinInsert_Glitch,
289 kMarkCoinMissing_Glitch,
290 kMarkCoinStart_Glitch,
Cary Clarkab87d7a2016-10-04 10:01:04 -0400291 kMergeMatches_Glitch,
292 kMissingCoin_Glitch,
293 kMissingDone_Glitch,
294 kMissingIntersection_Glitch,
295 kMoveMultiple_Glitch,
296 kMoveNearbyClearAll_Glitch,
297 kMoveNearbyClearAll2_Glitch,
298 kMoveNearbyMerge_Glitch,
299 kMoveNearbyMergeFinal_Glitch,
300 kMoveNearbyRelease_Glitch,
301 kMoveNearbyReleaseFinal_Glitch,
302 kReleasedSpan_Glitch,
303 kReturnFalse_Glitch,
304 kUnaligned_Glitch,
305 kUnalignedHead_Glitch,
306 kUnalignedTail_Glitch,
307 };
308
309 struct CoinDictEntry {
310 int fIteration;
311 int fLineNumber;
312 GlitchType fGlitchType;
313 const char* fFunctionName;
314 };
315
316 struct CoinDict {
317 void add(const CoinDictEntry& key);
318 void add(const CoinDict& dict);
319 void dump(const char* str, bool visitCheck) const;
320 SkTDArray<CoinDictEntry> fDict;
321 };
322
323 static CoinDict gCoinSumChangedDict;
324 static CoinDict gCoinSumVisitedDict;
325 static CoinDict gCoinVistedDict;
326#endif
327
commit-bot@chromium.org8cb1daa2014-04-25 12:59:11 +0000328#if defined(SK_DEBUG) || !FORCE_RELEASE
caryclark@google.com570863f2013-09-16 15:55:01 +0000329 static int gContourID;
330 static int gSegmentID;
commit-bot@chromium.org8cb1daa2014-04-25 12:59:11 +0000331#endif
caryclark@google.com570863f2013-09-16 15:55:01 +0000332
caryclark624637c2015-05-11 07:21:27 -0700333#if DEBUG_SORT
caryclark@google.com570863f2013-09-16 15:55:01 +0000334 static int gSortCountDefault;
335 static int gSortCount;
336#endif
337
338#if DEBUG_ACTIVE_OP
339 static const char* kPathOpStr[];
340#endif
Cary Clarkb8421ed2018-03-14 15:55:02 -0400341 static bool gRunFail;
342 static bool gVeryVerbose;
caryclark@google.com570863f2013-09-16 15:55:01 +0000343
Cary Clarkb8421ed2018-03-14 15:55:02 -0400344#if DEBUG_ACTIVE_SPANS
345 static SkString gActiveSpans;
346#endif
347#if DEBUG_DUMP_VERIFY
348 static bool gDumpOp;
349 static bool gVerifyOp;
350#endif
351
352 static const char* OpStr(SkPathOp );
caryclark@google.com570863f2013-09-16 15:55:01 +0000353 static void MathematicaIze(char* str, size_t bufferSize);
354 static bool ValidWind(int winding);
355 static void WindingPrintf(int winding);
356
357#if DEBUG_SHOW_TEST_NAME
358 static void* CreateNameStr();
359 static void DeleteNameStr(void* v);
360#define DEBUG_FILENAME_STRING_LENGTH 64
361#define DEBUG_FILENAME_STRING (reinterpret_cast<char* >(SkTLS::Get(SkPathOpsDebug::CreateNameStr, \
362 SkPathOpsDebug::DeleteNameStr)))
363 static void BumpTestName(char* );
caryclark@google.com570863f2013-09-16 15:55:01 +0000364#endif
caryclark55888e42016-07-18 10:01:36 -0700365 static void ShowActiveSpans(SkOpContourHead* contourList);
caryclark19eb3b22014-07-18 05:08:14 -0700366 static void ShowOnePath(const SkPath& path, const char* name, bool includeDeclaration);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000367 static void ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name);
caryclark54359292015-03-26 07:52:43 -0700368
Cary Clarkb8421ed2018-03-14 15:55:02 -0400369 static bool ChaseContains(const SkTDArray<SkOpSpanBase*>& , const SkOpSpanBase* );
caryclark54359292015-03-26 07:52:43 -0700370
Cary Clarkab87d7a2016-10-04 10:01:04 -0400371 static void CheckHealth(class SkOpContourHead* contourList);
caryclark26ad22a2015-10-16 09:03:38 -0700372
Cary Clarkab87d7a2016-10-04 10:01:04 -0400373#if DEBUG_COIN
Cary Clarkb8421ed2018-03-14 15:55:02 -0400374 static void DumpCoinDict();
375 static void DumpGlitchType(GlitchType );
Cary Clarkff114282016-12-14 11:56:16 -0500376#endif
377
caryclark@google.com570863f2013-09-16 15:55:01 +0000378};
379
Cary Clarkb8421ed2018-03-14 15:55:02 -0400380// Visual Studio 2017 does not permit calling member functions from the Immediate Window.
381// Global functions work fine, however. Use globals within a namespace rather than
382// static members inside a class.
383namespace SkOpDebug {
384 const SkOpAngle* AngleAngle(const SkOpAngle*, int id);
385 SkOpContour* AngleContour(SkOpAngle*, int id);
386 const SkOpPtT* AnglePtT(const SkOpAngle*, int id);
387 const SkOpSegment* AngleSegment(const SkOpAngle*, int id);
388 const SkOpSpanBase* AngleSpan(const SkOpAngle*, int id);
389
390 const SkOpAngle* ContourAngle(SkOpContour*, int id);
391 SkOpContour* ContourContour(SkOpContour*, int id);
392 const SkOpPtT* ContourPtT(SkOpContour*, int id);
393 const SkOpSegment* ContourSegment(SkOpContour*, int id);
394 const SkOpSpanBase* ContourSpan(SkOpContour*, int id);
395
396 const SkOpAngle* CoincidenceAngle(SkOpCoincidence*, int id);
397 SkOpContour* CoincidenceContour(SkOpCoincidence*, int id);
398 const SkOpPtT* CoincidencePtT(SkOpCoincidence*, int id);
399 const SkOpSegment* CoincidenceSegment(SkOpCoincidence*, int id);
400 const SkOpSpanBase* CoincidenceSpan(SkOpCoincidence*, int id);
401
402 const SkOpAngle* PtTAngle(const SkOpPtT*, int id);
403 SkOpContour* PtTContour(SkOpPtT*, int id);
404 const SkOpPtT* PtTPtT(const SkOpPtT*, int id);
405 const SkOpSegment* PtTSegment(const SkOpPtT*, int id);
406 const SkOpSpanBase* PtTSpan(const SkOpPtT*, int id);
407
408 const SkOpAngle* SegmentAngle(const SkOpSegment*, int id);
409 SkOpContour* SegmentContour(SkOpSegment*, int id);
410 const SkOpPtT* SegmentPtT(const SkOpSegment*, int id);
411 const SkOpSegment* SegmentSegment(const SkOpSegment*, int id);
412 const SkOpSpanBase* SegmentSpan(const SkOpSegment*, int id);
413
414 const SkOpAngle* SpanAngle(const SkOpSpanBase*, int id);
415 SkOpContour* SpanContour(SkOpSpanBase*, int id);
416 const SkOpPtT* SpanPtT(const SkOpSpanBase*, int id);
417 const SkOpSegment* SpanSegment(const SkOpSpanBase*, int id);
418 const SkOpSpanBase* SpanSpan(const SkOpSpanBase*, int id);
419
420#if DEBUG_DUMP_VERIFY
421 void DumpOp(const SkPath& one, const SkPath& two, SkPathOp op,
422 const char* testName);
423 void DumpOp(FILE* file, const SkPath& one, const SkPath& two, SkPathOp op,
424 const char* testName);
425 void DumpSimplify(const SkPath& path, const char* testName);
426 void DumpSimplify(FILE* file, const SkPath& path, const char* testName);
427 void ReportOpFail(const SkPath& one, const SkPath& two, SkPathOp op);
428 void ReportSimplifyFail(const SkPath& path);
429 void VerifyOp(const SkPath& one, const SkPath& two, SkPathOp op,
430 const SkPath& result);
431 void VerifySimplify(const SkPath& path, const SkPath& result);
432#endif
433
434 // global path dumps for msvs Visual Studio 17 to use from Immediate Window
435 void Dump(const SkOpContour& );
436 void DumpAll(const SkOpContour& );
437 void DumpAngles(const SkOpContour& );
438 void DumpContours(const SkOpContour& );
439 void DumpContoursAll(const SkOpContour& );
440 void DumpContoursAngles(const SkOpContour& );
441 void DumpContoursPts(const SkOpContour& );
442 void DumpContoursPt(const SkOpContour& , int segmentID);
443 void DumpContoursSegment(const SkOpContour& , int segmentID);
444 void DumpContoursSpan(const SkOpContour& , int segmentID);
445 void DumpContoursSpans(const SkOpContour& );
446 void DumpPt(const SkOpContour& , int );
447 void DumpPts(const SkOpContour& , const char* prefix = "seg");
448 void DumpSegment(const SkOpContour& , int );
449 void DumpSegments(const SkOpContour& , const char* prefix = "seg", SkPathOp op = (SkPathOp) -1);
450 void DumpSpan(const SkOpContour& , int );
451 void DumpSpans(const SkOpContour& );
452
453 void Dump(const SkOpSegment& );
454 void DumpAll(const SkOpSegment& );
455 void DumpAngles(const SkOpSegment& );
456 void DumpCoin(const SkOpSegment& );
457 void DumpPts(const SkOpSegment& , const char* prefix = "seg");
458
459 void Dump(const SkOpPtT& );
460 void DumpAll(const SkOpPtT& );
461
462 void Dump(const SkOpSpanBase& );
463 void DumpCoin(const SkOpSpanBase& );
464 void DumpAll(const SkOpSpanBase& );
465
466 void DumpCoin(const SkOpSpan& );
467 bool DumpSpan(const SkOpSpan& );
468
469 void Dump(const SkDConic& );
470 void DumpID(const SkDConic& , int id);
471
472 void Dump(const SkDCubic& );
473 void DumpID(const SkDCubic& , int id);
474
475 void Dump(const SkDLine& );
476 void DumpID(const SkDLine& , int id);
477
478 void Dump(const SkDQuad& );
479 void DumpID(const SkDQuad& , int id);
480
481 void Dump(const SkDPoint& );
482
483// dummy declarations to fool msvs Visual Studio 2018 Immediate Window
484#define DummyDeclarations(a, b) \
485 void Dump(const SkDebugTCoincident##a##b& ); \
486 \
487 void Dump(const SkDebugTSect##a##b& ); \
488 void DumpBoth(const SkDebugTSect##a##b& , SkDebugTSect##a##b* ); \
489 void DumpBounded(const SkDebugTSect##a##b& , int id); \
490 void DumpBounds(const SkDebugTSect##a##b& ); \
491 void DumpCoin(const SkDebugTSect##a##b& ); \
492 void DumpCoinCurves(const SkDebugTSect##a##b& ); \
493 void DumpCurves(const SkDebugTSect##a##b& ); \
494 \
495 void Dump(const SkDebugTSpan##a##b& ); \
496 void DumpAll(const SkDebugTSpan##a##b& ); \
497 void DumpBounded(const SkDebugTSpan##a##b& , int id); \
498 void DumpBounds(const SkDebugTSpan##a##b& ); \
499 void DumpCoin(const SkDebugTSpan##a##b& )
500
501 DummyDeclarations(Quad, Quad);
502 DummyDeclarations(Conic, Quad);
503 DummyDeclarations(Conic, Conic);
504 DummyDeclarations(Cubic, Quad);
505 DummyDeclarations(Cubic, Conic);
506 DummyDeclarations(Cubic, Cubic);
507#undef DummyDeclarations
508}
caryclarkdac1d172014-06-17 05:15:38 -0700509
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000510// generates tools/path_sorter.htm and path_visualizer.htm compatible data
caryclark54359292015-03-26 07:52:43 -0700511void DumpQ(const SkDQuad& quad1, const SkDQuad& quad2, int testNo);
512void DumpT(const SkDQuad& quad, double t);
commit-bot@chromium.org4431e772014-04-14 17:08:59 +0000513
Cary Clarkb8421ed2018-03-14 15:55:02 -0400514// global path dumps for msvs Visual Studio 17 to use from Immediate Window
515void Dump(const SkPath& path);
516void DumpHex(const SkPath& path);
517
caryclark@google.com07393ca2013-04-08 11:47:37 +0000518#endif