| 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 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 layer_impl_destruction_list_->push_back(id()); | 35 layer_impl_destruction_list_->push_back(id()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 void SetLayerImplDestructionList(std::vector<int>* list) { | 38 void SetLayerImplDestructionList(std::vector<int>* list) { |
| 39 layer_impl_destruction_list_ = list; | 39 layer_impl_destruction_list_ = list; |
| 40 } | 40 } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 MockLayerImpl(LayerTreeImpl* tree_impl, int layer_id) | 43 MockLayerImpl(LayerTreeImpl* tree_impl, int layer_id) |
| 44 : LayerImpl(tree_impl, layer_id), | 44 : LayerImpl(tree_impl, layer_id), |
| 45 layer_impl_destruction_list_(NULL) {} | 45 layer_impl_destruction_list_(nullptr) {} |
| 46 | 46 |
| 47 std::vector<int>* layer_impl_destruction_list_; | 47 std::vector<int>* layer_impl_destruction_list_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class MockLayer : public Layer { | 50 class MockLayer : public Layer { |
| 51 public: | 51 public: |
| 52 static scoped_refptr<MockLayer> Create( | 52 static scoped_refptr<MockLayer> Create( |
| 53 std::vector<int>* layer_impl_destruction_list) { | 53 std::vector<int>* layer_impl_destruction_list) { |
| 54 return make_scoped_refptr(new MockLayer(layer_impl_destruction_list)); | 54 return make_scoped_refptr(new MockLayer(layer_impl_destruction_list)); |
| 55 } | 55 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 protected: | 196 protected: |
| 197 FakeLayerTreeHostClient client_; | 197 FakeLayerTreeHostClient client_; |
| 198 scoped_ptr<FakeLayerTreeHost> host_; | 198 scoped_ptr<FakeLayerTreeHost> host_; |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 // Attempts to synchronizes a null tree. This should not crash, and should | 201 // Attempts to synchronizes a null tree. This should not crash, and should |
| 202 // return a null tree. | 202 // return a null tree. |
| 203 TEST_F(TreeSynchronizerTest, SyncNullTree) { | 203 TEST_F(TreeSynchronizerTest, SyncNullTree) { |
| 204 scoped_ptr<LayerImpl> layer_impl_tree_root = | 204 scoped_ptr<LayerImpl> layer_impl_tree_root = |
| 205 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(NULL), | 205 TreeSynchronizer::SynchronizeTrees(static_cast<Layer*>(nullptr), |
| 206 scoped_ptr<LayerImpl>(), | 206 scoped_ptr<LayerImpl>(), |
| 207 host_->active_tree()); | 207 host_->active_tree()); |
| 208 | 208 |
| 209 EXPECT_TRUE(!layer_impl_tree_root.get()); | 209 EXPECT_TRUE(!layer_impl_tree_root.get()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Constructs a very simple tree and synchronizes it without trying to reuse any | 212 // Constructs a very simple tree and synchronizes it without trying to reuse any |
| 213 // preexisting layers. | 213 // preexisting layers. |
| 214 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) { | 214 TEST_F(TreeSynchronizerTest, SyncSimpleTreeFromEmpty) { |
| 215 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 215 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 scoped_ptr<LayerImpl> layer_impl_tree_root = | 519 scoped_ptr<LayerImpl> layer_impl_tree_root = |
| 520 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 520 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 521 scoped_ptr<LayerImpl>(), | 521 scoped_ptr<LayerImpl>(), |
| 522 host_->active_tree()); | 522 host_->active_tree()); |
| 523 | 523 |
| 524 ExpectTreesAreIdentical(layer_tree_root.get(), | 524 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 525 layer_impl_tree_root.get(), | 525 layer_impl_tree_root.get(), |
| 526 host_->active_tree()); | 526 host_->active_tree()); |
| 527 | 527 |
| 528 // Remove the mask layer. | 528 // Remove the mask layer. |
| 529 layer_tree_root->children()[0]->SetMaskLayer(NULL); | 529 layer_tree_root->children()[0]->SetMaskLayer(nullptr); |
| 530 layer_impl_tree_root = | 530 layer_impl_tree_root = |
| 531 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 531 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 532 layer_impl_tree_root.Pass(), | 532 layer_impl_tree_root.Pass(), |
| 533 host_->active_tree()); | 533 host_->active_tree()); |
| 534 ExpectTreesAreIdentical(layer_tree_root.get(), | 534 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 535 layer_impl_tree_root.get(), | 535 layer_impl_tree_root.get(), |
| 536 host_->active_tree()); | 536 host_->active_tree()); |
| 537 | 537 |
| 538 // Remove the replica layer. | 538 // Remove the replica layer. |
| 539 layer_tree_root->children()[1]->SetReplicaLayer(NULL); | 539 layer_tree_root->children()[1]->SetReplicaLayer(nullptr); |
| 540 layer_impl_tree_root = | 540 layer_impl_tree_root = |
| 541 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 541 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 542 layer_impl_tree_root.Pass(), | 542 layer_impl_tree_root.Pass(), |
| 543 host_->active_tree()); | 543 host_->active_tree()); |
| 544 ExpectTreesAreIdentical(layer_tree_root.get(), | 544 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 545 layer_impl_tree_root.get(), | 545 layer_impl_tree_root.get(), |
| 546 host_->active_tree()); | 546 host_->active_tree()); |
| 547 | 547 |
| 548 // Remove the replica mask. | 548 // Remove the replica mask. |
| 549 replica_layer_with_mask->SetMaskLayer(NULL); | 549 replica_layer_with_mask->SetMaskLayer(nullptr); |
| 550 layer_impl_tree_root = | 550 layer_impl_tree_root = |
| 551 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 551 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 552 layer_impl_tree_root.Pass(), | 552 layer_impl_tree_root.Pass(), |
| 553 host_->active_tree()); | 553 host_->active_tree()); |
| 554 ExpectTreesAreIdentical(layer_tree_root.get(), | 554 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 555 layer_impl_tree_root.get(), | 555 layer_impl_tree_root.get(), |
| 556 host_->active_tree()); | 556 host_->active_tree()); |
| 557 } | 557 } |
| 558 | 558 |
| 559 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { | 559 TEST_F(TreeSynchronizerTest, SynchronizeAnimations) { |
| 560 LayerTreeSettings settings; | 560 LayerTreeSettings settings; |
| 561 FakeProxy proxy; | 561 FakeProxy proxy; |
| 562 DebugScopedSetImplThread impl(&proxy); | 562 DebugScopedSetImplThread impl(&proxy); |
| 563 FakeRenderingStatsInstrumentation stats_instrumentation; | 563 FakeRenderingStatsInstrumentation stats_instrumentation; |
| 564 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 564 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 565 new TestSharedBitmapManager()); | 565 new TestSharedBitmapManager()); |
| 566 scoped_ptr<LayerTreeHostImpl> host_impl = | 566 scoped_ptr<LayerTreeHostImpl> host_impl = |
| 567 LayerTreeHostImpl::Create(settings, | 567 LayerTreeHostImpl::Create(settings, |
| 568 NULL, | 568 nullptr, |
| 569 &proxy, | 569 &proxy, |
| 570 &stats_instrumentation, | 570 &stats_instrumentation, |
| 571 shared_bitmap_manager.get(), | 571 shared_bitmap_manager.get(), |
| 572 0); | 572 0); |
| 573 | 573 |
| 574 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 574 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 575 host_->SetRootLayer(layer_tree_root); | 575 host_->SetRootLayer(layer_tree_root); |
| 576 | 576 |
| 577 layer_tree_root->SetLayerAnimationControllerForTest( | 577 layer_tree_root->SetLayerAnimationControllerForTest( |
| 578 FakeLayerAnimationController::Create()); | 578 FakeLayerAnimationController::Create()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 597 | 597 |
| 598 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { | 598 TEST_F(TreeSynchronizerTest, SynchronizeScrollParent) { |
| 599 LayerTreeSettings settings; | 599 LayerTreeSettings settings; |
| 600 FakeProxy proxy; | 600 FakeProxy proxy; |
| 601 DebugScopedSetImplThread impl(&proxy); | 601 DebugScopedSetImplThread impl(&proxy); |
| 602 FakeRenderingStatsInstrumentation stats_instrumentation; | 602 FakeRenderingStatsInstrumentation stats_instrumentation; |
| 603 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 603 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 604 new TestSharedBitmapManager()); | 604 new TestSharedBitmapManager()); |
| 605 scoped_ptr<LayerTreeHostImpl> host_impl = | 605 scoped_ptr<LayerTreeHostImpl> host_impl = |
| 606 LayerTreeHostImpl::Create(settings, | 606 LayerTreeHostImpl::Create(settings, |
| 607 NULL, | 607 nullptr, |
| 608 &proxy, | 608 &proxy, |
| 609 &stats_instrumentation, | 609 &stats_instrumentation, |
| 610 shared_bitmap_manager.get(), | 610 shared_bitmap_manager.get(), |
| 611 0); | 611 0); |
| 612 | 612 |
| 613 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 613 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 614 scoped_refptr<Layer> scroll_parent = Layer::Create(); | 614 scoped_refptr<Layer> scroll_parent = Layer::Create(); |
| 615 layer_tree_root->AddChild(scroll_parent); | 615 layer_tree_root->AddChild(scroll_parent); |
| 616 layer_tree_root->AddChild(Layer::Create()); | 616 layer_tree_root->AddChild(Layer::Create()); |
| 617 layer_tree_root->AddChild(Layer::Create()); | 617 layer_tree_root->AddChild(Layer::Create()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 670 |
| 671 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { | 671 TEST_F(TreeSynchronizerTest, SynchronizeClipParent) { |
| 672 LayerTreeSettings settings; | 672 LayerTreeSettings settings; |
| 673 FakeProxy proxy; | 673 FakeProxy proxy; |
| 674 DebugScopedSetImplThread impl(&proxy); | 674 DebugScopedSetImplThread impl(&proxy); |
| 675 FakeRenderingStatsInstrumentation stats_instrumentation; | 675 FakeRenderingStatsInstrumentation stats_instrumentation; |
| 676 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( | 676 scoped_ptr<SharedBitmapManager> shared_bitmap_manager( |
| 677 new TestSharedBitmapManager()); | 677 new TestSharedBitmapManager()); |
| 678 scoped_ptr<LayerTreeHostImpl> host_impl = | 678 scoped_ptr<LayerTreeHostImpl> host_impl = |
| 679 LayerTreeHostImpl::Create(settings, | 679 LayerTreeHostImpl::Create(settings, |
| 680 NULL, | 680 nullptr, |
| 681 &proxy, | 681 &proxy, |
| 682 &stats_instrumentation, | 682 &stats_instrumentation, |
| 683 shared_bitmap_manager.get(), | 683 shared_bitmap_manager.get(), |
| 684 0); | 684 0); |
| 685 | 685 |
| 686 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 686 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 687 scoped_refptr<Layer> clip_parent = Layer::Create(); | 687 scoped_refptr<Layer> clip_parent = Layer::Create(); |
| 688 scoped_refptr<Layer> intervening = Layer::Create(); | 688 scoped_refptr<Layer> intervening = Layer::Create(); |
| 689 scoped_refptr<Layer> clip_child1 = Layer::Create(); | 689 scoped_refptr<Layer> clip_child1 = Layer::Create(); |
| 690 scoped_refptr<Layer> clip_child2 = Layer::Create(); | 690 scoped_refptr<Layer> clip_child2 = Layer::Create(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 704 scoped_ptr<LayerImpl>(), | 704 scoped_ptr<LayerImpl>(), |
| 705 host_impl->active_tree()); | 705 host_impl->active_tree()); |
| 706 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 706 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
| 707 layer_impl_tree_root.get()); | 707 layer_impl_tree_root.get()); |
| 708 ExpectTreesAreIdentical(layer_tree_root.get(), | 708 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 709 layer_impl_tree_root.get(), | 709 layer_impl_tree_root.get(), |
| 710 host_impl->active_tree()); | 710 host_impl->active_tree()); |
| 711 | 711 |
| 712 // Remove the first clip child. | 712 // Remove the first clip child. |
| 713 clip_child1->RemoveFromParent(); | 713 clip_child1->RemoveFromParent(); |
| 714 clip_child1 = NULL; | 714 clip_child1 = nullptr; |
| 715 | 715 |
| 716 layer_impl_tree_root = | 716 layer_impl_tree_root = |
| 717 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 717 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 718 layer_impl_tree_root.Pass(), | 718 layer_impl_tree_root.Pass(), |
| 719 host_impl->active_tree()); | 719 host_impl->active_tree()); |
| 720 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 720 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
| 721 layer_impl_tree_root.get()); | 721 layer_impl_tree_root.get()); |
| 722 ExpectTreesAreIdentical(layer_tree_root.get(), | 722 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 723 layer_impl_tree_root.get(), | 723 layer_impl_tree_root.get(), |
| 724 host_impl->active_tree()); | 724 host_impl->active_tree()); |
| 725 | 725 |
| 726 // Add an additional clip child. | 726 // Add an additional clip child. |
| 727 scoped_refptr<Layer> additional_clip_child = Layer::Create(); | 727 scoped_refptr<Layer> additional_clip_child = Layer::Create(); |
| 728 intervening->AddChild(additional_clip_child); | 728 intervening->AddChild(additional_clip_child); |
| 729 additional_clip_child->SetClipParent(clip_parent.get()); | 729 additional_clip_child->SetClipParent(clip_parent.get()); |
| 730 layer_impl_tree_root = | 730 layer_impl_tree_root = |
| 731 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 731 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 732 layer_impl_tree_root.Pass(), | 732 layer_impl_tree_root.Pass(), |
| 733 host_impl->active_tree()); | 733 host_impl->active_tree()); |
| 734 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 734 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
| 735 layer_impl_tree_root.get()); | 735 layer_impl_tree_root.get()); |
| 736 ExpectTreesAreIdentical(layer_tree_root.get(), | 736 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 737 layer_impl_tree_root.get(), | 737 layer_impl_tree_root.get(), |
| 738 host_impl->active_tree()); | 738 host_impl->active_tree()); |
| 739 | 739 |
| 740 // Remove the nearest clipping ancestor. | 740 // Remove the nearest clipping ancestor. |
| 741 clip_parent->RemoveFromParent(); | 741 clip_parent->RemoveFromParent(); |
| 742 clip_parent = NULL; | 742 clip_parent = nullptr; |
| 743 layer_impl_tree_root = | 743 layer_impl_tree_root = |
| 744 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), | 744 TreeSynchronizer::SynchronizeTrees(layer_tree_root.get(), |
| 745 layer_impl_tree_root.Pass(), | 745 layer_impl_tree_root.Pass(), |
| 746 host_impl->active_tree()); | 746 host_impl->active_tree()); |
| 747 TreeSynchronizer::PushProperties(layer_tree_root.get(), | 747 TreeSynchronizer::PushProperties(layer_tree_root.get(), |
| 748 layer_impl_tree_root.get()); | 748 layer_impl_tree_root.get()); |
| 749 ExpectTreesAreIdentical(layer_tree_root.get(), | 749 ExpectTreesAreIdentical(layer_tree_root.get(), |
| 750 layer_impl_tree_root.get(), | 750 layer_impl_tree_root.get(), |
| 751 host_impl->active_tree()); | 751 host_impl->active_tree()); |
| 752 | 752 |
| 753 // The clip children should have been unhooked. | 753 // The clip children should have been unhooked. |
| 754 EXPECT_EQ(2u, intervening->children().size()); | 754 EXPECT_EQ(2u, intervening->children().size()); |
| 755 EXPECT_FALSE(clip_child2->clip_parent()); | 755 EXPECT_FALSE(clip_child2->clip_parent()); |
| 756 EXPECT_FALSE(additional_clip_child->clip_parent()); | 756 EXPECT_FALSE(additional_clip_child->clip_parent()); |
| 757 } | 757 } |
| 758 | 758 |
| 759 } // namespace | 759 } // namespace |
| 760 } // namespace cc | 760 } // namespace cc |
| OLD | NEW |