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 // We would like to use M_PI on windows too. | 5 // We would like to use M_PI on windows too. |
6 #ifdef _WIN32 | 6 #ifdef _WIN32 |
7 #define _USE_MATH_DEFINES | 7 #define _USE_MATH_DEFINES |
8 #endif | 8 #endif |
9 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 vertices_b.push_back(gfx::Point3F(5.0f, 10.0f, -5.0f)); | 291 vertices_b.push_back(gfx::Point3F(5.0f, 10.0f, -5.0f)); |
292 vertices_b.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f)); | 292 vertices_b.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f)); |
293 vertices_b.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f)); | 293 vertices_b.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f)); |
294 vertices_b.push_back(gfx::Point3F(5.0f, 10.0f, 5.0f)); | 294 vertices_b.push_back(gfx::Point3F(5.0f, 10.0f, 5.0f)); |
295 | 295 |
296 CREATE_NEW_DRAW_POLYGON( | 296 CREATE_NEW_DRAW_POLYGON( |
297 polygon_a, vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0); | 297 polygon_a, vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0); |
298 CREATE_NEW_DRAW_POLYGON( | 298 CREATE_NEW_DRAW_POLYGON( |
299 polygon_b, vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1); | 299 polygon_b, vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1); |
300 | 300 |
301 EXPECT_EQ(BSP_SPLIT, DrawPolygon::SideCompare(polygon_b, polygon_a)); | |
302 | |
303 std::unique_ptr<DrawPolygon> front_polygon; | 301 std::unique_ptr<DrawPolygon> front_polygon; |
304 std::unique_ptr<DrawPolygon> back_polygon; | 302 std::unique_ptr<DrawPolygon> back_polygon; |
305 polygon_b.Split(polygon_a, &front_polygon, &back_polygon); | 303 EXPECT_FALSE( |
306 EXPECT_EQ(BSP_FRONT, DrawPolygon::SideCompare(*front_polygon, polygon_a)); | 304 polygon_a.SplitPolygon(polygon_b, &front_polygon, &back_polygon)); |
307 EXPECT_EQ(BSP_BACK, DrawPolygon::SideCompare(*back_polygon, polygon_a)); | 305 EXPECT_TRUE(front_polygon != nullptr); |
| 306 EXPECT_TRUE(back_polygon != nullptr); |
308 | 307 |
309 std::vector<gfx::Point3F> test_points_a; | 308 std::vector<gfx::Point3F> test_points_a; |
310 test_points_a.push_back(gfx::Point3F(5.0f, 0.0f, 0.0f)); | 309 test_points_a.push_back(gfx::Point3F(5.0f, 0.0f, 0.0f)); |
311 test_points_a.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f)); | 310 test_points_a.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f)); |
312 test_points_a.push_back(gfx::Point3F(5.0f, 10.0f, 5.0f)); | 311 test_points_a.push_back(gfx::Point3F(5.0f, 10.0f, 5.0f)); |
313 test_points_a.push_back(gfx::Point3F(5.0f, 10.0f, 0.0f)); | 312 test_points_a.push_back(gfx::Point3F(5.0f, 10.0f, 0.0f)); |
314 std::vector<gfx::Point3F> test_points_b; | 313 std::vector<gfx::Point3F> test_points_b; |
315 test_points_b.push_back(gfx::Point3F(5.0f, 10.0f, 0.0f)); | 314 test_points_b.push_back(gfx::Point3F(5.0f, 10.0f, 0.0f)); |
316 test_points_b.push_back(gfx::Point3F(5.0f, 10.0f, -5.0f)); | 315 test_points_b.push_back(gfx::Point3F(5.0f, 10.0f, -5.0f)); |
317 test_points_b.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f)); | 316 test_points_b.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f)); |
(...skipping 17 matching lines...) Expand all Loading... |
335 vertices_b.push_back(gfx::Point3F(2.0f, 5.0f, 1.0f)); | 334 vertices_b.push_back(gfx::Point3F(2.0f, 5.0f, 1.0f)); |
336 vertices_b.push_back(gfx::Point3F(2.0f, -5.0f, 1.0f)); | 335 vertices_b.push_back(gfx::Point3F(2.0f, -5.0f, 1.0f)); |
337 vertices_b.push_back(gfx::Point3F(-1.0f, -5.0f, -2.0f)); | 336 vertices_b.push_back(gfx::Point3F(-1.0f, -5.0f, -2.0f)); |
338 vertices_b.push_back(gfx::Point3F(-1.0f, 5.0f, -2.0f)); | 337 vertices_b.push_back(gfx::Point3F(-1.0f, 5.0f, -2.0f)); |
339 | 338 |
340 CREATE_NEW_DRAW_POLYGON( | 339 CREATE_NEW_DRAW_POLYGON( |
341 polygon_a, vertices_a, gfx::Vector3dF(0.0f, 1.0f, 0.0f), 0); | 340 polygon_a, vertices_a, gfx::Vector3dF(0.0f, 1.0f, 0.0f), 0); |
342 CREATE_NEW_DRAW_POLYGON( | 341 CREATE_NEW_DRAW_POLYGON( |
343 polygon_b, vertices_b, gfx::Vector3dF(0.707107f, 0.0f, -0.707107f), 1); | 342 polygon_b, vertices_b, gfx::Vector3dF(0.707107f, 0.0f, -0.707107f), 1); |
344 | 343 |
345 EXPECT_EQ(BSP_SPLIT, DrawPolygon::SideCompare(polygon_a, polygon_b)); | |
346 | |
347 std::unique_ptr<DrawPolygon> front_polygon; | 344 std::unique_ptr<DrawPolygon> front_polygon; |
348 std::unique_ptr<DrawPolygon> back_polygon; | 345 std::unique_ptr<DrawPolygon> back_polygon; |
349 polygon_a.Split(polygon_b, &front_polygon, &back_polygon); | 346 EXPECT_FALSE( |
350 EXPECT_EQ(BSP_FRONT, DrawPolygon::SideCompare(*front_polygon, polygon_b)); | 347 polygon_b.SplitPolygon(polygon_a, &front_polygon, &back_polygon)); |
351 EXPECT_EQ(BSP_BACK, DrawPolygon::SideCompare(*back_polygon, polygon_b)); | 348 EXPECT_TRUE(front_polygon != nullptr); |
352 | 349 EXPECT_TRUE(back_polygon != nullptr); |
353 EXPECT_EQ(3u, front_polygon->points().size()); | |
354 EXPECT_EQ(5u, back_polygon->points().size()); | |
355 | 350 |
356 std::vector<gfx::Point3F> test_points_a; | 351 std::vector<gfx::Point3F> test_points_a; |
357 test_points_a.push_back(gfx::Point3F(10.0f, 0.0f, 9.0f)); | 352 test_points_a.push_back(gfx::Point3F(10.0f, 0.0f, 9.0f)); |
358 test_points_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); | 353 test_points_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); |
359 test_points_a.push_back(gfx::Point3F(1.0f, 0.0f, 0.0f)); | 354 test_points_a.push_back(gfx::Point3F(1.0f, 0.0f, 0.0f)); |
360 std::vector<gfx::Point3F> test_points_b; | 355 std::vector<gfx::Point3F> test_points_b; |
361 test_points_b.push_back(gfx::Point3F(1.0f, 0.0f, 0.0f)); | 356 test_points_b.push_back(gfx::Point3F(1.0f, 0.0f, 0.0f)); |
362 test_points_b.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); | 357 test_points_b.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); |
363 test_points_b.push_back(gfx::Point3F(0.0f, 0.0f, 10.0f)); | 358 test_points_b.push_back(gfx::Point3F(0.0f, 0.0f, 10.0f)); |
364 test_points_b.push_back(gfx::Point3F(10.0f, 0.0f, 10.0f)); | 359 test_points_b.push_back(gfx::Point3F(10.0f, 0.0f, 10.0f)); |
(...skipping 21 matching lines...) Expand all Loading... |
386 | 381 |
387 // Note: We use EXPECT_FLOAT_WITHIN_EPSILON instead of EXPECT_FLOAT_EQUAL here | 382 // Note: We use EXPECT_FLOAT_WITHIN_EPSILON instead of EXPECT_FLOAT_EQUAL here |
388 // because some architectures (e.g., Arm64) employ a fused multiply-add | 383 // because some architectures (e.g., Arm64) employ a fused multiply-add |
389 // instruction which causes rounding asymmetry and reduces precision. | 384 // instruction which causes rounding asymmetry and reduces precision. |
390 // http://crbug.com/401117. | 385 // http://crbug.com/401117. |
391 EXPECT_NORMAL(polygon_a, 0.0f, 0.0f, -1.0f); | 386 EXPECT_NORMAL(polygon_a, 0.0f, 0.0f, -1.0f); |
392 } | 387 } |
393 | 388 |
394 } // namespace | 389 } // namespace |
395 } // namespace cc | 390 } // namespace cc |
OLD | NEW |