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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(IntSize(10, 10)); |
218 layer1->setContentBounds(IntSize(10, 10)); | |
219 layer1->setDrawTransform(BehindMatrix); | 218 layer1->setDrawTransform(BehindMatrix); |
220 layer1->setDrawsContent(true); | 219 layer1->setDrawsContent(true); |
221 | 220 |
222 layer2->setBounds(IntSize(20, 20)); | 221 layer2->setBounds(IntSize(20, 20)); |
223 layer2->setContentBounds(IntSize(20, 20)); | |
224 layer2->setDrawTransform(BehindMatrix); | 222 layer2->setDrawTransform(BehindMatrix); |
225 layer2->setDrawsContent(true); | 223 layer2->setDrawsContent(true); |
226 | 224 |
227 layer3->setBounds(IntSize(30, 30)); | 225 layer3->setBounds(IntSize(30, 30)); |
228 layer3->setContentBounds(IntSize(30, 30)); | |
229 layer3->setDrawTransform(FrontMatrix); | 226 layer3->setDrawTransform(FrontMatrix); |
230 layer3->setDrawsContent(true); | 227 layer3->setDrawsContent(true); |
231 | 228 |
232 layer4->setBounds(IntSize(40, 40)); | 229 layer4->setBounds(IntSize(40, 40)); |
233 layer4->setContentBounds(IntSize(40, 40)); | |
234 layer4->setDrawTransform(FrontMatrix); | 230 layer4->setDrawTransform(FrontMatrix); |
235 layer4->setDrawsContent(true); | 231 layer4->setDrawsContent(true); |
236 | 232 |
237 layer5->setBounds(IntSize(50, 50)); | 233 layer5->setBounds(IntSize(50, 50)); |
238 layer5->setContentBounds(IntSize(50, 50)); | |
239 layer5->setDrawTransform(BehindMatrix); | 234 layer5->setDrawTransform(BehindMatrix); |
240 layer5->setDrawsContent(true); | 235 layer5->setDrawsContent(true); |
241 | 236 |
242 std::vector<LayerImpl*> layerList; | 237 std::vector<LayerImpl*> layerList; |
243 layerList.push_back(layer1.get()); | 238 layerList.push_back(layer1.get()); |
244 layerList.push_back(layer2.get()); | 239 layerList.push_back(layer2.get()); |
245 layerList.push_back(layer3.get()); | 240 layerList.push_back(layer3.get()); |
246 layerList.push_back(layer4.get()); | 241 layerList.push_back(layer4.get()); |
247 layerList.push_back(layer5.get()); | 242 layerList.push_back(layer5.get()); |
248 | 243 |
249 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 244 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
250 EXPECT_EQ(1, layerList[0]->id()); | 245 EXPECT_EQ(1, layerList[0]->id()); |
251 EXPECT_EQ(2, layerList[1]->id()); | 246 EXPECT_EQ(2, layerList[1]->id()); |
252 EXPECT_EQ(3, layerList[2]->id()); | 247 EXPECT_EQ(3, layerList[2]->id()); |
253 EXPECT_EQ(4, layerList[3]->id()); | 248 EXPECT_EQ(4, layerList[3]->id()); |
254 EXPECT_EQ(5, layerList[4]->id()); | 249 EXPECT_EQ(5, layerList[4]->id()); |
255 | 250 |
256 LayerSorter layerSorter; | 251 LayerSorter layerSorter; |
257 layerSorter.sort(layerList.begin(), layerList.end()); | 252 layerSorter.sort(layerList.begin(), layerList.end()); |
258 | 253 |
259 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 254 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
260 EXPECT_EQ(3, layerList[0]->id()); | 255 EXPECT_EQ(3, layerList[0]->id()); |
261 EXPECT_EQ(4, layerList[1]->id()); | 256 EXPECT_EQ(4, layerList[1]->id()); |
262 EXPECT_EQ(1, layerList[2]->id()); | 257 EXPECT_EQ(1, layerList[2]->id()); |
263 EXPECT_EQ(2, layerList[3]->id()); | 258 EXPECT_EQ(2, layerList[3]->id()); |
264 EXPECT_EQ(5, layerList[4]->id()); | 259 EXPECT_EQ(5, layerList[4]->id()); |
265 } | 260 } |
266 | 261 |
267 } // namespace | 262 } // namespace |
OLD | NEW |