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 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 case 1: | 2370 case 1: |
2371 // Test not owning the surface. | 2371 // Test not owning the surface. |
2372 parent_layer_->SetOpacity(1.0f); | 2372 parent_layer_->SetOpacity(1.0f); |
2373 break; | 2373 break; |
2374 case 2: | 2374 case 2: |
2375 parent_layer_->SetOpacity(0.0f); | 2375 parent_layer_->SetOpacity(0.0f); |
2376 break; | 2376 break; |
2377 case 3: | 2377 case 3: |
2378 // Test owning the surface. | 2378 // Test owning the surface. |
2379 parent_layer_->SetOpacity(0.5f); | 2379 parent_layer_->SetOpacity(0.5f); |
2380 parent_layer_->SetForceRenderSurfaceForTesting(true); | 2380 parent_layer_->SetForceRenderSurface(true); |
2381 break; | 2381 break; |
2382 case 4: | 2382 case 4: |
2383 EndTest(); | 2383 EndTest(); |
2384 break; | 2384 break; |
2385 default: | 2385 default: |
2386 NOTREACHED(); | 2386 NOTREACHED(); |
2387 } | 2387 } |
2388 } | 2388 } |
2389 | 2389 |
2390 void AfterTest() override {} | 2390 void AfterTest() override {} |
(...skipping 3502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5893 child_ = Layer::Create(); | 5893 child_ = Layer::Create(); |
5894 grand_child_ = Layer::Create(); | 5894 grand_child_ = Layer::Create(); |
5895 | 5895 |
5896 layer_tree_host()->SetRootLayer(root_); | 5896 layer_tree_host()->SetRootLayer(root_); |
5897 root_->AddChild(child_); | 5897 root_->AddChild(child_); |
5898 child_->AddChild(grand_child_); | 5898 child_->AddChild(grand_child_); |
5899 | 5899 |
5900 root_->SetBounds(gfx::Size(50, 50)); | 5900 root_->SetBounds(gfx::Size(50, 50)); |
5901 child_->SetBounds(gfx::Size(50, 50)); | 5901 child_->SetBounds(gfx::Size(50, 50)); |
5902 grand_child_->SetBounds(gfx::Size(50, 50)); | 5902 grand_child_->SetBounds(gfx::Size(50, 50)); |
5903 child_->SetForceRenderSurfaceForTesting(true); | 5903 child_->SetForceRenderSurface(true); |
5904 grand_child_->SetForceRenderSurfaceForTesting(true); | 5904 grand_child_->SetForceRenderSurface(true); |
5905 | 5905 |
5906 LayerTreeHostTest::SetupTree(); | 5906 LayerTreeHostTest::SetupTree(); |
5907 } | 5907 } |
5908 | 5908 |
5909 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5909 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
5910 if (host_impl->sync_tree()->source_frame_number() >= 1) { | 5910 if (host_impl->sync_tree()->source_frame_number() >= 1) { |
5911 LayerImpl* grand_child_impl = | 5911 LayerImpl* grand_child_impl = |
5912 host_impl->sync_tree()->LayerById(grand_child_->id()); | 5912 host_impl->sync_tree()->LayerById(grand_child_->id()); |
5913 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5913 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
5914 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); | 5914 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); |
(...skipping 19 matching lines...) Expand all Loading... |
5934 EndTest(); | 5934 EndTest(); |
5935 } | 5935 } |
5936 } | 5936 } |
5937 | 5937 |
5938 void DidCommit() override { | 5938 void DidCommit() override { |
5939 switch (layer_tree_host()->SourceFrameNumber()) { | 5939 switch (layer_tree_host()->SourceFrameNumber()) { |
5940 case 2: | 5940 case 2: |
5941 // Setting an empty viewport causes draws to get skipped, so the active | 5941 // Setting an empty viewport causes draws to get skipped, so the active |
5942 // tree won't update draw properties. | 5942 // tree won't update draw properties. |
5943 layer_tree_host()->SetViewportSize(gfx::Size()); | 5943 layer_tree_host()->SetViewportSize(gfx::Size()); |
5944 child_->SetForceRenderSurfaceForTesting(false); | 5944 child_->SetForceRenderSurface(false); |
5945 break; | 5945 break; |
5946 case 3: | 5946 case 3: |
5947 layer_tree_host()->SetViewportSize(root_->bounds()); | 5947 layer_tree_host()->SetViewportSize(root_->bounds()); |
5948 } | 5948 } |
5949 } | 5949 } |
5950 | 5950 |
5951 void AfterTest() override {} | 5951 void AfterTest() override {} |
5952 | 5952 |
5953 private: | 5953 private: |
5954 scoped_refptr<Layer> root_; | 5954 scoped_refptr<Layer> root_; |
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7963 void AfterTest() override {} | 7963 void AfterTest() override {} |
7964 | 7964 |
7965 private: | 7965 private: |
7966 bool received_ack_ = false; | 7966 bool received_ack_ = false; |
7967 }; | 7967 }; |
7968 | 7968 |
7969 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); | 7969 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); |
7970 | 7970 |
7971 } // namespace | 7971 } // namespace |
7972 } // namespace cc | 7972 } // namespace cc |
OLD | NEW |