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 "PathOpsCubicIntersectionTestData.h" | 7 #include "PathOpsCubicIntersectionTestData.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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 #endif | 299 #endif |
300 SkIntersections intersections; | 300 SkIntersections intersections; |
301 intersections.intersect(cubic1, cubic2); | 301 intersections.intersect(cubic1, cubic2); |
302 double tt1, tt2; | 302 double tt1, tt2; |
303 SkDPoint xy1, xy2; | 303 SkDPoint xy1, xy2; |
304 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { | 304 for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { |
305 tt1 = intersections[0][pt3]; | 305 tt1 = intersections[0][pt3]; |
306 xy1 = cubic1.xyAtT(tt1); | 306 xy1 = cubic1.xyAtT(tt1); |
307 tt2 = intersections[1][pt3]; | 307 tt2 = intersections[1][pt3]; |
308 xy2 = cubic2.xyAtT(tt2); | 308 xy2 = cubic2.xyAtT(tt2); |
| 309 const SkDPoint& iPt = intersections.pt(pt3); |
309 #if ONE_OFF_DEBUG | 310 #if ONE_OFF_DEBUG |
310 DEBUGCODE(const SkDPoint& iPt = intersections.pt(pt3);) | |
311 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1
.9g\n", | 311 SkDebugf("%s t1=%1.9g (%1.9g, %1.9g) (%1.9g, %1.9g) (%1.9g, %1.9g) t2=%1
.9g\n", |
312 __FUNCTION__, tt1, xy1.fX, xy1.fY, iPt.fX, | 312 __FUNCTION__, tt1, xy1.fX, xy1.fY, iPt.fX, |
313 iPt.fY, xy2.fX, xy2.fY, tt2); | 313 iPt.fY, xy2.fX, xy2.fY, tt2); |
314 #endif | 314 #endif |
315 #if 0 | |
316 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt)); | 315 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(iPt)); |
317 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); | 316 REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); |
318 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); | 317 REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); |
319 #endif | |
320 } | 318 } |
321 } | 319 } |
322 | 320 |
323 static void oneOff(skiatest::Reporter* reporter, int outer, int inner) { | 321 static void oneOff(skiatest::Reporter* reporter, int outer, int inner) { |
324 const SkDCubic& cubic1 = testSet[outer]; | 322 const SkDCubic& cubic1 = testSet[outer]; |
325 const SkDCubic& cubic2 = testSet[inner]; | 323 const SkDCubic& cubic2 = testSet[inner]; |
326 oneOff(reporter, cubic1, cubic2); | 324 oneOff(reporter, cubic1, cubic2); |
327 } | 325 } |
328 | 326 |
329 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { | 327 static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { |
330 const SkDCubic& cubic1 = newTestSet[outer]; | 328 const SkDCubic& cubic1 = newTestSet[outer]; |
331 const SkDCubic& cubic2 = newTestSet[inner]; | 329 const SkDCubic& cubic2 = newTestSet[inner]; |
332 oneOff(reporter, cubic1, cubic2); | 330 oneOff(reporter, cubic1, cubic2); |
333 } | 331 } |
334 | 332 |
335 static void oneOffTests(skiatest::Reporter* reporter) { | 333 static void oneOffTests(skiatest::Reporter* reporter) { |
336 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { | 334 for (size_t outer = 0; outer < testSetCount - 1; ++outer) { |
337 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { | 335 for (size_t inner = outer + 1; inner < testSetCount; ++inner) { |
338 oneOff(reporter, outer, inner); | 336 oneOff(reporter, outer, inner); |
339 } | 337 } |
340 } | 338 } |
341 for (size_t outer = 0; outer < newTestSetCount - 1; ++outer) { | 339 for (size_t outer = 0; outer < newTestSetCount - 1; ++outer) { |
342 for (size_t inner = outer + 1; inner < newTestSetCount; ++inner) { | 340 for (size_t inner = outer + 1; inner < newTestSetCount; ++inner) { |
343 oneOff(reporter, outer, inner); | 341 newOneOff(reporter, outer, inner); |
344 } | 342 } |
345 } | 343 } |
346 } | 344 } |
347 | 345 |
348 #define DEBUG_CRASH 0 | 346 #define DEBUG_CRASH 0 |
349 | 347 |
350 static void CubicIntersection_RandTest(skiatest::Reporter* reporter) { | 348 static void CubicIntersection_RandTest(skiatest::Reporter* reporter) { |
351 srand(0); | 349 srand(0); |
352 const int tests = 10000000; | 350 const int tests = 10000000; |
353 #if !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID) | 351 #if !defined(SK_BUILD_FOR_WIN) && !defined(SK_BUILD_FOR_ANDROID) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 cubicIntersectionSelfTest(reporter); | 552 cubicIntersectionSelfTest(reporter); |
555 standardTestCases(reporter); | 553 standardTestCases(reporter); |
556 if (false) CubicIntersection_IntersectionFinder(); | 554 if (false) CubicIntersection_IntersectionFinder(); |
557 if (false) CubicIntersection_RandTest(reporter); | 555 if (false) CubicIntersection_RandTest(reporter); |
558 } | 556 } |
559 | 557 |
560 #include "TestClassDef.h" | 558 #include "TestClassDef.h" |
561 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) | 559 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) |
562 | 560 |
563 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest) | 561 DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest) |
OLD | NEW |