OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkPathOpsDebug.h" | 8 #include "SkPathOpsDebug.h" |
9 #include "SkPath.h" | 9 #include "SkPath.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 #if DEBUG_SORT || DEBUG_SWAP_TOP | 55 #if DEBUG_SORT || DEBUG_SWAP_TOP |
56 int gDebugSortCountDefault = SK_MaxS32; | 56 int gDebugSortCountDefault = SK_MaxS32; |
57 int gDebugSortCount; | 57 int gDebugSortCount; |
58 #endif | 58 #endif |
59 | 59 |
60 #if DEBUG_ACTIVE_OP | 60 #if DEBUG_ACTIVE_OP |
61 const char* kPathOpStr[] = {"diff", "sect", "union", "xor"}; | 61 const char* kPathOpStr[] = {"diff", "sect", "union", "xor"}; |
62 #endif | 62 #endif |
63 | 63 |
64 #if DEBUG_SHOW_PATH | 64 #if DEBUG_SHOW_TEST_NAME |
65 static void showPathContours(SkPath::Iter& iter, const char* pathName) { | 65 void* PathOpsDebugCreateNameStr() { |
66 uint8_t verb; | 66 return SkNEW_ARRAY(char, DEBUG_FILENAME_STRING_LENGTH); |
67 SkPoint pts[4]; | |
68 while ((verb = iter.next(pts)) != SkPath::kDone_Verb) { | |
69 switch (verb) { | |
70 case SkPath::kMove_Verb: | |
71 SkDebugf(" %s.moveTo(%#1.9gf, %#1.9gf);\n", pathName, pts[0].
fX, pts[0].fY); | |
72 continue; | |
73 case SkPath::kLine_Verb: | |
74 SkDebugf(" %s.lineTo(%#1.9gf, %#1.9gf);\n", pathName, pts[1].
fX, pts[1].fY); | |
75 break; | |
76 case SkPath::kQuad_Verb: | |
77 SkDebugf(" %s.quadTo(%#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf);\n",
pathName, | |
78 pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY); | |
79 break; | |
80 case SkPath::kCubic_Verb: | |
81 SkDebugf(" %s.cubicTo(%#1.9gf, %#1.9gf, %#1.9gf, %#1.9gf, %#1
.9gf, %#1.9gf);\n", | |
82 pathName, pts[1].fX, pts[1].fY, pts[2].fX, pts[2].fY, pts[3]
.fX, pts[3].fY); | |
83 break; | |
84 case SkPath::kClose_Verb: | |
85 SkDebugf(" %s.close();\n", pathName); | |
86 break; | |
87 default: | |
88 SkDEBUGFAIL("bad verb"); | |
89 return; | |
90 } | |
91 } | |
92 } | 67 } |
93 | 68 |
94 static const char* gFillTypeStr[] = { | 69 void PathOpsDebugDeleteNameStr(void* v) { |
95 "kWinding_FillType", | 70 SkDELETE_ARRAY(reinterpret_cast<char* >(v)); |
96 "kEvenOdd_FillType", | |
97 "kInverseWinding_FillType", | |
98 "kInverseEvenOdd_FillType" | |
99 }; | |
100 | |
101 | |
102 void ShowFunctionHeader() { | |
103 SkDebugf("\nstatic void test#(skiatest::Reporter* reporter) {\n"); | |
104 } | 71 } |
105 | 72 |
106 void ShowPath(const SkPath& path, const char* pathName) { | 73 void DebugBumpTestName(char* test) { |
107 SkPath::Iter iter(path, true); | 74 char* num = test + strlen(test); |
108 SkPath::FillType fillType = path.getFillType(); | 75 while (num[-1] >= '0' && num[-1] <= '9') { |
109 SkASSERT(fillType >= SkPath::kWinding_FillType && fillType <= SkPath::kInver
seEvenOdd_FillType); | 76 --num; |
110 SkDebugf(" SkPath %s;\n", pathName); | 77 } |
111 SkDebugf(" %s.setFillType(SkPath::%s);\n", pathName, gFillTypeStr[fillTyp
e]); | 78 if (num[0] == '\0') { |
112 iter.setPath(path, true); | 79 return; |
113 showPathContours(iter, pathName); | 80 } |
114 } | 81 int dec = atoi(num); |
115 | 82 if (dec == 0) { |
116 static const char* gOpStrs[] = { | 83 return; |
117 "kDifference_PathOp", | 84 } |
118 "kIntersect_PathOp", | 85 ++dec; |
119 "kUnion_PathOp", | 86 SK_SNPRINTF(num, DEBUG_FILENAME_STRING_LENGTH - (num - test), "%d", dec); |
120 "kXor_PathOp", | |
121 "kReverseDifference_PathOp", | |
122 }; | |
123 | |
124 void ShowOp(SkPathOp op, const char* pathOne, const char* pathTwo) { | |
125 SkDebugf(" testPathOp(reporter, %s, %s, %s);\n", pathOne, pathTwo, gOpStr
s[op]); | |
126 SkDebugf("}\n"); | |
127 } | 87 } |
128 #endif | 88 #endif |
| 89 |
OLD | NEW |