| 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 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2141 case 1: | 2141 case 1: |
| 2142 // Test not owning the surface. | 2142 // Test not owning the surface. |
| 2143 parent_layer_->SetOpacity(1.0f); | 2143 parent_layer_->SetOpacity(1.0f); |
| 2144 break; | 2144 break; |
| 2145 case 2: | 2145 case 2: |
| 2146 parent_layer_->SetOpacity(0.0f); | 2146 parent_layer_->SetOpacity(0.0f); |
| 2147 break; | 2147 break; |
| 2148 case 3: | 2148 case 3: |
| 2149 // Test owning the surface. | 2149 // Test owning the surface. |
| 2150 parent_layer_->SetOpacity(0.5f); | 2150 parent_layer_->SetOpacity(0.5f); |
| 2151 parent_layer_->SetForceRenderSurfaceForTesting(true); | 2151 parent_layer_->SetForceRenderSurface(true); |
| 2152 break; | 2152 break; |
| 2153 case 4: | 2153 case 4: |
| 2154 EndTest(); | 2154 EndTest(); |
| 2155 break; | 2155 break; |
| 2156 default: | 2156 default: |
| 2157 NOTREACHED(); | 2157 NOTREACHED(); |
| 2158 } | 2158 } |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 void AfterTest() override {} | 2161 void AfterTest() override {} |
| (...skipping 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5660 child_ = Layer::Create(); | 5660 child_ = Layer::Create(); |
| 5661 grand_child_ = Layer::Create(); | 5661 grand_child_ = Layer::Create(); |
| 5662 | 5662 |
| 5663 layer_tree_host()->SetRootLayer(root_); | 5663 layer_tree_host()->SetRootLayer(root_); |
| 5664 root_->AddChild(child_); | 5664 root_->AddChild(child_); |
| 5665 child_->AddChild(grand_child_); | 5665 child_->AddChild(grand_child_); |
| 5666 | 5666 |
| 5667 root_->SetBounds(gfx::Size(50, 50)); | 5667 root_->SetBounds(gfx::Size(50, 50)); |
| 5668 child_->SetBounds(gfx::Size(50, 50)); | 5668 child_->SetBounds(gfx::Size(50, 50)); |
| 5669 grand_child_->SetBounds(gfx::Size(50, 50)); | 5669 grand_child_->SetBounds(gfx::Size(50, 50)); |
| 5670 child_->SetForceRenderSurfaceForTesting(true); | 5670 child_->SetForceRenderSurface(true); |
| 5671 grand_child_->SetForceRenderSurfaceForTesting(true); | 5671 grand_child_->SetForceRenderSurface(true); |
| 5672 | 5672 |
| 5673 LayerTreeHostTest::SetupTree(); | 5673 LayerTreeHostTest::SetupTree(); |
| 5674 } | 5674 } |
| 5675 | 5675 |
| 5676 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 5676 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 5677 if (host_impl->sync_tree()->source_frame_number() >= 1) { | 5677 if (host_impl->sync_tree()->source_frame_number() >= 1) { |
| 5678 LayerImpl* grand_child_impl = | 5678 LayerImpl* grand_child_impl = |
| 5679 host_impl->sync_tree()->LayerById(grand_child_->id()); | 5679 host_impl->sync_tree()->LayerById(grand_child_->id()); |
| 5680 EXPECT_EQ(grand_child_impl->effect_tree_index(), | 5680 EXPECT_EQ(grand_child_impl->effect_tree_index(), |
| 5681 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); | 5681 GetRenderSurface(grand_child_impl)->EffectTreeIndex()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5701 EndTest(); | 5701 EndTest(); |
| 5702 } | 5702 } |
| 5703 } | 5703 } |
| 5704 | 5704 |
| 5705 void DidCommit() override { | 5705 void DidCommit() override { |
| 5706 switch (layer_tree_host()->SourceFrameNumber()) { | 5706 switch (layer_tree_host()->SourceFrameNumber()) { |
| 5707 case 2: | 5707 case 2: |
| 5708 // Setting an empty viewport causes draws to get skipped, so the active | 5708 // Setting an empty viewport causes draws to get skipped, so the active |
| 5709 // tree won't update draw properties. | 5709 // tree won't update draw properties. |
| 5710 layer_tree_host()->SetViewportSize(gfx::Size()); | 5710 layer_tree_host()->SetViewportSize(gfx::Size()); |
| 5711 child_->SetForceRenderSurfaceForTesting(false); | 5711 child_->SetForceRenderSurface(false); |
| 5712 break; | 5712 break; |
| 5713 case 3: | 5713 case 3: |
| 5714 layer_tree_host()->SetViewportSize(root_->bounds()); | 5714 layer_tree_host()->SetViewportSize(root_->bounds()); |
| 5715 } | 5715 } |
| 5716 } | 5716 } |
| 5717 | 5717 |
| 5718 void AfterTest() override {} | 5718 void AfterTest() override {} |
| 5719 | 5719 |
| 5720 private: | 5720 private: |
| 5721 scoped_refptr<Layer> root_; | 5721 scoped_refptr<Layer> root_; |
| (...skipping 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7723 void AfterTest() override {} | 7723 void AfterTest() override {} |
| 7724 | 7724 |
| 7725 private: | 7725 private: |
| 7726 bool received_ack_ = false; | 7726 bool received_ack_ = false; |
| 7727 }; | 7727 }; |
| 7728 | 7728 |
| 7729 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); | 7729 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestDiscardAckAfterRelease); |
| 7730 | 7730 |
| 7731 } // namespace | 7731 } // namespace |
| 7732 } // namespace cc | 7732 } // namespace cc |
| OLD | NEW |