blob: 584ecdabb3122fefc635167cc2a22fcf69d16a03 [file] [log] [blame]
caryclark@google.coma5764232012-03-28 16:20:21 +00001#include "EdgeWalker_Test.h"
2#include "Intersection_Tests.h"
caryclark@google.com198e0542012-03-30 18:47:02 +00003#include "SkBitmap.h"
4
5static SkBitmap bitmap;
caryclark@google.coma5764232012-03-28 16:20:21 +00006
7static 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.com198e0542012-03-30 18:47:02 +000015 testSimplify(path, true, out, bitmap);
caryclark@google.coma5764232012-03-28 16:20:21 +000016}
17
18static 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.com198e0542012-03-30 18:47:02 +000026 testSimplify(path, true, out, bitmap);
caryclark@google.coma5764232012-03-28 16:20:21 +000027}
28
29static 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.com198e0542012-03-30 18:47:02 +000037 testSimplify(path, true, out, bitmap);
38}
39
40static 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.coma5764232012-03-28 16:20:21 +000049 drawAsciiPaths(path, out, true);
50}
51
52static void (*simplifyTests[])() = {
caryclark@google.com198e0542012-03-30 18:47:02 +000053 testSimplifyQuadratic4,
caryclark@google.coma5764232012-03-28 16:20:21 +000054 testSimplifyQuadratic3,
55 testSimplifyQuadratic2,
56 testSimplifyQuadratic1,
57};
58
59static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);
60
61static void (*firstTest)() = 0;
62
63void 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}