OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2012 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 #include "EdgeWalker_Test.h" | |
8 #include "Intersection_Tests.h" | |
9 #include "SkBitmap.h" | |
10 | |
11 static SkBitmap bitmap; | |
12 | |
13 static void testSimplifyQuadratic1() { | |
14 SkPath path, out; | |
15 path.moveTo(0, 0); | |
16 path.quadTo(1, 0, 1, 1); | |
17 path.close(); | |
18 path.moveTo(1, 0); | |
19 path.quadTo(0, 0, 0, 1); | |
20 path.close(); | |
21 testSimplify(path, true, out, bitmap); | |
22 } | |
23 | |
24 static void testSimplifyQuadratic2() { | |
25 SkPath path, out; | |
26 path.moveTo(0, 0); | |
27 path.quadTo(20, 0, 20, 20); | |
28 path.close(); | |
29 path.moveTo(20, 0); | |
30 path.quadTo(0, 0, 0, 20); | |
31 path.close(); | |
32 testSimplify(path, true, out, bitmap); | |
33 } | |
34 | |
35 static void testSimplifyQuadratic3() { | |
36 SkPath path, out; | |
37 path.moveTo(0, 0); | |
38 path.quadTo(20, 0, 20, 20); | |
39 path.close(); | |
40 path.moveTo(0, 20); | |
41 path.quadTo(0, 0, 20, 0); | |
42 path.close(); | |
43 testSimplify(path, true, out, bitmap); | |
44 } | |
45 | |
46 static void testSimplifyQuadratic4() { | |
47 SkPath path, out; | |
48 path.moveTo(0, 20); | |
49 path.quadTo(20, 0, 40, 20); | |
50 path.close(); | |
51 path.moveTo(40, 10); | |
52 path.quadTo(20, 30, 0, 10); | |
53 path.close(); | |
54 testSimplify(path, true, out, bitmap); | |
55 drawAsciiPaths(path, out, true); | |
56 } | |
57 | |
58 static void testSimplifyQuadratic5() { | |
59 SkPath path, out; | |
60 path.moveTo(0, 0); | |
61 path.quadTo(0, 0, 0, 0); | |
62 path.lineTo(0, 0); | |
63 path.close(); | |
64 path.moveTo(0, 0); | |
65 path.lineTo(0, 0); | |
66 path.quadTo(0, 0, 0, 1); | |
67 path.close(); | |
68 testSimplify(path, true, out, bitmap); | |
69 drawAsciiPaths(path, out, true); | |
70 } | |
71 | |
72 static void testSimplifyQuadratic6() { | |
73 SkPath path, out; | |
74 path.moveTo(0, 0); | |
75 path.quadTo(0, 0, 0, 0); | |
76 path.lineTo(1, 0); | |
77 path.close(); | |
78 path.moveTo(0, 0); | |
79 path.lineTo(0, 0); | |
80 path.quadTo(1, 0, 0, 1); | |
81 path.close(); | |
82 testSimplify(path, true, out, bitmap); | |
83 drawAsciiPaths(path, out, true); | |
84 } | |
85 | |
86 static void testSimplifyQuadratic7() { | |
87 SkPath path, out; | |
88 path.moveTo(0, 0); | |
89 path.quadTo(0, 0, 0, 0); | |
90 path.lineTo(0, 1); | |
91 path.close(); | |
92 path.moveTo(0, 0); | |
93 path.lineTo(0, 0); | |
94 path.quadTo(1, 0, 0, 2); | |
95 path.close(); | |
96 testSimplify(path, true, out, bitmap); | |
97 drawAsciiPaths(path, out, true); | |
98 } | |
99 | |
100 static void testSimplifyQuadratic8() { | |
101 SkPath path, out; | |
102 path.moveTo(0, 0); | |
103 path.quadTo(0, 0, 0, 0); | |
104 path.lineTo(0, 0); | |
105 path.close(); | |
106 path.moveTo(0, 0); | |
107 path.lineTo(0, 0); | |
108 path.quadTo(1, 0, 0, 2); | |
109 path.close(); | |
110 testSimplify(path, true, out, bitmap); | |
111 drawAsciiPaths(path, out, true); | |
112 } | |
113 | |
114 static void testSimplifyQuadratic9() { | |
115 SkPath path, out; | |
116 path.moveTo(0, 0); | |
117 path.quadTo(0, 0, 0, 0); | |
118 path.lineTo(1, 1); | |
119 path.close(); | |
120 path.moveTo(0, 0); | |
121 path.lineTo(0, 0); | |
122 path.quadTo(1, 0, 2, 2); | |
123 path.close(); | |
124 testSimplify(path, true, out, bitmap); | |
125 drawAsciiPaths(path, out, true); | |
126 } | |
127 | |
128 static void testSimplifyQuadratic10() { | |
129 SkPath path, out; | |
130 path.moveTo(0, 0); | |
131 path.quadTo(0, 0, 0, 0); | |
132 path.lineTo(0, 0); | |
133 path.close(); | |
134 path.moveTo(0, 0); | |
135 path.lineTo(0, 1); | |
136 path.quadTo(1, 1, 1, 2); | |
137 path.close(); | |
138 testSimplify(path, true, out, bitmap); | |
139 drawAsciiPaths(path, out, true); | |
140 } | |
141 | |
142 static void testSimplifyQuadratic11() { | |
143 SkPath path, out; | |
144 path.moveTo(0, 0); | |
145 path.quadTo(0, 0, 0, 0); | |
146 path.lineTo(0, 2); | |
147 path.close(); | |
148 path.moveTo(0, 0); | |
149 path.lineTo(2, 1); | |
150 path.quadTo(2, 2, 3, 3); | |
151 path.close(); | |
152 testSimplify(path, true, out, bitmap); | |
153 drawAsciiPaths(path, out, true); | |
154 } | |
155 | |
156 static void testSimplifyQuadratic12() { | |
157 SkPath path, out; | |
158 path.moveTo(0, 0); | |
159 path.lineTo(0, 2); | |
160 path.lineTo(0, 0); | |
161 path.close(); | |
162 path.moveTo(3, 0); | |
163 path.quadTo(1, 1, 0, 2); | |
164 path.lineTo(3, 0); | |
165 path.close(); | |
166 testSimplify(path, true, out, bitmap); | |
167 drawAsciiPaths(path, out, true); | |
168 } | |
169 | |
170 static void testSimplifyQuadratic13() { | |
171 SkPath path, out; | |
172 path.moveTo(0, 0); | |
173 path.quadTo(0, 0, 1, 0); | |
174 path.lineTo(1, 1); | |
175 path.lineTo(0, 0); | |
176 path.close(); | |
177 path.moveTo(0, 0); | |
178 path.quadTo(3, 0, 1, 1); | |
179 path.lineTo(0, 0); | |
180 path.close(); | |
181 testSimplify(path, true, out, bitmap); | |
182 drawAsciiPaths(path, out, true); | |
183 } | |
184 | |
185 static void testSimplifyQuadratic14() { | |
186 SkPath path, out; | |
187 path.moveTo(0, 0); | |
188 path.quadTo(0, 0, 0, 0); | |
189 path.lineTo(1, 1); | |
190 path.close(); | |
191 path.moveTo(0, 0); | |
192 path.lineTo(0, 0); | |
193 path.quadTo(0, 1, 2, 1); | |
194 path.close(); | |
195 testSimplify(path, true, out, bitmap); | |
196 drawAsciiPaths(path, out, true); | |
197 } | |
198 | |
199 static void testSimplifyQuadratic15() { | |
200 SkPath path, out; | |
201 path.moveTo(0, 0); | |
202 path.quadTo(0, 0, 1, 3); | |
203 path.lineTo(3, 3); | |
204 path.close(); | |
205 path.moveTo(0, 1); | |
206 path.lineTo(1, 1); | |
207 path.quadTo(0, 3, 3, 3); | |
208 path.close(); | |
209 testSimplify(path, true, out, bitmap); | |
210 drawAsciiPaths(path, out, true); | |
211 } | |
212 | |
213 static void testSimplifyQuadratic16() { | |
214 SkPath path, out; | |
215 path.moveTo(0, 0); | |
216 path.quadTo(0, 0, 0, 0); | |
217 path.lineTo(0, 1); | |
218 path.close(); | |
219 path.moveTo(0, 0); | |
220 path.lineTo(0, 0); | |
221 path.quadTo(1, 0, 0, 1); | |
222 path.close(); | |
223 testSimplify(path, true, out, bitmap); | |
224 drawAsciiPaths(path, out, true); | |
225 } | |
226 | |
227 static void testSimplifyQuadratic17() { | |
228 SkPath path, out; | |
229 path.moveTo(0, 0); | |
230 path.quadTo(0, 0, 0, 0); | |
231 path.lineTo(2, 2); | |
232 path.close(); | |
233 path.moveTo(0, 1); | |
234 path.lineTo(0, 1); | |
235 path.quadTo(2, 1, 3, 3); | |
236 path.close(); | |
237 testSimplify(path, true, out, bitmap); | |
238 drawAsciiPaths(path, out, true); | |
239 } | |
240 | |
241 static void (*simplifyTests[])() = { | |
242 testSimplifyQuadratic17, | |
243 testSimplifyQuadratic16, | |
244 testSimplifyQuadratic15, | |
245 testSimplifyQuadratic14, | |
246 testSimplifyQuadratic13, | |
247 testSimplifyQuadratic12, | |
248 testSimplifyQuadratic11, | |
249 testSimplifyQuadratic10, | |
250 testSimplifyQuadratic9, | |
251 testSimplifyQuadratic8, | |
252 testSimplifyQuadratic7, | |
253 testSimplifyQuadratic6, | |
254 testSimplifyQuadratic5, | |
255 testSimplifyQuadratic4, | |
256 testSimplifyQuadratic3, | |
257 testSimplifyQuadratic2, | |
258 testSimplifyQuadratic1, | |
259 }; | |
260 | |
261 static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[
0]); | |
262 | |
263 static void (*firstTest)() = testSimplifyQuadratic14; | |
264 static bool skipAll = false; | |
265 | |
266 void SimplifyQuadraticPaths_Test() { | |
267 if (skipAll) { | |
268 return; | |
269 } | |
270 size_t index = 0; | |
271 if (firstTest) { | |
272 while (index < simplifyTestsCount && simplifyTests[index] != firstTest)
{ | |
273 ++index; | |
274 } | |
275 } | |
276 bool firstTestComplete = false; | |
277 for ( ; index < simplifyTestsCount; ++index) { | |
278 (*simplifyTests[index])(); | |
279 if (simplifyTests[index] == testSimplifyQuadratic1) { | |
280 SkDebugf("%s last fast quad test\n", __FUNCTION__); | |
281 } | |
282 firstTestComplete = true; | |
283 } | |
284 } | |
OLD | NEW |