blob: cc1b8ead9521bad0a75ef6d67a8ad7947322cea3 [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.com66089e42013-04-10 15:55:37 +000033#if defined SK_DEBUG || !FORCE_RELEASE
34
caryclark@google.com07393ca2013-04-08 11:47:37 +000035void mathematica_ize(char* str, size_t bufferSize);
caryclark@google.com07393ca2013-04-08 11:47:37 +000036
37extern int gDebugMaxWindSum;
38extern int gDebugMaxWindValue;
caryclark@google.com66089e42013-04-10 15:55:37 +000039
caryclark@google.com07393ca2013-04-08 11:47:37 +000040#endif
41
42#if FORCE_RELEASE
43
44#define DEBUG_ACTIVE_OP 0
45#define DEBUG_ACTIVE_SPANS 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000046#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0
47#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000048#define DEBUG_ADD_INTERSECTING_TS 0
49#define DEBUG_ADD_T_PAIR 0
50#define DEBUG_ANGLE 0
51#define DEBUG_AS_C_CODE 1
52#define DEBUG_ASSEMBLE 0
53#define DEBUG_CONCIDENT 0
54#define DEBUG_CROSS 0
55#define DEBUG_FLAT_QUADS 0
56#define DEBUG_FLOW 0
57#define DEBUG_MARK_DONE 0
58#define DEBUG_PATH_CONSTRUCTION 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000059#define DEBUG_SHOW_PATH 0
caryclark@google.com03610322013-04-18 15:58:21 +000060#define DEBUG_SHOW_TEST_NAME 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000061#define DEBUG_SHOW_TEST_PROGRESS 0
62#define DEBUG_SHOW_WINDING 0
63#define DEBUG_SORT 0
caryclark@google.comcffbcc32013-06-04 17:59:42 +000064#define DEBUG_SORT_COMPACT 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000065#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000066#define DEBUG_SWAP_TOP 0
67#define DEBUG_UNSORTABLE 0
68#define DEBUG_WIND_BUMP 0
69#define DEBUG_WINDING 0
70#define DEBUG_WINDING_AT_T 0
71
72#else
73
74#define DEBUG_ACTIVE_OP 1
75#define DEBUG_ACTIVE_SPANS 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000076#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0
caryclark@google.comcffbcc32013-06-04 17:59:42 +000077#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000078#define DEBUG_ADD_INTERSECTING_TS 1
79#define DEBUG_ADD_T_PAIR 1
80#define DEBUG_ANGLE 1
81#define DEBUG_AS_C_CODE 1
82#define DEBUG_ASSEMBLE 1
83#define DEBUG_CONCIDENT 1
84#define DEBUG_CROSS 0
85#define DEBUG_FLAT_QUADS 0
86#define DEBUG_FLOW 1
87#define DEBUG_MARK_DONE 1
88#define DEBUG_PATH_CONSTRUCTION 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000089#define DEBUG_SHOW_PATH 0
caryclark@google.com03610322013-04-18 15:58:21 +000090#define DEBUG_SHOW_TEST_NAME 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000091#define DEBUG_SHOW_TEST_PROGRESS 1
92#define DEBUG_SHOW_WINDING 0
93#define DEBUG_SORT 1
caryclark@google.comcffbcc32013-06-04 17:59:42 +000094#define DEBUG_SORT_COMPACT 0
caryclark@google.coma5e55922013-05-07 18:51:31 +000095#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000096#define DEBUG_SWAP_TOP 1
97#define DEBUG_UNSORTABLE 1
98#define DEBUG_WIND_BUMP 0
99#define DEBUG_WINDING 1
100#define DEBUG_WINDING_AT_T 1
101
102#endif
103
104#define DEBUG_DUMP (DEBUG_ACTIVE_OP | DEBUG_ACTIVE_SPANS | DEBUG_CONCIDENT | DEBUG_SORT | \
caryclark@google.coma5e55922013-05-07 18:51:31 +0000105 DEBUG_SORT_SINGLE | DEBUG_PATH_CONSTRUCTION)
caryclark@google.com07393ca2013-04-08 11:47:37 +0000106
107#if DEBUG_AS_C_CODE
108#define CUBIC_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
109#define QUAD_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
110#define LINE_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}}"
111#define PT_DEBUG_STR "{{%1.17g,%1.17g}}"
112#else
113#define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
114#define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
115#define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)"
116#define PT_DEBUG_STR "(%1.9g,%1.9g)"
117#endif
118#define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g"
119#define TX_DEBUG_STR(t) #t "[%d]=%1.9g"
120#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
121#define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY
122#define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY
123#define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY
124
125#if DEBUG_DUMP
126extern const char* kLVerbStr[];
127// extern const char* kUVerbStr[];
128extern int gContourID;
129extern int gSegmentID;
130#endif
131
132#if DEBUG_SORT || DEBUG_SWAP_TOP
133extern int gDebugSortCountDefault;
134extern int gDebugSortCount;
caryclark@google.com03610322013-04-18 15:58:21 +0000135
136bool valid_wind(int winding);
137void winding_printf(int winding);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000138#endif
139
140#if DEBUG_ACTIVE_OP
141extern const char* kPathOpStr[];
142#endif
143
144#ifndef DEBUG_TEST
145#define DEBUG_TEST 0
146#endif
147
caryclark@google.coma5e55922013-05-07 18:51:31 +0000148#if DEBUG_SHOW_PATH
caryclark@google.comcffbcc32013-06-04 17:59:42 +0000149void ShowFunctionHeader();
caryclark@google.coma5e55922013-05-07 18:51:31 +0000150void ShowPath(const SkPath& path, const char* pathName);
151void ShowOp(SkPathOp op, const char* pathOne, const char* pathTwo);
152#endif
153
caryclark@google.com07393ca2013-04-08 11:47:37 +0000154#endif