blob: 53991bc6421fa83c5db7464565efb0f11e6117b7 [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
10#include "SkTypes.h"
11
12#ifdef SK_RELEASE
13#define FORCE_RELEASE 1
14#else
15#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging
16#endif
17
18#define ONE_OFF_DEBUG 0
19#define ONE_OFF_DEBUG_MATHEMATICA 0
20
caryclark@google.com07393ca2013-04-08 11:47:37 +000021#ifdef SK_BUILD_FOR_WIN
22 #define SK_RAND(seed) rand()
skia.committer@gmail.com32840172013-04-09 07:01:27 +000023 #define SK_SNPRINTF _snprintf
caryclark@google.com07393ca2013-04-08 11:47:37 +000024#else
25 #define SK_RAND(seed) rand_r(&seed)
skia.committer@gmail.com32840172013-04-09 07:01:27 +000026 #define SK_SNPRINTF snprintf
caryclark@google.com07393ca2013-04-08 11:47:37 +000027#endif
28
caryclark@google.com66089e42013-04-10 15:55:37 +000029#if defined SK_DEBUG || !FORCE_RELEASE
30
caryclark@google.com07393ca2013-04-08 11:47:37 +000031void mathematica_ize(char* str, size_t bufferSize);
32bool valid_wind(int winding);
33void winding_printf(int winding);
34
35extern int gDebugMaxWindSum;
36extern int gDebugMaxWindValue;
caryclark@google.com66089e42013-04-10 15:55:37 +000037
caryclark@google.com07393ca2013-04-08 11:47:37 +000038#endif
39
40#if FORCE_RELEASE
41
42#define DEBUG_ACTIVE_OP 0
43#define DEBUG_ACTIVE_SPANS 0
44#define DEBUG_ACTIVE_SPANS_SHORT_FORM 0
45#define DEBUG_ADD_INTERSECTING_TS 0
46#define DEBUG_ADD_T_PAIR 0
47#define DEBUG_ANGLE 0
48#define DEBUG_AS_C_CODE 1
49#define DEBUG_ASSEMBLE 0
50#define DEBUG_CONCIDENT 0
51#define DEBUG_CROSS 0
52#define DEBUG_FLAT_QUADS 0
53#define DEBUG_FLOW 0
54#define DEBUG_MARK_DONE 0
55#define DEBUG_PATH_CONSTRUCTION 0
56#define DEBUG_SHOW_TEST_PROGRESS 0
57#define DEBUG_SHOW_WINDING 0
58#define DEBUG_SORT 0
59#define DEBUG_SWAP_TOP 0
60#define DEBUG_UNSORTABLE 0
61#define DEBUG_WIND_BUMP 0
62#define DEBUG_WINDING 0
63#define DEBUG_WINDING_AT_T 0
64
65#else
66
67#define DEBUG_ACTIVE_OP 1
68#define DEBUG_ACTIVE_SPANS 1
69#define DEBUG_ACTIVE_SPANS_SHORT_FORM 0
70#define DEBUG_ADD_INTERSECTING_TS 1
71#define DEBUG_ADD_T_PAIR 1
72#define DEBUG_ANGLE 1
73#define DEBUG_AS_C_CODE 1
74#define DEBUG_ASSEMBLE 1
75#define DEBUG_CONCIDENT 1
76#define DEBUG_CROSS 0
77#define DEBUG_FLAT_QUADS 0
78#define DEBUG_FLOW 1
79#define DEBUG_MARK_DONE 1
80#define DEBUG_PATH_CONSTRUCTION 1
81#define DEBUG_SHOW_TEST_PROGRESS 1
82#define DEBUG_SHOW_WINDING 0
83#define DEBUG_SORT 1
84#define DEBUG_SWAP_TOP 1
85#define DEBUG_UNSORTABLE 1
86#define DEBUG_WIND_BUMP 0
87#define DEBUG_WINDING 1
88#define DEBUG_WINDING_AT_T 1
89
90#endif
91
92#define DEBUG_DUMP (DEBUG_ACTIVE_OP | DEBUG_ACTIVE_SPANS | DEBUG_CONCIDENT | DEBUG_SORT | \
93 DEBUG_PATH_CONSTRUCTION)
94
95#if DEBUG_AS_C_CODE
96#define CUBIC_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
97#define QUAD_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
98#define LINE_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}}"
99#define PT_DEBUG_STR "{{%1.17g,%1.17g}}"
100#else
101#define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
102#define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
103#define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)"
104#define PT_DEBUG_STR "(%1.9g,%1.9g)"
105#endif
106#define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g"
107#define TX_DEBUG_STR(t) #t "[%d]=%1.9g"
108#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
109#define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY
110#define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY
111#define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY
112
113#if DEBUG_DUMP
114extern const char* kLVerbStr[];
115// extern const char* kUVerbStr[];
116extern int gContourID;
117extern int gSegmentID;
118#endif
119
120#if DEBUG_SORT || DEBUG_SWAP_TOP
121extern int gDebugSortCountDefault;
122extern int gDebugSortCount;
123#endif
124
125#if DEBUG_ACTIVE_OP
126extern const char* kPathOpStr[];
127#endif
128
129#ifndef DEBUG_TEST
130#define DEBUG_TEST 0
131#endif
132
133#endif