blob: 1071b52050f67ba5f5fb791f30e3f1e73fa6c7e7 [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
8#include "SkPathOpsDebug.h"
caryclark@google.coma5e55922013-05-07 18:51:31 +00009#include "SkPath.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +000010
11#if defined SK_DEBUG || !FORCE_RELEASE
12
13int gDebugMaxWindSum = SK_MaxS32;
14int gDebugMaxWindValue = SK_MaxS32;
15
16void 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.com03610322013-04-18 15:58:21 +000032#endif
caryclark@google.com07393ca2013-04-08 11:47:37 +000033
caryclark@google.com03610322013-04-18 15:58:21 +000034#if DEBUG_SORT || DEBUG_SWAP_TOP
caryclark@google.com07393ca2013-04-08 11:47:37 +000035bool valid_wind(int wind) {
36 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
37}
38
39void 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
49const char* kLVerbStr[] = {"", "line", "quad", "cubic"};
50// static const char* kUVerbStr[] = {"", "Line", "Quad", "Cubic"};
51int gContourID;
52int gSegmentID;
53#endif
54
55#if DEBUG_SORT || DEBUG_SWAP_TOP
56int gDebugSortCountDefault = SK_MaxS32;
57int gDebugSortCount;
58#endif
59
60#if DEBUG_ACTIVE_OP
61const char* kPathOpStr[] = {"diff", "sect", "union", "xor"};
62#endif
caryclark@google.coma5e55922013-05-07 18:51:31 +000063
caryclark@google.com07e97fc2013-07-08 17:17:02 +000064#if DEBUG_SHOW_TEST_NAME
65void* PathOpsDebugCreateNameStr() {
66 return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH);
67}
68
69void PathOpsDebugDeleteNameStr(void* v) {
70 SkDELETE_ARRAY(reinterpret_cast<char* >(v));
71}
72
73void DebugBumpTestName(char* test) {
74 char* num = test + strlen(test);
75 while (num[-1] >= '0' && num[-1] <= '9') {
76 --num;
caryclark@google.coma5e55922013-05-07 18:51:31 +000077 }
caryclark@google.com07e97fc2013-07-08 17:17:02 +000078 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.coma5e55922013-05-07 18:51:31 +000087}
88#endif
caryclark@google.com07e97fc2013-07-08 17:17:02 +000089