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 "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 layerSorter.sort(layerList.begin(), layerList.end()); | 256 layerSorter.sort(layerList.begin(), layerList.end()); |
257 | 257 |
258 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); | 258 ASSERT_EQ(static_cast<size_t>(5), layerList.size()); |
259 EXPECT_EQ(3, layerList[0]->id()); | 259 EXPECT_EQ(3, layerList[0]->id()); |
260 EXPECT_EQ(4, layerList[1]->id()); | 260 EXPECT_EQ(4, layerList[1]->id()); |
261 EXPECT_EQ(1, layerList[2]->id()); | 261 EXPECT_EQ(1, layerList[2]->id()); |
262 EXPECT_EQ(2, layerList[3]->id()); | 262 EXPECT_EQ(2, layerList[3]->id()); |
263 EXPECT_EQ(5, layerList[4]->id()); | 263 EXPECT_EQ(5, layerList[4]->id()); |
264 } | 264 } |
265 | 265 |
| 266 TEST(LayerSorterTest, verifyConcidentLayerPrecisionLossResultsInDocumentOrder) |
| 267 { |
| 268 FakeImplProxy proxy; |
| 269 FakeLayerTreeHostImpl hostImpl(&proxy); |
| 270 |
| 271 scoped_ptr<LayerImpl> layer1 = LayerImpl::create(hostImpl.activeTree(), 1); |
| 272 scoped_ptr<LayerImpl> layer2 = LayerImpl::create(hostImpl.activeTree(), 2); |
| 273 |
| 274 // Layer 1 should occur before layer 2 in paint. However, due to numeric |
| 275 // issues in the sorter, it will put the layers in the wrong order |
| 276 // in some situations. Here we test a patch that results in document |
| 277 // order rather than calculated order when numeric percision is suspect |
| 278 // in calculated order. |
| 279 |
| 280 gfx::Transform BehindMatrix; |
| 281 BehindMatrix.Translate3d(0, 0, 0.999999f); |
| 282 BehindMatrix.RotateAboutXAxis(38.5f); |
| 283 BehindMatrix.RotateAboutYAxis(77.0f); |
| 284 gfx::Transform FrontMatrix; |
| 285 FrontMatrix.Translate3d(0, 0, 1.0f); |
| 286 FrontMatrix.RotateAboutXAxis(38.5f); |
| 287 FrontMatrix.RotateAboutYAxis(77.0f); |
| 288 |
| 289 layer1->setBounds(gfx::Size(10, 10)); |
| 290 layer1->setContentBounds(gfx::Size(10, 10)); |
| 291 layer1->drawProperties().target_space_transform = BehindMatrix; |
| 292 layer1->setDrawsContent(true); |
| 293 |
| 294 layer2->setBounds(gfx::Size(10, 10)); |
| 295 layer2->setContentBounds(gfx::Size(10, 10)); |
| 296 layer2->drawProperties().target_space_transform = FrontMatrix; |
| 297 layer2->setDrawsContent(true); |
| 298 |
| 299 std::vector<LayerImpl*> layerList; |
| 300 layerList.push_back(layer1.get()); |
| 301 layerList.push_back(layer2.get()); |
| 302 |
| 303 ASSERT_EQ(static_cast<size_t>(2), layerList.size()); |
| 304 EXPECT_EQ(1, layerList[0]->id()); |
| 305 EXPECT_EQ(2, layerList[1]->id()); |
| 306 |
| 307 LayerSorter layerSorter; |
| 308 layerSorter.sort(layerList.begin(), layerList.end()); |
| 309 |
| 310 ASSERT_EQ(static_cast<size_t>(2), layerList.size()); |
| 311 EXPECT_EQ(1, layerList[0]->id()); |
| 312 EXPECT_EQ(2, layerList[1]->id()); |
| 313 } |
| 314 |
266 } // namespace | 315 } // namespace |
267 } // namespace cc | 316 } // namespace cc |
| 317 |
OLD | NEW |