caryclark@google.com | a576423 | 2012-03-28 16:20:21 +0000 | [diff] [blame] | 1 | #include "EdgeWalker_Test.h" |
| 2 | #include "Intersection_Tests.h" |
| 3 | |
| 4 | static void testSimplifyQuadratic1() { |
| 5 | SkPath path, out; |
| 6 | path.moveTo(0, 0); |
| 7 | path.quadTo(1, 0, 1, 1); |
| 8 | path.close(); |
| 9 | path.moveTo(1, 0); |
| 10 | path.quadTo(0, 0, 0, 1); |
| 11 | path.close(); |
| 12 | testSimplify(path, true, out); |
| 13 | } |
| 14 | |
| 15 | static void testSimplifyQuadratic2() { |
| 16 | SkPath path, out; |
| 17 | path.moveTo(0, 0); |
| 18 | path.quadTo(20, 0, 20, 20); |
| 19 | path.close(); |
| 20 | path.moveTo(20, 0); |
| 21 | path.quadTo(0, 0, 0, 20); |
| 22 | path.close(); |
| 23 | testSimplify(path, true, out); |
| 24 | drawAsciiPaths(path, out, true); |
| 25 | } |
| 26 | |
| 27 | static void testSimplifyQuadratic3() { |
| 28 | SkPath path, out; |
| 29 | path.moveTo(0, 0); |
| 30 | path.quadTo(20, 0, 20, 20); |
| 31 | path.close(); |
| 32 | path.moveTo(0, 20); |
| 33 | path.quadTo(0, 0, 20, 0); |
| 34 | path.close(); |
| 35 | testSimplify(path, true, out); |
| 36 | drawAsciiPaths(path, out, true); |
| 37 | } |
| 38 | |
| 39 | static void (*simplifyTests[])() = { |
| 40 | testSimplifyQuadratic3, |
| 41 | testSimplifyQuadratic2, |
| 42 | testSimplifyQuadratic1, |
| 43 | }; |
| 44 | |
| 45 | static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]); |
| 46 | |
| 47 | static void (*firstTest)() = 0; |
| 48 | |
| 49 | void SimplifyQuadraticPaths_Test() { |
| 50 | size_t index = 0; |
| 51 | if (firstTest) { |
| 52 | while (index < simplifyTestsCount && simplifyTests[index] != firstTest) { |
| 53 | ++index; |
| 54 | } |
| 55 | } |
| 56 | bool firstTestComplete = false; |
| 57 | for ( ; index < simplifyTestsCount; ++index) { |
| 58 | (*simplifyTests[index])(); |
| 59 | if (simplifyTests[index] == testSimplifyQuadratic1) { |
| 60 | SkDebugf("%s last fast quad test\n", __FUNCTION__); |
| 61 | } |
| 62 | firstTestComplete = true; |
| 63 | } |
| 64 | } |