OLD | NEW |
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 "PathOpsQuadIntersectionTestData.h" | 7 #include "PathOpsQuadIntersectionTestData.h" |
8 #include "PathOpsTestCommon.h" | 8 #include "PathOpsTestCommon.h" |
9 #include "SkIntersections.h" | 9 #include "SkIntersections.h" |
10 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 tt2, xy2.fX, xy2.fY); | 46 tt2, xy2.fX, xy2.fY); |
47 REPORTER_ASSERT(reporter, 0); | 47 REPORTER_ASSERT(reporter, 0); |
48 } | 48 } |
49 } | 49 } |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 static const SkDQuad testSet[] = { | 55 static const SkDQuad testSet[] = { |
| 56 {{{-708.00779269310044, -154.36998607290101}, {-707.90560262312511, -154.3699860
7290101}, {-707.8333433370193, -154.44224536635932}}}, |
| 57 {{{-708.00779269310044, -154.61669472244046}, {-701.04513225634582, -128.8597073
4043804}, {505.58447265625, -504.9130859375}}}, |
| 58 |
56 {{{164, -40}, {231.51681518554687, -40}, {279.25839233398438, 7.7416000366210938
}}}, | 59 {{{164, -40}, {231.51681518554687, -40}, {279.25839233398438, 7.7416000366210938
}}}, |
57 {{{279.25839233398438, 7.7416000366210938}, {275.2164306640625, 3.69964003562927
25}, {271.03286743164062, -5.3290705182007514e-015}}}, | 60 {{{279.25839233398438, 7.7416000366210938}, {275.2164306640625, 3.69964003562927
25}, {271.03286743164062, -5.3290705182007514e-015}}}, |
58 | 61 |
59 {{{2.9999997378517067, 1.9737872594345709}, {2.9999997432230918, 1.9739647181863
822}, {1.2414155459263587e-163, 5.2957833941332142e-315}}}, | 62 {{{2.9999997378517067, 1.9737872594345709}, {2.9999997432230918, 1.9739647181863
822}, {1.2414155459263587e-163, 5.2957833941332142e-315}}}, |
60 {{{2.9999047485265304, 1.9739164225694723}, {3.0000947268526112, 1.9738379076623
633}, {0.61149411077591886, 0.0028382324376270418}}}, | 63 {{{2.9999047485265304, 1.9739164225694723}, {3.0000947268526112, 1.9738379076623
633}, {0.61149411077591886, 0.0028382324376270418}}}, |
61 | 64 |
62 {{{2.9999996843656502, 1.9721416019045801}, {2.9999997725237835, 1.974979834
3422071}, | 65 {{{2.9999996843656502, 1.9721416019045801}, {2.9999997725237835, 1.974979834
3422071}, |
63 {5.3039068214821359e-315, 8.9546185262775165e-307}}}, | 66 {5.3039068214821359e-315, 8.9546185262775165e-307}}}, |
64 {{{2.9984791443874976, 1.974505741312242}, {2.9999992702127476, 1.9738772171
479178}, | 67 {{{2.9984791443874976, 1.974505741312242}, {2.9999992702127476, 1.9738772171
479178}, |
65 {3.0015187977319759, 1.9732495027303418}}}, | 68 {3.0015187977319759, 1.9732495027303418}}}, |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 #if 0 | 302 #if 0 |
300 {{{97.9337615966796875,100}, {88,112.94264984130859375}, {88,130}}}, | 303 {{{97.9337615966796875,100}, {88,112.94264984130859375}, {88,130}}}, |
301 {{{88,130}, {88,124.80951690673828125}, {88.91983795166015625,120}}}, | 304 {{{88,130}, {88,124.80951690673828125}, {88.91983795166015625,120}}}, |
302 #endif | 305 #endif |
303 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, | 306 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, |
304 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, | 307 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, |
305 {{{8, 8}, {10, 10}, {8, -10}}}, | 308 {{{8, 8}, {10, 10}, {8, -10}}}, |
306 {{{8, -10}, {10, 10}, {8, 8}}}, | 309 {{{8, -10}, {10, 10}, {8, 8}}}, |
307 }; | 310 }; |
308 | 311 |
309 const size_t coincidentTestSetCount = SK_ARRAY_COUNT(coincidentTestSet); | 312 static const int coincidentTestSetCount = (int) SK_ARRAY_COUNT(coincidentTestSet
); |
310 | 313 |
311 static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2
) { | 314 static void coincidentTestOne(skiatest::Reporter* reporter, int test1, int test2
) { |
312 const SkDQuad& quad1 = coincidentTestSet[test1]; | 315 const SkDQuad& quad1 = coincidentTestSet[test1]; |
313 SkASSERT(ValidQuad(quad1)); | 316 SkASSERT(ValidQuad(quad1)); |
314 const SkDQuad& quad2 = coincidentTestSet[test2]; | 317 const SkDQuad& quad2 = coincidentTestSet[test2]; |
315 SkASSERT(ValidQuad(quad2)); | 318 SkASSERT(ValidQuad(quad2)); |
316 SkIntersections intersections2; | 319 SkIntersections intersections2; |
317 intersections2.intersect(quad1, quad2); | 320 intersections2.intersect(quad1, quad2); |
318 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2); | 321 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2); |
319 REPORTER_ASSERT(reporter, intersections2.used() == 2); | 322 REPORTER_ASSERT(reporter, intersections2.used() == 2); |
320 for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) { | 323 for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) { |
321 double tt1 = intersections2[0][pt]; | 324 double tt1 = intersections2[0][pt]; |
322 double tt2 = intersections2[1][pt]; | 325 double tt2 = intersections2[1][pt]; |
323 SkDPoint pt1 = quad1.ptAtT(tt1); | 326 SkDPoint pt1 = quad1.ptAtT(tt1); |
324 SkDPoint pt2 = quad2.ptAtT(tt2); | 327 SkDPoint pt2 = quad2.ptAtT(tt2); |
325 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); | 328 REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); |
326 } | 329 } |
327 } | 330 } |
328 | 331 |
329 static void coincidentTest(skiatest::Reporter* reporter) { | 332 static void coincidentTest(skiatest::Reporter* reporter) { |
330 for (size_t testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex
+= 2) { | 333 for (int testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex +=
2) { |
331 coincidentTestOne(reporter, testIndex, testIndex + 1); | 334 coincidentTestOne(reporter, testIndex, testIndex + 1); |
332 } | 335 } |
333 } | 336 } |
334 | 337 |
335 DEF_TEST(PathOpsQuadIntersectionCoincidenceOneOff, reporter) { | 338 DEF_TEST(PathOpsQuadIntersectionCoincidenceOneOff, reporter) { |
336 coincidentTestOne(reporter, 0, 1); | 339 coincidentTestOne(reporter, 0, 1); |
337 } | 340 } |
338 | 341 |
339 static int floatSign(double x) { | 342 static int floatSign(double x) { |
340 return x < 0 ? -1 : x > 0 ? 1 : 0; | 343 return x < 0 ? -1 : x > 0 ? 1 : 0; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 intersectionFinder(0, 1); | 502 intersectionFinder(0, 1); |
500 } | 503 } |
501 | 504 |
502 DEF_TEST(PathOpsQuadIntersection, reporter) { | 505 DEF_TEST(PathOpsQuadIntersection, reporter) { |
503 oneOffTests(reporter); | 506 oneOffTests(reporter); |
504 coincidentTest(reporter); | 507 coincidentTest(reporter); |
505 standardTestCases(reporter); | 508 standardTestCases(reporter); |
506 if (false) QuadraticIntersection_IntersectionFinder(); | 509 if (false) QuadraticIntersection_IntersectionFinder(); |
507 if (false) QuadraticIntersection_PointFinder(); | 510 if (false) QuadraticIntersection_PointFinder(); |
508 } | 511 } |
OLD | NEW |