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/trees/layer_sorter.h" | 5 #include "cc/trees/layer_sorter.h" |
6 | 6 |
7 #include "cc/base/math_util.h" | 7 #include "cc/base/math_util.h" |
8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| 11 #include "cc/test/test_shared_bitmap_manager.h" |
11 #include "cc/trees/single_thread_proxy.h" | 12 #include "cc/trees/single_thread_proxy.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 namespace { | 17 namespace { |
17 | 18 |
18 // Note: In the following overlap tests, the "camera" is looking down the | 19 // Note: In the following overlap tests, the "camera" is looking down the |
19 // negative Z axis, meaning that layers with smaller z values (more negative) | 20 // negative Z axis, meaning that layers with smaller z values (more negative) |
20 // are further from the camera and therefore must be drawn before layers with | 21 // are further from the camera and therefore must be drawn before layers with |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 | 204 |
204 // Input list of layers: [1, 2, 3, 4, 5]. | 205 // Input list of layers: [1, 2, 3, 4, 5]. |
205 // Expected output: [3, 4, 1, 2, 5]. | 206 // Expected output: [3, 4, 1, 2, 5]. |
206 // - 1, 2, and 5 do not have a 3d z difference, and therefore their | 207 // - 1, 2, and 5 do not have a 3d z difference, and therefore their |
207 // relative ordering should be retained. | 208 // relative ordering should be retained. |
208 // - 3 and 4 do not have a 3d z difference, and therefore their relative | 209 // - 3 and 4 do not have a 3d z difference, and therefore their relative |
209 // ordering should be retained. | 210 // ordering should be retained. |
210 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. | 211 // - 3 and 4 should be re-sorted so they are in front of 1, 2, and 5. |
211 | 212 |
212 FakeImplProxy proxy; | 213 FakeImplProxy proxy; |
213 FakeLayerTreeHostImpl host_impl(&proxy); | 214 TestSharedBitmapManager shared_bitmap_manager; |
| 215 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
214 | 216 |
215 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.active_tree(), 1); | 217 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.active_tree(), 1); |
216 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.active_tree(), 2); | 218 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.active_tree(), 2); |
217 scoped_ptr<LayerImpl> layer3 = LayerImpl::Create(host_impl.active_tree(), 3); | 219 scoped_ptr<LayerImpl> layer3 = LayerImpl::Create(host_impl.active_tree(), 3); |
218 scoped_ptr<LayerImpl> layer4 = LayerImpl::Create(host_impl.active_tree(), 4); | 220 scoped_ptr<LayerImpl> layer4 = LayerImpl::Create(host_impl.active_tree(), 4); |
219 scoped_ptr<LayerImpl> layer5 = LayerImpl::Create(host_impl.active_tree(), 5); | 221 scoped_ptr<LayerImpl> layer5 = LayerImpl::Create(host_impl.active_tree(), 5); |
220 | 222 |
221 gfx::Transform BehindMatrix; | 223 gfx::Transform BehindMatrix; |
222 BehindMatrix.Translate3d(0.0, 0.0, 2.0); | 224 BehindMatrix.Translate3d(0.0, 0.0, 2.0); |
223 gfx::Transform FrontMatrix; | 225 gfx::Transform FrontMatrix; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 ASSERT_EQ(5u, layer_list.size()); | 270 ASSERT_EQ(5u, layer_list.size()); |
269 EXPECT_EQ(3, layer_list[0]->id()); | 271 EXPECT_EQ(3, layer_list[0]->id()); |
270 EXPECT_EQ(4, layer_list[1]->id()); | 272 EXPECT_EQ(4, layer_list[1]->id()); |
271 EXPECT_EQ(1, layer_list[2]->id()); | 273 EXPECT_EQ(1, layer_list[2]->id()); |
272 EXPECT_EQ(2, layer_list[3]->id()); | 274 EXPECT_EQ(2, layer_list[3]->id()); |
273 EXPECT_EQ(5, layer_list[4]->id()); | 275 EXPECT_EQ(5, layer_list[4]->id()); |
274 } | 276 } |
275 | 277 |
276 TEST(LayerSorterTest, VerifyConcidentLayerPrecisionLossResultsInDocumentOrder) { | 278 TEST(LayerSorterTest, VerifyConcidentLayerPrecisionLossResultsInDocumentOrder) { |
277 FakeImplProxy proxy; | 279 FakeImplProxy proxy; |
278 FakeLayerTreeHostImpl host_impl(&proxy); | 280 TestSharedBitmapManager shared_bitmap_manager; |
| 281 FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); |
279 | 282 |
280 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.active_tree(), 1); | 283 scoped_ptr<LayerImpl> layer1 = LayerImpl::Create(host_impl.active_tree(), 1); |
281 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.active_tree(), 2); | 284 scoped_ptr<LayerImpl> layer2 = LayerImpl::Create(host_impl.active_tree(), 2); |
282 | 285 |
283 // Layer 1 should occur before layer 2 in paint. However, due to numeric | 286 // Layer 1 should occur before layer 2 in paint. However, due to numeric |
284 // issues in the sorter, it will put the layers in the wrong order | 287 // issues in the sorter, it will put the layers in the wrong order |
285 // in some situations. Here we test a patch that results in document | 288 // in some situations. Here we test a patch that results in document |
286 // order rather than calculated order when numeric percision is suspect | 289 // order rather than calculated order when numeric percision is suspect |
287 // in calculated order. | 290 // in calculated order. |
288 | 291 |
(...skipping 28 matching lines...) Expand all Loading... |
317 layer_sorter.Sort(layer_list.begin(), layer_list.end()); | 320 layer_sorter.Sort(layer_list.begin(), layer_list.end()); |
318 | 321 |
319 ASSERT_EQ(2u, layer_list.size()); | 322 ASSERT_EQ(2u, layer_list.size()); |
320 EXPECT_EQ(1, layer_list[0]->id()); | 323 EXPECT_EQ(1, layer_list[0]->id()); |
321 EXPECT_EQ(2, layer_list[1]->id()); | 324 EXPECT_EQ(2, layer_list[1]->id()); |
322 } | 325 } |
323 | 326 |
324 } // namespace | 327 } // namespace |
325 } // namespace cc | 328 } // namespace cc |
326 | 329 |
OLD | NEW |