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/tree_synchronizer.h" | 5 #include "cc/trees/tree_synchronizer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 layer_tree_root->AddChild(Layer::Create()); | 280 layer_tree_root->AddChild(Layer::Create()); |
281 layer_tree_root->AddChild(Layer::Create()); | 281 layer_tree_root->AddChild(Layer::Create()); |
282 | 282 |
283 host_->SetRootLayer(layer_tree_root); | 283 host_->SetRootLayer(layer_tree_root); |
284 | 284 |
285 // Pick some random properties to set. The values are not important, we're | 285 // Pick some random properties to set. The values are not important, we're |
286 // just testing that at least some properties are making it through. | 286 // just testing that at least some properties are making it through. |
287 gfx::PointF root_position = gfx::PointF(2.3f, 7.4f); | 287 gfx::PointF root_position = gfx::PointF(2.3f, 7.4f); |
288 layer_tree_root->SetPosition(root_position); | 288 layer_tree_root->SetPosition(root_position); |
289 | 289 |
290 float first_child_opacity = 0.25f; | |
291 layer_tree_root->children()[0]->SetOpacity(first_child_opacity); | |
292 | |
293 gfx::Size second_child_bounds = gfx::Size(25, 53); | 290 gfx::Size second_child_bounds = gfx::Size(25, 53); |
294 layer_tree_root->children()[1]->SetBounds(second_child_bounds); | 291 layer_tree_root->children()[1]->SetBounds(second_child_bounds); |
295 layer_tree_root->children()[1]->SavePaintProperties(); | 292 layer_tree_root->children()[1]->SavePaintProperties(); |
296 | 293 |
297 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 294 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
298 host_->active_tree()); | 295 host_->active_tree()); |
299 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); | 296 LayerImpl* layer_impl_tree_root = host_->active_tree()->root_layer(); |
300 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, | 297 ExpectTreesAreIdentical(layer_tree_root.get(), layer_impl_tree_root, |
301 host_->active_tree()); | 298 host_->active_tree()); |
302 | 299 |
303 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), | 300 TreeSynchronizer::PushLayerProperties(layer_tree_root->layer_tree_host(), |
304 host_->active_tree()); | 301 host_->active_tree()); |
305 | 302 |
306 // Check that the property values we set on the Layer tree are reflected in | 303 // Check that the property values we set on the Layer tree are reflected in |
307 // the LayerImpl tree. | 304 // the LayerImpl tree. |
308 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); | 305 gfx::PointF root_layer_impl_position = layer_impl_tree_root->position(); |
309 EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); | 306 EXPECT_EQ(root_position.x(), root_layer_impl_position.x()); |
310 EXPECT_EQ(root_position.y(), root_layer_impl_position.y()); | 307 EXPECT_EQ(root_position.y(), root_layer_impl_position.y()); |
311 | 308 |
312 EXPECT_EQ(first_child_opacity, | |
313 layer_impl_tree_root->children()[0]->opacity()); | |
314 | |
315 gfx::Size second_layer_impl_child_bounds = | 309 gfx::Size second_layer_impl_child_bounds = |
316 layer_impl_tree_root->children()[1]->bounds(); | 310 layer_impl_tree_root->children()[1]->bounds(); |
317 EXPECT_EQ(second_child_bounds.width(), | 311 EXPECT_EQ(second_child_bounds.width(), |
318 second_layer_impl_child_bounds.width()); | 312 second_layer_impl_child_bounds.width()); |
319 EXPECT_EQ(second_child_bounds.height(), | 313 EXPECT_EQ(second_child_bounds.height(), |
320 second_layer_impl_child_bounds.height()); | 314 second_layer_impl_child_bounds.height()); |
321 } | 315 } |
322 | 316 |
323 TEST_F(TreeSynchronizerTest, ReuseLayerImplsAfterStructuralChange) { | 317 TEST_F(TreeSynchronizerTest, ReuseLayerImplsAfterStructuralChange) { |
324 std::vector<int> layer_impl_destruction_list; | 318 std::vector<int> layer_impl_destruction_list; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); | 626 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); |
633 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); | 627 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); |
634 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( | 628 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( |
635 gfx::ScrollOffset(100, 100)); | 629 gfx::ScrollOffset(100, 100)); |
636 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); | 630 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); |
637 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); | 631 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); |
638 } | 632 } |
639 | 633 |
640 } // namespace | 634 } // namespace |
641 } // namespace cc | 635 } // namespace cc |
OLD | NEW |