| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "cc/base/scoped_ptr_deque.h" | 7 #include "cc/base/scoped_ptr_deque.h" |
| 8 #include "cc/base/scoped_ptr_vector.h" | 8 #include "cc/base/scoped_ptr_vector.h" |
| 9 #include "cc/output/bsp_tree.h" | 9 #include "cc/output/bsp_tree.h" |
| 10 #include "cc/output/bsp_walk_action.h" | 10 #include "cc/output/bsp_walk_action.h" |
| 11 #include "cc/quads/draw_polygon.h" | 11 #include "cc/quads/draw_polygon.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 #define EXPECT_SORTED_LISTS_EQ(polygon_list, compare_list) \ | 17 #define EXPECT_SORTED_LISTS_EQ(polygon_list, compare_list) \ |
| 18 do { \ | 18 do { \ |
| 19 EXPECT_EQ(polygon_list.size(), compare_list.size()); \ | 19 EXPECT_EQ(polygon_list.size(), compare_list.size()); \ |
| 20 for (unsigned int i = 0; i < polygon_list.size(); i++) { \ | 20 for (unsigned int i = 0; i < polygon_list.size(); i++) { \ |
| 21 EXPECT_EQ(polygon_list[i]->order_index(), compare_list[i]); \ | 21 EXPECT_EQ(polygon_list[i]->order_index(), compare_list[i]); \ |
| 22 } \ | 22 } \ |
| 23 } while (false); | 23 } while (false); |
| 24 | 24 |
| 25 #define INT_VECTOR_FROM_ARRAY(array) \ | 25 #define INT_VECTOR_FROM_ARRAY(array) \ |
| 26 std::vector<int>(array, array + arraysize(array)) | 26 std::vector<int>(array, array + arraysize(array)) |
| 27 | 27 |
| 28 #define CREATE_DRAW_POLYGON(vertex_vector, normal, polygon_id) \ | 28 #define CREATE_DRAW_POLYGON(vertex_vector, normal, polygon_id) \ |
| 29 new DrawPolygon(NULL, vertex_vector, normal, polygon_id) | 29 new DrawPolygon(nullptr, vertex_vector, normal, polygon_id) |
| 30 | 30 |
| 31 class BspTreeTest { | 31 class BspTreeTest { |
| 32 public: | 32 public: |
| 33 static void RunTest(ScopedPtrDeque<DrawPolygon>* test_polygons, | 33 static void RunTest(ScopedPtrDeque<DrawPolygon>* test_polygons, |
| 34 const std::vector<int>& compare_list) { | 34 const std::vector<int>& compare_list) { |
| 35 BspTree bsp_tree(test_polygons); | 35 BspTree bsp_tree(test_polygons); |
| 36 | 36 |
| 37 std::vector<DrawPolygon*> sorted_list; | 37 std::vector<DrawPolygon*> sorted_list; |
| 38 BspWalkActionToVector action_handler(&sorted_list); | 38 BspWalkActionToVector action_handler(&sorted_list); |
| 39 bsp_tree.TraverseWithActionHandler(&action_handler); | 39 bsp_tree.TraverseWithActionHandler(&action_handler); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 polygon_list.push_back(polygon_c.Pass()); | 339 polygon_list.push_back(polygon_c.Pass()); |
| 340 polygon_list.push_back(polygon_d.Pass()); | 340 polygon_list.push_back(polygon_d.Pass()); |
| 341 | 341 |
| 342 int compare_ids[] = {3, 0, 1, 2, 3}; | 342 int compare_ids[] = {3, 0, 1, 2, 3}; |
| 343 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); | 343 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); |
| 344 BspTreeTest::RunTest(&polygon_list, compare_list); | 344 BspTreeTest::RunTest(&polygon_list, compare_list); |
| 345 } | 345 } |
| 346 | 346 |
| 347 } // namespace | 347 } // namespace |
| 348 } // namespace cc | 348 } // namespace cc |
| OLD | NEW |