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 f795787eccc0ea38f5232ab250a32821445630bc..ad68560845e6532484c5b0fdf604a1c2d29e125b 100644 |
| --- a/cc/quads/draw_polygon_unittest.cc |
| +++ b/cc/quads/draw_polygon_unittest.cc |
| @@ -13,6 +13,7 @@ |
| #include <vector> |
| #include "base/memory/ptr_util.h" |
| +#include "base/stl_util.h" |
| #include "cc/output/bsp_compare_result.h" |
| #include "cc/quads/draw_polygon.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -486,6 +487,58 @@ TEST(DrawPolygonSplitTest, AngledSplit) { |
| ValidatePointsWithinDeltaOf(*back_polygon, test_points_b, 1e-6f); |
| } |
| +// This test was derived from crbug.com/693826. An almost coplanar |
| +// pair of polygons are used for splitting. In this case, the |
| +// splitting plane distance signs are [ 0 0 + - ]. This configuration |
| +// represents a case where snapping to the splitting plane causes the |
| +// polygon to become twisted. Splitting should still give a valid |
|
enne (OOO)
2017/02/27 17:35:32
I wish more unit tests explained themselves this w
|
| +// result, indicated by all four of the input split polygon vertices |
| +// being present in the output polygons. |
| +TEST(DrawPolygonSplitTest, AlmostCoplanarSplit) { |
| + std::vector<gfx::Point3F> vertices_a; |
| + vertices_a.push_back(gfx::Point3F(723.814758300781250, 552.810119628906250, |
| + -206.656036376953125)); |
| + vertices_a.push_back(gfx::Point3F(797.634155273437500, 549.095703125000000, |
| + -209.802902221679688)); |
| + vertices_a.push_back(gfx::Point3F(799.264648437500000, 490.325805664062500, |
| + -172.261627197265625)); |
| + vertices_a.push_back(gfx::Point3F(720.732421875000000, 493.944458007812500, |
| + -168.700469970703125)); |
| + std::vector<gfx::Point3F> vertices_b; |
| + vertices_b.push_back(gfx::Point3F(720.631286621093750, 487.595977783203125, |
| + -164.681198120117188)); |
| + vertices_b.push_back(gfx::Point3F(799.672851562500000, 484.059020996093750, |
| + -168.219161987304688)); |
| + vertices_b.push_back(gfx::Point3F(801.565490722656250, 416.416809082031250, |
| + -125.007690429687500)); |
| + vertices_b.push_back(gfx::Point3F(717.096801757812500, 419.792327880859375, |
| + -120.967689514160156)); |
| + |
| + CREATE_NEW_DRAW_POLYGON_PTR( |
| + splitting_polygon, vertices_a, |
| + gfx::Vector3dF(-0.062916249036789, -0.538499474525452, |
| + -0.840273618698120), |
| + 0); |
| + CREATE_NEW_DRAW_POLYGON_PTR(split_polygon, vertices_b, |
| + gfx::Vector3dF(0.707107f, 0.0f, -0.707107f), 1); |
| + |
| + std::unique_ptr<DrawPolygon> front_polygon; |
| + std::unique_ptr<DrawPolygon> back_polygon; |
| + bool is_coplanar; |
| + |
| + splitting_polygon->SplitPolygon(std::move(split_polygon), &front_polygon, |
| + &back_polygon, &is_coplanar); |
| + |
| + EXPECT_FALSE(is_coplanar); |
| + EXPECT_TRUE(front_polygon != nullptr); |
| + EXPECT_TRUE(back_polygon != nullptr); |
| + |
| + for (auto vertex : vertices_b) { |
| + EXPECT_TRUE(base::ContainsValue(front_polygon->points(), vertex) || |
| + base::ContainsValue(back_polygon->points(), vertex)); |
| + } |
| +} |
| + |
| // In this test we cut the corner of a quad so that it creates a triangle and |
| // a pentagon as a result, and then cut the pentagon. |
| TEST(DrawPolygonSplitTest, DoubleSplit) { |