| 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 "PathOpsTestCommon.h" |
| 7 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
| 8 #include "Test.h" | 9 #include "Test.h" |
| 9 | 10 |
| 10 // tests to verify that distance calculations are coded correctly | 11 // tests to verify that distance calculations are coded correctly |
| 11 static const SkDCubic tests[] = { | 12 static const SkDCubic tests[] = { |
| 12 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}}, | 13 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}}, |
| 13 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}}, | 14 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}}, |
| 14 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}}, | 15 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}}, |
| 15 {{{0, 2}, {1, 0}, {2, 0}, {3, 0}}}, | 16 {{{0, 2}, {1, 0}, {2, 0}, {3, 0}}}, |
| 16 {{{0, .2}, {1, 0}, {2, 0}, {3, 0}}}, | 17 {{{0, .2}, {1, 0}, {2, 0}, {3, 0}}}, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 33 {1.333333333e-05, 6.666666667e-06}, | 34 {1.333333333e-05, 6.666666667e-06}, |
| 34 {1.5894571940104115e-07, 7.9472859700520577e-08}, | 35 {1.5894571940104115e-07, 7.9472859700520577e-08}, |
| 35 }; | 36 }; |
| 36 | 37 |
| 37 static const size_t tests_count = SK_ARRAY_COUNT(tests); | 38 static const size_t tests_count = SK_ARRAY_COUNT(tests); |
| 38 | 39 |
| 39 static void PathOpsLineParametersTest(skiatest::Reporter* reporter) { | 40 static void PathOpsLineParametersTest(skiatest::Reporter* reporter) { |
| 40 for (size_t index = 0; index < tests_count; ++index) { | 41 for (size_t index = 0; index < tests_count; ++index) { |
| 41 SkLineParameters lineParameters; | 42 SkLineParameters lineParameters; |
| 42 const SkDCubic& cubic = tests[index]; | 43 const SkDCubic& cubic = tests[index]; |
| 44 SkASSERT(ValidCubic(cubic)); |
| 43 lineParameters.cubicEndPoints(cubic, 0, 3); | 45 lineParameters.cubicEndPoints(cubic, 0, 3); |
| 44 double denormalizedDistance[2]; | 46 double denormalizedDistance[2]; |
| 45 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1); | 47 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1); |
| 46 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2); | 48 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2); |
| 47 double normalSquared = lineParameters.normalSquared(); | 49 double normalSquared = lineParameters.normalSquared(); |
| 48 size_t inner; | 50 size_t inner; |
| 49 for (inner = 0; inner < 2; ++inner) { | 51 for (inner = 0; inner < 2; ++inner) { |
| 50 double distSq = denormalizedDistance[inner]; | 52 double distSq = denormalizedDistance[inner]; |
| 51 distSq *= distSq; | 53 distSq *= distSq; |
| 52 double answersSq = answers[index][inner]; | 54 double answersSq = answers[index][inner]; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 71 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n", | 73 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n", |
| 72 __FUNCTION__, static_cast<int>(index), (int)inner, | 74 __FUNCTION__, static_cast<int>(index), (int)inner, |
| 73 normalizedDistance[inner], answers[index][inner]); | 75 normalizedDistance[inner], answers[index][inner]); |
| 74 REPORTER_ASSERT(reporter, 0); | 76 REPORTER_ASSERT(reporter, 0); |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 } | 79 } |
| 78 | 80 |
| 79 #include "TestClassDef.h" | 81 #include "TestClassDef.h" |
| 80 DEFINE_TESTCLASS_SHORT(PathOpsLineParametersTest) | 82 DEFINE_TESTCLASS_SHORT(PathOpsLineParametersTest) |
| OLD | NEW |