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