| 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 | |
| 8 | #include "SkPathOpsDebug.h" |
| caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 9 | #include "SkPath.h" |
| caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 10 | |
| 11 | #if defined SK_DEBUG || !FORCE_RELEASE |
| 12 | |
| 13 | int gDebugMaxWindSum = SK_MaxS32; |
| 14 | int gDebugMaxWindValue = SK_MaxS32; |
| 15 | |
| 16 | void mathematica_ize(char* str, size_t bufferLen) { |
| 17 | size_t len = strlen(str); |
| 18 | bool num = false; |
| 19 | for (size_t idx = 0; idx < len; ++idx) { |
| 20 | if (num && str[idx] == 'e') { |
| 21 | if (len + 2 >= bufferLen) { |
| 22 | return; |
| 23 | } |
| 24 | memmove(&str[idx + 2], &str[idx + 1], len - idx); |
| 25 | str[idx] = '*'; |
| 26 | str[idx + 1] = '^'; |
| 27 | ++len; |
| 28 | } |
| 29 | num = str[idx] >= '0' && str[idx] <= '9'; |
| 30 | } |
| 31 | } |
| caryclark@google.com | 0361032 | 2013-04-18 15:58:21 +0000 | [diff] [blame] | 32 | #endif |
| caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 33 | |
| caryclark@google.com | 0361032 | 2013-04-18 15:58:21 +0000 | [diff] [blame] | 34 | #if DEBUG_SORT || DEBUG_SWAP_TOP |
| caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 35 | bool valid_wind(int wind) { |
| 36 | return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF; |
| 37 | } |
| 38 | |
| 39 | void winding_printf(int wind) { |
| 40 | if (wind == SK_MinS32) { |
| 41 | SkDebugf("?"); |
| 42 | } else { |
| 43 | SkDebugf("%d", wind); |
| 44 | } |
| 45 | } |
| 46 | #endif |
| 47 | |
| 48 | #if DEBUG_DUMP |
| 49 | const char* kLVerbStr[] = {"", "line", "quad", "cubic"}; |
| 50 | // static const char* kUVerbStr[] = {"", "Line", "Quad", "Cubic"}; |
| 51 | int gContourID; |
| 52 | int gSegmentID; |
| 53 | #endif |
| 54 | |
| 55 | #if DEBUG_SORT || DEBUG_SWAP_TOP |
| 56 | int gDebugSortCountDefault = SK_MaxS32; |
| 57 | int gDebugSortCount; |
| 58 | #endif |
| 59 | |
| 60 | #if DEBUG_ACTIVE_OP |
| 61 | const char* kPathOpStr[] = {"diff", "sect", "union", "xor"}; |
| 62 | #endif |
| caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 63 | |
| caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame^] | 64 | #if DEBUG_SHOW_TEST_NAME |
| 65 | void* PathOpsDebugCreateNameStr() { |
| 66 | return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH); |
| 67 | } |
| 68 | |
| 69 | void PathOpsDebugDeleteNameStr(void* v) { |
| 70 | SkDELETE_ARRAY(reinterpret_cast<char* >(v)); |
| 71 | } |
| 72 | |
| 73 | void DebugBumpTestName(char* test) { |
| 74 | char* num = test + strlen(test); |
| 75 | while (num[-1] >= '0' && num[-1] <= '9') { |
| 76 | --num; |
| caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 77 | } |
| caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame^] | 78 | if (num[0] == '\0') { |
| 79 | return; |
| 80 | } |
| 81 | int dec = atoi(num); |
| 82 | if (dec == 0) { |
| 83 | return; |
| 84 | } |
| 85 | ++dec; |
| 86 | SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec); |
| caryclark@google.com | a5e5592 | 2013-05-07 18:51:31 +0000 | [diff] [blame] | 87 | } |
| 88 | #endif |
| caryclark@google.com | 07e97fc | 2013-07-08 17:17:02 +0000 | [diff] [blame^] | 89 | |