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 "SkPathOps.h" 11#include "SkTypes.h" 12 13#ifdef SK_RELEASE 14#define FORCE_RELEASE 1 15#else 16#define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging 17#endif 18 19#define ONE_OFF_DEBUG 0 20#define ONE_OFF_DEBUG_MATHEMATICA 0 21 22#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_ANDROID) 23 #define SK_RAND(seed) rand() 24#else 25 #define SK_RAND(seed) rand_r(&seed) 26#endif 27#ifdef SK_BUILD_FOR_WIN 28 #define SK_SNPRINTF _snprintf 29#else 30 #define SK_SNPRINTF snprintf 31#endif 32 33#if defined SK_DEBUG || !FORCE_RELEASE 34 35void mathematica_ize(char* str, size_t bufferSize); 36 37extern int gDebugMaxWindSum; 38extern int gDebugMaxWindValue; 39 40#endif 41 42#if FORCE_RELEASE 43 44#define DEBUG_ACTIVE_OP 0 45#define DEBUG_ACTIVE_SPANS 0 46#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0 47#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1 48#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 59#define DEBUG_SHOW_TEST_NAME 0 60#define DEBUG_SHOW_TEST_PROGRESS 0 61#define DEBUG_SHOW_WINDING 0 62#define DEBUG_SORT 0 63#define DEBUG_SORT_COMPACT 0 64#define DEBUG_SORT_SINGLE 0 65#define DEBUG_SWAP_TOP 0 66#define DEBUG_UNSORTABLE 0 67#define DEBUG_VALIDATE 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 76#define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0 77#define DEBUG_ACTIVE_SPANS_SHORT_FORM 1 78#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 89#define DEBUG_SHOW_TEST_NAME 1 90#define DEBUG_SHOW_TEST_PROGRESS 1 91#define DEBUG_SHOW_WINDING 0 92#define DEBUG_SORT 1 93#define DEBUG_SORT_COMPACT 0 94#define DEBUG_SORT_SINGLE 0 95#define DEBUG_SWAP_TOP 1 96#define DEBUG_UNSORTABLE 1 97#define DEBUG_VALIDATE 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 | \ 105 DEBUG_SORT_SINGLE | DEBUG_PATH_CONSTRUCTION) 106 107#if DEBUG_AS_C_CODE 108#define CUBIC_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}" 109#define QUAD_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}" 110#define LINE_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}}" 111#define PT_DEBUG_STR "{{%1.9g,%1.9g}}" 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; 135 136bool valid_wind(int winding); 137void winding_printf(int winding); 138#endif 139 140#if DEBUG_ACTIVE_OP 141extern const char* kPathOpStr[]; 142#endif 143 144#if DEBUG_SHOW_TEST_NAME 145#include "SkTLS.h" 146 147extern void* PathOpsDebugCreateNameStr(); 148extern void PathOpsDebugDeleteNameStr(void* v); 149#define DEBUG_FILENAME_STRING_LENGTH 64 150#define DEBUG_FILENAME_STRING \ 151 (reinterpret_cast<char* >(SkTLS::Get(PathOpsDebugCreateNameStr, PathOpsDebugDeleteNameStr))) 152extern void DebugBumpTestName(char* ); 153extern void DebugShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name); 154#endif 155 156#ifndef DEBUG_TEST 157#define DEBUG_TEST 0 158#endif 159 160#endif 161