Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: cc/quads/draw_polygon_unittest.cc

Issue 443903004: [CC]: Reduce required precision for TransformNormal test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 6 #include <vector>
6 7
7 #include "cc/output/bsp_compare_result.h" 8 #include "cc/output/bsp_compare_result.h"
8 #include "cc/quads/draw_polygon.h" 9 #include "cc/quads/draw_polygon.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/transform.h" 11 #include "ui/gfx/transform.h"
11 12
12 namespace cc { 13 namespace cc {
13 namespace { 14 namespace {
14 15
15 #define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \ 16 #define CREATE_NEW_DRAW_POLYGON(name, points_vector, normal, polygon_id) \
16 DrawPolygon name(NULL, points_vector, normal, polygon_id) 17 DrawPolygon name(NULL, points_vector, normal, polygon_id)
17 18
19 #define EXPECT_FLOAT_WITHIN_EPSILON_OF(a, b) \
20 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
21
18 #define EXPECT_POINT_EQ(point_a, point_b) \ 22 #define EXPECT_POINT_EQ(point_a, point_b) \
19 EXPECT_FLOAT_EQ(point_a.x(), point_b.x()); \ 23 EXPECT_FLOAT_EQ(point_a.x(), point_b.x()); \
20 EXPECT_FLOAT_EQ(point_a.y(), point_b.y()); \ 24 EXPECT_FLOAT_EQ(point_a.y(), point_b.y()); \
21 EXPECT_FLOAT_EQ(point_a.z(), point_b.z()); 25 EXPECT_FLOAT_EQ(point_a.z(), point_b.z());
22 26
23 static void ValidatePoints(const DrawPolygon& polygon, 27 static void ValidatePoints(const DrawPolygon& polygon,
24 const std::vector<gfx::Point3F>& points) { 28 const std::vector<gfx::Point3F>& points) {
25 EXPECT_EQ(polygon.points().size(), points.size()); 29 EXPECT_EQ(polygon.points().size(), points.size());
26 for (size_t i = 0; i < points.size(); i++) { 30 for (size_t i = 0; i < points.size(); i++) {
27 EXPECT_POINT_EQ(polygon.points()[i], points[i]); 31 EXPECT_POINT_EQ(polygon.points()[i], points[i]);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 CREATE_NEW_DRAW_POLYGON( 170 CREATE_NEW_DRAW_POLYGON(
167 polygon_a, vertices_a, gfx::Vector3dF(0.707107f, 0.0f, -0.707107f), 0); 171 polygon_a, vertices_a, gfx::Vector3dF(0.707107f, 0.0f, -0.707107f), 0);
168 172
169 gfx::Transform transform; 173 gfx::Transform transform;
170 transform.RotateAboutYAxis(45.0); 174 transform.RotateAboutYAxis(45.0);
171 // This would transform the vertices as well, but we are transforming a 175 // This would transform the vertices as well, but we are transforming a
172 // DrawPolygon with 0 vertices just to make sure our normal transformation 176 // DrawPolygon with 0 vertices just to make sure our normal transformation
173 // using the inverse tranpose matrix gives us the right result. 177 // using the inverse tranpose matrix gives us the right result.
174 polygon_a.TransformToScreenSpace(transform); 178 polygon_a.TransformToScreenSpace(transform);
175 179
176 EXPECT_FLOAT_EQ(polygon_a.normal().x(), 0); 180 // Note: We use EXPECT_FLOAT_WITHIN_EPSILON instead of EXPECT_FLOAT_EQUAL here
177 EXPECT_FLOAT_EQ(polygon_a.normal().y(), 0); 181 // because some architectures (e.g., Arm64) employ a fused multiply-add
178 EXPECT_FLOAT_EQ(polygon_a.normal().z(), -1); 182 // instruction which causes rounding asymmetry and reduces precision.
183 // http://crbug.com/401117.
184 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().x(), 0);
185 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().y(), 0);
186 EXPECT_FLOAT_WITHIN_EPSILON_OF(polygon_a.normal().z(), -1);
179 } 187 }
180 188
181 } // namespace 189 } // namespace
182 } // namespace cc 190 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698