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 | |
| 65 | static void testLine4() { |
| 66 | SkPath path, simple; |
| 67 | addOuterCCWTriangle(path); |
| 68 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 69 | testSimplifyx(path); |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | static void testLine5() { |
| 73 | SkPath path, simple; |
| 74 | addOuterCWTriangle(path); |
| 75 | addOuterCWTriangle(path); |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 76 | testSimplifyx(path); |
caryclark@google.com | 495f8e4 | 2012-05-31 13:13:11 +0000 | [diff] [blame] | 77 | } |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 78 | |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 79 | static void testLine6() { |
| 80 | SkPath path, simple; |
| 81 | path.moveTo(0,0); |
| 82 | path.lineTo(4,0); |
| 83 | path.lineTo(2,2); |
| 84 | path.close(); |
| 85 | path.moveTo(2,0); |
| 86 | path.lineTo(6,0); |
| 87 | path.lineTo(4,2); |
| 88 | path.close(); |
| 89 | testSimplifyx(path); |
| 90 | } |
| 91 | |
| 92 | static void testLine7() { |
| 93 | SkPath path, simple; |
| 94 | path.moveTo(0,0); |
| 95 | path.lineTo(4,0); |
| 96 | path.lineTo(2,2); |
| 97 | path.close(); |
| 98 | path.moveTo(6,0); |
| 99 | path.lineTo(2,0); |
| 100 | path.lineTo(4,2); |
| 101 | path.close(); |
| 102 | testSimplifyx(path); |
| 103 | } |
| 104 | |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 105 | static void testLine7a() { |
| 106 | SkPath path, simple; |
| 107 | path.moveTo(0,0); |
| 108 | path.lineTo(4,0); |
| 109 | path.lineTo(2,2); |
| 110 | path.close(); |
| 111 | testSimplifyx(path); |
| 112 | } |
| 113 | |
| 114 | static void testLine7b() { |
| 115 | SkPath path, simple; |
| 116 | path.moveTo(0,0); |
| 117 | path.lineTo(4,0); |
| 118 | path.close(); |
| 119 | path.moveTo(6,0); |
| 120 | path.lineTo(2,0); |
| 121 | path.lineTo(4,2); |
| 122 | path.close(); |
| 123 | testSimplifyx(path); |
| 124 | } |
| 125 | |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 126 | static void testLine8() { |
| 127 | SkPath path, simple; |
| 128 | path.moveTo(0,4); |
| 129 | path.lineTo(4,4); |
| 130 | path.lineTo(2,2); |
| 131 | path.close(); |
| 132 | path.moveTo(2,4); |
| 133 | path.lineTo(6,4); |
| 134 | path.lineTo(4,2); |
| 135 | path.close(); |
| 136 | testSimplifyx(path); |
| 137 | } |
| 138 | |
| 139 | static void testLine9() { |
| 140 | SkPath path, simple; |
| 141 | path.moveTo(0,4); |
| 142 | path.lineTo(4,4); |
| 143 | path.lineTo(2,2); |
| 144 | path.close(); |
| 145 | path.moveTo(6,4); |
| 146 | path.lineTo(2,4); |
| 147 | path.lineTo(4,2); |
| 148 | path.close(); |
| 149 | testSimplifyx(path); |
| 150 | } |
| 151 | |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 152 | static void testLine10() { |
| 153 | SkPath path, simple; |
| 154 | path.moveTo(0,4); |
| 155 | path.lineTo(4,4); |
| 156 | path.lineTo(2,2); |
| 157 | path.close(); |
| 158 | path.moveTo(2,1); |
| 159 | path.lineTo(3,4); |
| 160 | path.lineTo(6,1); |
| 161 | path.close(); |
| 162 | testSimplifyx(path); |
| 163 | } |
caryclark@google.com | 88f7d0c | 2012-06-07 21:09:20 +0000 | [diff] [blame] | 164 | |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 165 | static void testLine10a() { |
| 166 | SkPath path, simple; |
| 167 | path.moveTo(0,4); |
| 168 | path.lineTo(8,4); |
| 169 | path.lineTo(4,0); |
| 170 | path.close(); |
| 171 | path.moveTo(2,2); |
| 172 | path.lineTo(3,3); |
| 173 | path.lineTo(4,2); |
| 174 | path.close(); |
| 175 | testSimplifyx(path); |
| 176 | } |
| 177 | |
| 178 | static void addCWContainer(SkPath& path) { |
| 179 | path.moveTo(6,4); |
| 180 | path.lineTo(0,4); |
| 181 | path.lineTo(3,1); |
| 182 | path.close(); |
| 183 | } |
| 184 | |
| 185 | static void addCCWContainer(SkPath& path) { |
| 186 | path.moveTo(0,4); |
| 187 | path.lineTo(6,4); |
| 188 | path.lineTo(3,1); |
| 189 | path.close(); |
| 190 | } |
| 191 | |
| 192 | static void addCWContents(SkPath& path) { |
| 193 | path.moveTo(2,3); |
| 194 | path.lineTo(3,2); |
| 195 | path.lineTo(4,3); |
| 196 | path.close(); |
| 197 | } |
| 198 | |
| 199 | static void addCCWContents(SkPath& path) { |
| 200 | path.moveTo(3,2); |
| 201 | path.lineTo(2,3); |
| 202 | path.lineTo(4,3); |
| 203 | path.close(); |
| 204 | } |
| 205 | |
| 206 | static void testLine11() { |
| 207 | SkPath path, simple; |
| 208 | addCWContainer(path); |
| 209 | addCWContents(path); |
| 210 | testSimplifyx(path); |
| 211 | } |
| 212 | |
| 213 | static void testLine12() { |
| 214 | SkPath path, simple; |
| 215 | addCCWContainer(path); |
| 216 | addCWContents(path); |
| 217 | testSimplifyx(path); |
| 218 | } |
| 219 | |
| 220 | static void testLine13() { |
| 221 | SkPath path, simple; |
| 222 | addCWContainer(path); |
| 223 | addCCWContents(path); |
| 224 | testSimplifyx(path); |
| 225 | } |
| 226 | |
| 227 | static void testLine14() { |
| 228 | SkPath path, simple; |
| 229 | addCCWContainer(path); |
| 230 | addCCWContents(path); |
| 231 | testSimplifyx(path); |
| 232 | } |
| 233 | |
| 234 | static void testLine15() { |
| 235 | SkPath path, simple; |
| 236 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 237 | testSimplifyx(path); |
| 238 | } |
| 239 | |
| 240 | static void testLine16() { |
| 241 | SkPath path, simple; |
| 242 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 243 | path.addRect(0, 4, 9, 9, (SkPath::Direction) 0); |
| 244 | testSimplifyx(path); |
| 245 | } |
| 246 | |
| 247 | static void testLine17() { |
| 248 | SkPath path, simple; |
| 249 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 250 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 251 | testSimplifyx(path); |
| 252 | } |
| 253 | |
| 254 | static void testLine18() { |
| 255 | SkPath path, simple; |
| 256 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 257 | path.addRect(12, 4, 21, 21, (SkPath::Direction) 0); |
| 258 | testSimplifyx(path); |
| 259 | } |
| 260 | |
| 261 | static void testLine19() { |
| 262 | SkPath path, simple; |
| 263 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 264 | path.addRect(12, 16, 21, 21, (SkPath::Direction) 0); |
| 265 | testSimplifyx(path); |
| 266 | } |
| 267 | |
| 268 | static void testLine20() { |
| 269 | SkPath path, simple; |
| 270 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 271 | path.addRect(0, 12, 9, 9, (SkPath::Direction) 0); |
| 272 | testSimplifyx(path); |
| 273 | } |
| 274 | |
| 275 | static void testLine21() { |
| 276 | SkPath path, simple; |
| 277 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 278 | path.addRect(0, 16, 9, 9, (SkPath::Direction) 0); |
| 279 | testSimplifyx(path); |
| 280 | } |
| 281 | |
| 282 | static void testLine22() { |
| 283 | SkPath path, simple; |
| 284 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 285 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 286 | testSimplifyx(path); |
| 287 | } |
| 288 | |
| 289 | static void testLine23() { |
| 290 | SkPath path, simple; |
| 291 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 292 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 293 | testSimplifyx(path); |
| 294 | } |
| 295 | |
| 296 | |
| 297 | |
| 298 | static void testLine24a() { |
| 299 | SkPath path, simple; |
| 300 | path.moveTo(2,0); |
| 301 | path.lineTo(4,4); |
| 302 | path.lineTo(0,4); |
| 303 | path.close(); |
| 304 | path.moveTo(2,0); |
| 305 | path.lineTo(1,2); |
| 306 | path.lineTo(2,2); |
| 307 | path.close(); |
| 308 | testSimplifyx(path); |
| 309 | } |
| 310 | |
| 311 | static void testLine24() { |
| 312 | SkPath path, simple; |
| 313 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 314 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 315 | testSimplifyx(path); |
| 316 | } |
| 317 | |
| 318 | static void testLine25() { |
| 319 | SkPath path, simple; |
| 320 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 321 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 322 | testSimplifyx(path); |
| 323 | } |
| 324 | |
| 325 | static void testLine26() { |
| 326 | SkPath path, simple; |
| 327 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 328 | path.addRect(0, 12, 9, 9, (SkPath::Direction) 0); |
| 329 | testSimplifyx(path); |
| 330 | } |
| 331 | |
| 332 | static void testLine27() { |
| 333 | SkPath path, simple; |
| 334 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 335 | path.addRect(12, 8, 21, 21, (SkPath::Direction) 0); |
| 336 | testSimplifyx(path); |
| 337 | } |
| 338 | |
caryclark@google.com | fa4a6e9 | 2012-07-11 17:52:32 +0000 | [diff] [blame] | 339 | static void testLine28() { |
| 340 | SkPath path, simple; |
| 341 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 342 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 343 | testSimplifyx(path); |
| 344 | } |
| 345 | |
| 346 | static void testLine29() { |
| 347 | SkPath path, simple; |
| 348 | path.addRect(0, 18, 12, 12, (SkPath::Direction) 0); |
| 349 | path.addRect(12, 12, 21, 21, (SkPath::Direction) 0); |
| 350 | testSimplifyx(path); |
| 351 | } |
| 352 | |
| 353 | static void testLine30() { |
| 354 | SkPath path, simple; |
| 355 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 356 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 357 | path.addRect(4, 4, 13, 13, (SkPath::Direction) 0); |
| 358 | testSimplifyx(path); |
| 359 | } |
| 360 | |
| 361 | static void testLine31() { |
| 362 | SkPath path, simple; |
| 363 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 364 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 365 | path.addRect(0, 4, 9, 9, (SkPath::Direction) 0); |
| 366 | testSimplifyx(path); |
| 367 | } |
| 368 | |
| 369 | static void testLine32() { |
| 370 | SkPath path, simple; |
| 371 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 372 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 373 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 374 | testSimplifyx(path); |
| 375 | } |
| 376 | |
caryclark@google.com | 210acaf | 2012-07-12 21:05:13 +0000 | [diff] [blame] | 377 | static void testLine33() { |
| 378 | SkPath path, simple; |
| 379 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 380 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 381 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 382 | testSimplifyx(path); |
| 383 | } |
| 384 | |
| 385 | static void testLine34() { |
| 386 | SkPath path, simple; |
| 387 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 388 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 389 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 0); |
| 390 | testSimplifyx(path); |
| 391 | } |
| 392 | |
| 393 | static void testLine35() { |
| 394 | SkPath path, simple; |
| 395 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 396 | path.addRect(6, 0, 18, 18, (SkPath::Direction) 0); |
| 397 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 398 | testSimplifyx(path); |
| 399 | } |
| 400 | |
caryclark@google.com | 0e08a19 | 2012-07-13 21:07:52 +0000 | [diff] [blame] | 401 | static void testLine36() { |
| 402 | SkPath path, simple; |
| 403 | path.addRect(0, 10, 20, 20, (SkPath::Direction) 0); |
| 404 | path.addRect(6, 12, 18, 18, (SkPath::Direction) 0); |
| 405 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 406 | testSimplifyx(path); |
| 407 | } |
| 408 | |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 409 | static void testLine37() { |
| 410 | SkPath path, simple; |
| 411 | path.addRect(0, 20, 20, 20, (SkPath::Direction) 0); |
| 412 | path.addRect(18, 24, 30, 30, (SkPath::Direction) 0); |
| 413 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 414 | testSimplifyx(path); |
| 415 | } |
| 416 | |
| 417 | static void testLine38() { |
| 418 | SkPath path, simple; |
| 419 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 420 | path.addRect(6, 12, 18, 18, (SkPath::Direction) 0); |
| 421 | path.addRect(12, 12, 21, 21, (SkPath::Direction) 0); |
| 422 | testSimplifyx(path); |
| 423 | } |
| 424 | |
| 425 | static void testLine40() { |
| 426 | SkPath path, simple; |
| 427 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 428 | path.addRect(12, 18, 24, 24, (SkPath::Direction) 0); |
| 429 | path.addRect(4, 16, 13, 13, (SkPath::Direction) 0); |
| 430 | testSimplifyx(path); |
| 431 | } |
| 432 | |
| 433 | static void testLine41() { |
| 434 | SkPath path, simple; |
| 435 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 436 | path.addRect(18, 24, 30, 30, (SkPath::Direction) 0); |
| 437 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 0); |
| 438 | testSimplifyx(path); |
| 439 | } |
| 440 | |
| 441 | static void testLine42() { |
| 442 | SkPath path, simple; |
| 443 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 444 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 445 | path.addRect(8, 16, 17, 17, (SkPath::Direction) 0); |
| 446 | testSimplifyx(path); |
| 447 | } |
| 448 | |
| 449 | static void testLine43() { |
| 450 | SkPath path, simple; |
| 451 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 452 | path.addRect(6, 24, 18, 18, (SkPath::Direction) 0); |
| 453 | path.addRect(0, 32, 9, 36, (SkPath::Direction) 1); |
| 454 | testSimplifyx(path); |
| 455 | } |
| 456 | |
| 457 | static void testLine44() { |
| 458 | SkPath path, simple; |
| 459 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 460 | path.addRect(18, 0, 30, 30, (SkPath::Direction) 0); |
| 461 | path.addRect(18, 32, 27, 36, (SkPath::Direction) 1); |
| 462 | testSimplifyx(path); |
| 463 | } |
| 464 | |
| 465 | static void testLine45() { |
| 466 | SkPath path, simple; |
| 467 | path.addRect(10, 0, 30, 30, (SkPath::Direction) 0); |
| 468 | path.addRect(18, 0, 30, 30, (SkPath::Direction) 0); |
| 469 | path.addRect(24, 32, 33, 36, (SkPath::Direction) 0); |
| 470 | testSimplifyx(path); |
| 471 | } |
| 472 | |
| 473 | static void testLine46() { |
| 474 | SkPath path, simple; |
| 475 | path.addRect(10, 40, 30, 30, (SkPath::Direction) 0); |
| 476 | path.addRect(24, 0, 36, 36, (SkPath::Direction) 0); |
| 477 | path.addRect(24, 32, 33, 36, (SkPath::Direction) 0); |
| 478 | testSimplifyx(path); |
| 479 | } |
| 480 | |
| 481 | static void testLine47() { |
| 482 | SkPath path, simple; |
| 483 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 484 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 485 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 1); |
| 486 | testSimplifyx(path); |
| 487 | } |
| 488 | |
| 489 | static void testLine48() { |
| 490 | SkPath path, simple; |
| 491 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 492 | path.addRect(0, 6, 12, 12, (SkPath::Direction) 0); |
| 493 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 1); |
| 494 | testSimplifyx(path); |
| 495 | } |
| 496 | |
| 497 | static void testLine49() { |
| 498 | SkPath path, simple; |
| 499 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 500 | path.addRect(0, 0, 12, 12, (SkPath::Direction) 0); |
| 501 | path.addRect(0, 0, 9, 9, (SkPath::Direction) 0); |
| 502 | testSimplifyx(path); |
| 503 | } |
| 504 | |
| 505 | static void testLine50() { |
| 506 | SkPath path, simple; |
| 507 | path.addRect(10, 30, 30, 30, (SkPath::Direction) 0); |
| 508 | path.addRect(24, 20, 36, 30, (SkPath::Direction) 0); |
| 509 | testSimplifyx(path); |
| 510 | } |
| 511 | |
| 512 | |
| 513 | static void testLine51() { |
| 514 | SkPath path, simple; |
| 515 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 516 | path.addRect(0, 12, 12, 12, (SkPath::Direction) 0); |
| 517 | path.addRect(4, 12, 13, 13, (SkPath::Direction) 1); |
| 518 | testSimplifyx(path); |
| 519 | } |
| 520 | |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 521 | static void testLine52() { |
| 522 | SkPath path, simple; |
| 523 | path.addRect(0, 30, 20, 20, (SkPath::Direction) 0); |
| 524 | path.addRect(6, 20, 18, 30, (SkPath::Direction) 0); |
| 525 | path.addRect(32, 0, 36, 41, (SkPath::Direction) 0); |
| 526 | testSimplifyx(path); |
| 527 | } |
| 528 | |
| 529 | static void testLine53() { |
| 530 | SkPath path, simple; |
| 531 | path.addRect(10, 30, 30, 30, (SkPath::Direction) 0); |
| 532 | path.addRect(12, 20, 24, 30, (SkPath::Direction) 0); |
| 533 | path.addRect(12, 32, 21, 36, (SkPath::Direction) 1); |
| 534 | testSimplifyx(path); |
| 535 | } |
| 536 | |
| 537 | static void testLine54() { |
| 538 | SkPath path, simple; |
| 539 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 540 | path.addRect(6, 0, 18, 18, (SkPath::Direction) 0); |
| 541 | path.addRect(8, 4, 17, 17, (SkPath::Direction) 1); |
| 542 | testSimplifyx(path); |
| 543 | } |
| 544 | |
| 545 | static void testLine55() { |
| 546 | SkPath path, simple; |
| 547 | path.addRect(0, 0, 20, 20, (SkPath::Direction) 0); |
| 548 | path.addRect(6, 6, 18, 18, (SkPath::Direction) 0); |
| 549 | path.addRect(4, 4, 13, 13, (SkPath::Direction) 1); |
| 550 | testSimplifyx(path); |
| 551 | } |
| 552 | |
caryclark@google.com | 1806344 | 2012-07-25 12:05:18 +0000 | [diff] [blame^] | 553 | static void testLine56() { |
| 554 | SkPath path, simple; |
| 555 | path.addRect(0, 20, 20, 20, (SkPath::Direction) 0); |
| 556 | path.addRect(18, 20, 30, 30, (SkPath::Direction) 0); |
| 557 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 1); |
| 558 | testSimplifyx(path); |
| 559 | } |
| 560 | |
| 561 | static void testLine57() { |
| 562 | SkPath path, simple; |
| 563 | path.addRect(20, 0, 40, 40, (SkPath::Direction) 0); |
| 564 | path.addRect(20, 0, 30, 40, (SkPath::Direction) 0); |
| 565 | path.addRect(12, 0, 21, 21, (SkPath::Direction) 1); |
| 566 | testSimplifyx(path); |
| 567 | } |
| 568 | |
| 569 | static void (*firstTest)() = testLine57; |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 570 | |
| 571 | static struct { |
| 572 | void (*fun)(); |
| 573 | const char* str; |
| 574 | } tests[] = { |
caryclark@google.com | 1806344 | 2012-07-25 12:05:18 +0000 | [diff] [blame^] | 575 | TEST(testLine57), |
| 576 | TEST(testLine56), |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 577 | TEST(testLine55), |
| 578 | TEST(testLine54), |
| 579 | TEST(testLine53), |
| 580 | TEST(testLine52), |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 581 | TEST(testLine51), |
| 582 | TEST(testLine50), |
| 583 | TEST(testLine49), |
| 584 | TEST(testLine48), |
| 585 | TEST(testLine47), |
| 586 | TEST(testLine46), |
| 587 | TEST(testLine45), |
| 588 | TEST(testLine44), |
| 589 | TEST(testLine43), |
| 590 | TEST(testLine42), |
| 591 | TEST(testLine41), |
| 592 | TEST(testLine40), |
| 593 | TEST(testLine38), |
| 594 | TEST(testLine37), |
| 595 | TEST(testLine36), |
| 596 | TEST(testLine35), |
| 597 | TEST(testLine34), |
| 598 | TEST(testLine33), |
| 599 | TEST(testLine32), |
| 600 | TEST(testLine31), |
| 601 | TEST(testLine30), |
| 602 | TEST(testLine29), |
| 603 | TEST(testLine28), |
| 604 | TEST(testLine27), |
| 605 | TEST(testLine26), |
| 606 | TEST(testLine25), |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 607 | TEST(testLine24a), |
| 608 | TEST(testLine24), |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 609 | TEST(testLine23), |
| 610 | TEST(testLine22), |
| 611 | TEST(testLine21), |
| 612 | TEST(testLine20), |
| 613 | TEST(testLine19), |
| 614 | TEST(testLine18), |
| 615 | TEST(testLine17), |
| 616 | TEST(testLine16), |
| 617 | TEST(testLine15), |
| 618 | TEST(testLine14), |
| 619 | TEST(testLine13), |
| 620 | TEST(testLine12), |
| 621 | TEST(testLine11), |
| 622 | TEST(testLine10a), |
| 623 | TEST(testLine10), |
| 624 | TEST(testLine9), |
| 625 | TEST(testLine8), |
| 626 | TEST(testLine7b), |
| 627 | TEST(testLine7a), |
| 628 | TEST(testLine7), |
| 629 | TEST(testLine6), |
| 630 | TEST(testLine5), |
| 631 | TEST(testLine4), |
| 632 | TEST(testLine3), |
| 633 | TEST(testLine2), |
| 634 | TEST(testLine1), |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 635 | }; |
| 636 | |
| 637 | static const size_t testCount = sizeof(tests) / sizeof(tests[0]); |
| 638 | |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 639 | static bool skipAll = false; |
| 640 | |
| 641 | void SimplifyNew_Test() { |
| 642 | if (skipAll) { |
| 643 | return; |
| 644 | } |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 645 | #ifdef SK_DEBUG |
| 646 | gDebugMaxWindSum = 3; |
| 647 | gDebugMaxWindValue = 3; |
| 648 | #endif |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 649 | size_t index = testCount - 1; |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 650 | if (firstTest) { |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 651 | while (index > 0 && tests[index].fun != firstTest) { |
| 652 | --index; |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 653 | } |
| 654 | } |
| 655 | bool firstTestComplete = false; |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 656 | do { |
| 657 | SkDebugf(" %s [%s]\n", __FUNCTION__, tests[index].str); |
caryclark@google.com | 8dcf114 | 2012-07-02 20:27:02 +0000 | [diff] [blame] | 658 | (*tests[index].fun)(); |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 659 | firstTestComplete = true; |
caryclark@google.com | e21cb18 | 2012-07-23 21:26:31 +0000 | [diff] [blame] | 660 | } while (index--); |
caryclark@google.com | 4758069 | 2012-07-23 12:14:49 +0000 | [diff] [blame] | 661 | #ifdef SK_DEBUG |
| 662 | gDebugMaxWindSum = SK_MaxS32; |
| 663 | gDebugMaxWindValue = SK_MaxS32; |
| 664 | #endif |
caryclark@google.com | af46cff | 2012-05-22 21:12:00 +0000 | [diff] [blame] | 665 | } |