OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "PathOpsExtendedTest.h" | 7 #include "PathOpsExtendedTest.h" |
8 #include "PathOpsThreadedCommon.h" | 8 #include "PathOpsThreadedCommon.h" |
9 | 9 |
10 // four rects, of four sizes | 10 // four rects, of four sizes |
11 // for 3 smaller sizes, tall, wide | 11 // for 3 smaller sizes, tall, wide |
12 // top upper mid lower bottom aligned (3 bits, 5 values) | 12 // top upper mid lower bottom aligned (3 bits, 5 values) |
13 // same with x (3 bits, 5 values) | 13 // same with x (3 bits, 5 values) |
14 // not included, square, tall, wide (2 bits) | 14 // not included, square, tall, wide (2 bits) |
15 // cw or ccw (1 bit) | 15 // cw or ccw (1 bit) |
16 | 16 |
17 static void testSimplify4x4RectsMain(PathOpsThreadState* data) | 17 static void testSimplify4x4RectsMain(PathOpsThreadState* data) |
18 { | 18 { |
19 SkASSERT(data); | 19 SkASSERT(data); |
20 PathOpsThreadState& state = *data; | 20 PathOpsThreadState& state = *data; |
21 char pathStr[1024]; // gdb: set print elements 400 | 21 char pathStr[1024]; // gdb: set print elements 400 |
22 sk_bzero(pathStr, sizeof(pathStr)); | 22 bool progress = state.fReporter->verbose(); // FIXME: break out into its own
parameter? |
| 23 if (progress) { |
| 24 sk_bzero(pathStr, sizeof(pathStr)); |
| 25 } |
23 int aShape = state.fA & 0x03; | 26 int aShape = state.fA & 0x03; |
24 SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; | 27 SkPath::Direction aCW = state.fA >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
25 int bShape = state.fB & 0x03; | 28 int bShape = state.fB & 0x03; |
26 SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; | 29 SkPath::Direction bCW = state.fB >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
27 int cShape = state.fC & 0x03; | 30 int cShape = state.fC & 0x03; |
28 SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; | 31 SkPath::Direction cCW = state.fC >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
29 int dShape = state.fD & 0x03; | 32 int dShape = state.fD & 0x03; |
30 SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; | 33 SkPath::Direction dCW = state.fD >> 2 ? SkPath::kCCW_Direction : SkPath::kCW
_Direction; |
31 for (int aXAlign = 0; aXAlign < 5; ++aXAlign) { | 34 for (int aXAlign = 0; aXAlign < 5; ++aXAlign) { |
32 for (int aYAlign = 0; aYAlign < 5; ++aYAlign) { | 35 for (int aYAlign = 0; aYAlign < 5; ++aYAlign) { |
(...skipping 23 matching lines...) Expand all Loading... |
56 break; | 59 break; |
57 case 3: | 60 case 3: |
58 l = 0; r = 60; | 61 l = 0; r = 60; |
59 t = aYAlign * 12; | 62 t = aYAlign * 12; |
60 b = l + 30; | 63 b = l + 30; |
61 aXAlign = 5; | 64 aXAlign = 5; |
62 break; | 65 break; |
63 } | 66 } |
64 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), | 67 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
65 aCW); | 68 aCW); |
66 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 69 if (progress) { |
67 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" : ""); | 70 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 71 " SkPath::kC%sW_Direction);\n", l, t, r, b, aCW ? "C" :
""); |
| 72 } |
68 } else { | 73 } else { |
69 aXAlign = 5; | 74 aXAlign = 5; |
70 aYAlign = 5; | 75 aYAlign = 5; |
71 } | 76 } |
72 if (bShape) { | 77 if (bShape) { |
73 switch (bShape) { | 78 switch (bShape) { |
74 case 1: // square | 79 case 1: // square |
75 l = bXAlign * 10; | 80 l = bXAlign * 10; |
76 r = l + 20; | 81 r = l + 20; |
77 t = bYAlign * 10; | 82 t = bYAlign * 10; |
78 b = l + 20; | 83 b = l + 20; |
79 break; | 84 break; |
80 case 2: | 85 case 2: |
81 l = bXAlign * 10; | 86 l = bXAlign * 10; |
82 r = l + 20; | 87 r = l + 20; |
83 t = 10; b = 40; | 88 t = 10; b = 40; |
84 bYAlign = 5; | 89 bYAlign = 5; |
85 break; | 90 break; |
86 case 3: | 91 case 3: |
87 l = 10; r = 40; | 92 l = 10; r = 40; |
88 t = bYAlign * 10; | 93 t = bYAlign * 10; |
89 b = l + 20; | 94 b = l + 20; |
90 bXAlign = 5; | 95 bXAlign = 5; |
91 break; | 96 break; |
92 } | 97 } |
93 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), | 98 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
94 bCW); | 99 bCW); |
95 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 100 if (progress) { |
96 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" : ""); | 101 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 102 " SkPath::kC%sW_Direction);\n", l, t, r, b, bCW ? "C" :
""); |
| 103 } |
97 } else { | 104 } else { |
98 bXAlign = 5; | 105 bXAlign = 5; |
99 bYAlign = 5; | 106 bYAlign = 5; |
100 } | 107 } |
101 if (cShape) { | 108 if (cShape) { |
102 switch (cShape) { | 109 switch (cShape) { |
103 case 1: // square | 110 case 1: // square |
104 l = cXAlign * 6; | 111 l = cXAlign * 6; |
105 r = l + 12; | 112 r = l + 12; |
106 t = cYAlign * 6; | 113 t = cYAlign * 6; |
107 b = l + 12; | 114 b = l + 12; |
108 break; | 115 break; |
109 case 2: | 116 case 2: |
110 l = cXAlign * 6; | 117 l = cXAlign * 6; |
111 r = l + 12; | 118 r = l + 12; |
112 t = 20; b = 30; | 119 t = 20; b = 30; |
113 cYAlign = 5; | 120 cYAlign = 5; |
114 break; | 121 break; |
115 case 3: | 122 case 3: |
116 l = 20; r = 30; | 123 l = 20; r = 30; |
117 t = cYAlign * 6; | 124 t = cYAlign * 6; |
118 b = l + 20; | 125 b = l + 20; |
119 cXAlign = 5; | 126 cXAlign = 5; |
120 break; | 127 break; |
121 } | 128 } |
122 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), | 129 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
123 cCW); | 130 cCW); |
124 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 131 if (progress) { |
125 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" : ""); | 132 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 133 " SkPath::kC%sW_Direction);\n", l, t, r, b, cCW ? "C" :
""); |
| 134 } |
126 } else { | 135 } else { |
127 cXAlign = 5; | 136 cXAlign = 5; |
128 cYAlign = 5; | 137 cYAlign = 5; |
129 } | 138 } |
130 if (dShape) { | 139 if (dShape) { |
131 switch (dShape) { | 140 switch (dShape) { |
132 case 1: // square | 141 case 1: // square |
133 l = dXAlign * 4; | 142 l = dXAlign * 4; |
134 r = l + 9; | 143 r = l + 9; |
135 t = dYAlign * 4; | 144 t = dYAlign * 4; |
136 b = l + 9; | 145 b = l + 9; |
137 break; | 146 break; |
138 case 2: | 147 case 2: |
139 l = dXAlign * 6; | 148 l = dXAlign * 6; |
140 r = l + 9; | 149 r = l + 9; |
141 t = 32; b = 36; | 150 t = 32; b = 36; |
142 dYAlign = 5; | 151 dYAlign = 5; |
143 break; | 152 break; |
144 case 3: | 153 case 3: |
145 l = 32; r = 36; | 154 l = 32; r = 36; |
146 t = dYAlign * 6; | 155 t = dYAlign * 6; |
147 b = l + 9; | 156 b = l + 9; |
148 dXAlign = 5; | 157 dXAlign = 5; |
149 break; | 158 break; |
150 } | 159 } |
151 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), | 160 path.addRect(SkIntToScalar(l), SkIntToScalar(t), SkIntToScalar(r), S
kIntToScalar(b), |
152 dCW); | 161 dCW); |
153 str += sprintf(str, " path.addRect(%d, %d, %d, %d," | 162 if (progress) { |
154 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" : ""); | 163 str += sprintf(str, " path.addRect(%d, %d, %d, %d," |
| 164 " SkPath::kC%sW_Direction);\n", l, t, r, b, dCW ? "C" :
""); |
| 165 } |
155 } else { | 166 } else { |
156 dXAlign = 5; | 167 dXAlign = 5; |
157 dYAlign = 5; | 168 dYAlign = 5; |
158 } | 169 } |
159 path.close(); | 170 path.close(); |
160 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType); | 171 if (progress) { |
| 172 outputProgress(state.fPathStr, pathStr, SkPath::kWinding_FillType); |
| 173 } |
161 testSimplify(path, false, out, state, pathStr); | 174 testSimplify(path, false, out, state, pathStr); |
162 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType); | 175 if (progress) { |
| 176 outputProgress(state.fPathStr, pathStr, SkPath::kEvenOdd_FillType); |
| 177 } |
163 testSimplify(path, true, out, state, pathStr); | 178 testSimplify(path, true, out, state, pathStr); |
164 } | 179 } |
165 } | 180 } |
166 } | 181 } |
167 } | 182 } |
168 } | 183 } |
169 } | 184 } |
170 } | 185 } |
171 } | 186 } |
172 } | 187 } |
(...skipping 12 matching lines...) Expand all Loading... |
185 if (!reporter->allowExtendedTest()) goto finish; | 200 if (!reporter->allowExtendedTest()) goto finish; |
186 } | 201 } |
187 } | 202 } |
188 } | 203 } |
189 finish: | 204 finish: |
190 testRunner.render(); | 205 testRunner.render(); |
191 } | 206 } |
192 | 207 |
193 #include "TestClassDef.h" | 208 #include "TestClassDef.h" |
194 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyRectsThreadedTest) | 209 DEFINE_TESTCLASS_SHORT(PathOpsSimplifyRectsThreadedTest) |
OLD | NEW |