| caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame^] | 1 | /* |
| 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 | |
| 21 | #if defined SK_DEBUG || !FORCE_RELEASE |
| 22 | |
| 23 | #ifdef SK_BUILD_FOR_WIN |
| 24 | #define SK_RAND(seed) rand() |
| 25 | #define SK_SNPRINTF _snprintf |
| 26 | #else |
| 27 | #define SK_RAND(seed) rand_r(&seed) |
| 28 | #define SK_SNPRINTF snprintf |
| 29 | #endif |
| 30 | |
| 31 | void mathematica_ize(char* str, size_t bufferSize); |
| 32 | bool valid_wind(int winding); |
| 33 | void winding_printf(int winding); |
| 34 | |
| 35 | extern int gDebugMaxWindSum; |
| 36 | extern int gDebugMaxWindValue; |
| 37 | #endif |
| 38 | |
| 39 | #if FORCE_RELEASE |
| 40 | |
| 41 | #define DEBUG_ACTIVE_OP 0 |
| 42 | #define DEBUG_ACTIVE_SPANS 0 |
| 43 | #define DEBUG_ACTIVE_SPANS_SHORT_FORM 0 |
| 44 | #define DEBUG_ADD_INTERSECTING_TS 0 |
| 45 | #define DEBUG_ADD_T_PAIR 0 |
| 46 | #define DEBUG_ANGLE 0 |
| 47 | #define DEBUG_AS_C_CODE 1 |
| 48 | #define DEBUG_ASSEMBLE 0 |
| 49 | #define DEBUG_CONCIDENT 0 |
| 50 | #define DEBUG_CROSS 0 |
| 51 | #define DEBUG_FLAT_QUADS 0 |
| 52 | #define DEBUG_FLOW 0 |
| 53 | #define DEBUG_MARK_DONE 0 |
| 54 | #define DEBUG_PATH_CONSTRUCTION 0 |
| 55 | #define DEBUG_SHOW_TEST_PROGRESS 0 |
| 56 | #define DEBUG_SHOW_WINDING 0 |
| 57 | #define DEBUG_SORT 0 |
| 58 | #define DEBUG_SWAP_TOP 0 |
| 59 | #define DEBUG_UNSORTABLE 0 |
| 60 | #define DEBUG_WIND_BUMP 0 |
| 61 | #define DEBUG_WINDING 0 |
| 62 | #define DEBUG_WINDING_AT_T 0 |
| 63 | |
| 64 | #else |
| 65 | |
| 66 | #define DEBUG_ACTIVE_OP 1 |
| 67 | #define DEBUG_ACTIVE_SPANS 1 |
| 68 | #define DEBUG_ACTIVE_SPANS_SHORT_FORM 0 |
| 69 | #define DEBUG_ADD_INTERSECTING_TS 1 |
| 70 | #define DEBUG_ADD_T_PAIR 1 |
| 71 | #define DEBUG_ANGLE 1 |
| 72 | #define DEBUG_AS_C_CODE 1 |
| 73 | #define DEBUG_ASSEMBLE 1 |
| 74 | #define DEBUG_CONCIDENT 1 |
| 75 | #define DEBUG_CROSS 0 |
| 76 | #define DEBUG_FLAT_QUADS 0 |
| 77 | #define DEBUG_FLOW 1 |
| 78 | #define DEBUG_MARK_DONE 1 |
| 79 | #define DEBUG_PATH_CONSTRUCTION 1 |
| 80 | #define DEBUG_SHOW_TEST_PROGRESS 1 |
| 81 | #define DEBUG_SHOW_WINDING 0 |
| 82 | #define DEBUG_SORT 1 |
| 83 | #define DEBUG_SWAP_TOP 1 |
| 84 | #define DEBUG_UNSORTABLE 1 |
| 85 | #define DEBUG_WIND_BUMP 0 |
| 86 | #define DEBUG_WINDING 1 |
| 87 | #define DEBUG_WINDING_AT_T 1 |
| 88 | |
| 89 | #endif |
| 90 | |
| 91 | #define DEBUG_DUMP (DEBUG_ACTIVE_OP | DEBUG_ACTIVE_SPANS | DEBUG_CONCIDENT | DEBUG_SORT | \ |
| 92 | DEBUG_PATH_CONSTRUCTION) |
| 93 | |
| 94 | #if DEBUG_AS_C_CODE |
| 95 | #define CUBIC_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}" |
| 96 | #define QUAD_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}, {%1.17g,%1.17g}}" |
| 97 | #define LINE_DEBUG_STR "{{%1.17g,%1.17g}, {%1.17g,%1.17g}}" |
| 98 | #define PT_DEBUG_STR "{{%1.17g,%1.17g}}" |
| 99 | #else |
| 100 | #define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)" |
| 101 | #define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)" |
| 102 | #define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)" |
| 103 | #define PT_DEBUG_STR "(%1.9g,%1.9g)" |
| 104 | #endif |
| 105 | #define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g" |
| 106 | #define TX_DEBUG_STR(t) #t "[%d]=%1.9g" |
| 107 | #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 |
| 108 | #define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY |
| 109 | #define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY |
| 110 | #define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY |
| 111 | |
| 112 | #if DEBUG_DUMP |
| 113 | extern const char* kLVerbStr[]; |
| 114 | // extern const char* kUVerbStr[]; |
| 115 | extern int gContourID; |
| 116 | extern int gSegmentID; |
| 117 | #endif |
| 118 | |
| 119 | #if DEBUG_SORT || DEBUG_SWAP_TOP |
| 120 | extern int gDebugSortCountDefault; |
| 121 | extern int gDebugSortCount; |
| 122 | #endif |
| 123 | |
| 124 | #if DEBUG_ACTIVE_OP |
| 125 | extern const char* kPathOpStr[]; |
| 126 | #endif |
| 127 | |
| 128 | #ifndef DEBUG_TEST |
| 129 | #define DEBUG_TEST 0 |
| 130 | #endif |
| 131 | |
| 132 | #endif |