caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 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 | |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 8 | #include "EdgeWalker_Test.h" |
| 9 | #include "Intersection_Tests.h" |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 10 | #include "ShapeOps.h" |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 11 | |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 12 | #define TEST(name) { name, #name } |
| 13 | |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 14 | static void testLine1() { |
| 15 | SkPath path, simple; |
| 16 | path.moveTo(2,0); |
| 17 | path.lineTo(1,1); |
| 18 | path.lineTo(0,0); |
| 19 | path.close(); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 20 | testSimplifyx(path); |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | static void addInnerCWTriangle(SkPath& path) { |
| 24 | path.moveTo(3,0); |
| 25 | path.lineTo(4,1); |
| 26 | path.lineTo(2,1); |
| 27 | path.close(); |
| 28 | } |
| 29 | |
| 30 | static void addInnerCCWTriangle(SkPath& path) { |
| 31 | path.moveTo(3,0); |
| 32 | path.lineTo(2,1); |
| 33 | path.lineTo(4,1); |
| 34 | path.close(); |
| 35 | } |
| 36 | |
| 37 | static void addOuterCWTriangle(SkPath& path) { |
| 38 | path.moveTo(3,0); |
| 39 | path.lineTo(6,2); |
| 40 | path.lineTo(0,2); |
| 41 | path.close(); |
| 42 | } |
| 43 | |
| 44 | static void addOuterCCWTriangle(SkPath& path) { |
| 45 | path.moveTo(3,0); |
| 46 | path.lineTo(0,2); |
| 47 | path.lineTo(6,2); |
| 48 | path.close(); |
| 49 | } |
| 50 | |
| 51 | static void testLine2() { |
| 52 | SkPath path, simple; |
| 53 | addInnerCWTriangle(path); |
| 54 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 55 | testSimplifyx(path); |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 56 | } |
| 57 | |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 58 | static void testLine3() { |
| 59 | SkPath path, simple; |
| 60 | addInnerCCWTriangle(path); |
| 61 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 62 | testSimplifyx(path); |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 63 | } |
| 64 | |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 65 | static void testLine3a() { |
| 66 | SkPath path, simple; |
| 67 | addInnerCWTriangle(path); |
| 68 | addOuterCCWTriangle(path); |
| 69 | testSimplifyx(path); |
| 70 | } |
| 71 | |
| 72 | static void testLine3b() { |
| 73 | SkPath path, simple; |
| 74 | addInnerCCWTriangle(path); |
| 75 | addOuterCCWTriangle(path); |
| 76 | testSimplifyx(path); |
| 77 | } |
| 78 | |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 79 | static void testLine4() { |
| 80 | SkPath path, simple; |
| 81 | addOuterCCWTriangle(path); |
| 82 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 83 | testSimplifyx(path); |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static void testLine5() { |
| 87 | SkPath path, simple; |
| 88 | addOuterCWTriangle(path); |
| 89 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 90 | testSimplifyx(path); |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 91 | } |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 92 | |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 93 | static void testLine6() { |
| 94 | SkPath path, simple; |
| 95 | path.moveTo(0,0); |
| 96 | path.lineTo(4,0); |
| 97 | path.lineTo(2,2); |
| 98 | path.close(); |
| 99 | path.moveTo(2,0); |
| 100 | path.lineTo(6,0); |
| 101 | path.lineTo(4,2); |
| 102 | path.close(); |
| 103 | testSimplifyx(path); |
| 104 | } |
| 105 | |
| 106 | static void testLine7() { |
| 107 | SkPath path, simple; |
| 108 | path.moveTo(0,0); |
| 109 | path.lineTo(4,0); |
| 110 | path.lineTo(2,2); |
| 111 | path.close(); |
| 112 | path.moveTo(6,0); |
| 113 | path.lineTo(2,0); |
| 114 | path.lineTo(4,2); |
| 115 | path.close(); |
| 116 | testSimplifyx(path); |
| 117 | } |
| 118 | |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 119 | static void testLine7a() { |
| 120 | SkPath path, simple; |
| 121 | path.moveTo(0,0); |
| 122 | path.lineTo(4,0); |
| 123 | path.lineTo(2,2); |
| 124 | path.close(); |
| 125 | testSimplifyx(path); |
| 126 | } |
| 127 | |
| 128 | static void testLine7b() { |
| 129 | SkPath path, simple; |
| 130 | path.moveTo(0,0); |
| 131 | path.lineTo(4,0); |
| 132 | path.close(); |
| 133 | path.moveTo(6,0); |
| 134 | path.lineTo(2,0); |
| 135 | path.lineTo(4,2); |
| 136 | path.close(); |
| 137 | testSimplifyx(path); |
| 138 | } |
| 139 | |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 140 | static void testLine8() { |
| 141 | SkPath path, simple; |
| 142 | path.moveTo(0,4); |
| 143 | path.lineTo(4,4); |
| 144 | path.lineTo(2,2); |
| 145 | path.close(); |
| 146 | path.moveTo(2,4); |
| 147 | path.lineTo(6,4); |
| 148 | path.lineTo(4,2); |
| 149 | path.close(); |
| 150 | testSimplifyx(path); |
| 151 | } |
| 152 | |
| 153 | static void testLine9() { |
| 154 | SkPath path, simple; |
| 155 | path.moveTo(0,4); |
| 156 | path.lineTo(4,4); |
| 157 | path.lineTo(2,2); |
| 158 | path.close(); |
| 159 | path.moveTo(6,4); |
| 160 | path.lineTo(2,4); |
| 161 | path.lineTo(4,2); |
| 162 | path.close(); |
| 163 | testSimplifyx(path); |
| 164 | } |
| 165 | |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 166 | static void testLine10() { |
| 167 | SkPath path, simple; |
| 168 | path.moveTo(0,4); |
| 169 | path.lineTo(4,4); |
| 170 | path.lineTo(2,2); |
| 171 | path.close(); |
| 172 | path.moveTo(2,1); |
| 173 | path.lineTo(3,4); |
| 174 | path.lineTo(6,1); |
| 175 | path.close(); |
| 176 | testSimplifyx(path); |
| 177 | } |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 178 | |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 179 | static void testLine10a() { |
| 180 | SkPath path, simple; |
| 181 | path.moveTo(0,4); |
| 182 | path.lineTo(8,4); |
| 183 | path.lineTo(4,0); |
| 184 | path.close(); |
| 185 | path.moveTo(2,2); |
| 186 | path.lineTo(3,3); |
| 187 | path.lineTo(4,2); |
| 188 | path.close(); |
| 189 | testSimplifyx(path); |
| 190 | } |
| 191 | |
| 192 | static void addCWContainer(SkPath& path) { |
| 193 | path.moveTo(6,4); |
| 194 | path.lineTo(0,4); |
| 195 | path.lineTo(3,1); |
| 196 | path.close(); |
| 197 | } |
| 198 | |
| 199 | static void addCCWContainer(SkPath& path) { |
| 200 | path.moveTo(0,4); |
| 201 | path.lineTo(6,4); |
| 202 | path.lineTo(3,1); |
| 203 | path.close(); |
| 204 | } |
| 205 | |
| 206 | static void addCWContents(SkPath& path) { |
| 207 | path.moveTo(2,3); |
| 208 | path.lineTo(3,2); |
| 209 | path.lineTo(4,3); |
| 210 | path.close(); |
| 211 | } |
| 212 | |
| 213 | static void addCCWContents(SkPath& path) { |
| 214 | path.moveTo(3,2); |
| 215 | path.lineTo(2,3); |
| 216 | path.lineTo(4,3); |
| 217 | path.close(); |
| 218 | } |
| 219 | |
| 220 | static void testLine11() { |
| 221 | SkPath path, simple; |
| 222 | addCWContainer(path); |
| 223 | addCWContents(path); |
| 224 | testSimplifyx(path); |
| 225 | } |
| 226 | |
| 227 | static void testLine12() { |
| 228 | SkPath path, simple; |
| 229 | addCCWContainer(path); |
| 230 | addCWContents(path); |
| 231 | testSimplifyx(path); |
| 232 | } |
| 233 | |
| 234 | static void testLine13() { |
| 235 | SkPath path, simple; |
| 236 | addCWContainer(path); |
| 237 | addCCWContents(path); |
| 238 | testSimplifyx(path); |
| 239 | } |
| 240 | |
| 241 | static void testLine14() { |
| 242 | SkPath path, simple; |
| 243 | addCCWContainer(path); |
| 244 | addCCWContents(path); |
| 245 | testSimplifyx(path); |
| 246 | } |
| 247 | |
| 248 | static void testLine15() { |
| 249 | SkPath path, simple; |
| 250 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 251 | testSimplifyx(path); |
| 252 | } |
| 253 | |
| 254 | static void testLine16() { |
| 255 | SkPath path, simple; |
| 256 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 257 | path.addRect(0, 4, 9, 9, (SkPath::Direction) 0); |
| 258 | testSimplifyx(path); |
| 259 | } |
| 260 | |
| 261 | static void testLine17() { |
| 262 | SkPath path, simple; |
| 263 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 264 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 265 | testSimplifyx(path); |
| 266 | } |
| 267 | |
| 268 | static void testLine18() { |
| 269 | SkPath path, simple; |
| 270 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 271 | path.addRect(12, 4, 21, 21, (SkPath::Direction) 0); |
| 272 | testSimplifyx(path); |
| 273 | } |
| 274 | |
| 275 | static void testLine19() { |
| 276 | SkPath path, simple; |
| 277 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 278 | path.addRect(12, 16, 21, 21, (SkPath::Direction) 0); |
| 279 | testSimplifyx(path); |
| 280 | } |
| 281 | |
| 282 | static void testLine20() { |
| 283 | SkPath path, simple; |
| 284 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 285 | path.addRect(0, 12, 9, 9, (SkPath::Direction) 0); |
| 286 | testSimplifyx(path); |
| 287 | } |
| 288 | |
| 289 | static void testLine21() { |
| 290 | SkPath path, simple; |
| 291 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 292 | path.addRect(0, 16, 9, 9, (SkPath::Direction) 0); |
| 293 | testSimplifyx(path); |
| 294 | } |
| 295 | |
| 296 | static void testLine22() { |
| 297 | SkPath path, simple; |
| 298 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 299 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 300 | testSimplifyx(path); |
| 301 | } |
| 302 | |
| 303 | static void testLine23() { |
| 304 | SkPath path, simple; |
| 305 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 306 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 307 | testSimplifyx(path); |
| 308 | } |
| 309 | |
| 310 | |
| 311 | |
| 312 | static void testLine24a() { |
| 313 | SkPath path, simple; |
| 314 | path.moveTo(2,0); |
| 315 | path.lineTo(4,4); |
| 316 | path.lineTo(0,4); |
| 317 | path.close(); |
| 318 | path.moveTo(2,0); |
| 319 | path.lineTo(1,2); |
| 320 | path.lineTo(2,2); |
| 321 | path.close(); |
| 322 | testSimplifyx(path); |
| 323 | } |
| 324 | |
| 325 | static void testLine24() { |
| 326 | SkPath path, simple; |
| 327 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 328 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 329 | testSimplifyx(path); |
| 330 | } |
| 331 | |
| 332 | static void testLine25() { |
| 333 | SkPath path, simple; |
| 334 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 335 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 336 | testSimplifyx(path); |
| 337 | } |
| 338 | |
| 339 | static void testLine26() { |
| 340 | SkPath path, simple; |
| 341 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 342 | path.addRect(0, 12, 9, 9, (SkPath::Direction) 0); |
| 343 | testSimplifyx(path); |
| 344 | } |
| 345 | |
| 346 | static void testLine27() { |
| 347 | SkPath path, simple; |
| 348 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 349 | path.addRect(12, 8, 21, 21, (SkPath::Direction) 0); |
| 350 | testSimplifyx(path); |
| 351 | } |
| 352 | |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 353 | static void testLine28() { |
| 354 | SkPath path, simple; |
| 355 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 356 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 357 | testSimplifyx(path); |
| 358 | } |
| 359 | |
| 360 | static void testLine29() { |
| 361 | SkPath path, simple; |
| 362 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 363 | path.addRect(12, 12, 21, 21, (SkPath::Direction) 0); |
| 364 | testSimplifyx(path); |
| 365 | } |
| 366 | |
| 367 | static void testLine30() { |
| 368 | SkPath path, simple; |
| 369 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 370 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 371 | path.addRect(4, 4, 13, 13, (SkPath::Direction) 0); |
| 372 | testSimplifyx(path); |
| 373 | } |
| 374 | |
| 375 | static void testLine31() { |
| 376 | SkPath path, simple; |
| 377 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 378 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 379 | path.addRect(0, 4, 9, 9, (SkPath::Direction) 0); |
| 380 | testSimplifyx(path); |
| 381 | } |
| 382 | |
| 383 | static void testLine32() { |
| 384 | SkPath path, simple; |
| 385 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 386 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 387 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 388 | testSimplifyx(path); |
| 389 | } |
| 390 | |
caryclark@google.com | 210acaf | 2012-07-12 21:05:13 +0000 | [diff] [blame] | 391 | static void testLine33() { |
| 392 | SkPath path, simple; |
| 393 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 394 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 395 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 396 | testSimplifyx(path); |
| 397 | } |
| 398 | |
| 399 | static void testLine34() { |
| 400 | SkPath path, simple; |
| 401 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 402 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 403 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 404 | testSimplifyx(path); |
| 405 | } |
| 406 | |
| 407 | static void testLine35() { |
| 408 | SkPath path, simple; |
| 409 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 410 | path.addRect(6, 0, 18, 18, (SkPath::Direction) 0); |
| 411 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 412 | testSimplifyx(path); |
| 413 | } |
| 414 | |
caryclark@google.com | 0e08a19 | 2012-07-13 21:07:52 +0000 | [diff] [blame] | 415 | static void testLine36() { |
| 416 | SkPath path, simple; |
| 417 | path.addRect(0, 10, 20, 20, (SkPath::Direction) 0); |
| 418 | path.addRect(6, 12, 18, 18, (SkPath::Direction) 0); |
| 419 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 420 | testSimplifyx(path); |
| 421 | } |
| 422 | |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 423 | static void testLine37() { |
| 424 | SkPath path, simple; |
| 425 | path.addRect(0, 20, 20, 20, (SkPath::Direction) 0); |
| 426 | path.addRect(18, 24, 30, 30, (SkPath::Direction) 0); |
| 427 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 428 | testSimplifyx(path); |
| 429 | } |
| 430 | |
| 431 | static void testLine38() { |
| 432 | SkPath path, simple; |
| 433 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 434 | path.addRect(6, 12, 18, 18, (SkPath::Direction) 0); |
| 435 | path.addRect(12, 12, 21, 21, (SkPath::Direction) 0); |
| 436 | testSimplifyx(path); |
| 437 | } |
| 438 | |
| 439 | static void testLine40() { |
| 440 | SkPath path, simple; |
| 441 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 442 | path.addRect(12, 18, 24, 24, (SkPath::Direction) 0); |
| 443 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 444 | testSimplifyx(path); |
| 445 | } |
| 446 | |
| 447 | static void testLine41() { |
| 448 | SkPath path, simple; |
| 449 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 450 | path.addRect(18, 24, 30, 30, (SkPath::Direction) 0); |
| 451 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 452 | testSimplifyx(path); |
| 453 | } |
| 454 | |
| 455 | static void testLine42() { |
| 456 | SkPath path, simple; |
| 457 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 458 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 459 | path.addRect(8, 16, 17, 17, (SkPath::Direction) 0); |
| 460 | testSimplifyx(path); |
| 461 | } |
| 462 | |
| 463 | static void testLine43() { |
| 464 | SkPath path, simple; |
| 465 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 466 | path.addRect(6, 24, 18, 18, (SkPath::Direction) 0); |
| 467 | path.addRect(0, 32, 9, 36, (SkPath::Direction) 1); |
| 468 | testSimplifyx(path); |
| 469 | } |
| 470 | |
| 471 | static void testLine44() { |
| 472 | SkPath path, simple; |
| 473 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 474 | path.addRect(18, 0, 30, 30, (SkPath::Direction) 0); |
| 475 | path.addRect(18, 32, 27, 36, (SkPath::Direction) 1); |
| 476 | testSimplifyx(path); |
| 477 | } |
| 478 | |
| 479 | static void testLine45() { |
| 480 | SkPath path, simple; |
| 481 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 482 | path.addRect(18, 0, 30, 30, (SkPath::Direction) 0); |
| 483 | path.addRect(24, 32, 33, 36, (SkPath::Direction) 0); |
| 484 | testSimplifyx(path); |
| 485 | } |
| 486 | |
| 487 | static void testLine46() { |
| 488 | SkPath path, simple; |
| 489 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 490 | path.addRect(24, 0, 36, 36, (SkPath::Direction) 0); |
| 491 | path.addRect(24, 32, 33, 36, (SkPath::Direction) 0); |
| 492 | testSimplifyx(path); |
| 493 | } |
| 494 | |
| 495 | static void testLine47() { |
| 496 | SkPath path, simple; |
| 497 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 498 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 499 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 1); |
| 500 | testSimplifyx(path); |
| 501 | } |
| 502 | |
| 503 | static void testLine48() { |
| 504 | SkPath path, simple; |
| 505 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 506 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 507 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 1); |
| 508 | testSimplifyx(path); |
| 509 | } |
| 510 | |
| 511 | static void testLine49() { |
| 512 | SkPath path, simple; |
| 513 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 514 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 515 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 516 | testSimplifyx(path); |
| 517 | } |
| 518 | |
| 519 | static void testLine50() { |
| 520 | SkPath path, simple; |
| 521 | path.addRect(10, 30, 30, 30, (SkPath::Direction) 0); |
| 522 | path.addRect(24, 20, 36, 30, (SkPath::Direction) 0); |
| 523 | testSimplifyx(path); |
| 524 | } |
| 525 | |
| 526 | |
| 527 | static void testLine51() { |
| 528 | SkPath path, simple; |
| 529 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 530 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 531 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 1); |
| 532 | testSimplifyx(path); |
| 533 | } |
| 534 | |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 535 | static void testLine52() { |
| 536 | SkPath path, simple; |
| 537 | path.addRect(0, 30, 20, 20, (SkPath::Direction) 0); |
| 538 | path.addRect(6, 20, 18, 30, (SkPath::Direction) 0); |
| 539 | path.addRect(32, 0, 36, 41, (SkPath::Direction) 0); |
| 540 | testSimplifyx(path); |
| 541 | } |
| 542 | |
| 543 | static void testLine53() { |
| 544 | SkPath path, simple; |
| 545 | path.addRect(10, 30, 30, 30, (SkPath::Direction) 0); |
| 546 | path.addRect(12, 20, 24, 30, (SkPath::Direction) 0); |
| 547 | path.addRect(12, 32, 21, 36, (SkPath::Direction) 1); |
| 548 | testSimplifyx(path); |
| 549 | } |
| 550 | |
| 551 | static void testLine54() { |
| 552 | SkPath path, simple; |
| 553 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 554 | path.addRect(6, 0, 18, 18, (SkPath::Direction) 0); |
| 555 | path.addRect(8, 4, 17, 17, (SkPath::Direction) 1); |
| 556 | testSimplifyx(path); |
| 557 | } |
| 558 | |
| 559 | static void testLine55() { |
| 560 | SkPath path, simple; |
| 561 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 562 | path.addRect(6, 6, 18, 18, (SkPath::Direction) 0); |
| 563 | path.addRect(4, 4, 13, 13, (SkPath::Direction) 1); |
| 564 | testSimplifyx(path); |
| 565 | } |
| 566 | |
caryclark@google.com | 1806344 | 2012-07-25 12:05:18 +0000 | [diff] [blame] | 567 | static void testLine56() { |
| 568 | SkPath path, simple; |
| 569 | path.addRect(0, 20, 20, 20, (SkPath::Direction) 0); |
| 570 | path.addRect(18, 20, 30, 30, (SkPath::Direction) 0); |
| 571 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 1); |
| 572 | testSimplifyx(path); |
| 573 | } |
| 574 | |
| 575 | static void testLine57() { |
| 576 | SkPath path, simple; |
| 577 | path.addRect(20, 0, 40, 40, (SkPath::Direction) 0); |
| 578 | path.addRect(20, 0, 30, 40, (SkPath::Direction) 0); |
| 579 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 1); |
| 580 | testSimplifyx(path); |
| 581 | } |
| 582 | |
caryclark@google.com | cc90505 | 2012-07-25 20:59:42 +0000 | [diff] [blame] | 583 | static void testLine58() { |
| 584 | SkPath path, simple; |
| 585 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 586 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 1); |
| 587 | path.addRect(0, 12, 9, 9, (SkPath::Direction) 1); |
| 588 | testSimplifyx(path); |
| 589 | } |
| 590 | |
| 591 | static void testLine59() { |
| 592 | SkPath path, simple; |
| 593 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 594 | path.addRect(6, 6, 18, 18, (SkPath::Direction) 1); |
| 595 | path.addRect(4, 4, 13, 13, (SkPath::Direction) 1); |
| 596 | testSimplifyx(path); |
| 597 | } |
| 598 | |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 599 | static void testLine60() { |
| 600 | SkPath path, simple; |
| 601 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 602 | path.addRect(6, 12, 18, 18, (SkPath::Direction) 1); |
| 603 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 1); |
| 604 | testSimplifyx(path); |
| 605 | } |
| 606 | |
| 607 | static void testLine61() { |
| 608 | SkPath path, simple; |
| 609 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 610 | path.addRect(12, 0, 24, 24, (SkPath::Direction) 1); |
| 611 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 1); |
| 612 | testSimplifyx(path); |
| 613 | } |
| 614 | |
| 615 | static void testLine62() { |
| 616 | SkPath path, simple; |
| 617 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 618 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 619 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 620 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 1); |
| 621 | testSimplifyx(path); |
| 622 | } |
| 623 | |
| 624 | static void testLine63() { |
| 625 | SkPath path, simple; |
| 626 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 627 | path.addRect(0, 10, 20, 20, (SkPath::Direction) 0); |
| 628 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 1); |
| 629 | path.addRect(0, 32, 9, 36, (SkPath::Direction) 1); |
| 630 | testSimplifyx(path); |
| 631 | } |
| 632 | |
| 633 | static void testLine64() { |
| 634 | SkPath path, simple; |
| 635 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 636 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 637 | path.addRect(18, 6, 30, 30, (SkPath::Direction) 0); |
| 638 | testSimplifyx(path); |
| 639 | } |
| 640 | |
| 641 | static void testLine65() { |
| 642 | SkPath path, simple; |
| 643 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 644 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 645 | path.addRect(24, 0, 36, 36, (SkPath::Direction) 0); |
| 646 | path.addRect(32, 6, 36, 41, (SkPath::Direction) 1); |
| 647 | testSimplifyx(path); |
| 648 | } |
| 649 | |
| 650 | static void testLine66() { |
| 651 | SkPath path, simple; |
| 652 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 653 | path.addRect(0, 30, 20, 20, (SkPath::Direction) 0); |
| 654 | path.addRect(12, 20, 24, 30, (SkPath::Direction) 0); |
| 655 | testSimplifyx(path); |
| 656 | } |
| 657 | |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 658 | static void testLine67() { |
| 659 | SkPath path, simple; |
| 660 | path.addRect(0, 0, 60, 60, (SkPath::Direction) 0); |
| 661 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 662 | path.addRect(24, 20, 36, 30, (SkPath::Direction) 0); |
| 663 | path.addRect(32, 0, 36, 41, (SkPath::Direction) 0); |
| 664 | testSimplifyx(path); |
| 665 | } |
| 666 | |
| 667 | static void testLine68a() { |
| 668 | SkPath path, simple; |
| 669 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 670 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 0); |
| 671 | path.addRect(1, 2, 4, 2, (SkPath::Direction) 0); |
| 672 | testSimplifyx(path); |
| 673 | } |
| 674 | |
| 675 | static void testLine68b() { |
| 676 | SkPath path, simple; |
| 677 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 678 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 679 | path.addRect(1, 2, 2, 2, (SkPath::Direction) 0); |
| 680 | testSimplifyx(path); |
| 681 | } |
| 682 | |
| 683 | static void testLine68c() { |
| 684 | SkPath path, simple; |
| 685 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 1); |
| 686 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 0); |
| 687 | path.addRect(1, 2, 4, 2, (SkPath::Direction) 0); |
| 688 | testSimplifyx(path); |
| 689 | } |
| 690 | |
| 691 | static void testLine68d() { |
| 692 | SkPath path, simple; |
| 693 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 1); |
| 694 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 695 | path.addRect(1, 2, 4, 2, (SkPath::Direction) 0); |
| 696 | testSimplifyx(path); |
| 697 | } |
| 698 | |
| 699 | static void testLine68e() { |
| 700 | SkPath path, simple; |
| 701 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 702 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 703 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 704 | path.addRect(1, 2, 2, 2, (SkPath::Direction) 0); |
| 705 | testSimplifyx(path); |
| 706 | } |
| 707 | |
| 708 | static void testLine68f() { |
| 709 | SkPath path, simple; |
| 710 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 711 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 712 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 713 | path.addRect(1, 2, 2, 2, (SkPath::Direction) 0); |
| 714 | testSimplifyx(path); |
| 715 | } |
| 716 | |
| 717 | static void testLine68g() { |
| 718 | SkPath path, simple; |
| 719 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 720 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 721 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 722 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 723 | path.addRect(1, 2, 2, 2, (SkPath::Direction) 0); |
| 724 | testSimplifyx(path); |
| 725 | } |
| 726 | |
| 727 | static void testLine68h() { |
| 728 | SkPath path, simple; |
| 729 | path.addRect(0, 0, 8, 8, (SkPath::Direction) 0); |
| 730 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 731 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 732 | path.addRect(2, 2, 6, 6, (SkPath::Direction) 1); |
| 733 | path.addRect(1, 2, 2, 2, (SkPath::Direction) 0); |
| 734 | testSimplifyx(path); |
| 735 | } |
| 736 | |
| 737 | static void testLine69() { |
| 738 | SkPath path, simple; |
| 739 | path.addRect(0, 20, 20, 20, (SkPath::Direction) 0); |
| 740 | path.addRect(0, 20, 12, 30, (SkPath::Direction) 0); |
| 741 | path.addRect(12, 32, 21, 36, (SkPath::Direction) 0); |
| 742 | testSimplifyx(path); |
| 743 | } |
| 744 | |
| 745 | static void testLine70() { |
| 746 | SkPath path, simple; |
| 747 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 748 | path.addRect(0, 24, 12, 12, (SkPath::Direction) 0); |
| 749 | path.addRect(12, 32, 21, 36, (SkPath::Direction) 1); |
| 750 | testSimplifyx(path); |
| 751 | } |
| 752 | |
| 753 | static void testLine71() { |
| 754 | SkPath path, simple; |
| 755 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 756 | path.addRect(12, 0, 24, 24, (SkPath::Direction) 0); |
| 757 | path.addRect(12, 32, 21, 36, (SkPath::Direction) 0); |
| 758 | testSimplifyx(path); |
| 759 | } |
| 760 | |
caryclark@google.com | 7db7c6b | 2012-07-27 21:22:25 +0000 | [diff] [blame] | 761 | static void (*firstTest)() = 0; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 762 | |
| 763 | static struct { |
| 764 | void (*fun)(); |
| 765 | const char* str; |
| 766 | } tests[] = { |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 767 | TEST(testLine71), |
| 768 | TEST(testLine70), |
| 769 | TEST(testLine69), |
| 770 | TEST(testLine68h), |
| 771 | TEST(testLine68g), |
| 772 | TEST(testLine68f), |
| 773 | TEST(testLine68e), |
| 774 | TEST(testLine68d), |
| 775 | TEST(testLine68c), |
| 776 | TEST(testLine68b), |
| 777 | TEST(testLine68a), |
| 778 | TEST(testLine67), |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 779 | TEST(testLine66), |
| 780 | TEST(testLine65), |
| 781 | TEST(testLine64), |
| 782 | TEST(testLine63), |
| 783 | TEST(testLine62), |
| 784 | TEST(testLine61), |
| 785 | TEST(testLine60), |
caryclark@google.com | cc90505 | 2012-07-25 20:59:42 +0000 | [diff] [blame] | 786 | TEST(testLine59), |
| 787 | TEST(testLine58), |
caryclark@google.com | 1806344 | 2012-07-25 12:05:18 +0000 | [diff] [blame] | 788 | TEST(testLine57), |
| 789 | TEST(testLine56), |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 790 | TEST(testLine55), |
| 791 | TEST(testLine54), |
| 792 | TEST(testLine53), |
| 793 | TEST(testLine52), |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 794 | TEST(testLine51), |
| 795 | TEST(testLine50), |
| 796 | TEST(testLine49), |
| 797 | TEST(testLine48), |
| 798 | TEST(testLine47), |
| 799 | TEST(testLine46), |
| 800 | TEST(testLine45), |
| 801 | TEST(testLine44), |
| 802 | TEST(testLine43), |
| 803 | TEST(testLine42), |
| 804 | TEST(testLine41), |
| 805 | TEST(testLine40), |
| 806 | TEST(testLine38), |
| 807 | TEST(testLine37), |
| 808 | TEST(testLine36), |
| 809 | TEST(testLine35), |
| 810 | TEST(testLine34), |
| 811 | TEST(testLine33), |
| 812 | TEST(testLine32), |
| 813 | TEST(testLine31), |
| 814 | TEST(testLine30), |
| 815 | TEST(testLine29), |
| 816 | TEST(testLine28), |
| 817 | TEST(testLine27), |
| 818 | TEST(testLine26), |
| 819 | TEST(testLine25), |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 820 | TEST(testLine24a), |
| 821 | TEST(testLine24), |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 822 | TEST(testLine23), |
| 823 | TEST(testLine22), |
| 824 | TEST(testLine21), |
| 825 | TEST(testLine20), |
| 826 | TEST(testLine19), |
| 827 | TEST(testLine18), |
| 828 | TEST(testLine17), |
| 829 | TEST(testLine16), |
| 830 | TEST(testLine15), |
| 831 | TEST(testLine14), |
| 832 | TEST(testLine13), |
| 833 | TEST(testLine12), |
| 834 | TEST(testLine11), |
| 835 | TEST(testLine10a), |
| 836 | TEST(testLine10), |
| 837 | TEST(testLine9), |
| 838 | TEST(testLine8), |
| 839 | TEST(testLine7b), |
| 840 | TEST(testLine7a), |
| 841 | TEST(testLine7), |
| 842 | TEST(testLine6), |
| 843 | TEST(testLine5), |
| 844 | TEST(testLine4), |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 845 | TEST(testLine3b), |
| 846 | TEST(testLine3a), |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 847 | TEST(testLine3), |
| 848 | TEST(testLine2), |
| 849 | TEST(testLine1), |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 850 | }; |
| 851 | |
| 852 | static const size_t testCount = sizeof(tests) / sizeof(tests[0]); |
| 853 | |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 854 | static struct { |
| 855 | void (*fun)(); |
| 856 | const char* str; |
| 857 | } subTests[] = { |
| 858 | TEST(testLine68h), |
| 859 | TEST(testLine68g), |
| 860 | TEST(testLine68f), |
| 861 | TEST(testLine68e), |
| 862 | TEST(testLine68d), |
| 863 | TEST(testLine68c), |
| 864 | TEST(testLine68b), |
| 865 | TEST(testLine68a), |
| 866 | }; |
| 867 | |
| 868 | static const size_t subTestCount = sizeof(subTests) / sizeof(subTests[0]); |
| 869 | |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 870 | static bool skipAll = false; |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 871 | static bool runSubTests = false; |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 872 | |
| 873 | void SimplifyNew_Test() { |
| 874 | if (skipAll) { |
| 875 | return; |
| 876 | } |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 877 | #ifdef SK_DEBUG |
caryclark@google.com | 27c449a | 2012-07-27 18:26:38 +0000 | [diff] [blame] | 878 | gDebugMaxWindSum = 4; |
| 879 | gDebugMaxWindValue = 4; |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 880 | size_t index; |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 881 | #endif |
caryclark@google.com | 534aa5b | 2012-08-02 20:08:21 +0000 | [diff] [blame^] | 882 | if (runSubTests) { |
| 883 | index = subTestCount - 1; |
| 884 | do { |
| 885 | SkDebugf(" %s [%s]\n", __FUNCTION__, subTests[index].str); |
| 886 | (*subTests[index].fun)(); |
| 887 | } while (index--); |
| 888 | } |
| 889 | index = testCount - 1; |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 890 | if (firstTest) { |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 891 | while (index > 0 && tests[index].fun != firstTest) { |
| 892 | --index; |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 893 | } |
| 894 | } |
| 895 | bool firstTestComplete = false; |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 896 | do { |
| 897 | SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 898 | (*tests[index].fun)(); |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 899 | firstTestComplete = true; |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 900 | } while (index--); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 901 | #ifdef SK_DEBUG |
| 902 | gDebugMaxWindSum = SK_MaxS32; |
| 903 | gDebugMaxWindValue = SK_MaxS32; |
| 904 | #endif |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 905 | } |