Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: tests/PathOpsLineIntersectionTest.cpp

Issue 23542056: path ops work in progress (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: verbose + mutex around file number access Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #include "PathOpsTestCommon.h" 7 #include "PathOpsTestCommon.h"
8 #include "SkIntersections.h" 8 #include "SkIntersections.h"
9 #include "SkPathOpsLine.h" 9 #include "SkPathOpsLine.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 30 matching lines...) Expand all
41 {{{{0, 0}, {1, 0}}}, {{{3, 0}, {2, 0}}}}, 41 {{{{0, 0}, {1, 0}}}, {{{3, 0}, {2, 0}}}},
42 {{{{0, 0}, {0, 0}}}, {{{1, 0}, {2, 0}}}}, 42 {{{{0, 0}, {0, 0}}}, {{{1, 0}, {2, 0}}}},
43 {{{{0, 1}, {0, 1}}}, {{{0, 3}, {0, 2}}}}, 43 {{{{0, 1}, {0, 1}}}, {{{0, 3}, {0, 2}}}},
44 {{{{0, 0}, {1, 0}}}, {{{2, 0}, {3, 0}}}}, 44 {{{{0, 0}, {1, 0}}}, {{{2, 0}, {3, 0}}}},
45 {{{{1, 1}, {2, 2}}}, {{{4, 4}, {3, 3}}}}, 45 {{{{1, 1}, {2, 2}}}, {{{4, 4}, {3, 3}}}},
46 }; 46 };
47 47
48 static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect); 48 static const size_t noIntersect_count = SK_ARRAY_COUNT(noIntersect);
49 49
50 static const SkDLine coincidentTests[][2] = { 50 static const SkDLine coincidentTests[][2] = {
51 {{{{0,482.5}, {-4.4408921e-016,682.5}}},
52 {{{0,683}, {0,482}}}},
53
54 {{{{1.77635684e-015,312}, {-1.24344979e-014,348}}},
55 {{{0,348}, {0,312}}}},
56
51 {{{{979.304871, 561}, {1036.69507, 291}}}, 57 {{{{979.304871, 561}, {1036.69507, 291}}},
52 {{{985.681519, 531}, {982.159790, 547.568542}}}}, 58 {{{985.681519, 531}, {982.159790, 547.568542}}}},
53 59
54 {{{{232.159805, 547.568542}, {235.681549, 531}}}, 60 {{{{232.159805, 547.568542}, {235.681549, 531}}},
55 {{{286.695129,291}, {229.304855,561}}}}, 61 {{{286.695129,291}, {229.304855,561}}}},
56 62
57 {{{{186.3661956787109375f, 134.7042236328125f}, {187.8782806396484375f, 133. 7258148193359375f}}}, 63 {{{{186.3661956787109375f, 134.7042236328125f}, {187.8782806396484375f, 133. 7258148193359375f}}},
58 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1 33.7258148193359375f}}}}, 64 {{{175.8309783935546875f, 141.5211334228515625f}, {187.8782806396484375f, 1 33.7258148193359375f}}}},
59 65
60 {{{{235.681549, 531.000000}, {280.318420, 321.000000}}}, 66 {{{{235.681549, 531.000000}, {280.318420, 321.000000}}},
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top); 115 ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
110 check_results(reporter, line2, line1, ts); 116 check_results(reporter, line2, line1, ts);
111 } 117 }
112 if (line2[0].fX == line2[1].fX) { 118 if (line2[0].fX == line2[1].fX) {
113 double top = SkTMin(line2[0].fY, line2[1].fY); 119 double top = SkTMin(line2[0].fY, line2[1].fY);
114 double bottom = SkTMax(line2[0].fY, line2[1].fY); 120 double bottom = SkTMax(line2[0].fY, line2[1].fY);
115 SkIntersections ts; 121 SkIntersections ts;
116 ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top); 122 ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
117 check_results(reporter, line1, line2, ts); 123 check_results(reporter, line1, line2, ts);
118 } 124 }
125 reporter->bumpTestCount();
119 } 126 }
120 127
121 static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1 , 128 static void testOneCoincident(skiatest::Reporter* reporter, const SkDLine& line1 ,
122 const SkDLine& line2) { 129 const SkDLine& line2) {
123 SkASSERT(ValidLine(line1)); 130 SkASSERT(ValidLine(line1));
124 SkASSERT(ValidLine(line2)); 131 SkASSERT(ValidLine(line2));
125 SkIntersections ts; 132 SkIntersections ts;
126 int pts = ts.intersect(line1, line2); 133 int pts = ts.intersect(line1, line2);
127 REPORTER_ASSERT(reporter, pts == 2); 134 REPORTER_ASSERT(reporter, pts == 2);
128 REPORTER_ASSERT(reporter, pts == ts.used()); 135 REPORTER_ASSERT(reporter, pts == ts.used());
129 check_results(reporter, line1, line2, ts); 136 check_results(reporter, line1, line2, ts);
137 if (line1[0] == line1[1] || line2[0] == line2[1]) {
138 return;
139 }
140 if (line1[0].fY == line1[1].fY) {
141 double left = SkTMin(line1[0].fX, line1[1].fX);
142 double right = SkTMax(line1[0].fX, line1[1].fX);
143 SkIntersections ts;
144 ts.horizontal(line2, left, right, line1[0].fY, line1[0].fX != left);
145 REPORTER_ASSERT(reporter, pts == 2);
146 REPORTER_ASSERT(reporter, pts == ts.used());
147 check_results(reporter, line2, line1, ts);
148 }
149 if (line2[0].fY == line2[1].fY) {
150 double left = SkTMin(line2[0].fX, line2[1].fX);
151 double right = SkTMax(line2[0].fX, line2[1].fX);
152 SkIntersections ts;
153 ts.horizontal(line1, left, right, line2[0].fY, line2[0].fX != left);
154 REPORTER_ASSERT(reporter, pts == 2);
155 REPORTER_ASSERT(reporter, pts == ts.used());
156 check_results(reporter, line1, line2, ts);
157 }
158 if (line1[0].fX == line1[1].fX) {
159 double top = SkTMin(line1[0].fY, line1[1].fY);
160 double bottom = SkTMax(line1[0].fY, line1[1].fY);
161 SkIntersections ts;
162 ts.vertical(line2, top, bottom, line1[0].fX, line1[0].fY != top);
163 REPORTER_ASSERT(reporter, pts == 2);
164 REPORTER_ASSERT(reporter, pts == ts.used());
165 check_results(reporter, line2, line1, ts);
166 }
167 if (line2[0].fX == line2[1].fX) {
168 double top = SkTMin(line2[0].fY, line2[1].fY);
169 double bottom = SkTMax(line2[0].fY, line2[1].fY);
170 SkIntersections ts;
171 ts.vertical(line1, top, bottom, line2[0].fX, line2[0].fY != top);
172 REPORTER_ASSERT(reporter, pts == 2);
173 REPORTER_ASSERT(reporter, pts == ts.used());
174 check_results(reporter, line1, line2, ts);
175 }
176 reporter->bumpTestCount();
130 } 177 }
131 178
132 static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) { 179 static void PathOpsLineIntersectionTest(skiatest::Reporter* reporter) {
133 size_t index; 180 size_t index;
134 for (index = 0; index < coincidentTests_count; ++index) { 181 for (index = 0; index < coincidentTests_count; ++index) {
135 const SkDLine& line1 = coincidentTests[index][0]; 182 const SkDLine& line1 = coincidentTests[index][0];
136 const SkDLine& line2 = coincidentTests[index][1]; 183 const SkDLine& line2 = coincidentTests[index][1];
137 testOneCoincident(reporter, line1, line2); 184 testOneCoincident(reporter, line1, line2);
138 reporter->bumpTestCount();
139 } 185 }
140 for (index = 0; index < tests_count; ++index) { 186 for (index = 0; index < tests_count; ++index) {
141 const SkDLine& line1 = tests[index][0]; 187 const SkDLine& line1 = tests[index][0];
142 const SkDLine& line2 = tests[index][1]; 188 const SkDLine& line2 = tests[index][1];
143 testOne(reporter, line1, line2); 189 testOne(reporter, line1, line2);
144 reporter->bumpTestCount();
145 } 190 }
146 for (index = 0; index < noIntersect_count; ++index) { 191 for (index = 0; index < noIntersect_count; ++index) {
147 const SkDLine& line1 = noIntersect[index][0]; 192 const SkDLine& line1 = noIntersect[index][0];
148 const SkDLine& line2 = noIntersect[index][1]; 193 const SkDLine& line2 = noIntersect[index][1];
149 SkIntersections ts; 194 SkIntersections ts;
150 int pts = ts.intersect(line1, line2); 195 int pts = ts.intersect(line1, line2);
151 REPORTER_ASSERT(reporter, !pts); 196 REPORTER_ASSERT(reporter, !pts);
152 REPORTER_ASSERT(reporter, pts == ts.used()); 197 REPORTER_ASSERT(reporter, pts == ts.used());
153 reporter->bumpTestCount(); 198 reporter->bumpTestCount();
154 } 199 }
(...skipping 13 matching lines...) Expand all
168 const SkDLine& line2 = coincidentTests[index][1]; 213 const SkDLine& line2 = coincidentTests[index][1];
169 testOneCoincident(reporter, line1, line2); 214 testOneCoincident(reporter, line1, line2);
170 } 215 }
171 216
172 #include "TestClassDef.h" 217 #include "TestClassDef.h"
173 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest) 218 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionTest)
174 219
175 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneOffTest) 220 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneOffTest)
176 221
177 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneCoincidentTest) 222 DEFINE_TESTCLASS_SHORT(PathOpsLineIntersectionOneCoincidentTest)
OLDNEW
« no previous file with comments | « tests/PathOpsExtendedTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698