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