| 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_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 int index_; | 685 int index_; |
| 686 }; | 686 }; |
| 687 | 687 |
| 688 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo); | 688 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPushPropertiesTo); |
| 689 | 689 |
| 690 // Verify damage status of property trees is preserved after commit. | 690 // Verify damage status of property trees is preserved after commit. |
| 691 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest { | 691 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest { |
| 692 protected: | 692 protected: |
| 693 void SetupTree() override { | 693 void SetupTree() override { |
| 694 scoped_refptr<Layer> root = Layer::Create(); | 694 scoped_refptr<Layer> root = Layer::Create(); |
| 695 scoped_refptr<Layer> child = Layer::Create(); |
| 696 // This is to force the child to create a transform and effect node. |
| 697 child->SetForceRenderSurface(true); |
| 698 root->AddChild(std::move(child)); |
| 695 layer_tree_host()->SetRootLayer(root); | 699 layer_tree_host()->SetRootLayer(root); |
| 696 LayerTreeHostTest::SetupTree(); | 700 LayerTreeHostTest::SetupTree(); |
| 697 } | 701 } |
| 698 | 702 |
| 699 enum Animations { | 703 enum Animations { |
| 700 OPACITY, | 704 OPACITY, |
| 701 TRANSFORM, | 705 TRANSFORM, |
| 702 FILTER, | 706 FILTER, |
| 703 END, | 707 END, |
| 704 }; | 708 }; |
| 705 | 709 |
| 706 void BeginTest() override { | 710 void BeginTest() override { |
| 707 index_ = OPACITY; | 711 index_ = OPACITY; |
| 708 PostSetNeedsCommitToMainThread(); | 712 PostSetNeedsCommitToMainThread(); |
| 709 } | 713 } |
| 710 | 714 |
| 715 void DidCommit() override { |
| 716 switch (layer_tree_host()->source_frame_number()) { |
| 717 case 2: |
| 718 // We rebuild property trees for this case to test the code path of |
| 719 // damage status synchronization when property trees are different. |
| 720 layer_tree_host()->property_trees()->needs_rebuild = true; |
| 721 break; |
| 722 default: |
| 723 EXPECT_FALSE(layer_tree_host()->property_trees()->needs_rebuild); |
| 724 } |
| 725 } |
| 726 |
| 711 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 727 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 712 gfx::Transform transform; | 728 gfx::Transform transform; |
| 713 FilterOperations filters; | 729 FilterOperations filters; |
| 714 switch (static_cast<Animations>(index_)) { | 730 switch (static_cast<Animations>(index_)) { |
| 715 case OPACITY: | 731 case OPACITY: |
| 716 index_++; | 732 index_++; |
| 717 impl->active_tree()->ResetAllChangeTracking( | 733 impl->active_tree()->ResetAllChangeTracking( |
| 718 PropertyTrees::ResetFlags::ALL_TREES); | 734 PropertyTrees::ResetFlags::ALL_TREES); |
| 719 impl->active_tree()->root_layer()->OnOpacityAnimated(0.5f); | 735 impl->active_tree()->root_layer()->OnOpacityAnimated(0.5f); |
| 720 PostSetNeedsCommitToMainThread(); | 736 PostSetNeedsCommitToMainThread(); |
| 721 break; | 737 break; |
| 722 case TRANSFORM: | 738 case TRANSFORM: |
| 723 index_++; | 739 index_++; |
| 724 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); | 740 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); |
| 725 impl->active_tree()->ResetAllChangeTracking( | 741 impl->active_tree()->ResetAllChangeTracking( |
| 726 PropertyTrees::ResetFlags::EFFECT_TREE); | 742 PropertyTrees::ResetFlags::EFFECT_TREE); |
| 727 EXPECT_FALSE(impl->active_tree()->root_layer()->LayerPropertyChanged()); | 743 EXPECT_FALSE(impl->active_tree()->root_layer()->LayerPropertyChanged()); |
| 744 EXPECT_FALSE(impl->active_tree() |
| 745 ->root_layer() |
| 746 ->child_at(0) |
| 747 ->LayerPropertyChanged()); |
| 728 transform.Translate(10, 10); | 748 transform.Translate(10, 10); |
| 729 impl->active_tree()->root_layer()->OnTransformAnimated(transform); | 749 impl->active_tree()->root_layer()->OnTransformAnimated(transform); |
| 730 PostSetNeedsCommitToMainThread(); | 750 PostSetNeedsCommitToMainThread(); |
| 731 break; | 751 break; |
| 732 case FILTER: | 752 case FILTER: |
| 733 index_++; | 753 index_++; |
| 734 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); | 754 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); |
| 755 EXPECT_TRUE(impl->active_tree() |
| 756 ->root_layer() |
| 757 ->child_at(0) |
| 758 ->LayerPropertyChanged()); |
| 735 impl->active_tree()->ResetAllChangeTracking( | 759 impl->active_tree()->ResetAllChangeTracking( |
| 736 PropertyTrees::ResetFlags::TRANSFORM_TREE); | 760 PropertyTrees::ResetFlags::TRANSFORM_TREE); |
| 737 EXPECT_FALSE(impl->active_tree()->root_layer()->LayerPropertyChanged()); | 761 EXPECT_FALSE(impl->active_tree()->root_layer()->LayerPropertyChanged()); |
| 762 EXPECT_FALSE(impl->active_tree() |
| 763 ->root_layer() |
| 764 ->child_at(0) |
| 765 ->LayerPropertyChanged()); |
| 738 filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); | 766 filters.Append(FilterOperation::CreateOpacityFilter(0.5f)); |
| 739 impl->active_tree()->root_layer()->OnFilterAnimated(filters); | 767 impl->active_tree()->root_layer()->OnFilterAnimated(filters); |
| 740 PostSetNeedsCommitToMainThread(); | 768 PostSetNeedsCommitToMainThread(); |
| 741 break; | 769 break; |
| 742 case END: | 770 case END: |
| 743 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); | 771 EXPECT_TRUE(impl->active_tree()->root_layer()->LayerPropertyChanged()); |
| 744 EndTest(); | 772 EndTest(); |
| 745 break; | 773 break; |
| 746 } | 774 } |
| 747 } | 775 } |
| (...skipping 5903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6651 EndTest(); | 6679 EndTest(); |
| 6652 } | 6680 } |
| 6653 | 6681 |
| 6654 void AfterTest() override {} | 6682 void AfterTest() override {} |
| 6655 }; | 6683 }; |
| 6656 | 6684 |
| 6657 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6685 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6658 | 6686 |
| 6659 } // namespace | 6687 } // namespace |
| 6660 } // namespace cc | 6688 } // namespace cc |
| OLD | NEW |