Chromium Code Reviews| Index: cc/quads/draw_polygon_unittest.cc |
| diff --git a/cc/quads/draw_polygon_unittest.cc b/cc/quads/draw_polygon_unittest.cc |
| index 3b8caf3600fb2179fec05150756b1e48becd1fe8..27cfed43816b02bc64df851c03d4806bf6efe268 100644 |
| --- a/cc/quads/draw_polygon_unittest.cc |
| +++ b/cc/quads/draw_polygon_unittest.cc |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <limits> |
| #include <vector> |
| #include "cc/output/bsp_compare_result.h" |
| @@ -15,6 +16,9 @@ namespace { |
| #define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \ |
| DrawPolygon name(NULL, points_vector, normal, polygon_id) |
| +#define EXPECT_FLOAT_WITHIN_EPSILON_OF(a, b) \ |
| + EXPECT_TRUE(std::abs(a - b) < std::numeric_limits<float>::epsilon()); |
|
Sami
2014/08/06 17:09:24
I think in general the epsilon should be scaled up
|
| + |
| #define EXPECT_POINT_EQ(point_a, point_b) \ |
| EXPECT_FLOAT_EQ(point_a.x(), point_b.x()); \ |
| EXPECT_FLOAT_EQ(point_a.y(), point_b.y()); \ |
| @@ -173,9 +177,13 @@ TEST(DrawPolygonTransformTest, TransformNormal) { |
| // using the inverse tranpose matrix gives us the right result. |
| polygon_a.TransformToScreenSpace(transform); |
| - EXPECT_FLOAT_EQ(polygon_a.normal().x(), 0); |
| - EXPECT_FLOAT_EQ(polygon_a.normal().y(), 0); |
| - EXPECT_FLOAT_EQ(polygon_a.normal().z(), -1); |
| + // Note: We use EXPECT_FLOAT_WITHIN_EPSILON instead of EXPECT_FLOAT_EQUAL here |
| + // because some architectures (e.g., Arm64) employ a fused multiply-add |
| + // instruction which causes rounding asymmetry and reduces precision. |
| + // http://crbug.com/401117. |
| + EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0); |
| + EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0); |
| + EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1); |
| } |
| } // namespace |