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