michael@0: /* michael@0: * Copyright 2013 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: #ifndef SkPathOpsDebug_DEFINED michael@0: #define SkPathOpsDebug_DEFINED michael@0: michael@0: #include "SkPathOps.h" michael@0: #include "SkTypes.h" michael@0: #include michael@0: michael@0: #ifdef SK_RELEASE michael@0: #define FORCE_RELEASE 1 michael@0: #else michael@0: #define FORCE_RELEASE 1 // set force release to 1 for multiple thread -- no debugging michael@0: #endif michael@0: michael@0: #define ONE_OFF_DEBUG 0 michael@0: #define ONE_OFF_DEBUG_MATHEMATICA 0 michael@0: michael@0: #if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_ANDROID) michael@0: #define SK_RAND(seed) rand() michael@0: #else michael@0: #define SK_RAND(seed) rand_r(&seed) michael@0: #endif michael@0: #ifdef SK_BUILD_FOR_WIN michael@0: #define SK_SNPRINTF _snprintf michael@0: #else michael@0: #define SK_SNPRINTF snprintf michael@0: #endif michael@0: michael@0: #if FORCE_RELEASE michael@0: michael@0: #define DEBUG_ACTIVE_OP 0 michael@0: #define DEBUG_ACTIVE_SPANS 0 michael@0: #define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0 michael@0: #define DEBUG_ACTIVE_SPANS_SHORT_FORM 1 michael@0: #define DEBUG_ADD_INTERSECTING_TS 0 michael@0: #define DEBUG_ADD_T_PAIR 0 michael@0: #define DEBUG_ANGLE 0 michael@0: #define DEBUG_AS_C_CODE 1 michael@0: #define DEBUG_ASSEMBLE 0 michael@0: #define DEBUG_CHECK_ENDS 0 michael@0: #define DEBUG_CHECK_TINY 0 michael@0: #define DEBUG_CONCIDENT 0 michael@0: #define DEBUG_CROSS 0 michael@0: #define DEBUG_FLAT_QUADS 0 michael@0: #define DEBUG_FLOW 0 michael@0: #define DEBUG_MARK_DONE 0 michael@0: #define DEBUG_PATH_CONSTRUCTION 0 michael@0: #define DEBUG_SHOW_TEST_NAME 0 michael@0: #define DEBUG_SHOW_TEST_PROGRESS 0 michael@0: #define DEBUG_SHOW_WINDING 0 michael@0: #define DEBUG_SORT 0 michael@0: #define DEBUG_SORT_COMPACT 0 michael@0: #define DEBUG_SORT_RAW 0 michael@0: #define DEBUG_SORT_SINGLE 0 michael@0: #define DEBUG_SWAP_TOP 0 michael@0: #define DEBUG_UNSORTABLE 0 michael@0: #define DEBUG_VALIDATE 0 michael@0: #define DEBUG_WIND_BUMP 0 michael@0: #define DEBUG_WINDING 0 michael@0: #define DEBUG_WINDING_AT_T 0 michael@0: michael@0: #else michael@0: michael@0: #define DEBUG_ACTIVE_OP 1 michael@0: #define DEBUG_ACTIVE_SPANS 1 michael@0: #define DEBUG_ACTIVE_SPANS_FIRST_ONLY 0 michael@0: #define DEBUG_ACTIVE_SPANS_SHORT_FORM 1 michael@0: #define DEBUG_ADD_INTERSECTING_TS 1 michael@0: #define DEBUG_ADD_T_PAIR 1 michael@0: #define DEBUG_ANGLE 1 michael@0: #define DEBUG_AS_C_CODE 1 michael@0: #define DEBUG_ASSEMBLE 1 michael@0: #define DEBUG_CHECK_ENDS 1 michael@0: #define DEBUG_CHECK_TINY 1 michael@0: #define DEBUG_CONCIDENT 1 michael@0: #define DEBUG_CROSS 01 michael@0: #define DEBUG_FLAT_QUADS 0 michael@0: #define DEBUG_FLOW 1 michael@0: #define DEBUG_MARK_DONE 1 michael@0: #define DEBUG_PATH_CONSTRUCTION 1 michael@0: #define DEBUG_SHOW_TEST_NAME 1 michael@0: #define DEBUG_SHOW_TEST_PROGRESS 1 michael@0: #define DEBUG_SHOW_WINDING 0 michael@0: #define DEBUG_SORT 1 michael@0: #define DEBUG_SORT_COMPACT 0 michael@0: #define DEBUG_SORT_RAW 0 michael@0: #define DEBUG_SORT_SINGLE 0 michael@0: #define DEBUG_SWAP_TOP 1 michael@0: #define DEBUG_UNSORTABLE 1 michael@0: #define DEBUG_VALIDATE 1 michael@0: #define DEBUG_WIND_BUMP 0 michael@0: #define DEBUG_WINDING 1 michael@0: #define DEBUG_WINDING_AT_T 1 michael@0: michael@0: #endif michael@0: michael@0: #if DEBUG_AS_C_CODE michael@0: #define CUBIC_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}" michael@0: #define QUAD_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}, {%1.9g,%1.9g}}" michael@0: #define LINE_DEBUG_STR "{{%1.9g,%1.9g}, {%1.9g,%1.9g}}" michael@0: #define PT_DEBUG_STR "{{%1.9g,%1.9g}}" michael@0: #else michael@0: #define CUBIC_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)" michael@0: #define QUAD_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g %1.9g,%1.9g)" michael@0: #define LINE_DEBUG_STR "(%1.9g,%1.9g %1.9g,%1.9g)" michael@0: #define PT_DEBUG_STR "(%1.9g,%1.9g)" michael@0: #endif michael@0: #define T_DEBUG_STR(t, n) #t "[" #n "]=%1.9g" michael@0: #define TX_DEBUG_STR(t) #t "[%d]=%1.9g" michael@0: #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 michael@0: #define QUAD_DEBUG_DATA(q) q[0].fX, q[0].fY, q[1].fX, q[1].fY, q[2].fX, q[2].fY michael@0: #define LINE_DEBUG_DATA(l) l[0].fX, l[0].fY, l[1].fX, l[1].fY michael@0: #define PT_DEBUG_DATA(i, n) i.pt(n).fX, i.pt(n).fY michael@0: michael@0: #ifndef DEBUG_TEST michael@0: #define DEBUG_TEST 0 michael@0: #endif michael@0: michael@0: #if defined SK_DEBUG || !FORCE_RELEASE michael@0: michael@0: #if DEBUG_SHOW_TEST_NAME michael@0: #include "SkTLS.h" michael@0: #endif michael@0: michael@0: #include "SkTArray.h" michael@0: michael@0: class SkPathOpsDebug { michael@0: public: michael@0: static int gMaxWindSum; michael@0: static int gMaxWindValue; michael@0: michael@0: static const char* kLVerbStr[]; michael@0: static int gContourID; michael@0: static int gSegmentID; michael@0: michael@0: #if DEBUG_SORT || DEBUG_SWAP_TOP michael@0: static int gSortCountDefault; michael@0: static int gSortCount; michael@0: #endif michael@0: michael@0: #if DEBUG_ACTIVE_OP michael@0: static const char* kPathOpStr[]; michael@0: #endif michael@0: michael@0: static void MathematicaIze(char* str, size_t bufferSize); michael@0: static bool ValidWind(int winding); michael@0: static void WindingPrintf(int winding); michael@0: michael@0: #if DEBUG_SHOW_TEST_NAME michael@0: static void* CreateNameStr(); michael@0: static void DeleteNameStr(void* v); michael@0: #define DEBUG_FILENAME_STRING_LENGTH 64 michael@0: #define DEBUG_FILENAME_STRING (reinterpret_cast(SkTLS::Get(SkPathOpsDebug::CreateNameStr, \ michael@0: SkPathOpsDebug::DeleteNameStr))) michael@0: static void BumpTestName(char* ); michael@0: static void ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name); michael@0: #endif michael@0: static void DumpAngles(const SkTArray& angles); michael@0: static void DumpAngles(const SkTArray& angles); michael@0: }; michael@0: michael@0: // shorthand for calling from debugger michael@0: void Dump(const SkTArray& angles); michael@0: void Dump(const SkTArray& angles); michael@0: void Dump(const SkTArray* angles); michael@0: void Dump(const SkTArray* angles); michael@0: michael@0: #endif // SK_DEBUG || !FORCE_RELEASE michael@0: michael@0: #endif