OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_sorter.h" | 5 #include "cc/layer_sorter.h" |
6 | 6 |
7 #include "cc/layer_impl.h" | 7 #include "cc/layer_impl.h" |
8 #include "cc/math_util.h" | 8 #include "cc/math_util.h" |
9 #include "cc/single_thread_proxy.h" | 9 #include "cc/single_thread_proxy.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 scoped_ptr<LayerImpl> layer4 = LayerImpl::create(4); | 203 scoped_ptr<LayerImpl> layer4 = LayerImpl::create(4); |
204 scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5); | 204 scoped_ptr<LayerImpl> layer5 = LayerImpl::create(5); |
205 | 205 |
206 gfx::Transform BehindMatrix; | 206 gfx::Transform BehindMatrix; |
207 BehindMatrix.Translate3d(0, 0, 2); | 207 BehindMatrix.Translate3d(0, 0, 2); |
208 gfx::Transform FrontMatrix; | 208 gfx::Transform FrontMatrix; |
209 FrontMatrix.Translate3d(0, 0, 1); | 209 FrontMatrix.Translate3d(0, 0, 1); |
210 | 210 |
211 layer1->setBounds(gfx::Size(10, 10)); | 211 layer1->setBounds(gfx::Size(10, 10)); |
212 layer1->setContentBounds(gfx::Size(10, 10)); | 212 layer1->setContentBounds(gfx::Size(10, 10)); |
213 layer1->setDrawTransform(BehindMatrix); | 213 layer1->drawProperties().target_space_transform = BehindMatrix; |
214 layer1->setDrawsContent(true); | 214 layer1->setDrawsContent(true); |
215 | 215 |
216 layer2->setBounds(gfx::Size(20, 20)); | 216 layer2->setBounds(gfx::Size(20, 20)); |
217 layer2->setContentBounds(gfx::Size(20, 20)); | 217 layer2->setContentBounds(gfx::Size(20, 20)); |
218 layer2->setDrawTransform(BehindMatrix); | 218 layer2->drawProperties().target_space_transform = BehindMatrix; |
219 layer2->setDrawsContent(true); | 219 layer2->setDrawsContent(true); |
220 | 220 |
221 layer3->setBounds(gfx::Size(30, 30)); | 221 layer3->setBounds(gfx::Size(30, 30)); |
222 layer3->setContentBounds(gfx::Size(30, 30)); | 222 layer3->setContentBounds(gfx::Size(30, 30)); |
223 layer3->setDrawTransform(FrontMatrix); | 223 layer3->drawProperties().target_space_transform = FrontMatrix; |
224 layer3->setDrawsContent(true); | 224 layer3->setDrawsContent(true); |
225 | 225 |
226 layer4->setBounds(gfx::Size(40, 40)); | 226 layer4->setBounds(gfx::Size(40, 40)); |
227 layer4->setContentBounds(gfx::Size(40, 40)); | 227 layer4->setContentBounds(gfx::Size(40, 40)); |
228 layer4->setDrawTransform(FrontMatrix); | 228 layer4->drawProperties().target_space_transform = FrontMatrix; |
229 layer4->setDrawsContent(true); | 229 layer4->setDrawsContent(true); |
230 | 230 |
231 layer5->setBounds(gfx::Size(50, 50)); | 231 layer5->setBounds(gfx::Size(50, 50)); |
232 layer5->setContentBounds(gfx::Size(50, 50)); | 232 layer5->setContentBounds(gfx::Size(50, 50)); |
233 layer5->setDrawTransform(BehindMatrix); | 233 layer5->drawProperties().target_space_transform = BehindMatrix; |
234 layer5->setDrawsContent(true); | 234 layer5->setDrawsContent(true); |
235 | 235 |
236 std::vector<LayerImpl*> layerList; | 236 std::vector<LayerImpl*> layerList; |
237 layerList.push_back(layer1.get()); | 237 layerList.push_back(layer1.get()); |
238 layerList.push_back(layer2.get()); | 238 layerList.push_back(layer2.get()); |
239 layerList.push_back(layer3.get()); | 239 layerList.push_back(layer3.get()); |
240 layerList.push_back(layer4.get()); | 240 layerList.push_back(layer4.get()); |
241 layerList.push_back(layer5.get()); | 241 layerList.push_back(layer5.get()); |
242 | 242 |
243 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 243 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
244 EXPECT_EQ(1, layerList[0]->id()); | 244 EXPECT_EQ(1, layerList[0]->id()); |
245 EXPECT_EQ(2, layerList[1]->id()); | 245 EXPECT_EQ(2, layerList[1]->id()); |
246 EXPECT_EQ(3, layerList[2]->id()); | 246 EXPECT_EQ(3, layerList[2]->id()); |
247 EXPECT_EQ(4, layerList[3]->id()); | 247 EXPECT_EQ(4, layerList[3]->id()); |
248 EXPECT_EQ(5, layerList[4]->id()); | 248 EXPECT_EQ(5, layerList[4]->id()); |
249 | 249 |
250 LayerSorter layerSorter; | 250 LayerSorter layerSorter; |
251 layerSorter.sort(layerList.begin(), layerList.end()); | 251 layerSorter.sort(layerList.begin(), layerList.end()); |
252 | 252 |
253 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 253 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
254 EXPECT_EQ(3, layerList[0]->id()); | 254 EXPECT_EQ(3, layerList[0]->id()); |
255 EXPECT_EQ(4, layerList[1]->id()); | 255 EXPECT_EQ(4, layerList[1]->id()); |
256 EXPECT_EQ(1, layerList[2]->id()); | 256 EXPECT_EQ(1, layerList[2]->id()); |
257 EXPECT_EQ(2, layerList[3]->id()); | 257 EXPECT_EQ(2, layerList[3]->id()); |
258 EXPECT_EQ(5, layerList[4]->id()); | 258 EXPECT_EQ(5, layerList[4]->id()); |
259 } | 259 } |
260 | 260 |
261 } // namespace | 261 } // namespace |
262 } // namespace cc | 262 } // namespace cc |
OLD | NEW |