xref: /aosp_15_r20/external/skia/tests/PathOpsQuadIntersectionTestData.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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 
8 #include "tests/PathOpsQuadIntersectionTestData.h"
9 
10 #include <array>
11 #include <cfloat>
12 
13 const QuadPts quadraticPoints[] = {
14     {{{0, 0}, {1, 0}, {0, 0}}},
15     {{{0, 0}, {0, 1}, {0, 0}}},
16     {{{0, 0}, {1, 1}, {0, 0}}},
17     {{{1, 1}, {2, 2}, {1, 1}}},
18 };
19 
20 const size_t quadraticPoints_count = std::size(quadraticPoints);
21 
22 const QuadPts quadraticLines[] = {
23     {{{0, 0}, {0, 0}, {1, 0}}},
24     {{{1, 0}, {0, 0}, {0, 0}}},
25     {{{1, 0}, {2, 0}, {3, 0}}},
26     {{{0, 0}, {0, 0}, {0, 1}}},
27     {{{0, 1}, {0, 0}, {0, 0}}},
28     {{{0, 1}, {0, 2}, {0, 3}}},
29     {{{0, 0}, {0, 0}, {1, 1}}},
30     {{{1, 1}, {0, 0}, {0, 0}}},
31     {{{1, 1}, {2, 2}, {3, 3}}},
32     {{{1, 1}, {3, 3}, {3, 3}}},
33     {{{1, 1}, {1, 1}, {2, 2}}},
34     {{{1, 1}, {1, 1}, {3, 3}}},
35     {{{1, 1}, {2, 2}, {4, 4}}},  // no coincident
36     {{{1, 1}, {3, 3}, {4, 4}}},
37     {{{1, 1}, {3, 3}, {2, 2}}},
38     {{{1, 1}, {4, 4}, {2, 2}}},
39     {{{1, 1}, {4, 4}, {3, 3}}},
40     {{{2, 2}, {1, 1}, {3, 3}}},
41     {{{2, 2}, {1, 1}, {4, 4}}},
42     {{{2, 2}, {3, 3}, {1, 1}}},
43     {{{2, 2}, {3, 3}, {4, 4}}},
44     {{{2, 2}, {4, 4}, {1, 1}}},
45     {{{2, 2}, {4, 4}, {3, 3}}},
46 };
47 
48 const size_t quadraticLines_count = std::size(quadraticLines);
49 
50 static const double F = FLT_EPSILON * 32;
51 static const double H = FLT_EPSILON * 32;
52 static const double J = FLT_EPSILON * 32;
53 static const double K = FLT_EPSILON * 32;  // INVESTIGATE: why are larger multiples necessary?
54 
55 const QuadPts quadraticModEpsilonLines[] = {
56     {{{0, F}, {0, 0}, {1, 0}}},
57     {{{0, 0}, {1, 0}, {0, F}}},
58     {{{1, 0}, {0, F}, {0, 0}}},
59     {{{1, H}, {2, 0}, {3, 0}}},
60 //  {{{F, 0}, {0, 0}, {0, 1}}},  // INVESTIGATE: even substituting K for F, quad is still linear.
61 //  {{{0, 0}, {0, 1}, {F, 0}}},
62 //  {{{0, 1}, {F, 0}, {0, 0}}},
63 //  {{{H, 1}, {0, 2}, {0, 3}}},
64     {{{0, F}, {0, 0}, {1, 1}}},
65     {{{0, 0}, {1, 1}, {F, 0}}},
66     {{{1, 1}, {F, 0}, {0, 0}}},
67     {{{1, 1+J}, {2, 2}, {3, 3}}},
68     {{{1, 1}, {3, 3}, {3+F, 3}}},
69     {{{1, 1}, {1+F, 1}, {2, 2}}},
70     {{{1, 1}, {2, 2}, {1, 1+K}}},
71     {{{1, 1}, {1, 1+F}, {3, 3}}},
72     {{{1+H, 1}, {2, 2}, {4, 4}}},  // no coincident
73     {{{1, 1+K}, {3, 3}, {4, 4}}},
74     {{{1, 1}, {3+F, 3}, {2, 2}}},
75     {{{1, 1}, {4, 4+F}, {2, 2}}},
76     {{{1, 1}, {4, 4}, {3+F, 3}}},
77     {{{2, 2}, {1, 1}, {3, 3+F}}},
78     {{{2+F, 2}, {1, 1}, {4, 4}}},
79     {{{2, 2+F}, {3, 3}, {1, 1}}},
80     {{{2, 2}, {3+F, 3}, {4, 4}}},
81     {{{2, 2}, {4, 4+F}, {1, 1}}},
82     {{{2, 2}, {4, 4}, {3+F, 3}}},
83 };
84 
85 const size_t quadraticModEpsilonLines_count =
86         std::size(quadraticModEpsilonLines);
87 
88 const QuadPts quadraticTests[][2] = {
89     {  // one intersection
90      {{{0, 0},
91       {0, 1},
92       {1, 1}}},
93      {{{0, 1},
94       {0, 0},
95       {1, 0}}}
96     },
97     {  // four intersections
98      {{{1, 0},
99       {2, 6},
100       {3, 0}}},
101      {{{0, 1},
102       {6, 2},
103       {0, 3}}}
104     }
105 };
106 
107 const size_t quadraticTests_count = std::size(quadraticTests);
108