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