| 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 testSimplifyTriangle() { | |
| 14 SkPath path, out; | |
| 15 path.setFillType(SkPath::kWinding_FillType); | |
| 16 path.moveTo(10,10); // triangle |\ . | |
| 17 path.lineTo(10,30); // |_\ . | |
| 18 path.lineTo(20,30); | |
| 19 path.close(); | |
| 20 path.moveTo(20,10); // triangle /| | |
| 21 path.lineTo(10,30); // /_| | |
| 22 path.lineTo(20,30); | |
| 23 path.close(); | |
| 24 testSimplify(path, true, out, bitmap); // expect |\/| | |
| 25 // |__| | |
| 26 } | |
| 27 | |
| 28 static void testSimplifyTriangle3() { | |
| 29 SkPath path, out; | |
| 30 path.moveTo(0, 0); | |
| 31 path.lineTo(1, 0); | |
| 32 path.lineTo(0, 1); | |
| 33 path.close(); | |
| 34 path.moveTo(0, 0); | |
| 35 path.lineTo(1, 0); | |
| 36 path.lineTo(3, 1); | |
| 37 path.close(); | |
| 38 testSimplify(path, true, out, bitmap); | |
| 39 } | |
| 40 | |
| 41 static void testSimplifyTriangle4() { | |
| 42 SkPath path, out; | |
| 43 path.moveTo(0, 0); | |
| 44 path.lineTo(1, 0); | |
| 45 path.lineTo(0, 1); | |
| 46 path.close(); | |
| 47 path.moveTo(0, 0); | |
| 48 path.lineTo(1, 0); | |
| 49 path.lineTo(2, 1); | |
| 50 path.close(); | |
| 51 testSimplify(path, true, out, bitmap); | |
| 52 } | |
| 53 | |
| 54 static void testSimplifyTriangle5() { | |
| 55 SkPath path, out; | |
| 56 path.moveTo(0, 0); | |
| 57 path.lineTo(1, 0); | |
| 58 path.lineTo(0, 1); | |
| 59 path.close(); | |
| 60 path.moveTo(0, 0); | |
| 61 path.lineTo(1, 1); | |
| 62 path.lineTo(2, 1); | |
| 63 path.close(); | |
| 64 testSimplify(path, true, out, bitmap); | |
| 65 } | |
| 66 | |
| 67 static void testSimplifyTriangle6() { | |
| 68 SkPath path, out; | |
| 69 path.moveTo(0, 0); | |
| 70 path.lineTo(1, 0); | |
| 71 path.lineTo(0, 1); | |
| 72 path.lineTo(0, 0); | |
| 73 path.close(); | |
| 74 path.moveTo(0, 0); | |
| 75 path.lineTo(0, 1); | |
| 76 path.lineTo(3, 1); | |
| 77 path.lineTo(0, 0); | |
| 78 path.close(); | |
| 79 testSimplify(path, true, out, bitmap); | |
| 80 } | |
| 81 | |
| 82 static void testSimplifyTriangle7() { | |
| 83 SkPath path, out; | |
| 84 path.moveTo(0, 0); | |
| 85 path.lineTo(1, 0); | |
| 86 path.lineTo(0, 1); | |
| 87 path.lineTo(0, 0); | |
| 88 path.close(); | |
| 89 path.moveTo(0, 0); | |
| 90 path.lineTo(1, 1); | |
| 91 path.lineTo(0, 2); | |
| 92 path.lineTo(0, 0); | |
| 93 path.close(); | |
| 94 testSimplify(path, true, out, bitmap); | |
| 95 } | |
| 96 | |
| 97 static void testSimplifyTriangle8() { | |
| 98 SkPath path, out; | |
| 99 path.moveTo(0, 0); | |
| 100 path.lineTo(1, 0); | |
| 101 path.lineTo(0, 1); | |
| 102 path.lineTo(0, 0); | |
| 103 path.close(); | |
| 104 path.moveTo(0, 1); | |
| 105 path.lineTo(1, 2); | |
| 106 path.lineTo(1, 3); | |
| 107 path.lineTo(0, 1); | |
| 108 path.close(); | |
| 109 testSimplify(path, true, out, bitmap); | |
| 110 } | |
| 111 | |
| 112 static void testSimplifyTriangle9() { | |
| 113 SkPath path, out; | |
| 114 path.moveTo(0, 0); | |
| 115 path.lineTo(1, 0); | |
| 116 path.lineTo(1, 1); | |
| 117 path.lineTo(0, 0); | |
| 118 path.close(); | |
| 119 path.moveTo(0, 0); | |
| 120 path.lineTo(1, 1); | |
| 121 path.lineTo(2, 1); | |
| 122 path.lineTo(0, 0); | |
| 123 path.close(); | |
| 124 testSimplify(path, true, out, bitmap); | |
| 125 } | |
| 126 | |
| 127 static void testSimplifyTriangle10() { | |
| 128 SkPath path, out; | |
| 129 path.moveTo(0, 0); | |
| 130 path.lineTo(1, 0); | |
| 131 path.lineTo(1, 1); | |
| 132 path.lineTo(0, 0); | |
| 133 path.close(); | |
| 134 path.moveTo(0, 0); | |
| 135 path.lineTo(2, 0); | |
| 136 path.lineTo(0, 1); | |
| 137 path.lineTo(0, 0); | |
| 138 path.close(); | |
| 139 testSimplify(path, true, out, bitmap); | |
| 140 } | |
| 141 | |
| 142 static void testSimplifyTriangle11() { | |
| 143 SkPath path, out; | |
| 144 path.moveTo(0, 0); | |
| 145 path.lineTo(1, 0); | |
| 146 path.lineTo(0, 2); | |
| 147 path.lineTo(0, 0); | |
| 148 path.close(); | |
| 149 path.moveTo(0, 0); | |
| 150 path.lineTo(2, 1); | |
| 151 path.lineTo(2, 2); | |
| 152 path.lineTo(0, 0); | |
| 153 path.close(); | |
| 154 testSimplify(path, true, out, bitmap); | |
| 155 } | |
| 156 | |
| 157 static void testSimplifyTriangle12() { | |
| 158 SkPath path, out; | |
| 159 path.moveTo(0, 0); | |
| 160 path.lineTo(1, 0); | |
| 161 path.lineTo(1, 2); | |
| 162 path.lineTo(0, 0); | |
| 163 path.close(); | |
| 164 path.moveTo(2, 0); | |
| 165 path.lineTo(0, 3); | |
| 166 path.lineTo(1, 1); | |
| 167 path.lineTo(2, 0); | |
| 168 path.close(); | |
| 169 testSimplify(path, true, out, bitmap); | |
| 170 } | |
| 171 | |
| 172 static void testSimplifyTriangle13() { | |
| 173 SkPath path, out; | |
| 174 path.moveTo(0, 0); | |
| 175 path.lineTo(1, 0); | |
| 176 path.lineTo(0, 3); | |
| 177 path.lineTo(0, 0); | |
| 178 path.close(); | |
| 179 path.moveTo(3, 0); | |
| 180 path.lineTo(0, 3); | |
| 181 path.lineTo(1, 1); | |
| 182 path.lineTo(3, 0); | |
| 183 path.close(); | |
| 184 testSimplify(path, true, out, bitmap); | |
| 185 } | |
| 186 | |
| 187 static void testSimplifyTriangle14() { | |
| 188 SkPath path, out; | |
| 189 path.moveTo(0, 0); | |
| 190 path.lineTo(1, 0); | |
| 191 path.lineTo(0, 1); | |
| 192 path.lineTo(0, 0); | |
| 193 path.close(); | |
| 194 path.moveTo(0, 0); | |
| 195 path.lineTo(1, 0); | |
| 196 path.lineTo(0, 1); | |
| 197 path.lineTo(0, 0); | |
| 198 path.close(); | |
| 199 testSimplify(path, true, out, bitmap); | |
| 200 } | |
| 201 | |
| 202 static void testSimplifyTriangle15() { | |
| 203 SkPath path, out; | |
| 204 path.setFillType(SkPath::kEvenOdd_FillType); | |
| 205 path.moveTo(0, 0); | |
| 206 path.lineTo(0, 1); | |
| 207 path.lineTo(1, 2); | |
| 208 path.close(); | |
| 209 path.moveTo(0, 0); | |
| 210 path.lineTo(0, 1); | |
| 211 path.lineTo(2, 2); | |
| 212 path.close(); | |
| 213 testSimplify(path, true, out, bitmap); | |
| 214 } | |
| 215 | |
| 216 static void testSimplifyTriangle16() { | |
| 217 SkPath path, out; | |
| 218 path.moveTo(0, 0); | |
| 219 path.lineTo(0, 1); | |
| 220 path.lineTo(1, 2); | |
| 221 path.close(); | |
| 222 path.moveTo(0, 0); | |
| 223 path.lineTo(0, 1); | |
| 224 path.lineTo(1, 3); | |
| 225 path.close(); | |
| 226 testSimplify(path, true, out, bitmap); | |
| 227 } | |
| 228 | |
| 229 static void testSimplifyTriangle17() { | |
| 230 SkPath path, out; | |
| 231 path.moveTo(0, 0); | |
| 232 path.lineTo(0, 1); | |
| 233 path.lineTo(1, 2); | |
| 234 path.close(); | |
| 235 path.moveTo(0, 0); | |
| 236 path.lineTo(1, 3); | |
| 237 path.lineTo(0, 1); | |
| 238 path.close(); | |
| 239 testSimplify(path, true, out, bitmap); | |
| 240 } | |
| 241 | |
| 242 static void testSimplifyTriangle18() { | |
| 243 SkPath path, out; | |
| 244 path.moveTo(0, 0); | |
| 245 path.lineTo(0, 1); | |
| 246 path.lineTo(1, 2); | |
| 247 path.close(); | |
| 248 path.moveTo(1, 0); | |
| 249 path.lineTo(0, 1); | |
| 250 path.lineTo(0, 3); | |
| 251 path.close(); | |
| 252 testSimplify(path, true, out, bitmap); | |
| 253 } | |
| 254 | |
| 255 static void testSimplifyTriangle19() { | |
| 256 SkPath path, out; | |
| 257 path.setFillType(SkPath::kEvenOdd_FillType); | |
| 258 path.moveTo(0, 0); | |
| 259 path.lineTo(0, 1); | |
| 260 path.lineTo(3, 2); | |
| 261 path.close(); | |
| 262 path.moveTo(0, 0); | |
| 263 path.lineTo(1, 1); | |
| 264 path.lineTo(2, 1); | |
| 265 path.close(); | |
| 266 testSimplify(path, true, out, bitmap); | |
| 267 } | |
| 268 | |
| 269 static void testSimplifyTriangle20() { | |
| 270 SkPath path, out; | |
| 271 path.moveTo(0, 0); | |
| 272 path.lineTo(2, 1); | |
| 273 path.lineTo(1, 3); | |
| 274 path.close(); | |
| 275 path.moveTo(2, 0); | |
| 276 path.lineTo(3, 2); | |
| 277 path.lineTo(0, 3); | |
| 278 path.close(); | |
| 279 testSimplify(path, true, out, bitmap); | |
| 280 } | |
| 281 | |
| 282 static void testSimplifyTriangle21() { | |
| 283 SkPath path, out; | |
| 284 path.moveTo(0, 0); | |
| 285 path.lineTo(1, 0); | |
| 286 path.lineTo(1, 2); | |
| 287 path.close(); | |
| 288 path.moveTo(2, 0); | |
| 289 path.lineTo(2, 1); | |
| 290 path.lineTo(0, 3); | |
| 291 path.close(); | |
| 292 testSimplify(path, true, out, bitmap); | |
| 293 } | |
| 294 | |
| 295 static void testSimplifyDegenerateTriangle1() { | |
| 296 SkPath path, out; | |
| 297 path.moveTo(0, 0); | |
| 298 path.lineTo(0, 0); | |
| 299 path.lineTo(0, 0); | |
| 300 path.close(); | |
| 301 path.moveTo(0, 0); | |
| 302 path.lineTo(0, 0); | |
| 303 path.lineTo(0, 0); | |
| 304 path.close(); | |
| 305 testSimplify(path, true, out, bitmap); | |
| 306 } | |
| 307 | |
| 308 static void testSimplifyDegenerateTriangle2() { | |
| 309 SkPath path, out; | |
| 310 path.moveTo(0, 0); | |
| 311 path.lineTo(1, 1); | |
| 312 path.lineTo(2, 2); | |
| 313 path.close(); | |
| 314 path.moveTo(1, 0); | |
| 315 path.lineTo(2, 2); | |
| 316 path.lineTo(3, 3); | |
| 317 path.close(); | |
| 318 testSimplify(path, true, out, bitmap); | |
| 319 } | |
| 320 | |
| 321 static void testSimplifyWindingParallelogram() { | |
| 322 SkPath path, out; | |
| 323 path.setFillType(SkPath::kWinding_FillType); | |
| 324 path.moveTo(20,10); // parallelogram _ | |
| 325 path.lineTo(30,30); // \ \ . | |
| 326 path.lineTo(40,30); // \_\ . | |
| 327 path.lineTo(30,10); | |
| 328 path.close(); | |
| 329 path.moveTo(20,10); // parallelogram _ | |
| 330 path.lineTo(10,30); // / / | |
| 331 path.lineTo(20,30); // /_/ | |
| 332 path.lineTo(30,10); | |
| 333 path.close(); | |
| 334 testSimplify(path, true, out, bitmap); // expect _ | |
| 335 // / \ . | |
| 336 } // /___\ . | |
| 337 | |
| 338 static void testSimplifyXorParallelogram() { | |
| 339 SkPath path, out; | |
| 340 path.setFillType(SkPath::kEvenOdd_FillType); | |
| 341 path.moveTo(20,10); // parallelogram _ | |
| 342 path.lineTo(30,30); // \ \ . | |
| 343 path.lineTo(40,30); // \_\ . | |
| 344 path.lineTo(30,10); | |
| 345 path.close(); | |
| 346 path.moveTo(20,10); // parallelogram _ | |
| 347 path.lineTo(10,30); // / / | |
| 348 path.lineTo(20,30); // /_/ | |
| 349 path.lineTo(30,10); | |
| 350 path.close(); | |
| 351 testSimplify(path, true, out, bitmap); // expect _ | |
| 352 } // \ / | |
| 353 | |
| 354 static void testSimplifyTriangle2() { | |
| 355 SkPath path, out; | |
| 356 path.setFillType(SkPath::kWinding_FillType); | |
| 357 path.moveTo(10,10); // triangle |\ . | |
| 358 path.lineTo(10,30); // |_\ . | |
| 359 path.lineTo(20,30); | |
| 360 path.close(); | |
| 361 path.moveTo(10,10); // triangle _ | |
| 362 path.lineTo(20,10); // \ | | |
| 363 path.lineTo(20,30); // \| | |
| 364 path.close(); // _ | |
| 365 testSimplify(path, true, out, bitmap); // expect | | | |
| 366 } // |_| | |
| 367 | |
| 368 #if 0 | |
| 369 static void testPathTriangleRendering() { | |
| 370 SkPath one, two; | |
| 371 one.moveTo(0, 0); | |
| 372 one.lineTo(3, 3); | |
| 373 one.lineTo(0, 3); | |
| 374 one.lineTo(1, 2); | |
| 375 one.close(); | |
| 376 for (float x = .1f; x <= 2.9ff; x += .1f) { | |
| 377 SkDebugf("%s x=%g\n", __FUNCTION__, x); | |
| 378 two.moveTo(0, 0); | |
| 379 two.lineTo(x, x); | |
| 380 two.lineTo(3, 3); | |
| 381 two.lineTo(0, 3); | |
| 382 two.lineTo(1, 2); | |
| 383 two.close(); | |
| 384 comparePaths(one, two); | |
| 385 two.reset(); | |
| 386 } | |
| 387 } | |
| 388 #endif | |
| 389 | |
| 390 static void simplify(const char* functionName, const SkPath& path, | |
| 391 bool fill, SkPath& out) { | |
| 392 if (false) SkDebugf("%s\n", functionName); | |
| 393 simplify(path, fill, out); | |
| 394 } | |
| 395 | |
| 396 static void testSimplifySkinnyTriangle1() { | |
| 397 for (int x = 1; x < 255; ++x) { | |
| 398 SkPath path, out; | |
| 399 path.moveTo((x * 101) % 10, 0); | |
| 400 path.lineTo((x * 91) % 10, 1000); | |
| 401 path.lineTo((x * 71) % 10, 2000); | |
| 402 path.lineTo((x * 51) % 10, 3000); | |
| 403 path.close(); | |
| 404 path.moveTo((x * 101) % 20, 0); | |
| 405 path.lineTo((x * 91) % 20, 1000); | |
| 406 path.lineTo((x * 71) % 20, 2000); | |
| 407 path.lineTo((x * 51) % 20, 3000); | |
| 408 path.close(); | |
| 409 path.moveTo((x * 101) % 30, 0); | |
| 410 path.lineTo((x * 91) % 30, 1000); | |
| 411 path.lineTo((x * 71) % 30, 2000); | |
| 412 path.lineTo((x * 51) % 30, 3000); | |
| 413 path.close(); | |
| 414 simplify(path, true, out); | |
| 415 } | |
| 416 } | |
| 417 | |
| 418 static void testSimplifySkinnyTriangle2() { | |
| 419 SkPath path, out; | |
| 420 #if 01 | |
| 421 path.moveTo(591.091064f, 627.534851f); | |
| 422 path.lineTo(541.088135f, 560.707642f); | |
| 423 path.lineTo(491.085175f, 493.880310f); | |
| 424 path.lineTo(441.082214f, 427.053101f); | |
| 425 //path.lineTo(591.091064f, 627.534851f); | |
| 426 path.close(); | |
| 427 #endif | |
| 428 path.moveTo(317.093445f, 592.013306f); | |
| 429 path.lineTo(366.316162f, 542.986572f); | |
| 430 path.lineTo(416.051514f, 486.978577f); | |
| 431 path.lineTo(465.786865f, 430.970581f); | |
| 432 //path.lineTo(317.093445f, 592.013306f); | |
| 433 path.close(); | |
| 434 #if 0 | |
| 435 path.moveTo(289.392517f, 517.138489f); | |
| 436 path.lineTo(249.886078f, 508.598022f); | |
| 437 path.lineTo(217.110916f, 450.916443f); | |
| 438 path.lineTo(196.621033f, 394.917633f); | |
| 439 //path.lineTo(289.392517f, 517.138489f); | |
| 440 path.close(); | |
| 441 #endif | |
| 442 simplify(__FUNCTION__, path, true, out); | |
| 443 } | |
| 444 | |
| 445 static void testSimplifySkinnyTriangle3() { | |
| 446 SkPath path, out; | |
| 447 path.moveTo(591, 627.534851f); | |
| 448 path.lineTo(541, 560.707642f); | |
| 449 path.lineTo(491, 493.880310f); | |
| 450 path.lineTo(441, 427.053101f); | |
| 451 path.close(); | |
| 452 path.moveTo(317, 592.013306f); | |
| 453 path.lineTo(366, 542.986572f); | |
| 454 path.lineTo(416, 486.978577f); | |
| 455 path.lineTo(465, 430.970581f); | |
| 456 path.close(); | |
| 457 simplify(__FUNCTION__, path, true, out); | |
| 458 } | |
| 459 | |
| 460 static void testSimplifySkinnyTriangle4() { | |
| 461 SkPath path, out; | |
| 462 path.moveTo(572.655212f, 614.959961f); | |
| 463 path.lineTo(524.618896f, 549.339600f); | |
| 464 path.lineTo(476.582581f, 483.719269f); | |
| 465 path.lineTo(428.546265f, 418.098938f); | |
| 466 path.lineTo(572.655212f, 614.959961f); | |
| 467 path.close(); | |
| 468 path.moveTo(312.166382f, 583.723083f); | |
| 469 path.lineTo(361.047791f, 529.824219f); | |
| 470 path.lineTo(409.929230f, 475.925354f); | |
| 471 path.lineTo(458.810669f, 422.026520f); | |
| 472 path.lineTo(312.166382f, 583.723083f); | |
| 473 path.close(); | |
| 474 path.moveTo(278.742737f, 508.065643f); | |
| 475 path.lineTo(241.475800f, 493.465118f); | |
| 476 path.lineTo(210.344177f, 437.315125f); | |
| 477 path.lineTo(197.019455f, 383.794556f); | |
| 478 path.lineTo(278.742737f, 508.065643f); | |
| 479 path.close(); | |
| 480 simplify(__FUNCTION__, path, true, out); | |
| 481 } | |
| 482 | |
| 483 static void testSimplifySkinnyTriangle5() { | |
| 484 SkPath path, out; | |
| 485 path.moveTo(554.690613f, 602.286072f); | |
| 486 path.lineTo(508.590057f, 537.906250f); | |
| 487 path.lineTo(462.489441f, 473.526520f); | |
| 488 path.lineTo(416.388855f, 409.146729f); | |
| 489 path.lineTo(554.690613f, 602.286072f); | |
| 490 path.close(); | |
| 491 path.moveTo(307.216949f, 575.189270f); | |
| 492 path.lineTo(355.826965f, 516.804688f); | |
| 493 path.lineTo(403.815918f, 464.990753f); | |
| 494 path.lineTo(451.804871f, 413.176819f); | |
| 495 path.lineTo(307.216949f, 575.189270f); | |
| 496 path.close(); | |
| 497 path.moveTo(271.998901f, 521.301025f); | |
| 498 path.lineTo(234.619705f, 499.687683f); | |
| 499 path.lineTo(203.059692f, 441.332336f); | |
| 500 path.lineTo(195.994370f, 386.856506f); | |
| 501 path.lineTo(271.998901f, 521.301025f); | |
| 502 path.close(); | |
| 503 simplify(__FUNCTION__, path, true, out); | |
| 504 } | |
| 505 | |
| 506 static void testSimplifySkinnyTriangle6() { | |
| 507 SkPath path, out; | |
| 508 path.moveTo(591.091064f, 627.534851f); | |
| 509 path.lineTo(541.088135f, 560.707642f); | |
| 510 path.lineTo(491.085175f, 493.880310f); | |
| 511 path.lineTo(441.082214f, 427.053101f); | |
| 512 path.lineTo(591.091064f, 627.534851f); | |
| 513 path.close(); | |
| 514 path.moveTo(317.093445f, 592.013306f); | |
| 515 path.lineTo(366.316162f, 542.986572f); | |
| 516 path.lineTo(416.051514f, 486.978577f); | |
| 517 path.lineTo(465.786865f, 430.970581f); | |
| 518 path.lineTo(317.093445f, 592.013306f); | |
| 519 path.close(); | |
| 520 path.moveTo(289.392517f, 517.138489f); | |
| 521 path.lineTo(249.886078f, 508.598022f); | |
| 522 path.lineTo(217.110916f, 450.916443f); | |
| 523 path.lineTo(196.621033f, 394.917633f); | |
| 524 path.lineTo(289.392517f, 517.138489f); | |
| 525 path.close(); | |
| 526 simplify(__FUNCTION__, path, true, out); | |
| 527 } | |
| 528 | |
| 529 static void testSimplifyTriangle22() { | |
| 530 SkPath path, out; | |
| 531 path.moveTo(0, 0); | |
| 532 path.lineTo(1, 0); | |
| 533 path.lineTo(0, 2); | |
| 534 path.close(); | |
| 535 path.moveTo(1, 0); | |
| 536 path.lineTo(0, 2); | |
| 537 path.lineTo(0, 1); | |
| 538 path.close(); | |
| 539 testSimplify(path, true, out, bitmap); | |
| 540 } | |
| 541 | |
| 542 static void testSimplifyTriangle23() { | |
| 543 SkPath path, out; | |
| 544 path.moveTo(0, 0); | |
| 545 path.lineTo(0, 0); | |
| 546 path.lineTo(0, 0); | |
| 547 path.close(); | |
| 548 path.moveTo(0, 0); | |
| 549 path.lineTo(0, 1); | |
| 550 path.lineTo(1, 2); | |
| 551 path.close(); | |
| 552 testSimplify(path, true, out, bitmap); | |
| 553 } | |
| 554 | |
| 555 static void testSimplifyTriangle24() { | |
| 556 SkPath path, out; | |
| 557 path.moveTo(0, 0); | |
| 558 path.lineTo(0, 0); | |
| 559 path.lineTo(0, 1); | |
| 560 path.close(); | |
| 561 path.moveTo(0, 0); | |
| 562 path.lineTo(1, 0); | |
| 563 path.lineTo(0, 1); | |
| 564 path.close(); | |
| 565 testSimplify(path, true, out, bitmap); | |
| 566 } | |
| 567 | |
| 568 static void testSimplifySkinnyTriangle7() { | |
| 569 SkPath path, out; | |
| 570 path.moveTo(487.502319f, 550.811279f); | |
| 571 path.lineTo(448.826050f, 491.720123f); | |
| 572 path.lineTo(410.149780f, 432.628967f); | |
| 573 path.lineTo(371.473572f, 373.537781f); | |
| 574 path.lineTo(487.502319f, 550.811279f); | |
| 575 path.close(); | |
| 576 path.moveTo(295.817108f, 532.655579f); | |
| 577 path.lineTo(342.896271f, 485.912292f); | |
| 578 path.lineTo(389.975433f, 439.169006f); | |
| 579 path.lineTo(437.054596f, 392.425781f); | |
| 580 path.lineTo(295.817108f, 532.655579f); | |
| 581 path.close(); | |
| 582 path.moveTo(239.726822f, 575.025269f); | |
| 583 path.lineTo(204.117569f, 521.429688f); | |
| 584 path.lineTo(171.275452f, 454.110382f); | |
| 585 path.lineTo(193.328583f, 397.859497f); | |
| 586 path.lineTo(239.726822f, 575.025269f); | |
| 587 path.close(); | |
| 588 simplify(__FUNCTION__, path, true, out); | |
| 589 } | |
| 590 | |
| 591 static void testSimplifySkinnyTriangle8() { | |
| 592 SkPath path, out; | |
| 593 path.moveTo(441.943115f, 511.678040f); | |
| 594 path.lineTo(408.487549f, 456.880920f); | |
| 595 path.lineTo(375.031952f, 402.083801f); | |
| 596 path.lineTo(341.576385f, 347.286682f); | |
| 597 path.lineTo(441.943115f, 511.678040f); | |
| 598 path.close(); | |
| 599 path.moveTo(297.548492f, 557.246704f); | |
| 600 path.lineTo(350.768494f, 507.627014f); | |
| 601 path.lineTo(403.988525f, 458.007385f); | |
| 602 path.lineTo(457.208527f, 408.387695f); | |
| 603 path.lineTo(297.548492f, 557.246704f); | |
| 604 path.close(); | |
| 605 path.moveTo(209.857895f, 615.802979f); | |
| 606 path.lineTo(178.249481f, 534.230347f); | |
| 607 path.lineTo(144.905640f, 460.056824f); | |
| 608 path.lineTo(192.953125f, 404.972900f); | |
| 609 path.lineTo(209.857895f, 615.802979f); | |
| 610 path.close(); | |
| 611 simplify(__FUNCTION__, path, true, out); | |
| 612 } | |
| 613 | |
| 614 static void testSimplifySkinnyTriangle9() { | |
| 615 SkPath path, out; | |
| 616 path.moveTo(439.867065f, 528.291931f); | |
| 617 path.lineTo(405.413025f, 469.107178f); | |
| 618 path.lineTo(370.958954f, 409.922363f); | |
| 619 path.lineTo(336.504883f, 350.737610f); | |
| 620 path.lineTo(439.867065f, 528.291931f); | |
| 621 path.close(); | |
| 622 path.moveTo(298.922455f, 573.251953f); | |
| 623 path.lineTo(356.360962f, 521.905090f); | |
| 624 path.lineTo(413.799438f, 470.558228f); | |
| 625 path.lineTo(471.237915f, 419.211365f); | |
| 626 path.lineTo(298.922455f, 573.251953f); | |
| 627 path.close(); | |
| 628 path.moveTo(187.200775f, 643.035156f); | |
| 629 path.lineTo(159.713165f, 540.993774f); | |
| 630 path.lineTo(126.257164f, 462.198517f); | |
| 631 path.lineTo(193.534012f, 409.266235f); | |
| 632 path.lineTo(187.200775f, 643.035156f); | |
| 633 path.close(); | |
| 634 path.close(); | |
| 635 simplify(__FUNCTION__, path, true, out); | |
| 636 } | |
| 637 | |
| 638 static void testSimplifySkinnyTriangle10() { | |
| 639 SkPath path, out; | |
| 640 #if 0 | |
| 641 path.moveTo(99.270325f, 239.365234f); | |
| 642 path.lineTo(105.967056f, 173.361206f); | |
| 643 path.lineTo(148.821381f, 141.309891f); | |
| 644 path.lineTo(159.101013f, 189.235138f); | |
| 645 path.lineTo(99.270325f, 239.365234f); | |
| 646 path.close(); | |
| 647 #endif | |
| 648 path.moveTo(213.673737f, 413.292938f); | |
| 649 path.lineTo(225.200134f, 343.616821f); | |
| 650 path.lineTo(236.726532f, 273.940704f); | |
| 651 path.lineTo(219.386414f, 231.373322f); | |
| 652 path.lineTo(213.673737f, 413.292938f); | |
| 653 path.close(); | |
| 654 path.moveTo(43.485352f, 308.984497f); | |
| 655 path.lineTo(122.610657f, 305.950134f); | |
| 656 path.lineTo(201.735962f, 302.915802f); | |
| 657 path.lineTo(280.861267f, 299.881470f); | |
| 658 path.lineTo(43.485352f, 308.984497f); | |
| 659 path.close(); | |
| 660 simplify(__FUNCTION__, path, true, out); | |
| 661 } | |
| 662 | |
| 663 static void testSimplifySkinnyTriangle11() { | |
| 664 SkPath path, out; | |
| 665 path.moveTo(-177.878387f, 265.368988f); | |
| 666 path.lineTo(-254.415771f, 303.709961f); | |
| 667 path.lineTo(-317.465363f, 271.325562f); | |
| 668 path.lineTo(-374.520386f, 207.507660f); | |
| 669 path.lineTo(-177.878387f, 265.368988f); | |
| 670 path.close(); | |
| 671 path.moveTo(-63.582489f, -3.679123f); | |
| 672 path.lineTo(-134.496841f, 26.434566f); | |
| 673 path.lineTo(-205.411209f, 56.548256f); | |
| 674 path.lineTo(-276.325562f, 86.661942f); | |
| 675 path.lineTo(-63.582489f, -3.679123f); | |
| 676 path.close(); | |
| 677 path.moveTo(-57.078423f, 162.633453f); | |
| 678 path.lineTo(-95.963928f, 106.261139f); | |
| 679 path.lineTo(-134.849457f, 49.888824f); | |
| 680 path.lineTo(-173.734955f, -6.483480f); | |
| 681 path.lineTo(-57.078423f, 162.633453f); | |
| 682 path.close(); | |
| 683 simplify(__FUNCTION__, path, true, out); | |
| 684 } | |
| 685 | |
| 686 static void testSimplifySkinnyTriangle12() { | |
| 687 SkPath path, out; | |
| 688 path.moveTo(98.666489f, -94.295059f); | |
| 689 path.lineTo(156.584320f, -61.939133f); | |
| 690 path.lineTo(174.672974f, -12.343765f); | |
| 691 path.lineTo(158.622345f, 52.028267f); | |
| 692 path.lineTo(98.666489f, -94.295059f); | |
| 693 path.close(); | |
| 694 path.moveTo(-133.225616f, -48.622055f); | |
| 695 path.lineTo(-73.855499f, -10.375397f); | |
| 696 path.lineTo(-14.485367f, 27.871277f); | |
| 697 path.lineTo(44.884750f, 66.117935f); | |
| 698 path.lineTo(-133.225616f, -48.622055f); | |
| 699 path.close(); | |
| 700 path.moveTo( 9.030045f, -163.413132f); | |
| 701 path.lineTo(-19.605331f, -89.588760f); | |
| 702 path.lineTo(-48.240707f, -15.764404f); | |
| 703 path.lineTo(-76.876053f, 58.059944f); | |
| 704 path.lineTo( 9.030045f, -163.413132f); | |
| 705 path.close(); | |
| 706 simplify(__FUNCTION__, path, true, out); | |
| 707 } | |
| 708 | |
| 709 static void testSimplifySkinnyTriangle13() { | |
| 710 SkPath path, out; | |
| 711 path.moveTo(340.41568f, -170.97171f); | |
| 712 path.lineTo(418.846893f, -142.428329f); | |
| 713 path.lineTo(497.278107f, -113.884933f); | |
| 714 path.lineTo(449.18222f, -45.6723022f); | |
| 715 path.lineTo(340.41568f, -170.97171f); | |
| 716 path.close(); | |
| 717 path.moveTo(326.610535f, 34.0393639f); | |
| 718 path.lineTo(371.334595f, -14.9620667f); | |
| 719 path.lineTo(416.058624f, -63.9634857f); | |
| 720 path.lineTo(460.782654f, -112.96492f); | |
| 721 path.lineTo(326.610535f, 34.0393639f); | |
| 722 path.close(); | |
| 723 simplify(__FUNCTION__, path, true, out); | |
| 724 } | |
| 725 | |
| 726 static void (*simplifyTests[])() = { | |
| 727 testSimplifySkinnyTriangle13, | |
| 728 testSimplifySkinnyTriangle12, | |
| 729 testSimplifySkinnyTriangle11, | |
| 730 testSimplifySkinnyTriangle10, | |
| 731 testSimplifySkinnyTriangle9, | |
| 732 testSimplifySkinnyTriangle8, | |
| 733 testSimplifySkinnyTriangle7, | |
| 734 testSimplifySkinnyTriangle6, | |
| 735 testSimplifySkinnyTriangle5, | |
| 736 testSimplifySkinnyTriangle4, | |
| 737 testSimplifySkinnyTriangle3, | |
| 738 testSimplifySkinnyTriangle2, | |
| 739 testSimplifySkinnyTriangle1, | |
| 740 testSimplifyTriangle24, | |
| 741 testSimplifyTriangle23, | |
| 742 testSimplifyTriangle22, | |
| 743 testSimplifyDegenerateTriangle2, | |
| 744 testSimplifyDegenerateTriangle1, | |
| 745 testSimplifyTriangle21, | |
| 746 testSimplifyTriangle20, | |
| 747 testSimplifyTriangle19, | |
| 748 testSimplifyTriangle18, | |
| 749 testSimplifyTriangle17, | |
| 750 testSimplifyTriangle16, | |
| 751 testSimplifyTriangle15, | |
| 752 testSimplifyTriangle14, | |
| 753 testSimplifyTriangle13, | |
| 754 testSimplifyTriangle12, | |
| 755 testSimplifyTriangle11, | |
| 756 testSimplifyTriangle10, | |
| 757 testSimplifyTriangle7, | |
| 758 testSimplifyTriangle9, | |
| 759 testSimplifyTriangle8, | |
| 760 testSimplifyTriangle6, | |
| 761 testSimplifyTriangle5, | |
| 762 testSimplifyTriangle4, | |
| 763 testSimplifyTriangle3, | |
| 764 testSimplifyTriangle, | |
| 765 testSimplifyTriangle2, | |
| 766 testSimplifyWindingParallelogram, | |
| 767 testSimplifyXorParallelogram, | |
| 768 // testPathTriangleRendering, | |
| 769 }; | |
| 770 | |
| 771 static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[
0]); | |
| 772 | |
| 773 static void (*firstTest)() = testSimplifySkinnyTriangle12; | |
| 774 | |
| 775 void SimplifyPolygonPaths_Test() { | |
| 776 size_t index = 0; | |
| 777 if (firstTest) { | |
| 778 while (index < simplifyTestsCount && simplifyTests[index] != firstTest)
{ | |
| 779 ++index; | |
| 780 } | |
| 781 } | |
| 782 bool firstTestComplete = false; | |
| 783 for ( ; index < simplifyTestsCount; ++index) { | |
| 784 (*simplifyTests[index])(); | |
| 785 if (simplifyTests[index] == testSimplifySkinnyTriangle2) { | |
| 786 if (false) SkDebugf("%s last fast skinny test\n", __FUNCTION__); | |
| 787 } | |
| 788 firstTestComplete = true; | |
| 789 } | |
| 790 } | |
| OLD | NEW |