OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <limits> | 5 #include <limits> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "cc/output/bsp_compare_result.h" | 8 #include "cc/output/bsp_compare_result.h" |
9 #include "cc/quads/draw_polygon.h" | 9 #include "cc/quads/draw_polygon.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/gfx/transform.h" | 11 #include "ui/gfx/transform.h" |
12 | 12 |
13 namespace cc { | 13 namespace cc { |
14 namespace { | 14 namespace { |
15 | 15 |
16 #define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \ | 16 #define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \ |
17 DrawPolygon name(NULL, points_vector, normal, polygon_id) | 17 DrawPolygon name(NULL, points_vector, normal, polygon_id) |
18 | 18 |
19 #define EXPECT_FLOAT_WITHIN_EPSILON_OF(a, b) \ | 19 #define EXPECT_FLOAT_WITHIN_EPSILON_OF(a, b) \ |
20 EXPECT_TRUE(std::abs(a - b) < std::numeric_limits<float>::epsilon()); | 20 EXPECT_TRUE(std::abs(a - b) < std::numeric_limits<float>::epsilon()); |
21 | 21 |
| 22 #define EXPECT_POINT_EQ(point_a, point_b) \ |
| 23 EXPECT_FLOAT_EQ(point_a.x(), point_b.x()); \ |
| 24 EXPECT_FLOAT_EQ(point_a.y(), point_b.y()); \ |
| 25 EXPECT_FLOAT_EQ(point_a.z(), point_b.z()); |
| 26 |
22 static void ValidatePoints(const DrawPolygon& polygon, | 27 static void ValidatePoints(const DrawPolygon& polygon, |
23 const std::vector<gfx::Point3F>& points) { | 28 const std::vector<gfx::Point3F>& points) { |
24 EXPECT_EQ(polygon.points().size(), points.size()); | 29 EXPECT_EQ(polygon.points().size(), points.size()); |
25 for (size_t i = 0; i < points.size(); i++) { | 30 for (size_t i = 0; i < points.size(); i++) { |
26 EXPECT_EQ(polygon.points()[i], points[i]); | 31 EXPECT_POINT_EQ(polygon.points()[i], points[i]); |
27 } | 32 } |
28 } | 33 } |
29 | 34 |
30 // Two quads are definitely not touching and so no split should occur. | 35 // Two quads are definitely not touching and so no split should occur. |
31 TEST(DrawPolygonSplitTest, NotTouchingNoSplit) { | 36 TEST(DrawPolygonSplitTest, NotTouchingNoSplit) { |
32 std::vector<gfx::Point3F> vertices_a; | 37 std::vector<gfx::Point3F> vertices_a; |
33 vertices_a.push_back(gfx::Point3F(0.0f, 10.0f, 0.0f)); | 38 vertices_a.push_back(gfx::Point3F(0.0f, 10.0f, 0.0f)); |
34 vertices_a.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); | 39 vertices_a.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); |
35 vertices_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); | 40 vertices_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); |
36 vertices_a.push_back(gfx::Point3F(10.0f, 10.0f, 0.0f)); | 41 vertices_a.push_back(gfx::Point3F(10.0f, 10.0f, 0.0f)); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // because some architectures (e.g., Arm64) employ a fused multiply-add | 181 // because some architectures (e.g., Arm64) employ a fused multiply-add |
177 // instruction which causes rounding asymmetry and reduces precision. | 182 // instruction which causes rounding asymmetry and reduces precision. |
178 // http://crbug.com/401117. | 183 // http://crbug.com/401117. |
179 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0); | 184 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0); |
180 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0); | 185 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0); |
181 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1); | 186 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1); |
182 } | 187 } |
183 | 188 |
184 } // namespace | 189 } // namespace |
185 } // namespace cc | 190 } // namespace cc |
OLD | NEW |