caryclark@google.com | 4917f17 | 2012-03-05 22:01: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 | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 6 | |
| 7 | static void testSimplifyQuad1() { |
| 8 | SkPath path, out; |
| 9 | path.moveTo(0, 0); |
| 10 | path.lineTo(1, 0); |
| 11 | path.lineTo(3, 2); |
| 12 | path.lineTo(3, 3); |
| 13 | path.close(); |
| 14 | path.moveTo(1, 0); |
| 15 | path.lineTo(1, 3); |
| 16 | path.lineTo(1, 3); |
| 17 | path.lineTo(1, 3); |
| 18 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 19 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | static void testSimplifyQuad2() { |
| 23 | SkPath path, out; |
| 24 | path.moveTo(0, 0); |
| 25 | path.lineTo(0, 0); |
| 26 | path.lineTo(0, 0); |
| 27 | path.lineTo(0, 2); |
| 28 | path.close(); |
| 29 | path.moveTo(0, 1); |
| 30 | path.lineTo(0, 1); |
| 31 | path.lineTo(1, 1); |
| 32 | path.lineTo(0, 2); |
| 33 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 34 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | static void testSimplifyQuad3() { |
| 38 | SkPath path, out; |
| 39 | path.moveTo(0, 0); |
| 40 | path.lineTo(0, 0); |
| 41 | path.lineTo(1, 0); |
| 42 | path.lineTo(1, 2); |
| 43 | path.close(); |
| 44 | path.moveTo(0, 1); |
| 45 | path.lineTo(1, 1); |
| 46 | path.lineTo(2, 1); |
| 47 | path.lineTo(0, 2); |
| 48 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 49 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static void testSimplifyQuad4() { |
| 53 | SkPath path, out; |
| 54 | path.moveTo(0, 0); |
| 55 | path.lineTo(0, 0); |
| 56 | path.lineTo(1, 0); |
| 57 | path.lineTo(2, 2); |
| 58 | path.close(); |
| 59 | path.moveTo(0, 0); |
| 60 | path.lineTo(2, 1); |
| 61 | path.lineTo(3, 1); |
| 62 | path.lineTo(3, 3); |
| 63 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 64 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static void testSimplifyQuad5() { |
| 68 | SkPath path, out; |
| 69 | path.moveTo(0, 0); |
| 70 | path.lineTo(0, 0); |
| 71 | path.lineTo(1, 0); |
| 72 | path.lineTo(3, 2); |
| 73 | path.close(); |
| 74 | path.moveTo(0, 1); |
| 75 | path.lineTo(1, 1); |
| 76 | path.lineTo(2, 1); |
| 77 | path.lineTo(0, 2); |
| 78 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 79 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | static void testSimplifyQuad6() { |
| 83 | SkPath path, out; |
| 84 | path.moveTo(0, 0); |
| 85 | path.lineTo(1, 0); |
| 86 | path.lineTo(1, 1); |
| 87 | path.lineTo(3, 3); |
| 88 | path.close(); |
| 89 | path.moveTo(1, 1); |
| 90 | path.lineTo(1, 1); |
| 91 | path.lineTo(1, 1); |
| 92 | path.lineTo(2, 2); |
| 93 | path.close(); |
caryclark@google.com | 198e054 | 2012-03-30 18:47:02 +0000 | [diff] [blame^] | 94 | testSimplify(path, true, out, bitmap); |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 95 | } |
| 96 | |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 97 | static void (*simplifyTests[])() = { |
caryclark@google.com | 2e7f4c8 | 2012-03-20 21:11:59 +0000 | [diff] [blame] | 98 | testSimplifyQuad6, |
| 99 | testSimplifyQuad5, |
| 100 | testSimplifyQuad4, |
| 101 | testSimplifyQuad3, |
| 102 | testSimplifyQuad2, |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 103 | testSimplifyQuad1, |
caryclark@google.com | 4917f17 | 2012-03-05 22:01:21 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]); |
| 107 | |
| 108 | static void (*firstTest)() = 0; |
| 109 | |
| 110 | void SimplifyQuadralateralPaths_Test() { |
| 111 | size_t index = 0; |
| 112 | if (firstTest) { |
| 113 | while (index < simplifyTestsCount && simplifyTests[index] != firstTest) { |
| 114 | ++index; |
| 115 | } |
| 116 | } |
| 117 | for ( ; index < simplifyTestsCount; ++index) { |
| 118 | (*simplifyTests[index])(); |
| 119 | } |
| 120 | } |