OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 7 |
8 // Unit tests for src/core/SkPoint3.cpp and its header | 8 // Unit tests for src/core/SkPoint3.cpp and its header |
9 | 9 |
10 #include "SkPoint3.h" | 10 #include "SkPoint3.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 v = SkPoint3::Make(SK_ScalarRoot2Over2, SK_ScalarRoot2Over2, 0.0f); | 70 v = SkPoint3::Make(SK_ScalarRoot2Over2, SK_ScalarRoot2Over2, 0.0f); |
71 | 71 |
72 dot = xAxis.dot(v); | 72 dot = xAxis.dot(v); |
73 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dot, SK_ScalarRoot2Over2)); | 73 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dot, SK_ScalarRoot2Over2)); |
74 | 74 |
75 dot = yAxis.dot(v); | 75 dot = yAxis.dot(v); |
76 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dot, SK_ScalarRoot2Over2)); | 76 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(dot, SK_ScalarRoot2Over2)); |
77 } | 77 } |
78 | 78 |
79 static void test_length(skiatest::Reporter* reporter, | 79 static void test_length(skiatest::Reporter* reporter, |
80 SkScalar x, SkScalar y, SkScalar z, SkScalar expectedLen
) { | 80 SkScalar x, SkScalar y, SkScalar z, SkScalar expectedLen
) { |
81 SkPoint3 point = SkPoint3::Make(x, y, z); | 81 SkPoint3 point = SkPoint3::Make(x, y, z); |
82 | 82 |
83 SkScalar s1 = point.length(); | 83 SkScalar s1 = point.length(); |
84 SkScalar s2 = SkPoint3::Length(x, y, z); | 84 SkScalar s2 = SkPoint3::Length(x, y, z); |
85 | 85 |
86 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, s2)); | 86 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, s2)); |
87 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, expectedLen)); | 87 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(s1, expectedLen)); |
88 } | 88 } |
89 | 89 |
(...skipping 18 matching lines...) Expand all Loading... |
108 | 108 |
109 DEF_TEST(Point3, reporter) { | 109 DEF_TEST(Point3, reporter) { |
110 test_eq_ops(reporter); | 110 test_eq_ops(reporter); |
111 test_ops(reporter); | 111 test_ops(reporter); |
112 test_dot(reporter); | 112 test_dot(reporter); |
113 | 113 |
114 static const struct { | 114 static const struct { |
115 SkScalar fX; | 115 SkScalar fX; |
116 SkScalar fY; | 116 SkScalar fY; |
117 SkScalar fZ; | 117 SkScalar fZ; |
118 SkScalar fLength; | 118 SkScalar fLength; |
119 } gRec[] = { | 119 } gRec[] = { |
120 { 0.0f, 0.0f, 0.0f, 0.0f }, | 120 { 0.0f, 0.0f, 0.0f, 0.0f }, |
121 { 0.3f, 0.4f, 0.5f, SK_ScalarRoot2Over2 }, | 121 { 0.3f, 0.4f, 0.5f, SK_ScalarRoot2Over2 }, |
122 { 1.0e-37f, 1.0e-37f, 1.0e-37f, 0.0f }, // underflows | 122 { 1.0e-37f, 1.0e-37f, 1.0e-37f, 0.0f }, // underflows |
123 { 3.4e38f, 0.0f, 0.0f, 3.4e38f } // overflows | 123 { 3.4e38f, 0.0f, 0.0f, 3.4e38f } // overflows |
124 }; | 124 }; |
125 | 125 |
126 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 126 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
127 test_length(reporter, gRec[i].fX, gRec[i].fY, gRec[i].fZ, gRec[i].fLengt
h); | 127 test_length(reporter, gRec[i].fX, gRec[i].fY, gRec[i].fZ, gRec[i].fLengt
h); |
128 test_normalize(reporter, gRec[i].fX, gRec[i].fY, gRec[i].fZ, gRec[i].fLe
ngth); | 128 test_normalize(reporter, gRec[i].fX, gRec[i].fY, gRec[i].fZ, gRec[i].fLe
ngth); |
129 } | 129 } |
130 } | 130 } |
OLD | NEW |