| 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 "SkIntersections.h" | 9 #include "SkIntersections.h" |
| 9 #include "SkPathOpsRect.h" | 10 #include "SkPathOpsRect.h" |
| 10 #include "SkReduceOrder.h" | 11 #include "SkReduceOrder.h" |
| 11 #include "Test.h" | 12 #include "Test.h" |
| 12 | 13 |
| 13 static void standardTestCases(skiatest::Reporter* reporter) { | 14 static void standardTestCases(skiatest::Reporter* reporter) { |
| 14 bool showSkipped = false; | 15 bool showSkipped = false; |
| 15 for (size_t index = 0; index < quadraticTests_count; ++index) { | 16 for (size_t index = 0; index < quadraticTests_count; ++index) { |
| 16 const SkDQuad& quad1 = quadraticTests[index][0]; | 17 const SkDQuad& quad1 = quadraticTests[index][0]; |
| 18 SkASSERT(ValidQuad(quad1)); |
| 17 const SkDQuad& quad2 = quadraticTests[index][1]; | 19 const SkDQuad& quad2 = quadraticTests[index][1]; |
| 20 SkASSERT(ValidQuad(quad2)); |
| 18 SkReduceOrder reduce1, reduce2; | 21 SkReduceOrder reduce1, reduce2; |
| 19 int order1 = reduce1.reduce(quad1, SkReduceOrder::kFill_Style); | 22 int order1 = reduce1.reduce(quad1, SkReduceOrder::kFill_Style); |
| 20 int order2 = reduce2.reduce(quad2, SkReduceOrder::kFill_Style); | 23 int order2 = reduce2.reduce(quad2, SkReduceOrder::kFill_Style); |
| 21 if (order1 < 3) { | 24 if (order1 < 3) { |
| 22 if (showSkipped) { | 25 if (showSkipped) { |
| 23 SkDebugf("[%d] quad1 order=%d\n", static_cast<int>(index), order
1); | 26 SkDebugf("[%d] quad1 order=%d\n", static_cast<int>(index), order
1); |
| 24 } | 27 } |
| 25 } | 28 } |
| 26 if (order2 < 3) { | 29 if (order2 < 3) { |
| 27 if (showSkipped) { | 30 if (showSkipped) { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 {{{362.607421875, 221.3671875}, {365.166015625, 218.3203125}, {369.228515625
, 218.3203125}}}, | 242 {{{362.607421875, 221.3671875}, {365.166015625, 218.3203125}, {369.228515625
, 218.3203125}}}, |
| 240 {{{8, 8}, {10, 10}, {8, -10}}}, | 243 {{{8, 8}, {10, 10}, {8, -10}}}, |
| 241 {{{8, 8}, {12, 12}, {14, 4}}}, | 244 {{{8, 8}, {12, 12}, {14, 4}}}, |
| 242 {{{8, 8}, {9, 9}, {10, 8}}} | 245 {{{8, 8}, {9, 9}, {10, 8}}} |
| 243 }; | 246 }; |
| 244 | 247 |
| 245 const size_t testSetCount = SK_ARRAY_COUNT(testSet); | 248 const size_t testSetCount = SK_ARRAY_COUNT(testSet); |
| 246 | 249 |
| 247 static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner
) { | 250 static void oneOffTest1(skiatest::Reporter* reporter, size_t outer, size_t inner
) { |
| 248 const SkDQuad& quad1 = testSet[outer]; | 251 const SkDQuad& quad1 = testSet[outer]; |
| 252 SkASSERT(ValidQuad(quad1)); |
| 249 const SkDQuad& quad2 = testSet[inner]; | 253 const SkDQuad& quad2 = testSet[inner]; |
| 254 SkASSERT(ValidQuad(quad2)); |
| 250 SkIntersections intersections2; | 255 SkIntersections intersections2; |
| 251 intersections2.intersect(quad1, quad2); | 256 intersections2.intersect(quad1, quad2); |
| 252 for (int pt = 0; pt < intersections2.used(); ++pt) { | 257 for (int pt = 0; pt < intersections2.used(); ++pt) { |
| 253 double tt1 = intersections2[0][pt]; | 258 double tt1 = intersections2[0][pt]; |
| 254 SkDPoint xy1 = quad1.xyAtT(tt1); | 259 SkDPoint xy1 = quad1.xyAtT(tt1); |
| 255 double tt2 = intersections2[1][pt]; | 260 double tt2 = intersections2[1][pt]; |
| 256 SkDPoint xy2 = quad2.xyAtT(tt2); | 261 SkDPoint xy2 = quad2.xyAtT(tt2); |
| 257 if (!xy1.approximatelyEqual(xy2)) { | 262 if (!xy1.approximatelyEqual(xy2)) { |
| 258 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", | 263 SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", |
| 259 __FUNCTION__, static_cast<int>(outer), static_cast<int>(inne
r), | 264 __FUNCTION__, static_cast<int>(outer), static_cast<int>(inne
r), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 284 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, | 289 {{{369.850525, 145.675964}, {382.362915, 121.29287}, {406.211273, 121.29287}
}}, |
| 285 {{{8, 8}, {10, 10}, {8, -10}}}, | 290 {{{8, 8}, {10, 10}, {8, -10}}}, |
| 286 {{{8, -10}, {10, 10}, {8, 8}}}, | 291 {{{8, -10}, {10, 10}, {8, 8}}}, |
| 287 }; | 292 }; |
| 288 | 293 |
| 289 const size_t coincidentTestSetCount = SK_ARRAY_COUNT(coincidentTestSet); | 294 const size_t coincidentTestSetCount = SK_ARRAY_COUNT(coincidentTestSet); |
| 290 | 295 |
| 291 static void coincidentTest(skiatest::Reporter* reporter) { | 296 static void coincidentTest(skiatest::Reporter* reporter) { |
| 292 for (size_t testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex
+= 2) { | 297 for (size_t testIndex = 0; testIndex < coincidentTestSetCount - 1; testIndex
+= 2) { |
| 293 const SkDQuad& quad1 = coincidentTestSet[testIndex]; | 298 const SkDQuad& quad1 = coincidentTestSet[testIndex]; |
| 299 SkASSERT(ValidQuad(quad1)); |
| 294 const SkDQuad& quad2 = coincidentTestSet[testIndex + 1]; | 300 const SkDQuad& quad2 = coincidentTestSet[testIndex + 1]; |
| 301 SkASSERT(ValidQuad(quad2)); |
| 295 SkIntersections intersections2; | 302 SkIntersections intersections2; |
| 296 intersections2.intersect(quad1, quad2); | 303 intersections2.intersect(quad1, quad2); |
| 297 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2); | 304 REPORTER_ASSERT(reporter, intersections2.coincidentUsed() == 2); |
| 298 REPORTER_ASSERT(reporter, intersections2.used() == 2); | 305 REPORTER_ASSERT(reporter, intersections2.used() == 2); |
| 299 for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) { | 306 for (int pt = 0; pt < intersections2.coincidentUsed(); ++pt) { |
| 300 double tt1 = intersections2[0][pt]; | 307 double tt1 = intersections2[0][pt]; |
| 301 double tt2 = intersections2[1][pt]; | 308 double tt2 = intersections2[1][pt]; |
| 302 REPORTER_ASSERT(reporter, approximately_equal(1, tt1) || approximate
ly_zero(tt1)); | 309 REPORTER_ASSERT(reporter, approximately_equal(1, tt1) || approximate
ly_zero(tt1)); |
| 303 REPORTER_ASSERT(reporter, approximately_equal(1, tt2) || approximate
ly_zero(tt2)); | 310 REPORTER_ASSERT(reporter, approximately_equal(1, tt2) || approximate
ly_zero(tt2)); |
| 304 } | 311 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 standardTestCases(reporter); | 481 standardTestCases(reporter); |
| 475 if (false) QuadraticIntersection_IntersectionFinder(); | 482 if (false) QuadraticIntersection_IntersectionFinder(); |
| 476 if (false) QuadraticIntersection_PointFinder(); | 483 if (false) QuadraticIntersection_PointFinder(); |
| 477 } | 484 } |
| 478 | 485 |
| 479 | 486 |
| 480 #include "TestClassDef.h" | 487 #include "TestClassDef.h" |
| 481 DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionTest) | 488 DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionTest) |
| 482 | 489 |
| 483 DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionOneOffTest) | 490 DEFINE_TESTCLASS_SHORT(PathOpsQuadIntersectionOneOffTest) |
| OLD | NEW |