gfx/skia/trunk/src/pathops/SkPathOpsDebug.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:317a6d54d147
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
13 int SkPathOpsDebug::gMaxWindSum = SK_MaxS32;
14 int SkPathOpsDebug::gMaxWindValue = SK_MaxS32;
15
16 const char* SkPathOpsDebug::kLVerbStr[] = {"", "line", "quad", "cubic"};
17 int SkPathOpsDebug::gContourID;
18 int SkPathOpsDebug::gSegmentID;
19
20 #if DEBUG_SORT || DEBUG_SWAP_TOP
21 int SkPathOpsDebug::gSortCountDefault = SK_MaxS32;
22 int SkPathOpsDebug::gSortCount;
23 #endif
24
25 #if DEBUG_ACTIVE_OP
26 const char* SkPathOpsDebug::kPathOpStr[] = {"diff", "sect", "union", "xor"};
27 #endif
28
29 void SkPathOpsDebug::MathematicaIze(char* str, size_t bufferLen) {
30 size_t len = strlen(str);
31 bool num = false;
32 for (size_t idx = 0; idx < len; ++idx) {
33 if (num && str[idx] == 'e') {
34 if (len + 2 >= bufferLen) {
35 return;
36 }
37 memmove(&str[idx + 2], &str[idx + 1], len - idx);
38 str[idx] = '*';
39 str[idx + 1] = '^';
40 ++len;
41 }
42 num = str[idx] >= '0' && str[idx] <= '9';
43 }
44 }
45
46 bool SkPathOpsDebug::ValidWind(int wind) {
47 return wind > SK_MinS32 + 0xFFFF && wind < SK_MaxS32 - 0xFFFF;
48 }
49
50 void SkPathOpsDebug::WindingPrintf(int wind) {
51 if (wind == SK_MinS32) {
52 SkDebugf("?");
53 } else {
54 SkDebugf("%d", wind);
55 }
56 }
57
58 #if DEBUG_SHOW_TEST_NAME
59 void* SkPathOpsDebug::CreateNameStr() {
60 return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH);
61 }
62
63 void SkPathOpsDebug::DeleteNameStr(void* v) {
64 SkDELETE_ARRAY(reinterpret_cast<char* >(v));
65 }
66
67 void SkPathOpsDebug::BumpTestName(char* test) {
68 char* num = test + strlen(test);
69 while (num[-1] >= '0' && num[-1] <= '9') {
70 --num;
71 }
72 if (num[0] == '\0') {
73 return;
74 }
75 int dec = atoi(num);
76 if (dec == 0) {
77 return;
78 }
79 ++dec;
80 SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec);
81 }
82 #endif
83
84 #include "SkOpSegment.h"
85
86 void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle, true>& angles) {
87 int count = angles.count();
88 for (int index = 0; index < count; ++index) {
89 angles[index].dump();
90 }
91 }
92
93 void SkPathOpsDebug::DumpAngles(const SkTArray<SkOpAngle* , true>& angles) {
94 int count = angles.count();
95 for (int index = 0; index < count; ++index) {
96 angles[index]->dump();
97 }
98 }
99 #endif // SK_DEBUG || !FORCE_RELEASE
100
101 #ifdef SK_DEBUG
102 void SkOpSpan::dump() const {
103 SkDebugf("t=");
104 DebugDumpDouble(fT);
105 SkDebugf(" pt=");
106 SkDPoint::dump(fPt);
107 SkDebugf(" other.fID=%d", fOther->debugID());
108 SkDebugf(" [%d] otherT=", fOtherIndex);
109 DebugDumpDouble(fOtherT);
110 SkDebugf(" windSum=");
111 SkPathOpsDebug::WindingPrintf(fWindSum);
112 if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
113 SkDebugf(" oppSum=");
114 SkPathOpsDebug::WindingPrintf(fOppSum);
115 }
116 SkDebugf(" windValue=%d", fWindValue);
117 if (SkPathOpsDebug::ValidWind(fOppSum) || fOppValue != 0) {
118 SkDebugf(" oppValue=%d", fOppValue);
119 }
120 if (fDone) {
121 SkDebugf(" done");
122 }
123 if (fUnsortableStart) {
124 SkDebugf(" unsortable-start");
125 }
126 if (fUnsortableEnd) {
127 SkDebugf(" unsortable-end");
128 }
129 if (fTiny) {
130 SkDebugf(" tiny");
131 } else if (fSmall) {
132 SkDebugf(" small");
133 }
134 if (fLoop) {
135 SkDebugf(" loop");
136 }
137 SkDebugf("\n");
138 }
139
140 void Dump(const SkTArray<class SkOpAngle, true>& angles) {
141 SkPathOpsDebug::DumpAngles(angles);
142 }
143
144 void Dump(const SkTArray<class SkOpAngle* , true>& angles) {
145 SkPathOpsDebug::DumpAngles(angles);
146 }
147
148 void Dump(const SkTArray<class SkOpAngle, true>* angles) {
149 SkPathOpsDebug::DumpAngles(*angles);
150 }
151
152 void Dump(const SkTArray<class SkOpAngle* , true>* angles) {
153 SkPathOpsDebug::DumpAngles(*angles);
154 }
155
156 #endif
157
158 #if !FORCE_RELEASE && 0 // enable when building without extended test
159 void SkPathOpsDebug::ShowPath(const SkPath& one, const SkPath& two, SkPathOp op, const char* name) {
160 }
161 #endif

mercurial