| 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 | |
| 27 static void ValidatePoints(const DrawPolygon& polygon, | 22 static void ValidatePoints(const DrawPolygon& polygon, |
| 28 const std::vector<gfx::Point3F>& points) { | 23 const std::vector<gfx::Point3F>& points) { |
| 29 EXPECT_EQ(polygon.points().size(), points.size()); | 24 EXPECT_EQ(polygon.points().size(), points.size()); |
| 30 for (size_t i = 0; i < points.size(); i++) { | 25 for (size_t i = 0; i < points.size(); i++) { |
| 31 EXPECT_POINT_EQ(polygon.points()[i], points[i]); | 26 EXPECT_EQ(polygon.points()[i], points[i]); |
| 32 } | 27 } |
| 33 } | 28 } |
| 34 | 29 |
| 35 // Two quads are definitely not touching and so no split should occur. | 30 // Two quads are definitely not touching and so no split should occur. |
| 36 TEST(DrawPolygonSplitTest, NotTouchingNoSplit) { | 31 TEST(DrawPolygonSplitTest, NotTouchingNoSplit) { |
| 37 std::vector<gfx::Point3F> vertices_a; | 32 std::vector<gfx::Point3F> vertices_a; |
| 38 vertices_a.push_back(gfx::Point3F(0.0f, 10.0f, 0.0f)); | 33 vertices_a.push_back(gfx::Point3F(0.0f, 10.0f, 0.0f)); |
| 39 vertices_a.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); | 34 vertices_a.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); |
| 40 vertices_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); | 35 vertices_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); |
| 41 vertices_a.push_back(gfx::Point3F(10.0f, 10.0f, 0.0f)); | 36 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... |
| 181 // because some architectures (e.g., Arm64) employ a fused multiply-add | 176 // because some architectures (e.g., Arm64) employ a fused multiply-add |
| 182 // instruction which causes rounding asymmetry and reduces precision. | 177 // instruction which causes rounding asymmetry and reduces precision. |
| 183 // http://crbug.com/401117. | 178 // http://crbug.com/401117. |
| 184 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0); | 179 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0); |
| 185 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0); | 180 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0); |
| 186 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1); | 181 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1); |
| 187 } | 182 } |
| 188 | 183 |
| 189 } // namespace | 184 } // namespace |
| 190 } // namespace cc | 185 } // namespace cc |
| OLD | NEW |