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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "cc/animation/layer_animation_controller.h" | 13 #include "cc/animation/layer_animation_controller.h" |
14 #include "cc/layers/layer.h" | 14 #include "cc/layers/layer.h" |
15 #include "cc/layers/layer_impl.h" | 15 #include "cc/layers/layer_impl.h" |
16 #include "cc/test/animation_test_common.h" | 16 #include "cc/test/animation_test_common.h" |
17 #include "cc/test/fake_impl_proxy.h" | 17 #include "cc/test/fake_impl_proxy.h" |
18 #include "cc/test/fake_layer_tree_host.h" | 18 #include "cc/test/fake_layer_tree_host.h" |
19 #include "cc/test/fake_rendering_stats_instrumentation.h" | 19 #include "cc/test/fake_rendering_stats_instrumentation.h" |
20 #include "cc/test/test_shared_bitmap_manager.h" | 20 #include "cc/test/test_shared_bitmap_manager.h" |
| 21 #include "cc/test/test_task_graph_runner.h" |
21 #include "cc/trees/proxy.h" | 22 #include "cc/trees/proxy.h" |
22 #include "cc/trees/single_thread_proxy.h" | 23 #include "cc/trees/single_thread_proxy.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
25 namespace cc { | 26 namespace cc { |
26 namespace { | 27 namespace { |
27 | 28 |
28 class MockLayerImpl : public LayerImpl { | 29 class MockLayerImpl : public LayerImpl { |
29 public: | 30 public: |
30 static scoped_ptr<MockLayerImpl> Create(LayerTreeImpl* tree_impl, | 31 static scoped_ptr<MockLayerImpl> Create(LayerTreeImpl* tree_impl, |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 SCOPED_TRACE(base::StringPrintf("child layer %" PRIuS, i).c_str()); | 189 SCOPED_TRACE(base::StringPrintf("child layer %" PRIuS, i).c_str()); |
189 ExpectTreesAreIdentical( | 190 ExpectTreesAreIdentical( |
190 layer_children[i].get(), layer_impl_children[i], tree_impl); | 191 layer_children[i].get(), layer_impl_children[i], tree_impl); |
191 } | 192 } |
192 } | 193 } |
193 | 194 |
194 class TreeSynchronizerTest : public testing::Test { | 195 class TreeSynchronizerTest : public testing::Test { |
195 public: | 196 public: |
196 TreeSynchronizerTest() | 197 TreeSynchronizerTest() |
197 : client_(FakeLayerTreeHostClient::DIRECT_3D), | 198 : client_(FakeLayerTreeHostClient::DIRECT_3D), |
198 host_(FakeLayerTreeHost::Create(&client_)) {} | 199 host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {} |
199 | 200 |
200 protected: | 201 protected: |
201 FakeLayerTreeHostClient client_; | 202 FakeLayerTreeHostClient client_; |
| 203 TestTaskGraphRunner task_graph_runner_; |
202 scoped_ptr<FakeLayerTreeHost> host_; | 204 scoped_ptr<FakeLayerTreeHost> host_; |
203 LayerSettings layer_settings_; | 205 LayerSettings layer_settings_; |
204 }; | 206 }; |
205 | 207 |
206 // Attempts to synchronizes a null tree. This should not crash, and should | 208 // Attempts to synchronizes a null tree. This should not crash, and should |
207 // return a null tree. | 209 // return a null tree. |
208 TEST_F(TreeSynchronizerTest, SyncNullTree) { | 210 TEST_F(TreeSynchronizerTest, SyncNullTree) { |
209 scoped_ptr<LayerImpl> layer_impl_tree_root = | 211 scoped_ptr<LayerImpl> layer_impl_tree_root = |
210 TreeSynchronizer::SynchronizeTrees( | 212 TreeSynchronizer::SynchronizeTrees( |
211 static_cast<Layer*>(NULL), nullptr, host_->active_tree()); | 213 static_cast<Layer*>(NULL), nullptr, host_->active_tree()); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 ExpectTreesAreIdentical(layer_tree_root.get(), | 561 ExpectTreesAreIdentical(layer_tree_root.get(), |
560 layer_impl_tree_root.get(), | 562 layer_impl_tree_root.get(), |
561 host_->active_tree()); | 563 host_->active_tree()); |
562 } | 564 } |
563 | 565 |
564 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { | 566 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { |
565 LayerTreeSettings settings; | 567 LayerTreeSettings settings; |
566 FakeProxy proxy; | 568 FakeProxy proxy; |
567 DebugScopedSetImplThread impl(&proxy); | 569 DebugScopedSetImplThread impl(&proxy); |
568 FakeRenderingStatsInstrumentation stats_instrumentation; | 570 FakeRenderingStatsInstrumentation stats_instrumentation; |
569 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 571 TestSharedBitmapManager shared_bitmap_manager; |
570 new TestSharedBitmapManager()); | 572 TestTaskGraphRunner task_graph_runner; |
571 scoped_ptr<LayerTreeHostImpl> host_impl = | 573 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
572 LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, | 574 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, |
573 shared_bitmap_manager.get(), NULL, NULL, 0); | 575 nullptr, &task_graph_runner, 0); |
574 | 576 |
575 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 577 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
576 host_->SetRootLayer(layer_tree_root); | 578 host_->SetRootLayer(layer_tree_root); |
577 | 579 |
578 layer_tree_root->SetLayerAnimationControllerForTest( | 580 layer_tree_root->SetLayerAnimationControllerForTest( |
579 FakeLayerAnimationController::Create()); | 581 FakeLayerAnimationController::Create()); |
580 | 582 |
581 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>( | 583 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>( |
582 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); | 584 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); |
583 | 585 |
584 scoped_ptr<LayerImpl> layer_impl_tree_root = | 586 scoped_ptr<LayerImpl> layer_impl_tree_root = |
585 TreeSynchronizer::SynchronizeTrees( | 587 TreeSynchronizer::SynchronizeTrees( |
586 layer_tree_root.get(), nullptr, host_->active_tree()); | 588 layer_tree_root.get(), nullptr, host_->active_tree()); |
587 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 589 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
588 layer_impl_tree_root.get()); | 590 layer_impl_tree_root.get()); |
589 layer_impl_tree_root = | 591 layer_impl_tree_root = |
590 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 592 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
591 layer_impl_tree_root.Pass(), | 593 layer_impl_tree_root.Pass(), |
592 host_->active_tree()); | 594 host_->active_tree()); |
593 | 595 |
594 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>( | 596 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>( |
595 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); | 597 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); |
596 } | 598 } |
597 | 599 |
598 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { | 600 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { |
599 LayerTreeSettings settings; | 601 LayerTreeSettings settings; |
600 FakeProxy proxy; | 602 FakeProxy proxy; |
601 DebugScopedSetImplThread impl(&proxy); | 603 DebugScopedSetImplThread impl(&proxy); |
602 FakeRenderingStatsInstrumentation stats_instrumentation; | 604 FakeRenderingStatsInstrumentation stats_instrumentation; |
603 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 605 TestSharedBitmapManager shared_bitmap_manager; |
604 new TestSharedBitmapManager()); | 606 TestTaskGraphRunner task_graph_runner; |
605 scoped_ptr<LayerTreeHostImpl> host_impl = | 607 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
606 LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, | 608 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, |
607 shared_bitmap_manager.get(), NULL, NULL, 0); | 609 nullptr, &task_graph_runner, 0); |
608 | 610 |
609 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 611 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
610 scoped_refptr<Layer> scroll_parent = Layer::Create(layer_settings_); | 612 scoped_refptr<Layer> scroll_parent = Layer::Create(layer_settings_); |
611 layer_tree_root->AddChild(scroll_parent); | 613 layer_tree_root->AddChild(scroll_parent); |
612 layer_tree_root->AddChild(Layer::Create(layer_settings_)); | 614 layer_tree_root->AddChild(Layer::Create(layer_settings_)); |
613 layer_tree_root->AddChild(Layer::Create(layer_settings_)); | 615 layer_tree_root->AddChild(Layer::Create(layer_settings_)); |
614 | 616 |
615 host_->SetRootLayer(layer_tree_root); | 617 host_->SetRootLayer(layer_tree_root); |
616 | 618 |
617 // First child is the second and third child's scroll parent. | 619 // First child is the second and third child's scroll parent. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 layer_impl_tree_root.get(), | 663 layer_impl_tree_root.get(), |
662 host_impl->active_tree()); | 664 host_impl->active_tree()); |
663 } | 665 } |
664 } | 666 } |
665 | 667 |
666 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { | 668 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { |
667 LayerTreeSettings settings; | 669 LayerTreeSettings settings; |
668 FakeProxy proxy; | 670 FakeProxy proxy; |
669 DebugScopedSetImplThread impl(&proxy); | 671 DebugScopedSetImplThread impl(&proxy); |
670 FakeRenderingStatsInstrumentation stats_instrumentation; | 672 FakeRenderingStatsInstrumentation stats_instrumentation; |
671 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 673 TestSharedBitmapManager shared_bitmap_manager; |
672 new TestSharedBitmapManager()); | 674 TestTaskGraphRunner task_graph_runner; |
673 scoped_ptr<LayerTreeHostImpl> host_impl = | 675 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
674 LayerTreeHostImpl::Create(settings, NULL, &proxy, &stats_instrumentation, | 676 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, |
675 shared_bitmap_manager.get(), NULL, NULL, 0); | 677 nullptr, &task_graph_runner, 0); |
676 | 678 |
677 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 679 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
678 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings_); | 680 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings_); |
679 scoped_refptr<Layer> intervening = Layer::Create(layer_settings_); | 681 scoped_refptr<Layer> intervening = Layer::Create(layer_settings_); |
680 scoped_refptr<Layer> clip_child1 = Layer::Create(layer_settings_); | 682 scoped_refptr<Layer> clip_child1 = Layer::Create(layer_settings_); |
681 scoped_refptr<Layer> clip_child2 = Layer::Create(layer_settings_); | 683 scoped_refptr<Layer> clip_child2 = Layer::Create(layer_settings_); |
682 layer_tree_root->AddChild(clip_parent); | 684 layer_tree_root->AddChild(clip_parent); |
683 clip_parent->AddChild(intervening); | 685 clip_parent->AddChild(intervening); |
684 intervening->AddChild(clip_child1); | 686 intervening->AddChild(clip_child1); |
685 intervening->AddChild(clip_child2); | 687 intervening->AddChild(clip_child2); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 host_impl->active_tree()); | 743 host_impl->active_tree()); |
742 | 744 |
743 // The clip children should have been unhooked. | 745 // The clip children should have been unhooked. |
744 EXPECT_EQ(2u, intervening->children().size()); | 746 EXPECT_EQ(2u, intervening->children().size()); |
745 EXPECT_FALSE(clip_child2->clip_parent()); | 747 EXPECT_FALSE(clip_child2->clip_parent()); |
746 EXPECT_FALSE(additional_clip_child->clip_parent()); | 748 EXPECT_FALSE(additional_clip_child->clip_parent()); |
747 } | 749 } |
748 | 750 |
749 } // namespace | 751 } // namespace |
750 } // namespace cc | 752 } // namespace cc |
OLD | NEW |