blob: 61b59c318902cb9be6bf9ade19cdf8c53b0caba1 [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.coma5e55922013-05-07 18:51:31 +000064#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000065#define DEBUG_SWAP_TOP 0
66#define DEBUG_UNSORTABLE 0
67#define DEBUG_WIND_BUMP 0
68#define DEBUG_WINDING 0
69#define DEBUG_WINDING_AT_T 0
70
71#else
72
73#define DEBUG_ACTIVE_OP 1
74#define DEBUG_ACTIVE_SPANS 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000075#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000076#define DEBUG_ACTIVE_SPANS_SHORT_FORM 0
77#define DEBUG_ADD_INTERSECTING_TS 1
78#define DEBUG_ADD_T_PAIR 1
79#define DEBUG_ANGLE 1
80#define DEBUG_AS_C_CODE 1
81#define DEBUG_ASSEMBLE 1
82#define DEBUG_CONCIDENT 1
83#define DEBUG_CROSS 0
84#define DEBUG_FLAT_QUADS 0
85#define DEBUG_FLOW 1
86#define DEBUG_MARK_DONE 1
87#define DEBUG_PATH_CONSTRUCTION 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000088#define DEBUG_SHOW_PATH 0
caryclark@google.com03610322013-04-18 15:58:21 +000089#define DEBUG_SHOW_TEST_NAME 1
caryclark@google.com07393ca2013-04-08 11:47:37 +000090#define DEBUG_SHOW_TEST_PROGRESS 1
91#define DEBUG_SHOW_WINDING 0
92#define DEBUG_SORT 1
caryclark@google.coma5e55922013-05-07 18:51:31 +000093#define DEBUG_SORT_SINGLE 0
caryclark@google.com07393ca2013-04-08 11:47:37 +000094#define DEBUG_SWAP_TOP 1
95#define DEBUG_UNSORTABLE 1
96#define DEBUG_WIND_BUMP 0
97#define DEBUG_WINDING 1
98#define DEBUG_WINDING_AT_T 1
99
100#endif
101
102#define DEBUG_DUMP (DEBUG_ACTIVE_OP | DEBUG_ACTIVE_SPANS | DEBUG_CONCIDENT | DEBUG_SORT | \
caryclark@google.coma5e55922013-05-07 18:51:31 +0000103 DEBUG_SORT_SINGLE | DEBUG_PATH_CONSTRUCTION)
caryclark@google.com07393ca2013-04-08 11:47:37 +0000104
105#if DEBUG_AS_C_CODE
106#define CUBIC_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
107#define QUAD_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}"
108#define LINE_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}}"
109#define PT_DEBUG_STR "{{%1.17g,%1.17g}}"
110#else
111#define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
112#define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)"
113#define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)"
114#define PT_DEBUG_STR "(%1.9g,%1.9g)"
115#endif
116#define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g"
117#define TX_DEBUG_STR(t) #t "[%d]=%1.9g"
118#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
119#define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY
120#define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY
121#define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY
122
123#if DEBUG_DUMP
124extern const char* kLVerbStr[];
125// extern const char* kUVerbStr[];
126extern int gContourID;
127extern int gSegmentID;
128#endif
129
130#if DEBUG_SORT || DEBUG_SWAP_TOP
131extern int gDebugSortCountDefault;
132extern int gDebugSortCount;
caryclark@google.com03610322013-04-18 15:58:21 +0000133
134bool valid_wind(int winding);
135void winding_printf(int winding);
caryclark@google.com07393ca2013-04-08 11:47:37 +0000136#endif
137
138#if DEBUG_ACTIVE_OP
139extern const char* kPathOpStr[];
140#endif
141
142#ifndef DEBUG_TEST
143#define DEBUG_TEST 0
144#endif
145
caryclark@google.coma5e55922013-05-07 18:51:31 +0000146#if DEBUG_SHOW_PATH
147void ShowPath(const SkPath& path, const char* pathName);
148void ShowOp(SkPathOp op, const char* pathOne, const char* pathTwo);
149#endif
150
caryclark@google.com07393ca2013-04-08 11:47:37 +0000151#endif