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 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 layer_tree_host()->SetRootLayer(root_); | 800 layer_tree_host()->SetRootLayer(root_); |
801 LayerTreeHostTest::SetupTree(); | 801 LayerTreeHostTest::SetupTree(); |
802 } | 802 } |
803 | 803 |
804 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 804 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
805 | 805 |
806 void DidCommit() override { | 806 void DidCommit() override { |
807 switch (layer_tree_host()->SourceFrameNumber()) { | 807 switch (layer_tree_host()->SourceFrameNumber()) { |
808 case 1: | 808 case 1: |
809 // child_ should create transform, effect node. | 809 // child_ should create transform, effect node. |
810 child_->SetForceRenderSurfaceForTesting(true); | 810 child_->SetForceRenderSurface(true); |
811 break; | 811 break; |
812 case 2: | 812 case 2: |
813 // child_ should create a scroll node. | 813 // child_ should create a scroll node. |
814 child_->SetScrollClipLayerId(root_->id()); | 814 child_->SetScrollClipLayerId(root_->id()); |
815 break; | 815 break; |
816 case 3: | 816 case 3: |
817 // child_ should create a clip node. | 817 // child_ should create a clip node. |
818 child_->SetMasksToBounds(true); | 818 child_->SetMasksToBounds(true); |
819 break; | 819 break; |
820 case 4: | 820 case 4: |
821 // child_ should not create any property tree node. | 821 // child_ should not create any property tree node. |
822 child_->SetMasksToBounds(false); | 822 child_->SetMasksToBounds(false); |
823 child_->SetForceRenderSurfaceForTesting(false); | 823 child_->SetForceRenderSurface(false); |
824 child_->SetScrollClipLayerId(Layer::INVALID_ID); | 824 child_->SetScrollClipLayerId(Layer::INVALID_ID); |
825 } | 825 } |
826 } | 826 } |
827 | 827 |
828 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 828 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
829 PropertyTrees* property_trees = impl->sync_tree()->property_trees(); | 829 PropertyTrees* property_trees = impl->sync_tree()->property_trees(); |
830 const TransformNode* root_transform_node = | 830 const TransformNode* root_transform_node = |
831 property_trees->transform_tree.FindNodeFromOwningLayerId(root_->id()); | 831 property_trees->transform_tree.FindNodeFromOwningLayerId(root_->id()); |
832 const TransformNode* child_transform_node = | 832 const TransformNode* child_transform_node = |
833 property_trees->transform_tree.FindNodeFromOwningLayerId(child_->id()); | 833 property_trees->transform_tree.FindNodeFromOwningLayerId(child_->id()); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 root_->AddChild(child_); | 907 root_->AddChild(child_); |
908 layer_tree_host()->SetRootLayer(root_); | 908 layer_tree_host()->SetRootLayer(root_); |
909 LayerTreeHostTest::SetupTree(); | 909 LayerTreeHostTest::SetupTree(); |
910 } | 910 } |
911 | 911 |
912 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 912 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
913 | 913 |
914 void DidCommit() override { | 914 void DidCommit() override { |
915 switch (layer_tree_host()->SourceFrameNumber()) { | 915 switch (layer_tree_host()->SourceFrameNumber()) { |
916 case 1: | 916 case 1: |
917 child_->SetForceRenderSurfaceForTesting(true); | 917 child_->SetForceRenderSurface(true); |
918 child_->AddMainThreadScrollingReasons( | 918 child_->AddMainThreadScrollingReasons( |
919 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 919 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
920 break; | 920 break; |
921 case 2: | 921 case 2: |
922 child_->SetForceRenderSurfaceForTesting(false); | 922 child_->SetForceRenderSurface(false); |
923 child_->ClearMainThreadScrollingReasons( | 923 child_->ClearMainThreadScrollingReasons( |
924 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); | 924 MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects); |
925 break; | 925 break; |
926 } | 926 } |
927 } | 927 } |
928 | 928 |
929 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 929 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
930 PropertyTrees* property_trees = impl->sync_tree()->property_trees(); | 930 PropertyTrees* property_trees = impl->sync_tree()->property_trees(); |
931 LayerImpl* child_impl_ = impl->sync_tree()->LayerById(child_->id()); | 931 LayerImpl* child_impl_ = impl->sync_tree()->LayerById(child_->id()); |
932 switch (impl->sync_tree()->source_frame_number()) { | 932 switch (impl->sync_tree()->source_frame_number()) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 root_ = Layer::Create(); | 1009 root_ = Layer::Create(); |
1010 child_ = Layer::Create(); | 1010 child_ = Layer::Create(); |
1011 grand_child_ = Layer::Create(); | 1011 grand_child_ = Layer::Create(); |
1012 | 1012 |
1013 layer_tree_host()->SetRootLayer(root_); | 1013 layer_tree_host()->SetRootLayer(root_); |
1014 root_->AddChild(child_); | 1014 root_->AddChild(child_); |
1015 child_->AddChild(grand_child_); | 1015 child_->AddChild(grand_child_); |
1016 | 1016 |
1017 root_->SetBounds(gfx::Size(50, 50)); | 1017 root_->SetBounds(gfx::Size(50, 50)); |
1018 root_->SetMasksToBounds(true); | 1018 root_->SetMasksToBounds(true); |
1019 child_->SetForceRenderSurfaceForTesting(true); | 1019 child_->SetForceRenderSurface(true); |
1020 | 1020 |
1021 LayerTreeHostTest::SetupTree(); | 1021 LayerTreeHostTest::SetupTree(); |
1022 } | 1022 } |
1023 | 1023 |
1024 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 1024 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
1025 | 1025 |
1026 void DidCommit() override { | 1026 void DidCommit() override { |
1027 switch (layer_tree_host()->SourceFrameNumber()) { | 1027 switch (layer_tree_host()->SourceFrameNumber()) { |
1028 case 1: | 1028 case 1: |
1029 grand_child_->SetOpacity(0.9f); | 1029 grand_child_->SetOpacity(0.9f); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 | 1084 |
1085 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceDamage); | 1085 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSurfaceDamage); |
1086 | 1086 |
1087 // Verify damage status of property trees is preserved after commit. | 1087 // Verify damage status of property trees is preserved after commit. |
1088 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest { | 1088 class LayerTreeHostTestPropertyTreesChangedSync : public LayerTreeHostTest { |
1089 protected: | 1089 protected: |
1090 void SetupTree() override { | 1090 void SetupTree() override { |
1091 root_ = Layer::Create(); | 1091 root_ = Layer::Create(); |
1092 child_ = Layer::Create(); | 1092 child_ = Layer::Create(); |
1093 // This is to force the child to create a transform and effect node. | 1093 // This is to force the child to create a transform and effect node. |
1094 child_->SetForceRenderSurfaceForTesting(true); | 1094 child_->SetForceRenderSurface(true); |
1095 root_->AddChild(child_); | 1095 root_->AddChild(child_); |
1096 layer_tree_host()->SetRootLayer(root_); | 1096 layer_tree_host()->SetRootLayer(root_); |
1097 LayerTreeHostTest::SetupTree(); | 1097 LayerTreeHostTest::SetupTree(); |
1098 } | 1098 } |
1099 | 1099 |
1100 enum Animations { | 1100 enum Animations { |
1101 OPACITY, | 1101 OPACITY, |
1102 TRANSFORM, | 1102 TRANSFORM, |
1103 FILTER, | 1103 FILTER, |
1104 END, | 1104 END, |
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 case 1: | 2149 case 1: |
2150 // Test not owning the surface. | 2150 // Test not owning the surface. |
2151 parent_layer_->SetOpacity(1.0f); | 2151 parent_layer_->SetOpacity(1.0f); |
2152 break; | 2152 break; |
2153 case 2: | 2153 case 2: |
2154 parent_layer_->SetOpacity(0.0f); | 2154 parent_layer_->SetOpacity(0.0f); |
2155 break; | 2155 break; |
2156 case 3: | 2156 case 3: |
2157 // Test owning the surface. | 2157 // Test owning the surface. |
2158 parent_layer_->SetOpacity(0.5f); | 2158 parent_layer_->SetOpacity(0.5f); |
2159 parent_layer_->SetForceRenderSurfaceForTesting(true); | 2159 parent_layer_->SetForceRenderSurface(true); |
2160 break; | 2160 break; |
2161 case 4: | 2161 case 4: |
2162 EndTest(); | 2162 EndTest(); |
2163 break; | 2163 break; |
2164 default: | 2164 default: |
2165 NOTREACHED(); | 2165 NOTREACHED(); |
2166 } | 2166 } |
2167 } | 2167 } |
2168 | 2168 |
2169 void AfterTest() override {} | 2169 void AfterTest() override {} |
(...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5669 child_ = Layer::Create(); | 5669 child_ = Layer::Create(); |
5670 grand_child_ = Layer::Create(); | 5670 grand_child_ = Layer::Create(); |
5671 | 5671 |
5672 layer_tree_host()->SetRootLayer(root_); | 5672 layer_tree_host()->SetRootLayer(root_); |
5673 root_->AddChild(child_); | 5673 root_->AddChild(child_); |
5674 child_->AddChild(grand_child_); | 5674 child_->AddChild(grand_child_); |
5675 | 5675 |
5676 root_->SetBounds(gfx::Size(50, 50)); | 5676 root_->SetBounds(gfx::Size(50, 50)); |
5677 child_->SetBounds(gfx::Size(50, 50)); | 5677 child_->SetBounds(gfx::Size(50, 50)); |
5678 grand_child_->SetBounds(gfx::Size(50, 50)); | 5678 grand_child_->SetBounds(gfx::Size(50, 50)); |
5679 child_->SetForceRenderSurfaceForTesting(true); | 5679 child_->SetForceRenderSurface(true); |
5680 grand_child_->SetForceRenderSurfaceForTesting(true); | 5680 grand_child_->SetForceRenderSurface(true); |
5681 | 5681 |
5682 LayerTreeHostTest::SetupTree(); | 5682 LayerTreeHostTest::SetupTree(); |
5683 } | 5683 } |
5684 | 5684 |
5685 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5685 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
5686 if (host_impl->sync_tree()->source_frame_number() >= 1) { | 5686 if (host_impl->sync_tree()->source_frame_number() >= 1) { |
5687 LayerImpl* grand_child_impl = | 5687 LayerImpl* grand_child_impl = |
5688 host_impl->sync_tree()->LayerById(grand_child_->id()); | 5688 host_impl->sync_tree()->LayerById(grand_child_->id()); |
5689 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5689 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
5690 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); | 5690 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); |
(...skipping 19 matching lines...) Expand all Loading... |
5710 EndTest(); | 5710 EndTest(); |
5711 } | 5711 } |
5712 } | 5712 } |
5713 | 5713 |
5714 void DidCommit() override { | 5714 void DidCommit() override { |
5715 switch (layer_tree_host()->SourceFrameNumber()) { | 5715 switch (layer_tree_host()->SourceFrameNumber()) { |
5716 case 2: | 5716 case 2: |
5717 // Setting an empty viewport causes draws to get skipped, so the active | 5717 // Setting an empty viewport causes draws to get skipped, so the active |
5718 // tree won't update draw properties. | 5718 // tree won't update draw properties. |
5719 layer_tree_host()->SetViewportSize(gfx::Size()); | 5719 layer_tree_host()->SetViewportSize(gfx::Size()); |
5720 child_->SetForceRenderSurfaceForTesting(false); | 5720 child_->SetForceRenderSurface(false); |
5721 break; | 5721 break; |
5722 case 3: | 5722 case 3: |
5723 layer_tree_host()->SetViewportSize(root_->bounds()); | 5723 layer_tree_host()->SetViewportSize(root_->bounds()); |
5724 } | 5724 } |
5725 } | 5725 } |
5726 | 5726 |
5727 void AfterTest() override {} | 5727 void AfterTest() override {} |
5728 | 5728 |
5729 private: | 5729 private: |
5730 scoped_refptr<Layer> root_; | 5730 scoped_refptr<Layer> root_; |
(...skipping 2005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7736 void AfterTest() override {} | 7736 void AfterTest() override {} |
7737 | 7737 |
7738 private: | 7738 private: |
7739 bool received_ack_ = false; | 7739 bool received_ack_ = false; |
7740 }; | 7740 }; |
7741 | 7741 |
7742 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); | 7742 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); |
7743 | 7743 |
7744 } // namespace | 7744 } // namespace |
7745 } // namespace cc | 7745 } // namespace cc |
OLD | NEW |