aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/EdgeWalkerQuadralaterals_Test.cpp
blob: 92e474b84a9679710625bd1615b51ad46e8fb0b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * Copyright 2012 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */
#include "EdgeWalker_Test.h"
#include "Intersection_Tests.h"
#include "SkBitmap.h"

static SkBitmap bitmap;

static void testSimplifyQuad1() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(3, 2);
    path.lineTo(3, 3);
    path.close();
    path.moveTo(1, 0);
    path.lineTo(1, 3);
    path.lineTo(1, 3);
    path.lineTo(1, 3);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void testSimplifyQuad2() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(0, 0);
    path.lineTo(0, 0);
    path.lineTo(0, 2);
    path.close();
    path.moveTo(0, 1);
    path.lineTo(0, 1);
    path.lineTo(1, 1);
    path.lineTo(0, 2);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void testSimplifyQuad3() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(1, 2);
    path.close();
    path.moveTo(0, 1);
    path.lineTo(1, 1);
    path.lineTo(2, 1);
    path.lineTo(0, 2);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void testSimplifyQuad4() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(2, 2);
    path.close();
    path.moveTo(0, 0);
    path.lineTo(2, 1);
    path.lineTo(3, 1);
    path.lineTo(3, 3);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void testSimplifyQuad5() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(3, 2);
    path.close();
    path.moveTo(0, 1);
    path.lineTo(1, 1);
    path.lineTo(2, 1);
    path.lineTo(0, 2);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void testSimplifyQuad6() {
    SkPath path, out;
    path.moveTo(0, 0);
    path.lineTo(1, 0);
    path.lineTo(1, 1);
    path.lineTo(3, 3);
    path.close();
    path.moveTo(1, 1);
    path.lineTo(1, 1);
    path.lineTo(1, 1);
    path.lineTo(2, 2);
    path.close();
    testSimplify(path, true, out, bitmap);
}

static void (*simplifyTests[])() = {
    testSimplifyQuad6,
    testSimplifyQuad5,
    testSimplifyQuad4,
    testSimplifyQuad3,
    testSimplifyQuad2,
    testSimplifyQuad1,
};

static size_t simplifyTestsCount = sizeof(simplifyTests) / sizeof(simplifyTests[0]);

static void (*firstTest)() = 0;

void SimplifyQuadralateralPaths_Test() {
    size_t index = 0;
    if (firstTest) {
        while (index < simplifyTestsCount && simplifyTests[index] != firstTest) {
            ++index;
        }
    }
    for ( ; index < simplifyTestsCount; ++index) {
        (*simplifyTests[index])();
    }
}