| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gfx/transform_util.h" | 5 #include "ui/gfx/transform_util.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/geometry/point.h" | 8 #include "ui/gfx/geometry/point.h" |
| 9 #include "ui/gfx/geometry/point3_f.h" | 9 #include "ui/gfx/geometry/point3_f.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 10 #include "ui/gfx/geometry/rect.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 transform.Scale3d(SkDoubleToMScalar(1.0), | 134 transform.Scale3d(SkDoubleToMScalar(1.0), |
| 135 SkDoubleToMScalar(3.00001), | 135 SkDoubleToMScalar(3.00001), |
| 136 SkDoubleToMScalar(2.0)); | 136 SkDoubleToMScalar(2.0)); |
| 137 | 137 |
| 138 Rect viewport(1920, 1200); | 138 Rect viewport(1920, 1200); |
| 139 bool snapped = SnapTransform(&result, transform, viewport); | 139 bool snapped = SnapTransform(&result, transform, viewport); |
| 140 ASSERT_TRUE(snapped) << "Viewport should snap all components."; | 140 ASSERT_TRUE(snapped) << "Viewport should snap all components."; |
| 141 | 141 |
| 142 Point3F point; | 142 Point3F point; |
| 143 | 143 |
| 144 point = Point3F(viewport.origin()); | 144 point = Point3F(PointF(viewport.origin())); |
| 145 result.TransformPoint(&point); | 145 result.TransformPoint(&point); |
| 146 EXPECT_EQ(Point3F(31.f, 20.f, 10.f), point) << "Transformed origin"; | 146 EXPECT_EQ(Point3F(31.f, 20.f, 10.f), point) << "Transformed origin"; |
| 147 | 147 |
| 148 point = Point3F(viewport.top_right()); | 148 point = Point3F(PointF(viewport.top_right())); |
| 149 result.TransformPoint(&point); | 149 result.TransformPoint(&point); |
| 150 EXPECT_EQ(Point3F(31.f, 1940.f, 10.f), point) << "Transformed top-right"; | 150 EXPECT_EQ(Point3F(31.f, 1940.f, 10.f), point) << "Transformed top-right"; |
| 151 | 151 |
| 152 point = Point3F(viewport.bottom_left()); | 152 point = Point3F(PointF(viewport.bottom_left())); |
| 153 result.TransformPoint(&point); | 153 result.TransformPoint(&point); |
| 154 EXPECT_EQ(Point3F(-3569.f, 20.f, 10.f), point) << "Transformed bottom-left"; | 154 EXPECT_EQ(Point3F(-3569.f, 20.f, 10.f), point) << "Transformed bottom-left"; |
| 155 | 155 |
| 156 point = Point3F(viewport.bottom_right()); | 156 point = Point3F(PointF(viewport.bottom_right())); |
| 157 result.TransformPoint(&point); | 157 result.TransformPoint(&point); |
| 158 EXPECT_EQ(Point3F(-3569.f, 1940.f, 10.f), point) | 158 EXPECT_EQ(Point3F(-3569.f, 1940.f, 10.f), point) |
| 159 << "Transformed bottom-right"; | 159 << "Transformed bottom-right"; |
| 160 } | 160 } |
| 161 | 161 |
| 162 TEST(TransformUtilTest, NoSnapSkewedCompositeTransform) { | 162 TEST(TransformUtilTest, NoSnapSkewedCompositeTransform) { |
| 163 Transform result(Transform::kSkipInitialization); | 163 Transform result(Transform::kSkipInitialization); |
| 164 Transform transform; | 164 Transform transform; |
| 165 | 165 |
| 166 | 166 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 DecomposedTransform result; | 200 DecomposedTransform result; |
| 201 BlendDecomposedTransforms(&result, first, second, 0.25); | 201 BlendDecomposedTransforms(&result, first, second, 0.25); |
| 202 for (size_t i = 0; i < 4; ++i) { | 202 for (size_t i = 0; i < 4; ++i) { |
| 203 EXPECT_TRUE(std::isfinite(result.quaternion[i])); | 203 EXPECT_TRUE(std::isfinite(result.quaternion[i])); |
| 204 EXPECT_FALSE(std::isnan(result.quaternion[i])); | 204 EXPECT_FALSE(std::isnan(result.quaternion[i])); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 } // namespace gfx | 209 } // namespace gfx |
| OLD | NEW |