SkPathOpsDebug.cpp revision a4aced47281e085201a356ce888b92138846e9f6
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"
9#include "SkPath.h"
10
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}
32#endif
33
34#if DEBUG_SORT || DEBUG_SWAP_TOP
35bool 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
63
64#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;
77    }
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);
87}
88#endif
89