aboutsummaryrefslogtreecommitdiffhomepage
path: root/experimental/Intersection/ActiveEdge_Test.cpp
blob: 2ee408921ee7228f8685668e1c698254580a18d7 (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
#include "CurveIntersection.h"
#include "LineIntersection.h"
#include "SkPath.h"
#include "SkRect.h"
#include "SkTArray.h"
#include "SkTDArray.h"
#include "TSearch.h"

namespace UnitTest {

#include "EdgeWalker.cpp"

} // end of UnitTest namespace

#include "Intersection_Tests.h"

SkPoint leftRight[][4] = {
// equal length
    {{10, 10}, {10, 50},   {20, 10}, {20, 50}},
    {{10, 10}, {10, 50},   {10, 10}, {20, 50}},
    {{10, 10}, {10, 50},   {20, 10}, {10, 50}},
// left top higher
    {{10,  0}, {10, 50},   {20, 10}, {20, 50}},
    {{10,  0}, {10, 50},   {10, 10}, {20, 50}},
    {{10,  0}, {10, 50},   {20, 10}, {10, 50}},
    {{10,  0}, {10, 50},   {20, 10}, {10 + 0.000001, 40}},
// left top lower
    {{10, 20}, {10, 50},   {20, 10}, {20, 50}},
    {{10, 20}, {10, 50},   {10, 10}, {20, 50}},
    {{10, 20}, {10, 50},   {20, 10}, {10, 50}},
    {{10, 20}, {10, 50},   {20, 10}, {10 + 0.000001, 40}},
    {{10, 20}, {10, 50},   { 0,  0}, {50, 50}},
// left bottom higher
    {{10, 10}, {10, 40},   {20, 10}, {20, 50}},
    {{10, 10}, {10, 40},   {10, 10}, {20, 50}},
    {{10, 10}, {10, 40},   {20, 10}, {10, 50}},
    {{10, 10}, {10, 40},   {20, 10}, { 0 + 0.000001, 70}},
// left bottom lower
    {{10, 10}, {10, 60},   {20, 10}, {20, 50}},
    {{10, 10}, {10, 60},   {10, 10}, {20, 50}},
    {{10, 10}, {10, 60},   {20, 10}, {10 + 0.000001, 50}},
    {{10, 10}, {10, 60},   {20, 10}, {10 + 0.000001, 40}},
    {{10, 10}, {10, 60},   { 0,  0}, {20 + 0.000001, 20}},
};

size_t leftRightCount = sizeof(leftRight) / sizeof(leftRight[0]);

void ActiveEdge_Test() {
    UnitTest::InEdge leftIn, rightIn;
    UnitTest::ActiveEdge left, right;
    left.fWorkEdge.fEdge = &leftIn;
    right.fWorkEdge.fEdge = &rightIn;
    for (size_t x = 0; x < leftRightCount; ++x) {
        left.fAbove = leftRight[x][0];
        left.fBelow = leftRight[x][1]; 
        right.fAbove = leftRight[x][2];
        right.fBelow = leftRight[x][3];
        SkASSERT(left < right);
        SkASSERT(left.operator_less_than(right));
        SkASSERT(!(right < left));
        SkASSERT(!right.operator_less_than(left));
    }
}