blob: ab4e39b637282679380e4503f86fdd6c469f8a81 [file] [log] [blame]
caryclark@google.coma5764232012-03-28 16:20:21 +00001#include "EdgeWalker_Test.h"
2#include "Intersection_Tests.h"
3
4static 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
15static 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
27static 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
39static void (*simplifyTests[])() = {
40 testSimplifyQuadratic3,
41 testSimplifyQuadratic2,
42 testSimplifyQuadratic1,
43};
44
45static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);
46
47static void (*firstTest)() = 0;
48
49void 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}