OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
8 #include "SkOpSegment.h" | 8 #include "SkOpSegment.h" |
9 #include "SkTArray.h" | 9 #include "SkTArray.h" |
10 #include "Test.h" | 10 #include "Test.h" |
| 11 #include "TestClassDef.h" |
11 | 12 |
12 static const SkPoint cubics[][4] = { | 13 static const SkPoint cubics[][4] = { |
13 /* 0 */ {{0, 1}, {2, 6}, {4, 2}, {5, 3}}, | 14 /* 0 */ {{0, 1}, {2, 6}, {4, 2}, {5, 3}}, |
14 /* 1 */ {{10, 234}, {10, 229.581726f}, {13.5817204f, 226}, {18, 226}}, | 15 /* 1 */ {{10, 234}, {10, 229.581726f}, {13.5817204f, 226}, {18, 226}}, |
15 /* 2 */ {{132, 11419}, {130.89543151855469f, 11419}, {130, 11418.1044921875f}
, {130, 11417}}, | 16 /* 2 */ {{132, 11419}, {130.89543151855469f, 11419}, {130, 11418.1044921875f}
, {130, 11417}}, |
16 /* 3 */ {{130.04275512695312f, 11417.4130859375f}, {130.23307800292969f, 1141
8.3193359375f}, | 17 /* 3 */ {{130.04275512695312f, 11417.4130859375f}, {130.23307800292969f, 1141
8.3193359375f}, |
17 {131.03709411621094f, 11419}, {132, 11419}}, | 18 {131.03709411621094f, 11419}, {132, 11419}}, |
18 /* 4 */ {{0,1}, {0,5}, {4,1}, {6,4}}, | 19 /* 4 */ {{0,1}, {0,5}, {4,1}, {6,4}}, |
19 /* 5 */ {{1,5}, {4,6}, {1,0}, {4,0}}, | 20 /* 5 */ {{1,5}, {4,6}, {1,0}, {4,0}}, |
20 /* 6 */ {{0,1}, {0,4}, {5,1}, {6,4}}, | 21 /* 6 */ {{0,1}, {0,4}, {5,1}, {6,4}}, |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 SkDebugf("%s test[%s]: second[%d] > first[%d]\n", __FUNCTIO
N__, | 385 SkDebugf("%s test[%s]: second[%d] > first[%d]\n", __FUNCTIO
N__, |
385 test.name, idxL, idxG); | 386 test.name, idxL, idxG); |
386 compare = second < first; | 387 compare = second < first; |
387 } | 388 } |
388 REPORTER_ASSERT(reporter, compare); | 389 REPORTER_ASSERT(reporter, compare); |
389 } | 390 } |
390 } | 391 } |
391 } | 392 } |
392 } | 393 } |
393 | 394 |
394 static void PathOpsAngleTest(skiatest::Reporter* reporter) { | 395 DEF_TEST(PathOpsAngle, reporter) { |
395 for (size_t index = 0; index < SK_ARRAY_COUNT(tests); ++index) { | 396 for (size_t index = 0; index < SK_ARRAY_COUNT(tests); ++index) { |
396 const SortSetTests& test = tests[index]; | 397 const SortSetTests& test = tests[index]; |
397 testOne(reporter, test); | 398 testOne(reporter, test); |
398 reporter->bumpTestCount(); | 399 reporter->bumpTestCount(); |
399 } | 400 } |
400 } | 401 } |
401 | 402 |
402 static void PathOpsAngleTestOne(skiatest::Reporter* reporter) { | 403 DEF_TEST(PathOpsAngleTestOne, reporter) { |
403 size_t index = 0; | 404 size_t index = 0; |
404 const SortSetTests& test = tests[index]; | 405 const SortSetTests& test = tests[index]; |
405 testOne(reporter, test); | 406 testOne(reporter, test); |
406 } | 407 } |
407 | 408 |
408 #if 0 | 409 #if 0 |
409 static int find_slop(double x, double y, double rx, double ry) { | 410 static int find_slop(double x, double y, double rx, double ry) { |
410 int slopBits = 0; | 411 int slopBits = 0; |
411 bool less1, less2; | 412 bool less1, less2; |
412 double absX = fabs(x); | 413 double absX = fabs(x); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 return (x < 0 ? 2-y/(-x-y) : 3+x/(x-y)); | 445 return (x < 0 ? 2-y/(-x-y) : 3+x/(x-y)); |
445 } | 446 } |
446 | 447 |
447 static const double slopTests[][4] = { | 448 static const double slopTests[][4] = { |
448 // x y rx ry | 449 // x y rx ry |
449 {-0.058554756452593892, -0.18804585843827226, -0.018568569646021160, -0.0596
15294434479438}, | 450 {-0.058554756452593892, -0.18804585843827226, -0.018568569646021160, -0.0596
15294434479438}, |
450 {-0.0013717412948608398, 0.0041152238845825195, -0.00045837944195925573, 0.0
013753175735478074}, | 451 {-0.0013717412948608398, 0.0041152238845825195, -0.00045837944195925573, 0.0
013753175735478074}, |
451 {-2.1033774145221198, -1.4046019261273715e-008, -0.70062688352066704, -1.270
6324683777995e-008}, | 452 {-2.1033774145221198, -1.4046019261273715e-008, -0.70062688352066704, -1.270
6324683777995e-008}, |
452 }; | 453 }; |
453 | 454 |
454 static void PathOpsAngleFindSlop(skiatest::Reporter* reporter) { | 455 /*DEF_TEST(PathOpsAngleFindSlop, reporter) { |
455 for (size_t index = 0; index < SK_ARRAY_COUNT(slopTests); ++index) { | 456 for (size_t index = 0; index < SK_ARRAY_COUNT(slopTests); ++index) { |
456 const double* slopTest = slopTests[index]; | 457 const double* slopTest = slopTests[index]; |
457 double x = slopTest[0]; | 458 double x = slopTest[0]; |
458 double y = slopTest[1]; | 459 double y = slopTest[1]; |
459 double rx = slopTest[2]; | 460 double rx = slopTest[2]; |
460 double ry = slopTest[3]; | 461 double ry = slopTest[3]; |
461 SkDebugf("%s xy %d=%d\n", __FUNCTION__, (int) index, find_slop(x, y, rx
, ry)); | 462 SkDebugf("%s xy %d=%d\n", __FUNCTION__, (int) index, find_slop(x, y, rx
, ry)); |
462 SkDebugf("%s rxy %d=%d\n", __FUNCTION__, (int) index, find_slop(rx, ry,
x, y)); | 463 SkDebugf("%s rxy %d=%d\n", __FUNCTION__, (int) index, find_slop(rx, ry,
x, y)); |
463 double angle = diamond_angle(y, x); | 464 double angle = diamond_angle(y, x); |
464 double rAngle = diamond_angle(ry, rx); | 465 double rAngle = diamond_angle(ry, rx); |
465 double diff = fabs(angle - rAngle); | 466 double diff = fabs(angle - rAngle); |
466 SkDebugf("%s diamond xy=%1.9g rxy=%1.9g diff=%1.9g factor=%d\n", __FUNCT
ION__, | 467 SkDebugf("%s diamond xy=%1.9g rxy=%1.9g diff=%1.9g factor=%d\n", __FUNCT
ION__, |
467 angle, rAngle, diff, (int) (diff / FLT_EPSILON)); | 468 angle, rAngle, diff, (int) (diff / FLT_EPSILON)); |
468 | 469 |
469 } | 470 } |
470 } | 471 }*/ |
471 #endif | 472 #endif |
472 | |
473 #include "TestClassDef.h" | |
474 DEFINE_TESTCLASS_SHORT(PathOpsAngleTest) | |
475 | |
476 DEFINE_TESTCLASS_SHORT(PathOpsAngleTestOne) | |
477 | |
478 // DEFINE_TESTCLASS_SHORT(PathOpsAngleFindSlop) | |
OLD | NEW |