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_task_runner_provider.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/test/test_task_graph_runner.h" |
22 #include "cc/trees/proxy.h" | |
23 #include "cc/trees/single_thread_proxy.h" | 22 #include "cc/trees/single_thread_proxy.h" |
| 23 #include "cc/trees/task_runner_provider.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace cc { | 26 namespace cc { |
27 namespace { | 27 namespace { |
28 | 28 |
29 class MockLayerImpl : public LayerImpl { | 29 class MockLayerImpl : public LayerImpl { |
30 public: | 30 public: |
31 static scoped_ptr<MockLayerImpl> Create(LayerTreeImpl* tree_impl, | 31 static scoped_ptr<MockLayerImpl> Create(LayerTreeImpl* tree_impl, |
32 int layer_id) { | 32 int layer_id) { |
33 return make_scoped_ptr(new MockLayerImpl(tree_impl, layer_id)); | 33 return make_scoped_ptr(new MockLayerImpl(tree_impl, layer_id)); |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 558 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
559 layer_impl_tree_root.Pass(), | 559 layer_impl_tree_root.Pass(), |
560 host_->active_tree()); | 560 host_->active_tree()); |
561 ExpectTreesAreIdentical(layer_tree_root.get(), | 561 ExpectTreesAreIdentical(layer_tree_root.get(), |
562 layer_impl_tree_root.get(), | 562 layer_impl_tree_root.get(), |
563 host_->active_tree()); | 563 host_->active_tree()); |
564 } | 564 } |
565 | 565 |
566 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { | 566 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { |
567 LayerTreeSettings settings; | 567 LayerTreeSettings settings; |
568 FakeProxy proxy; | 568 FakeImplTaskRunnerProvider task_runner_provider; |
569 DebugScopedSetImplThread impl(&proxy); | |
570 FakeRenderingStatsInstrumentation stats_instrumentation; | 569 FakeRenderingStatsInstrumentation stats_instrumentation; |
571 TestSharedBitmapManager shared_bitmap_manager; | 570 TestSharedBitmapManager shared_bitmap_manager; |
572 TestTaskGraphRunner task_graph_runner; | 571 TestTaskGraphRunner task_graph_runner; |
573 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 572 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
574 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, | 573 settings, nullptr, &task_runner_provider, &stats_instrumentation, |
575 nullptr, &task_graph_runner, 0); | 574 &shared_bitmap_manager, nullptr, &task_graph_runner, 0); |
576 | 575 |
577 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 576 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
578 host_->SetRootLayer(layer_tree_root); | 577 host_->SetRootLayer(layer_tree_root); |
579 | 578 |
580 layer_tree_root->SetLayerAnimationControllerForTest( | 579 layer_tree_root->SetLayerAnimationControllerForTest( |
581 FakeLayerAnimationController::Create()); | 580 FakeLayerAnimationController::Create()); |
582 | 581 |
583 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>( | 582 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>( |
584 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); | 583 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); |
585 | 584 |
586 scoped_ptr<LayerImpl> layer_impl_tree_root = | 585 scoped_ptr<LayerImpl> layer_impl_tree_root = |
587 TreeSynchronizer::SynchronizeTrees( | 586 TreeSynchronizer::SynchronizeTrees( |
588 layer_tree_root.get(), nullptr, host_->active_tree()); | 587 layer_tree_root.get(), nullptr, host_->active_tree()); |
589 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 588 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
590 layer_impl_tree_root.get()); | 589 layer_impl_tree_root.get()); |
591 layer_impl_tree_root = | 590 layer_impl_tree_root = |
592 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 591 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
593 layer_impl_tree_root.Pass(), | 592 layer_impl_tree_root.Pass(), |
594 host_->active_tree()); | 593 host_->active_tree()); |
595 | 594 |
596 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>( | 595 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>( |
597 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); | 596 layer_tree_root->layer_animation_controller())->SynchronizedAnimations()); |
598 } | 597 } |
599 | 598 |
600 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { | 599 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { |
601 LayerTreeSettings settings; | 600 LayerTreeSettings settings; |
602 FakeProxy proxy; | 601 FakeImplTaskRunnerProvider task_runner_provider; |
603 DebugScopedSetImplThread impl(&proxy); | |
604 FakeRenderingStatsInstrumentation stats_instrumentation; | 602 FakeRenderingStatsInstrumentation stats_instrumentation; |
605 TestSharedBitmapManager shared_bitmap_manager; | 603 TestSharedBitmapManager shared_bitmap_manager; |
606 TestTaskGraphRunner task_graph_runner; | 604 TestTaskGraphRunner task_graph_runner; |
607 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 605 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
608 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, | 606 settings, nullptr, &task_runner_provider, &stats_instrumentation, |
609 nullptr, &task_graph_runner, 0); | 607 &shared_bitmap_manager, nullptr, &task_graph_runner, 0); |
610 | 608 |
611 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 609 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
612 scoped_refptr<Layer> scroll_parent = Layer::Create(layer_settings_); | 610 scoped_refptr<Layer> scroll_parent = Layer::Create(layer_settings_); |
613 layer_tree_root->AddChild(scroll_parent); | 611 layer_tree_root->AddChild(scroll_parent); |
614 layer_tree_root->AddChild(Layer::Create(layer_settings_)); | 612 layer_tree_root->AddChild(Layer::Create(layer_settings_)); |
615 layer_tree_root->AddChild(Layer::Create(layer_settings_)); | 613 layer_tree_root->AddChild(Layer::Create(layer_settings_)); |
616 | 614 |
617 host_->SetRootLayer(layer_tree_root); | 615 host_->SetRootLayer(layer_tree_root); |
618 | 616 |
619 // First child is the second and third child's scroll parent. | 617 // First child is the second and third child's scroll parent. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 { | 658 { |
661 SCOPED_TRACE("case three"); | 659 SCOPED_TRACE("case three"); |
662 ExpectTreesAreIdentical(layer_tree_root.get(), | 660 ExpectTreesAreIdentical(layer_tree_root.get(), |
663 layer_impl_tree_root.get(), | 661 layer_impl_tree_root.get(), |
664 host_impl->active_tree()); | 662 host_impl->active_tree()); |
665 } | 663 } |
666 } | 664 } |
667 | 665 |
668 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { | 666 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { |
669 LayerTreeSettings settings; | 667 LayerTreeSettings settings; |
670 FakeProxy proxy; | 668 FakeImplTaskRunnerProvider task_runner_provider; |
671 DebugScopedSetImplThread impl(&proxy); | |
672 FakeRenderingStatsInstrumentation stats_instrumentation; | 669 FakeRenderingStatsInstrumentation stats_instrumentation; |
673 TestSharedBitmapManager shared_bitmap_manager; | 670 TestSharedBitmapManager shared_bitmap_manager; |
674 TestTaskGraphRunner task_graph_runner; | 671 TestTaskGraphRunner task_graph_runner; |
675 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 672 scoped_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
676 settings, nullptr, &proxy, &stats_instrumentation, &shared_bitmap_manager, | 673 settings, nullptr, &task_runner_provider, &stats_instrumentation, |
677 nullptr, &task_graph_runner, 0); | 674 &shared_bitmap_manager, nullptr, &task_graph_runner, 0); |
678 | 675 |
679 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); | 676 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings_); |
680 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings_); | 677 scoped_refptr<Layer> clip_parent = Layer::Create(layer_settings_); |
681 scoped_refptr<Layer> intervening = Layer::Create(layer_settings_); | 678 scoped_refptr<Layer> intervening = Layer::Create(layer_settings_); |
682 scoped_refptr<Layer> clip_child1 = Layer::Create(layer_settings_); | 679 scoped_refptr<Layer> clip_child1 = Layer::Create(layer_settings_); |
683 scoped_refptr<Layer> clip_child2 = Layer::Create(layer_settings_); | 680 scoped_refptr<Layer> clip_child2 = Layer::Create(layer_settings_); |
684 layer_tree_root->AddChild(clip_parent); | 681 layer_tree_root->AddChild(clip_parent); |
685 clip_parent->AddChild(intervening); | 682 clip_parent->AddChild(intervening); |
686 intervening->AddChild(clip_child1); | 683 intervening->AddChild(clip_child1); |
687 intervening->AddChild(clip_child2); | 684 intervening->AddChild(clip_child2); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 host_impl->active_tree()); | 740 host_impl->active_tree()); |
744 | 741 |
745 // The clip children should have been unhooked. | 742 // The clip children should have been unhooked. |
746 EXPECT_EQ(2u, intervening->children().size()); | 743 EXPECT_EQ(2u, intervening->children().size()); |
747 EXPECT_FALSE(clip_child2->clip_parent()); | 744 EXPECT_FALSE(clip_child2->clip_parent()); |
748 EXPECT_FALSE(additional_clip_child->clip_parent()); | 745 EXPECT_FALSE(additional_clip_child->clip_parent()); |
749 } | 746 } |
750 | 747 |
751 } // namespace | 748 } // namespace |
752 } // namespace cc | 749 } // namespace cc |
OLD | NEW |