blob: 912f2f5f50050ebe3e4280bbbcbf626f54429cbb [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"
12
13#ifdef SK_RELEASE
14#define FORCE_RELEASE 1
15#else
caryclark@google.comb3f09212013-04-17 15:49:16 +000016#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging
caryclark@google.com07393ca2013-04-08 11:47:37 +000017#endif
18
19#define ONE_OFF_DEBUG 0
20#define ONE_OFF_DEBUG_MATHEMATICA 0
21
caryclark@google.comdb60de72013-04-11 12:33:23 +000022#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_ANDROID)
caryclark@google.com07393ca2013-04-08 11:47:37 +000023 #define SK_RAND(seed) rand()
caryclark@google.com07393ca2013-04-08 11:47:37 +000024#else
25 #define SK_RAND(seed) rand_r(&seed)
caryclark@google.comdb60de72013-04-11 12:33:23 +000026#endif
27#ifdef SK_BUILD_FOR_WIN
28 #define SK_SNPRINTF _snprintf
29#else
skia.committer@gmail.com32840172013-04-09 07:01:27 +000030 #define SK_SNPRINTF snprintf
caryclark@google.com07393ca2013-04-08 11:47:37 +000031#endif
32
caryclark@google.com07393ca2013-04-08 11:47:37 +000033#if FORCE_RELEASE
34
35#define DEBUG_ACTIVE_OP 0
36#define DEBUG_ACTIVE_SPANS 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000037#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0
38#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000039#define DEBUG_ADD_INTERSECTING_TS 0
40#define DEBUG_ADD_T_PAIR 0
41#define DEBUG_ANGLE 0
42#define DEBUG_AS_C_CODE 1
43#define DEBUG_ASSEMBLE 0
caryclark@google.com570863f2013-09-16 15:55:01 +000044#define DEBUG_CHECK_ENDS 0
45#define DEBUG_CHECK_TINY 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000046#define DEBUG_CONCIDENT 0
47#define DEBUG_CROSS 0
48#define DEBUG_FLAT_QUADS 0
49#define DEBUG_FLOW 0
50#define DEBUG_MARK_DONE 0
51#define DEBUG_PATH_CONSTRUCTION 0
caryclark@google.com03610322013-04-18 15:58:21 +000052#define DEBUG_SHOW_TEST_NAME 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000053#define DEBUG_SHOW_TEST_PROGRESS 0
54#define DEBUG_SHOW_WINDING 0
55#define DEBUG_SORT 0
caryclark@google.comcffbcc32013-06-04 17:59:42 +000056#define DEBUG_SORT_COMPACT 0
caryclark@google.com570863f2013-09-16 15:55:01 +000057#define DEBUG_SORT_RAW 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000058#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000059#define DEBUG_SWAP_TOP 0
60#define DEBUG_UNSORTABLE 0
caryclark@google.com4fdbb222013-07-23 15:27:41 +000061#define DEBUG_VALIDATE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000062#define DEBUG_WIND_BUMP 0
63#define DEBUG_WINDING 0
64#define DEBUG_WINDING_AT_T 0
65
66#else
67
68#define DEBUG_ACTIVE_OP 1
69#define DEBUG_ACTIVE_SPANS 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000070#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0
caryclark@google.comcffbcc32013-06-04 17:59:42 +000071#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000072#define DEBUG_ADD_INTERSECTING_TS 1
73#define DEBUG_ADD_T_PAIR 1
74#define DEBUG_ANGLE 1
75#define DEBUG_AS_C_CODE 1
76#define DEBUG_ASSEMBLE 1
caryclark@google.com570863f2013-09-16 15:55:01 +000077#define DEBUG_CHECK_ENDS 1
78#define DEBUG_CHECK_TINY 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000079#define DEBUG_CONCIDENT 1
caryclark@google.com570863f2013-09-16 15:55:01 +000080#define DEBUG_CROSS 01
caryclark@google.com07393ca2013-04-08 11:47:37 +000081#define DEBUG_FLAT_QUADS 0
82#define DEBUG_FLOW 1
83#define DEBUG_MARK_DONE 1
84#define DEBUG_PATH_CONSTRUCTION 1
caryclark@google.com03610322013-04-18 15:58:21 +000085#define DEBUG_SHOW_TEST_NAME 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000086#define DEBUG_SHOW_TEST_PROGRESS 1
87#define DEBUG_SHOW_WINDING 0
88#define DEBUG_SORT 1
caryclark@google.comcffbcc32013-06-04 17:59:42 +000089#define DEBUG_SORT_COMPACT 0
caryclark@google.com570863f2013-09-16 15:55:01 +000090#define DEBUG_SORT_RAW 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000091#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000092#define DEBUG_SWAP_TOP 1
93#define DEBUG_UNSORTABLE 1
caryclark@google.com4fdbb222013-07-23 15:27:41 +000094#define DEBUG_VALIDATE 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000095#define DEBUG_WIND_BUMP 0
96#define DEBUG_WINDING 1
97#define DEBUG_WINDING_AT_T 1
98
99#endif
100
caryclark@google.com07393ca2013-04-08 11:47:37 +0000101#if DEBUG_AS_C_CODE
caryclark@google.comfa2aeee2013-07-15 13:29:13 +0000102#define CUBIC_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}"
103#define QUAD_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}"
104#define LINE_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}}"
105#define PT_DEBUG_STR "{{%1.9g,%1.9g}}"
caryclark@google.com07393ca2013-04-08 11:47:37 +0000106#else
107#define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
108#define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
109#define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)"
110#define PT_DEBUG_STR "(%1.9g,%1.9g)"
111#endif
112#define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g"
113#define TX_DEBUG_STR(t) #t "[%d]=%1.9g"
114#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
115#define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY
116#define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY
117#define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY
118
caryclark@google.com07e97fc2013-07-08 17:17:02 +0000119#ifndef DEBUG_TEST
120#define DEBUG_TEST 0
caryclark@google.coma5e55922013-05-07 18:51:31 +0000121#endif
122
caryclark@google.com570863f2013-09-16 15:55:01 +0000123#if defined SK_DEBUG || !FORCE_RELEASE
124
125#if DEBUG_SHOW_TEST_NAME
126#include "SkTLS.h"
127#endif
128
129#include "SkTArray.h"
130
131class SkPathOpsDebug {
132public:
133 static int gMaxWindSum;
134 static int gMaxWindValue;
135
136 static const char* kLVerbStr[];
137 static int gContourID;
138 static int gSegmentID;
139
140#if DEBUG_SORT || DEBUG_SWAP_TOP
141 static int gSortCountDefault;
142 static int gSortCount;
143#endif
144
145#if DEBUG_ACTIVE_OP
146 static const char* kPathOpStr[];
147#endif
148
149 static void MathematicaIze(char* str, size_t bufferSize);
150 static bool ValidWind(int winding);
151 static void WindingPrintf(int winding);
152
153#if DEBUG_SHOW_TEST_NAME
154 static void* CreateNameStr();
155 static void DeleteNameStr(void* v);
156#define DEBUG_FILENAME_STRING_LENGTH 64
157#define DEBUG_FILENAME_STRING (reinterpret_cast<char* >(SkTLS::Get(SkPathOpsDebug::CreateNameStr, \
158 SkPathOpsDebug::DeleteNameStr)))
159 static void BumpTestName(char* );
160 static void ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name);
161#endif
162 static void DumpAngles(const SkTArray<class SkOpAngle, true>& angles);
163};
164
165#endif // SK_DEBUG || !FORCE_RELEASE
166
caryclark@google.com07393ca2013-04-08 11:47:37 +0000167#endif