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

Side by Side Diff: cc/output/bsp_tree_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 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
« no previous file with comments | « cc/output/bsp_tree.cc ('k') | cc/output/bsp_walk_action.h » ('j') | 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 "cc/output/bsp_tree.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
7 #include <deque> 9 #include <deque>
10 #include <memory>
8 11
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/output/bsp_tree.h"
12 #include "cc/output/bsp_walk_action.h" 13 #include "cc/output/bsp_walk_action.h"
13 #include "cc/quads/draw_polygon.h" 14 #include "cc/quads/draw_polygon.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace cc { 17 namespace cc {
17 namespace { 18 namespace {
18 19
19 #define EXPECT_SORTED_LISTS_EQ(polygon_list, compare_list) \ 20 #define EXPECT_SORTED_LISTS_EQ(polygon_list, compare_list) \
20 do { \ 21 do { \
21 EXPECT_EQ(polygon_list.size(), compare_list.size()); \ 22 EXPECT_EQ(polygon_list.size(), compare_list.size()); \
22 for (unsigned int i = 0; i < polygon_list.size(); i++) { \ 23 for (unsigned int i = 0; i < polygon_list.size(); i++) { \
23 EXPECT_EQ(polygon_list[i]->order_index(), compare_list[i]); \ 24 EXPECT_EQ(polygon_list[i]->order_index(), compare_list[i]); \
24 } \ 25 } \
25 } while (false); 26 } while (false);
26 27
27 #define INT_VECTOR_FROM_ARRAY(array) \ 28 #define INT_VECTOR_FROM_ARRAY(array) \
28 std::vector<int>(array, array + arraysize(array)) 29 std::vector<int>(array, array + arraysize(array))
29 30
30 #define CREATE_DRAW_POLYGON(vertex_vector, normal, polygon_id) \ 31 #define CREATE_DRAW_POLYGON(vertex_vector, normal, polygon_id) \
31 new DrawPolygon(NULL, vertex_vector, normal, polygon_id) 32 new DrawPolygon(NULL, vertex_vector, normal, polygon_id)
32 33
33 class BspTreeTest { 34 class BspTreeTest {
34 public: 35 public:
35 static void RunTest(std::deque<scoped_ptr<DrawPolygon>>* test_polygons, 36 static void RunTest(std::deque<std::unique_ptr<DrawPolygon>>* test_polygons,
36 const std::vector<int>& compare_list) { 37 const std::vector<int>& compare_list) {
37 BspTree bsp_tree(test_polygons); 38 BspTree bsp_tree(test_polygons);
38 39
39 std::vector<DrawPolygon*> sorted_list; 40 std::vector<DrawPolygon*> sorted_list;
40 BspWalkActionToVector action_handler(&sorted_list); 41 BspWalkActionToVector action_handler(&sorted_list);
41 bsp_tree.TraverseWithActionHandler(&action_handler); 42 bsp_tree.TraverseWithActionHandler(&action_handler);
42 43
43 EXPECT_SORTED_LISTS_EQ(sorted_list, compare_list); 44 EXPECT_SORTED_LISTS_EQ(sorted_list, compare_list);
44 EXPECT_TRUE(VerifySidedness(bsp_tree.root())); 45 EXPECT_TRUE(VerifySidedness(bsp_tree.root()));
45 } 46 }
46 47
47 static bool VerifySidedness(const scoped_ptr<BspNode>& node) { 48 static bool VerifySidedness(const std::unique_ptr<BspNode>& node) {
48 // We check if both the front and back child nodes have geometry that is 49 // We check if both the front and back child nodes have geometry that is
49 // completely on the expected side of the current node. 50 // completely on the expected side of the current node.
50 bool front_ok = true; 51 bool front_ok = true;
51 bool back_ok = true; 52 bool back_ok = true;
52 if (node->back_child) { 53 if (node->back_child) {
53 // Make sure the back child lies entirely behind this node. 54 // Make sure the back child lies entirely behind this node.
54 BspCompareResult result = DrawPolygon::SideCompare( 55 BspCompareResult result = DrawPolygon::SideCompare(
55 *(node->back_child->node_data), *(node->node_data)); 56 *(node->back_child->node_data), *(node->node_data));
56 if (result != BSP_BACK) { 57 if (result != BSP_BACK) {
57 return false; 58 return false;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 vertices_b.push_back(gfx::Point3F(0.0f, 10.0f, -5.0f)); 102 vertices_b.push_back(gfx::Point3F(0.0f, 10.0f, -5.0f));
102 vertices_b.push_back(gfx::Point3F(0.0f, 0.0f, -5.0f)); 103 vertices_b.push_back(gfx::Point3F(0.0f, 0.0f, -5.0f));
103 vertices_b.push_back(gfx::Point3F(10.0f, 0.0f, -5.0f)); 104 vertices_b.push_back(gfx::Point3F(10.0f, 0.0f, -5.0f));
104 vertices_b.push_back(gfx::Point3F(10.0f, 10.0f, -5.0f)); 105 vertices_b.push_back(gfx::Point3F(10.0f, 10.0f, -5.0f));
105 std::vector<gfx::Point3F> vertices_c; 106 std::vector<gfx::Point3F> vertices_c;
106 vertices_c.push_back(gfx::Point3F(0.0f, 10.0f, 5.0f)); 107 vertices_c.push_back(gfx::Point3F(0.0f, 10.0f, 5.0f));
107 vertices_c.push_back(gfx::Point3F(0.0f, 0.0f, 5.0f)); 108 vertices_c.push_back(gfx::Point3F(0.0f, 0.0f, 5.0f));
108 vertices_c.push_back(gfx::Point3F(10.0f, 0.0f, 5.0f)); 109 vertices_c.push_back(gfx::Point3F(10.0f, 0.0f, 5.0f));
109 vertices_c.push_back(gfx::Point3F(10.0f, 10.0f, 5.0f)); 110 vertices_c.push_back(gfx::Point3F(10.0f, 10.0f, 5.0f));
110 111
111 scoped_ptr<DrawPolygon> polygon_a( 112 std::unique_ptr<DrawPolygon> polygon_a(
112 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 113 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
113 scoped_ptr<DrawPolygon> polygon_b( 114 std::unique_ptr<DrawPolygon> polygon_b(
114 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1)); 115 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1));
115 scoped_ptr<DrawPolygon> polygon_c( 116 std::unique_ptr<DrawPolygon> polygon_c(
116 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2)); 117 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2));
117 118
118 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 119 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
119 polygon_list.push_back(std::move(polygon_a)); 120 polygon_list.push_back(std::move(polygon_a));
120 polygon_list.push_back(std::move(polygon_b)); 121 polygon_list.push_back(std::move(polygon_b));
121 polygon_list.push_back(std::move(polygon_c)); 122 polygon_list.push_back(std::move(polygon_c));
122 123
123 int compare_ids[] = {1, 0, 2}; 124 int compare_ids[] = {1, 0, 2};
124 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 125 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
125 BspTreeTest::RunTest(&polygon_list, compare_list); 126 BspTreeTest::RunTest(&polygon_list, compare_list);
126 } 127 }
127 128
128 // Basic two polygon split, can be viewed as a + from above. 129 // Basic two polygon split, can be viewed as a + from above.
129 TEST(BspTreeTest, BasicSplit) { 130 TEST(BspTreeTest, BasicSplit) {
130 std::vector<gfx::Point3F> vertices_a; 131 std::vector<gfx::Point3F> vertices_a;
131 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f)); 132 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f));
132 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f)); 133 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f));
133 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f)); 134 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f));
134 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f)); 135 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f));
135 std::vector<gfx::Point3F> vertices_b; 136 std::vector<gfx::Point3F> vertices_b;
136 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -5.0f)); 137 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -5.0f));
137 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -5.0f)); 138 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -5.0f));
138 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, 5.0f)); 139 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, 5.0f));
139 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, 5.0f)); 140 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, 5.0f));
140 141
141 scoped_ptr<DrawPolygon> polygon_a( 142 std::unique_ptr<DrawPolygon> polygon_a(
142 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 143 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
143 scoped_ptr<DrawPolygon> polygon_b( 144 std::unique_ptr<DrawPolygon> polygon_b(
144 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); 145 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1));
145 146
146 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 147 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
147 polygon_list.push_back(std::move(polygon_a)); 148 polygon_list.push_back(std::move(polygon_a));
148 polygon_list.push_back(std::move(polygon_b)); 149 polygon_list.push_back(std::move(polygon_b));
149 150
150 int compare_ids[] = {1, 0, 1}; 151 int compare_ids[] = {1, 0, 1};
151 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 152 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
152 BspTreeTest::RunTest(&polygon_list, compare_list); 153 BspTreeTest::RunTest(&polygon_list, compare_list);
153 } 154 }
154 155
155 // Same as above with the second quad offset so it doesn't intersect. One quad 156 // Same as above with the second quad offset so it doesn't intersect. One quad
156 // should be very clearly on one side of the other, and no splitting should 157 // should be very clearly on one side of the other, and no splitting should
157 // occur. 158 // occur.
158 TEST(BspTreeTest, QuadOffset) { 159 TEST(BspTreeTest, QuadOffset) {
159 std::vector<gfx::Point3F> vertices_a; 160 std::vector<gfx::Point3F> vertices_a;
160 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f)); 161 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f));
161 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f)); 162 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f));
162 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f)); 163 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f));
163 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f)); 164 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f));
164 std::vector<gfx::Point3F> vertices_b; 165 std::vector<gfx::Point3F> vertices_b;
165 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -15.0f)); 166 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -15.0f));
166 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -15.0f)); 167 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -15.0f));
167 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -10.0f)); 168 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -10.0f));
168 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -10.0f)); 169 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -10.0f));
169 170
170 scoped_ptr<DrawPolygon> polygon_a( 171 std::unique_ptr<DrawPolygon> polygon_a(
171 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 172 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
172 scoped_ptr<DrawPolygon> polygon_b( 173 std::unique_ptr<DrawPolygon> polygon_b(
173 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); 174 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1));
174 175
175 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 176 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
176 polygon_list.push_back(std::move(polygon_a)); 177 polygon_list.push_back(std::move(polygon_a));
177 polygon_list.push_back(std::move(polygon_b)); 178 polygon_list.push_back(std::move(polygon_b));
178 179
179 int compare_ids[] = {1, 0}; 180 int compare_ids[] = {1, 0};
180 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 181 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
181 BspTreeTest::RunTest(&polygon_list, compare_list); 182 BspTreeTest::RunTest(&polygon_list, compare_list);
182 } 183 }
183 184
184 // Same as above, but this time we change the order in which the quads are 185 // Same as above, but this time we change the order in which the quads are
185 // inserted into the tree, causing one to actually cross the plane of the other 186 // inserted into the tree, causing one to actually cross the plane of the other
186 // and cause a split. 187 // and cause a split.
187 TEST(BspTreeTest, QuadOffsetSplit) { 188 TEST(BspTreeTest, QuadOffsetSplit) {
188 std::vector<gfx::Point3F> vertices_a; 189 std::vector<gfx::Point3F> vertices_a;
189 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f)); 190 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f));
190 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f)); 191 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f));
191 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f)); 192 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f));
192 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f)); 193 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f));
193 std::vector<gfx::Point3F> vertices_b; 194 std::vector<gfx::Point3F> vertices_b;
194 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -15.0f)); 195 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -15.0f));
195 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -15.0f)); 196 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -15.0f));
196 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -10.0f)); 197 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -10.0f));
197 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -10.0f)); 198 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -10.0f));
198 199
199 scoped_ptr<DrawPolygon> polygon_a( 200 std::unique_ptr<DrawPolygon> polygon_a(
200 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 201 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
201 scoped_ptr<DrawPolygon> polygon_b( 202 std::unique_ptr<DrawPolygon> polygon_b(
202 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); 203 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1));
203 204
204 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 205 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
205 polygon_list.push_back(std::move(polygon_b)); 206 polygon_list.push_back(std::move(polygon_b));
206 polygon_list.push_back(std::move(polygon_a)); 207 polygon_list.push_back(std::move(polygon_a));
207 208
208 int compare_ids[] = {0, 1, 0}; 209 int compare_ids[] = {0, 1, 0};
209 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 210 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
210 BspTreeTest::RunTest(&polygon_list, compare_list); 211 BspTreeTest::RunTest(&polygon_list, compare_list);
211 } 212 }
212 213
213 // In addition to what can be viewed as a + from above, another piece of 214 // In addition to what can be viewed as a + from above, another piece of
214 // geometry is inserted to cut these pieces right in the middle, viewed as 215 // geometry is inserted to cut these pieces right in the middle, viewed as
215 // a quad from overhead. 216 // a quad from overhead.
216 TEST(BspTreeTest, ThreeWaySplit) { 217 TEST(BspTreeTest, ThreeWaySplit) {
217 std::vector<gfx::Point3F> vertices_a; 218 std::vector<gfx::Point3F> vertices_a;
218 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f)); 219 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f));
219 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f)); 220 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f));
220 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f)); 221 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f));
221 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f)); 222 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f));
222 std::vector<gfx::Point3F> vertices_b; 223 std::vector<gfx::Point3F> vertices_b;
223 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -5.0f)); 224 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, -5.0f));
224 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -5.0f)); 225 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, -5.0f));
225 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, 5.0f)); 226 vertices_b.push_back(gfx::Point3F(0.0f, 5.0f, 5.0f));
226 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, 5.0f)); 227 vertices_b.push_back(gfx::Point3F(0.0f, -5.0f, 5.0f));
227 std::vector<gfx::Point3F> vertices_c; 228 std::vector<gfx::Point3F> vertices_c;
228 vertices_c.push_back(gfx::Point3F(-5.0f, 0.0f, -5.0f)); 229 vertices_c.push_back(gfx::Point3F(-5.0f, 0.0f, -5.0f));
229 vertices_c.push_back(gfx::Point3F(-5.0f, 0.0f, 5.0f)); 230 vertices_c.push_back(gfx::Point3F(-5.0f, 0.0f, 5.0f));
230 vertices_c.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f)); 231 vertices_c.push_back(gfx::Point3F(5.0f, 0.0f, 5.0f));
231 vertices_c.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f)); 232 vertices_c.push_back(gfx::Point3F(5.0f, 0.0f, -5.0f));
232 233
233 scoped_ptr<DrawPolygon> polygon_a( 234 std::unique_ptr<DrawPolygon> polygon_a(
234 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 235 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
235 scoped_ptr<DrawPolygon> polygon_b( 236 std::unique_ptr<DrawPolygon> polygon_b(
236 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1)); 237 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 1));
237 scoped_ptr<DrawPolygon> polygon_c( 238 std::unique_ptr<DrawPolygon> polygon_c(
238 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 1.0f, 0.0f), 2)); 239 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 1.0f, 0.0f), 2));
239 240
240 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 241 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
241 polygon_list.push_back(std::move(polygon_a)); 242 polygon_list.push_back(std::move(polygon_a));
242 polygon_list.push_back(std::move(polygon_b)); 243 polygon_list.push_back(std::move(polygon_b));
243 polygon_list.push_back(std::move(polygon_c)); 244 polygon_list.push_back(std::move(polygon_c));
244 245
245 int compare_ids[] = {2, 1, 2, 0, 2, 1, 2}; 246 int compare_ids[] = {2, 1, 2, 0, 2, 1, 2};
246 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 247 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
247 BspTreeTest::RunTest(&polygon_list, compare_list); 248 BspTreeTest::RunTest(&polygon_list, compare_list);
248 } 249 }
249 250
250 // This test checks whether coplanar geometry, when inserted into the tree in 251 // This test checks whether coplanar geometry, when inserted into the tree in
251 // order, comes back in the same order as it should. 252 // order, comes back in the same order as it should.
252 TEST(BspTreeTest, Coplanar) { 253 TEST(BspTreeTest, Coplanar) {
253 std::vector<gfx::Point3F> vertices_a; 254 std::vector<gfx::Point3F> vertices_a;
254 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f)); 255 vertices_a.push_back(gfx::Point3F(-5.0f, -5.0f, 0.0f));
255 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f)); 256 vertices_a.push_back(gfx::Point3F(-5.0f, 5.0f, 0.0f));
256 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f)); 257 vertices_a.push_back(gfx::Point3F(5.0f, 5.0f, 0.0f));
257 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f)); 258 vertices_a.push_back(gfx::Point3F(5.0f, -5.0f, 0.0f));
258 std::vector<gfx::Point3F> vertices_b; 259 std::vector<gfx::Point3F> vertices_b;
259 vertices_b.push_back(gfx::Point3F(-4.0f, -4.0f, 0.0f)); 260 vertices_b.push_back(gfx::Point3F(-4.0f, -4.0f, 0.0f));
260 vertices_b.push_back(gfx::Point3F(-4.0f, 4.0f, 0.0f)); 261 vertices_b.push_back(gfx::Point3F(-4.0f, 4.0f, 0.0f));
261 vertices_b.push_back(gfx::Point3F(4.0f, 4.0f, 0.0f)); 262 vertices_b.push_back(gfx::Point3F(4.0f, 4.0f, 0.0f));
262 vertices_b.push_back(gfx::Point3F(4.0f, -4.0f, 0.0f)); 263 vertices_b.push_back(gfx::Point3F(4.0f, -4.0f, 0.0f));
263 std::vector<gfx::Point3F> vertices_c; 264 std::vector<gfx::Point3F> vertices_c;
264 vertices_c.push_back(gfx::Point3F(-3.0f, -3.0f, 0.0f)); 265 vertices_c.push_back(gfx::Point3F(-3.0f, -3.0f, 0.0f));
265 vertices_c.push_back(gfx::Point3F(-3.0f, 3.0f, 0.0f)); 266 vertices_c.push_back(gfx::Point3F(-3.0f, 3.0f, 0.0f));
266 vertices_c.push_back(gfx::Point3F(3.0f, 3.0f, 0.0f)); 267 vertices_c.push_back(gfx::Point3F(3.0f, 3.0f, 0.0f));
267 vertices_c.push_back(gfx::Point3F(3.0f, -3.0f, 0.0f)); 268 vertices_c.push_back(gfx::Point3F(3.0f, -3.0f, 0.0f));
268 269
269 scoped_ptr<DrawPolygon> polygon_a( 270 std::unique_ptr<DrawPolygon> polygon_a(
270 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 271 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
271 scoped_ptr<DrawPolygon> polygon_b( 272 std::unique_ptr<DrawPolygon> polygon_b(
272 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1)); 273 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1));
273 scoped_ptr<DrawPolygon> polygon_c( 274 std::unique_ptr<DrawPolygon> polygon_c(
274 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2)); 275 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2));
275 276
276 scoped_ptr<DrawPolygon> polygon_d = polygon_a->CreateCopy(); 277 std::unique_ptr<DrawPolygon> polygon_d = polygon_a->CreateCopy();
277 scoped_ptr<DrawPolygon> polygon_e = polygon_b->CreateCopy(); 278 std::unique_ptr<DrawPolygon> polygon_e = polygon_b->CreateCopy();
278 scoped_ptr<DrawPolygon> polygon_f = polygon_c->CreateCopy(); 279 std::unique_ptr<DrawPolygon> polygon_f = polygon_c->CreateCopy();
279 280
280 { 281 {
281 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 282 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
282 polygon_list.push_back(std::move(polygon_a)); 283 polygon_list.push_back(std::move(polygon_a));
283 polygon_list.push_back(std::move(polygon_b)); 284 polygon_list.push_back(std::move(polygon_b));
284 polygon_list.push_back(std::move(polygon_c)); 285 polygon_list.push_back(std::move(polygon_c));
285 286
286 int compare_ids[] = {0, 1, 2}; 287 int compare_ids[] = {0, 1, 2};
287 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 288 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
288 BspTreeTest::RunTest(&polygon_list, compare_list); 289 BspTreeTest::RunTest(&polygon_list, compare_list);
289 } 290 }
290 291
291 // Now check a different order and ensure we get that back as well 292 // Now check a different order and ensure we get that back as well
292 { 293 {
293 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 294 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
294 polygon_list.push_back(std::move(polygon_f)); 295 polygon_list.push_back(std::move(polygon_f));
295 polygon_list.push_back(std::move(polygon_d)); 296 polygon_list.push_back(std::move(polygon_d));
296 polygon_list.push_back(std::move(polygon_e)); 297 polygon_list.push_back(std::move(polygon_e));
297 298
298 int compare_ids[] = {0, 1, 2}; 299 int compare_ids[] = {0, 1, 2};
299 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 300 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
300 BspTreeTest::RunTest(&polygon_list, compare_list); 301 BspTreeTest::RunTest(&polygon_list, compare_list);
301 } 302 }
302 } 303 }
303 304
(...skipping 15 matching lines...) Expand all
319 vertices_c.push_back(gfx::Point3F(-3.0f, -3.0f, 0.0f)); 320 vertices_c.push_back(gfx::Point3F(-3.0f, -3.0f, 0.0f));
320 vertices_c.push_back(gfx::Point3F(-3.0f, 3.0f, 0.0f)); 321 vertices_c.push_back(gfx::Point3F(-3.0f, 3.0f, 0.0f));
321 vertices_c.push_back(gfx::Point3F(3.0f, 3.0f, 0.0f)); 322 vertices_c.push_back(gfx::Point3F(3.0f, 3.0f, 0.0f));
322 vertices_c.push_back(gfx::Point3F(3.0f, -3.0f, 0.0f)); 323 vertices_c.push_back(gfx::Point3F(3.0f, -3.0f, 0.0f));
323 std::vector<gfx::Point3F> vertices_d; 324 std::vector<gfx::Point3F> vertices_d;
324 vertices_d.push_back(gfx::Point3F(0.0f, -15.0f, -15.0f)); 325 vertices_d.push_back(gfx::Point3F(0.0f, -15.0f, -15.0f));
325 vertices_d.push_back(gfx::Point3F(0.0f, 15.0f, -15.0f)); 326 vertices_d.push_back(gfx::Point3F(0.0f, 15.0f, -15.0f));
326 vertices_d.push_back(gfx::Point3F(0.0f, 15.0f, 15.0f)); 327 vertices_d.push_back(gfx::Point3F(0.0f, 15.0f, 15.0f));
327 vertices_d.push_back(gfx::Point3F(0.0f, -15.0f, 15.0f)); 328 vertices_d.push_back(gfx::Point3F(0.0f, -15.0f, 15.0f));
328 329
329 scoped_ptr<DrawPolygon> polygon_a( 330 std::unique_ptr<DrawPolygon> polygon_a(
330 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0)); 331 CREATE_DRAW_POLYGON(vertices_a, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 0));
331 scoped_ptr<DrawPolygon> polygon_b( 332 std::unique_ptr<DrawPolygon> polygon_b(
332 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1)); 333 CREATE_DRAW_POLYGON(vertices_b, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 1));
333 scoped_ptr<DrawPolygon> polygon_c( 334 std::unique_ptr<DrawPolygon> polygon_c(
334 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2)); 335 CREATE_DRAW_POLYGON(vertices_c, gfx::Vector3dF(0.0f, 0.0f, 1.0f), 2));
335 scoped_ptr<DrawPolygon> polygon_d( 336 std::unique_ptr<DrawPolygon> polygon_d(
336 CREATE_DRAW_POLYGON(vertices_d, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 3)); 337 CREATE_DRAW_POLYGON(vertices_d, gfx::Vector3dF(-1.0f, 0.0f, 0.0f), 3));
337 338
338 std::deque<scoped_ptr<DrawPolygon>> polygon_list; 339 std::deque<std::unique_ptr<DrawPolygon>> polygon_list;
339 polygon_list.push_back(std::move(polygon_a)); 340 polygon_list.push_back(std::move(polygon_a));
340 polygon_list.push_back(std::move(polygon_b)); 341 polygon_list.push_back(std::move(polygon_b));
341 polygon_list.push_back(std::move(polygon_c)); 342 polygon_list.push_back(std::move(polygon_c));
342 polygon_list.push_back(std::move(polygon_d)); 343 polygon_list.push_back(std::move(polygon_d));
343 344
344 int compare_ids[] = {3, 0, 1, 2, 3}; 345 int compare_ids[] = {3, 0, 1, 2, 3};
345 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids); 346 std::vector<int> compare_list = INT_VECTOR_FROM_ARRAY(compare_ids);
346 BspTreeTest::RunTest(&polygon_list, compare_list); 347 BspTreeTest::RunTest(&polygon_list, compare_list);
347 } 348 }
348 349
349 } // namespace 350 } // namespace
350 } // namespace cc 351 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/bsp_tree.cc ('k') | cc/output/bsp_walk_action.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698