Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: cc/trees/layer_tree_host_common_unittest.cc

Issue 2846653002: cc : Stop pushing layers from hidden subtrees at commit
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 4722 matching lines...) Expand 10 before | Expand all | Expand 10 after
4733 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText()); 4733 EXPECT_EQ(expect_not_lcd_text, child_->CanUseLCDText());
4734 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText()); 4734 EXPECT_EQ(expect_lcd_text, grand_child_->CanUseLCDText());
4735 } 4735 }
4736 4736
4737 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest, 4737 INSTANTIATE_TEST_CASE_P(LayerTreeHostCommonTest,
4738 LCDTextTest, 4738 LCDTextTest,
4739 testing::Combine(testing::Bool(), 4739 testing::Combine(testing::Bool(),
4740 testing::Bool(), 4740 testing::Bool(),
4741 testing::Bool())); 4741 testing::Bool()));
4742 4742
4743 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_SingleLayerImpl) {
4744 FakeImplTaskRunnerProvider task_runner_provider;
4745 TestTaskGraphRunner task_graph_runner;
4746 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
4747 host_impl.CreatePendingTree();
4748
4749 std::unique_ptr<LayerImpl> root =
4750 LayerImpl::Create(host_impl.pending_tree(), 1);
4751 root->SetBounds(gfx::Size(50, 50));
4752 root->SetDrawsContent(true);
4753 LayerImpl* root_layer = root.get();
4754
4755 std::unique_ptr<LayerImpl> child =
4756 LayerImpl::Create(host_impl.pending_tree(), 2);
4757 child->SetBounds(gfx::Size(40, 40));
4758 child->SetDrawsContent(true);
4759 LayerImpl* child_layer = child.get();
4760
4761 std::unique_ptr<LayerImpl> grand_child =
4762 LayerImpl::Create(host_impl.pending_tree(), 3);
4763 grand_child->SetBounds(gfx::Size(30, 30));
4764 grand_child->SetDrawsContent(true);
4765 grand_child->test_properties()->hide_layer_and_subtree = true;
4766 LayerImpl* grand_child_layer = grand_child.get();
4767
4768 child->test_properties()->AddChild(std::move(grand_child));
4769 root->test_properties()->AddChild(std::move(child));
4770 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
4771
4772 RenderSurfaceList render_surface_list;
4773 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
4774 root_layer, root_layer->bounds(), &render_surface_list);
4775 inputs.can_adjust_raster_scales = true;
4776 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
4777
4778 // We should have one render surface and two layers. The grand child has
4779 // hidden itself.
4780 ASSERT_EQ(1u, render_surface_list.size());
4781 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors());
4782 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface());
4783 EXPECT_TRUE(child_layer->contributes_to_drawn_render_surface());
4784 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface());
4785 }
4786
4787 TEST_F(LayerTreeHostCommonTest, SubtreeHidden_TwoLayersImpl) {
4788 FakeImplTaskRunnerProvider task_runner_provider;
4789 TestTaskGraphRunner task_graph_runner;
4790 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
4791 host_impl.CreatePendingTree();
4792
4793 std::unique_ptr<LayerImpl> root =
4794 LayerImpl::Create(host_impl.pending_tree(), 1);
4795 root->SetBounds(gfx::Size(50, 50));
4796 root->SetDrawsContent(true);
4797 LayerImpl* root_layer = root.get();
4798
4799 std::unique_ptr<LayerImpl> child =
4800 LayerImpl::Create(host_impl.pending_tree(), 2);
4801 child->SetBounds(gfx::Size(40, 40));
4802 child->SetDrawsContent(true);
4803 child->test_properties()->hide_layer_and_subtree = true;
4804 LayerImpl* child_layer = child.get();
4805
4806 std::unique_ptr<LayerImpl> grand_child =
4807 LayerImpl::Create(host_impl.pending_tree(), 3);
4808 grand_child->SetBounds(gfx::Size(30, 30));
4809 grand_child->SetDrawsContent(true);
4810 LayerImpl* grand_child_layer = grand_child.get();
4811
4812 child->test_properties()->AddChild(std::move(grand_child));
4813 root->test_properties()->AddChild(std::move(child));
4814 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
4815
4816 RenderSurfaceList render_surface_list;
4817 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs(
4818 root_layer, root_layer->bounds(), &render_surface_list);
4819 inputs.can_adjust_raster_scales = true;
4820 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
4821
4822 // We should have one render surface and one layer. The child has
4823 // hidden itself and the grand child.
4824 ASSERT_EQ(1u, render_surface_list.size());
4825 ASSERT_EQ(1, GetRenderSurface(root_layer)->num_contributors());
4826 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface());
4827 EXPECT_FALSE(child_layer->contributes_to_drawn_render_surface());
4828 EXPECT_FALSE(grand_child_layer->contributes_to_drawn_render_surface());
4829 }
4830
4831 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {} 4743 void EmptyCopyOutputCallback(std::unique_ptr<CopyOutputResult> result) {}
4832 4744
4833 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) { 4745 TEST_F(LayerTreeHostCommonTest, SubtreeHiddenWithCopyRequest) {
4834 FakeImplTaskRunnerProvider task_runner_provider; 4746 scoped_refptr<Layer> root = Layer::Create();
4835 TestTaskGraphRunner task_graph_runner; 4747 scoped_refptr<Layer> copy_grand_parent = Layer::Create();
4836 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 4748 scoped_refptr<Layer> copy_parent = Layer::Create();
4837 host_impl.CreatePendingTree(); 4749 scoped_refptr<Layer> copy_layer = Layer::Create();
4750 scoped_refptr<Layer> copy_child = Layer::Create();
4751 scoped_refptr<Layer> copy_grand_child = Layer::Create();
4752 scoped_refptr<Layer> copy_grand_parent_sibling_before = Layer::Create();
4753 scoped_refptr<Layer> copy_grand_parent_sibling_after = Layer::Create();
4838 4754
4839 std::unique_ptr<LayerImpl> root =
4840 LayerImpl::Create(host_impl.pending_tree(), 1);
4841 root->SetBounds(gfx::Size(50, 50)); 4755 root->SetBounds(gfx::Size(50, 50));
4842 root->SetDrawsContent(true); 4756 copy_grand_parent->SetBounds(gfx::Size(50, 50));
4843 LayerImpl* root_layer = root.get(); 4757 copy_parent->SetBounds(gfx::Size(50, 50));
4758 copy_parent->SetForceRenderSurfaceForTesting(true);
4759 copy_layer->SetBounds(gfx::Size(50, 50));
4760 copy_child->SetBounds(gfx::Size(50, 50));
4761 copy_grand_child->SetBounds(gfx::Size(50, 50));
4762 copy_grand_parent_sibling_before->SetBounds(gfx::Size(50, 50));
4763 copy_grand_parent_sibling_after->SetBounds(gfx::Size(50, 50));
4844 4764
4845 std::unique_ptr<LayerImpl> copy_grand_parent = 4765 root->AddChild(copy_grand_parent_sibling_before);
4846 LayerImpl::Create(host_impl.pending_tree(), 2); 4766 root->AddChild(copy_grand_parent);
4847 copy_grand_parent->SetBounds(gfx::Size(40, 40)); 4767 root->AddChild(copy_grand_parent_sibling_after);
4848 copy_grand_parent->SetDrawsContent(true); 4768 copy_grand_parent->AddChild(copy_parent);
4849 LayerImpl* copy_grand_parent_layer = copy_grand_parent.get(); 4769 copy_parent->AddChild(copy_layer);
4770 copy_layer->AddChild(copy_child);
4771 copy_child->AddChild(copy_grand_child);
4772 host()->SetRootLayer(root);
4850 4773
4851 std::unique_ptr<LayerImpl> copy_parent = 4774 copy_layer->RequestCopyOfOutput(
4852 LayerImpl::Create(host_impl.pending_tree(), 3);
4853 copy_parent->SetBounds(gfx::Size(30, 30));
4854 copy_parent->SetDrawsContent(true);
4855 copy_parent->test_properties()->force_render_surface = true;
4856 LayerImpl* copy_parent_layer = copy_parent.get();
4857
4858 std::unique_ptr<LayerImpl> copy_request =
4859 LayerImpl::Create(host_impl.pending_tree(), 4);
4860 copy_request->SetBounds(gfx::Size(20, 20));
4861 copy_request->SetDrawsContent(true);
4862 copy_request->test_properties()->force_render_surface = true;
4863 LayerImpl* copy_layer = copy_request.get();
4864
4865 std::unique_ptr<LayerImpl> copy_child =
4866 LayerImpl::Create(host_impl.pending_tree(), 5);
4867 copy_child->SetBounds(gfx::Size(20, 20));
4868 copy_child->SetDrawsContent(true);
4869 LayerImpl* copy_child_layer = copy_child.get();
4870
4871 std::unique_ptr<LayerImpl> copy_grand_child =
4872 LayerImpl::Create(host_impl.pending_tree(), 6);
4873 copy_grand_child->SetBounds(gfx::Size(20, 20));
4874 copy_grand_child->SetDrawsContent(true);
4875 LayerImpl* copy_grand_child_layer = copy_grand_child.get();
4876
4877 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_before =
4878 LayerImpl::Create(host_impl.pending_tree(), 7);
4879 copy_grand_parent_sibling_before->SetBounds(gfx::Size(40, 40));
4880 copy_grand_parent_sibling_before->SetDrawsContent(true);
4881 LayerImpl* copy_grand_parent_sibling_before_layer =
4882 copy_grand_parent_sibling_before.get();
4883
4884 std::unique_ptr<LayerImpl> copy_grand_parent_sibling_after =
4885 LayerImpl::Create(host_impl.pending_tree(), 8);
4886 copy_grand_parent_sibling_after->SetBounds(gfx::Size(40, 40));
4887 copy_grand_parent_sibling_after->SetDrawsContent(true);
4888 LayerImpl* copy_grand_parent_sibling_after_layer =
4889 copy_grand_parent_sibling_after.get();
4890
4891 copy_child->test_properties()->AddChild(std::move(copy_grand_child));
4892 copy_request->test_properties()->AddChild(std::move(copy_child));
4893 copy_parent->test_properties()->AddChild(std::move(copy_request));
4894 copy_grand_parent->test_properties()->AddChild(std::move(copy_parent));
4895 root->test_properties()->AddChild(
4896 std::move(copy_grand_parent_sibling_before));
4897 root->test_properties()->AddChild(std::move(copy_grand_parent));
4898 root->test_properties()->AddChild(std::move(copy_grand_parent_sibling_after));
4899 host_impl.pending_tree()->SetRootLayerForTesting(std::move(root));
4900
4901 // Hide the copy_grand_parent and its subtree. But make a copy request in that
4902 // hidden subtree on copy_layer. Also hide the copy grand child and its
4903 // subtree.
4904 copy_grand_parent_layer->test_properties()->hide_layer_and_subtree = true;
4905 copy_grand_parent_sibling_before_layer->test_properties()
4906 ->hide_layer_and_subtree = true;
4907 copy_grand_parent_sibling_after_layer->test_properties()
4908 ->hide_layer_and_subtree = true;
4909 copy_grand_child_layer->test_properties()->hide_layer_and_subtree = true;
4910
4911 copy_layer->test_properties()->copy_requests.push_back(
4912 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); 4775 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
4913 4776
4914 RenderSurfaceList render_surface_list; 4777 copy_grand_parent->SetHideLayerAndSubtree(true);
4915 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( 4778 copy_grand_parent_sibling_before->SetHideLayerAndSubtree(true);
4916 root_layer, root_layer->bounds(), &render_surface_list); 4779 copy_grand_parent_sibling_after->SetHideLayerAndSubtree(true);
4917 inputs.can_adjust_raster_scales = true; 4780 copy_grand_child->SetHideLayerAndSubtree(true);
4918 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs);
4919 4781
4920 EXPECT_TRUE(root_layer->has_copy_requests_in_target_subtree()); 4782 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
4921 EXPECT_TRUE(copy_grand_parent_layer->has_copy_requests_in_target_subtree()); 4783 EXPECT_FALSE(copy_grand_parent->is_hidden());
4922 EXPECT_TRUE(copy_parent_layer->has_copy_requests_in_target_subtree()); 4784 EXPECT_TRUE(copy_grand_parent_sibling_after->is_hidden());
4923 EXPECT_TRUE(copy_layer->has_copy_requests_in_target_subtree()); 4785 EXPECT_TRUE(copy_grand_parent_sibling_before->is_hidden());
4786 EXPECT_TRUE(copy_grand_child->is_hidden());
4924 4787
4925 // We should have four render surfaces, one for the root, one for the grand 4788 EffectTree& tree = host()->property_trees()->effect_tree;
4926 // parent since it has opacity and two drawing descendants, one for the parent 4789 EffectNode* node = tree.Node(copy_grand_parent->effect_tree_index());
4927 // since it owns a surface, and one for the copy_layer.
4928 ASSERT_EQ(4u, render_surface_list.size());
4929 EXPECT_EQ(static_cast<uint64_t>(root_layer->id()),
4930 render_surface_list.at(0)->id());
4931 EXPECT_EQ(static_cast<uint64_t>(copy_grand_parent_layer->id()),
4932 render_surface_list.at(1)->id());
4933 EXPECT_EQ(static_cast<uint64_t>(copy_parent_layer->id()),
4934 render_surface_list.at(2)->id());
4935 EXPECT_EQ(static_cast<uint64_t>(copy_layer->id()),
4936 render_surface_list.at(3)->id());
4937
4938 // The root render surface should have 2 contributing layers.
4939 EXPECT_EQ(2, GetRenderSurface(root_layer)->num_contributors());
4940 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface());
4941 EXPECT_FALSE(copy_grand_parent_layer->contributes_to_drawn_render_surface());
4942 EXPECT_FALSE(copy_grand_parent_sibling_before_layer
4943 ->contributes_to_drawn_render_surface());
4944 EXPECT_FALSE(copy_grand_parent_sibling_after_layer
4945 ->contributes_to_drawn_render_surface());
4946
4947 // Nothing actually draws into the copy parent, so only the copy_layer will
4948 // appear in its list, since it needs to be drawn for the copy request.
4949 ASSERT_EQ(1, GetRenderSurface(copy_parent_layer)->num_contributors());
4950 EXPECT_FALSE(copy_parent_layer->contributes_to_drawn_render_surface());
4951
4952 // The copy layer's render surface should have 2 contributing layers.
4953 ASSERT_EQ(2, GetRenderSurface(copy_layer)->num_contributors());
4954 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface());
4955 EXPECT_TRUE(copy_child_layer->contributes_to_drawn_render_surface());
4956 EXPECT_FALSE(copy_grand_child_layer->contributes_to_drawn_render_surface());
4957
4958 // copy_grand_parent, copy_parent shouldn't be drawn because they are hidden,
4959 // but the copy_layer and copy_child should be drawn for the copy request.
4960 // copy grand child should not be drawn as its hidden even in the copy
4961 // request.
4962 EffectTree& tree =
4963 root_layer->layer_tree_impl()->property_trees()->effect_tree;
4964 EffectNode* node = tree.Node(copy_grand_parent_layer->effect_tree_index());
4965 EXPECT_FALSE(node->is_drawn); 4790 EXPECT_FALSE(node->is_drawn);
4966 node = tree.Node(copy_parent_layer->effect_tree_index()); 4791 node = tree.Node(copy_parent->effect_tree_index());
4967 EXPECT_FALSE(node->is_drawn); 4792 EXPECT_FALSE(node->is_drawn);
4968 node = tree.Node(copy_layer->effect_tree_index()); 4793 node = tree.Node(copy_layer->effect_tree_index());
4969 EXPECT_TRUE(node->is_drawn); 4794 EXPECT_TRUE(node->is_drawn);
4970 node = tree.Node(copy_child_layer->effect_tree_index()); 4795 node = tree.Node(copy_child->effect_tree_index());
4971 EXPECT_TRUE(node->is_drawn); 4796 EXPECT_TRUE(node->is_drawn);
4972 node = tree.Node(copy_grand_child_layer->effect_tree_index());
4973 EXPECT_FALSE(node->is_drawn);
4974
4975 // Though copy_layer is drawn, it shouldn't contribute to drawn surface as its
4976 // actually hidden.
4977 EXPECT_FALSE(GetRenderSurface(copy_layer)->contributes_to_drawn_surface());
4978 } 4797 }
4979 4798
4980 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) { 4799 TEST_F(LayerTreeHostCommonTest, ClippedOutCopyRequest) {
4981 FakeImplTaskRunnerProvider task_runner_provider; 4800 FakeImplTaskRunnerProvider task_runner_provider;
4982 TestTaskGraphRunner task_graph_runner; 4801 TestTaskGraphRunner task_graph_runner;
4983 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner); 4802 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &task_graph_runner);
4984 host_impl.CreatePendingTree(); 4803 host_impl.CreatePendingTree();
4985 4804
4986 std::unique_ptr<LayerImpl> root = 4805 std::unique_ptr<LayerImpl> root =
4987 LayerImpl::Create(host_impl.pending_tree(), 1); 4806 LayerImpl::Create(host_impl.pending_tree(), 1);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
5024 EXPECT_EQ(static_cast<uint64_t>(root_layer->id()), 4843 EXPECT_EQ(static_cast<uint64_t>(root_layer->id()),
5025 render_surface_list.at(0)->id()); 4844 render_surface_list.at(0)->id());
5026 4845
5027 // The root render surface should have only 2 contributing layer, since the 4846 // The root render surface should have only 2 contributing layer, since the
5028 // other layers are clipped away. 4847 // other layers are clipped away.
5029 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors()); 4848 ASSERT_EQ(2, GetRenderSurface(root_layer)->num_contributors());
5030 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface()); 4849 EXPECT_TRUE(root_layer->contributes_to_drawn_render_surface());
5031 } 4850 }
5032 4851
5033 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) { 4852 TEST_F(LayerTreeHostCommonTest, SingularTransformAndCopyRequests) {
5034 LayerImpl* root = root_layer_for_testing(); 4853 scoped_refptr<Layer> root = Layer::Create();
4854 scoped_refptr<Layer> singular_transform_layer = Layer::Create();
4855 scoped_refptr<Layer> copy_layer = Layer::Create();
4856 scoped_refptr<Layer> copy_child = Layer::Create();
4857 scoped_refptr<Layer> copy_grand_child = Layer::Create();
4858
4859 root->AddChild(singular_transform_layer);
4860 singular_transform_layer->AddChild(copy_layer);
4861 copy_layer->AddChild(copy_child);
4862 copy_child->AddChild(copy_grand_child);
4863 host()->SetRootLayer(root);
4864
5035 root->SetBounds(gfx::Size(50, 50)); 4865 root->SetBounds(gfx::Size(50, 50));
5036 root->SetDrawsContent(true); 4866 root->SetIsDrawable(true);
5037
5038 LayerImpl* singular_transform_layer = AddChild<LayerImpl>(root);
5039 singular_transform_layer->SetBounds(gfx::Size(100, 100)); 4867 singular_transform_layer->SetBounds(gfx::Size(100, 100));
5040 singular_transform_layer->SetDrawsContent(true);
5041 gfx::Transform singular; 4868 gfx::Transform singular;
5042 singular.Scale3d(6.f, 6.f, 0.f); 4869 singular.Scale3d(6.f, 6.f, 0.f);
5043 singular_transform_layer->test_properties()->transform = singular; 4870 singular_transform_layer->SetTransform(singular);
4871 singular_transform_layer->SetIsDrawable(true);
4872 copy_layer->SetBounds(gfx::Size(100, 100));
4873 copy_layer->SetIsDrawable(true);
4874 copy_layer->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest(
4875 base::Bind(&EmptyCopyOutputCallback)));
4876 copy_child->SetBounds(gfx::Size(100, 100));
4877 copy_child->SetIsDrawable(true);
4878 copy_grand_child->SetBounds(gfx::Size(100, 100));
4879 copy_grand_child->SetTransform(singular);
4880 copy_grand_child->SetIsDrawable(true);
5044 4881
5045 LayerImpl* copy_layer = AddChild<LayerImpl>(singular_transform_layer); 4882 ExecuteCalculateDrawProperties(root.get());
5046 copy_layer->SetBounds(gfx::Size(100, 100));
5047 copy_layer->SetDrawsContent(true);
5048 copy_layer->test_properties()->copy_requests.push_back(
5049 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback)));
5050 4883
5051 LayerImpl* copy_child = AddChild<LayerImpl>(copy_layer); 4884 host()->host_impl()->CreatePendingTree();
5052 copy_child->SetBounds(gfx::Size(100, 100)); 4885 host()->CommitAndCreatePendingTree();
5053 copy_child->SetDrawsContent(true); 4886 host()->host_impl()->ActivateSyncTree();
4887 LayerTreeImpl* layer_tree_impl = host()->host_impl()->active_tree();
5054 4888
5055 LayerImpl* copy_grand_child = AddChild<LayerImpl>(copy_child); 4889 LayerImpl* root_impl = layer_tree_impl->LayerById(root->id());
5056 copy_grand_child->SetBounds(gfx::Size(100, 100)); 4890 LayerImpl* singular_transform_layer_impl =
5057 copy_grand_child->SetDrawsContent(true); 4891 layer_tree_impl->LayerById(singular_transform_layer->id());
5058 copy_grand_child->test_properties()->transform = singular; 4892 LayerImpl* copy_layer_impl = layer_tree_impl->LayerById(copy_layer->id());
5059 4893 LayerImpl* copy_child_impl = layer_tree_impl->LayerById(copy_child->id());
5060 DCHECK(!copy_layer->test_properties()->copy_requests.empty()); 4894 LayerImpl* copy_grand_child_impl =
5061 ExecuteCalculateDrawProperties(root); 4895 layer_tree_impl->LayerById(copy_grand_child->id());
5062 DCHECK(copy_layer->test_properties()->copy_requests.empty()); 4896 ExecuteCalculateDrawProperties(root_impl);
5063 4897
5064 // A layer with singular transform should not contribute to drawn render 4898 // A layer with singular transform should not contribute to drawn render
5065 // surface. 4899 // surface.
5066 EXPECT_FALSE(singular_transform_layer->contributes_to_drawn_render_surface()); 4900 EXPECT_FALSE(
4901 singular_transform_layer_impl->contributes_to_drawn_render_surface());
5067 // Even though copy_layer and copy_child have singular screen space transform, 4902 // Even though copy_layer and copy_child have singular screen space transform,
5068 // they still contribute to drawn render surface as their transform to the 4903 // they still contribute to drawn render surface as their transform to the
5069 // closest ancestor with copy request is not singular. 4904 // closest ancestor with copy request is not singular.
5070 EXPECT_TRUE(copy_layer->contributes_to_drawn_render_surface()); 4905 EXPECT_TRUE(copy_layer_impl->contributes_to_drawn_render_surface());
5071 EXPECT_TRUE(copy_child->contributes_to_drawn_render_surface()); 4906 EXPECT_TRUE(copy_child_impl->contributes_to_drawn_render_surface());
5072 // copy_grand_child's transform to its closest ancestor with copy request is 4907 // copy_grand_child's transform to its closest ancestor with copy request is
5073 // also singular. So, it doesn't contribute to drawn render surface. 4908 // also singular. So, it doesn't contribute to drawn render surface.
5074 EXPECT_FALSE(copy_grand_child->contributes_to_drawn_render_surface()); 4909 EXPECT_FALSE(copy_grand_child_impl->contributes_to_drawn_render_surface());
5075 } 4910 }
5076 4911
5077 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) { 4912 TEST_F(LayerTreeHostCommonTest, VisibleRectInNonRootCopyRequest) {
5078 LayerImpl* root = root_layer_for_testing(); 4913 LayerImpl* root = root_layer_for_testing();
5079 root->SetBounds(gfx::Size(50, 50)); 4914 root->SetBounds(gfx::Size(50, 50));
5080 root->SetDrawsContent(true); 4915 root->SetDrawsContent(true);
5081 root->SetMasksToBounds(true); 4916 root->SetMasksToBounds(true);
5082 4917
5083 LayerImpl* copy_layer = AddChild<LayerImpl>(root); 4918 LayerImpl* copy_layer = AddChild<LayerImpl>(root);
5084 copy_layer->SetBounds(gfx::Size(100, 100)); 4919 copy_layer->SetBounds(gfx::Size(100, 100));
(...skipping 3668 matching lines...) Expand 10 before | Expand all | Expand 10 after
8753 8588
8754 child->SetTransform(singular); 8589 child->SetTransform(singular);
8755 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 8590 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
8756 update_list = GetUpdateLayerList(); 8591 update_list = GetUpdateLayerList();
8757 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); 8592 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list));
8758 child->SetTransform(gfx::Transform()); 8593 child->SetTransform(gfx::Transform());
8759 8594
8760 child->SetHideLayerAndSubtree(true); 8595 child->SetHideLayerAndSubtree(true);
8761 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); 8596 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
8762 update_list = GetUpdateLayerList(); 8597 update_list = GetUpdateLayerList();
8598 EXPECT_TRUE(child->is_hidden());
8599 EXPECT_TRUE(grandchild->is_hidden());
8600 EXPECT_FALSE(VerifyLayerInList(child, update_list));
8763 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list)); 8601 EXPECT_FALSE(VerifyLayerInList(grandchild, update_list));
8764 child->SetHideLayerAndSubtree(false); 8602 child->SetHideLayerAndSubtree(false);
8765 8603
8766 gfx::Transform zero_z_scale; 8604 gfx::Transform zero_z_scale;
8767 zero_z_scale.Scale3d(1, 1, 0); 8605 zero_z_scale.Scale3d(1, 1, 0);
8768 child->SetTransform(zero_z_scale); 8606 child->SetTransform(zero_z_scale);
8769 8607
8770 // Add a transform animation with a start delay. Now, even though |child| has 8608 // Add a transform animation with a start delay. Now, even though |child| has
8771 // a singular transform, the subtree should still get processed. 8609 // a singular transform, the subtree should still get processed.
8772 int animation_id = 0; 8610 int animation_id = 0;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
8866 gfx::Transform rotate_back_and_translate; 8704 gfx::Transform rotate_back_and_translate;
8867 rotate_back_and_translate.RotateAboutYAxis(180); 8705 rotate_back_and_translate.RotateAboutYAxis(180);
8868 rotate_back_and_translate.Translate(-10, 0); 8706 rotate_back_and_translate.Translate(-10, 0);
8869 8707
8870 child_ptr->test_properties()->transform = singular; 8708 child_ptr->test_properties()->transform = singular;
8871 host_impl.active_tree()->property_trees()->needs_rebuild = true; 8709 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8872 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); 8710 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
8873 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8711 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8874 child_ptr->test_properties()->transform = gfx::Transform(); 8712 child_ptr->test_properties()->transform = gfx::Transform();
8875 8713
8876 child_ptr->test_properties()->hide_layer_and_subtree = true;
8877 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
8878 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8879 child_ptr->test_properties()->hide_layer_and_subtree = false;
8880
8881 child_ptr->test_properties()->opacity = 0.f; 8714 child_ptr->test_properties()->opacity = 0.f;
8882 host_impl.active_tree()->property_trees()->needs_rebuild = true; 8715 host_impl.active_tree()->property_trees()->needs_rebuild = true;
8883 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr); 8716 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root_ptr);
8884 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect()); 8717 EXPECT_EQ(gfx::Rect(0, 0), grandchild_ptr->visible_layer_rect());
8885 child_ptr->test_properties()->opacity = 1.f; 8718 child_ptr->test_properties()->opacity = 1.f;
8886 8719
8887 root_ptr->test_properties()->transform = singular; 8720 root_ptr->test_properties()->transform = singular;
8888 // Force transform tree to have a node for child, so that ancestor's 8721 // Force transform tree to have a node for child, so that ancestor's
8889 // invertible transform can be tested. 8722 // invertible transform can be tested.
8890 child_ptr->test_properties()->transform = rotate; 8723 child_ptr->test_properties()->transform = rotate;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
9065 LayerImpl* child = AddChild<LayerImpl>(root); 8898 LayerImpl* child = AddChild<LayerImpl>(root);
9066 8899
9067 root->SetBounds(gfx::Size(100, 100)); 8900 root->SetBounds(gfx::Size(100, 100));
9068 child->SetBounds(gfx::Size(10, 10)); 8901 child->SetBounds(gfx::Size(10, 10));
9069 child->SetDrawsContent(true); 8902 child->SetDrawsContent(true);
9070 8903
9071 ExecuteCalculateDrawProperties(root); 8904 ExecuteCalculateDrawProperties(root);
9072 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 8905 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
9073 child->set_visible_layer_rect(gfx::Rect()); 8906 child->set_visible_layer_rect(gfx::Rect());
9074 8907
9075 child->test_properties()->hide_layer_and_subtree = true;
9076 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9077 ExecuteCalculateDrawProperties(root);
9078 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9079 child->test_properties()->hide_layer_and_subtree = false;
9080
9081 child->SetBounds(gfx::Size()); 8908 child->SetBounds(gfx::Size());
9082 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 8909 root->layer_tree_impl()->property_trees()->needs_rebuild = true;
9083 ExecuteCalculateDrawProperties(root); 8910 ExecuteCalculateDrawProperties(root);
9084 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect()); 8911 EXPECT_EQ(gfx::Rect(0, 0), child->visible_layer_rect());
9085 child->SetBounds(gfx::Size(10, 10)); 8912 child->SetBounds(gfx::Size(10, 10));
9086 8913
9087 gfx::Transform rotate; 8914 gfx::Transform rotate;
9088 child->test_properties()->double_sided = false; 8915 child->test_properties()->double_sided = false;
9089 rotate.RotateAboutXAxis(180.f); 8916 rotate.RotateAboutXAxis(180.f);
9090 child->test_properties()->transform = rotate; 8917 child->test_properties()->transform = rotate;
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
9594 test_layer->SetDrawsContent(true); 9421 test_layer->SetDrawsContent(true);
9595 ExecuteCalculateDrawProperties(root); 9422 ExecuteCalculateDrawProperties(root);
9596 9423
9597 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect()); 9424 EXPECT_EQ(gfx::Rect(30, 30), root->clip_rect());
9598 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect()); 9425 EXPECT_EQ(gfx::Rect(50, 50), render_surface->clip_rect());
9599 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect()); 9426 EXPECT_EQ(gfx::Rect(50, 50), test_layer->clip_rect());
9600 } 9427 }
9601 9428
9602 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) { 9429 TEST_F(LayerTreeHostCommonTest, SubtreeIsHiddenTest) {
9603 // Tests that subtree is hidden is updated. 9430 // Tests that subtree is hidden is updated.
9604 LayerImpl* root = root_layer_for_testing(); 9431 scoped_refptr<Layer> root = Layer::Create();
9605 LayerImpl* hidden = AddChild<LayerImpl>(root); 9432 scoped_refptr<Layer> hidden = Layer::Create();
9606 LayerImpl* test = AddChild<LayerImpl>(hidden); 9433 scoped_refptr<Layer> test = Layer::Create();
9607 9434
9608 root->SetBounds(gfx::Size(30, 30)); 9435 root->SetBounds(gfx::Size(30, 30));
9609 hidden->SetBounds(gfx::Size(30, 30)); 9436 hidden->SetBounds(gfx::Size(30, 30));
9610 hidden->test_properties()->force_render_surface = true; 9437 hidden->SetHideLayerAndSubtree(true);
9611 hidden->test_properties()->hide_layer_and_subtree = true;
9612 test->SetBounds(gfx::Size(30, 30)); 9438 test->SetBounds(gfx::Size(30, 30));
9613 test->test_properties()->force_render_surface = true;
9614 9439
9615 ExecuteCalculateDrawProperties(root); 9440 root->AddChild(hidden);
9616 EXPECT_EQ(0.f, 9441 hidden->AddChild(test);
9617 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); 9442 host()->SetRootLayer(root);
9618 9443
9619 hidden->test_properties()->hide_layer_and_subtree = false; 9444 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9620 root->layer_tree_impl()->property_trees()->needs_rebuild = true; 9445 EXPECT_TRUE(test->is_hidden());
9621 ExecuteCalculateDrawProperties(root); 9446 // Hidden layers should have invalid property tree indices.
9622 EXPECT_EQ(1.f, 9447 const int kInvalidNodeId = -1;
9623 GetRenderSurface(test)->OwningEffectNode()->screen_space_opacity); 9448 EXPECT_EQ(test->effect_tree_index(), kInvalidNodeId);
9449 EXPECT_EQ(test->scroll_tree_index(), kInvalidNodeId);
9450 EXPECT_EQ(test->clip_tree_index(), kInvalidNodeId);
9451 EXPECT_EQ(test->transform_tree_index(), kInvalidNodeId);
9452
9453 hidden->SetHideLayerAndSubtree(false);
9454 root->layer_tree_host()->property_trees()->needs_rebuild = true;
9455 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get());
9456 EXPECT_FALSE(test->is_hidden());
9457 EXPECT_NE(test->effect_tree_index(), kInvalidNodeId);
9458 EXPECT_NE(test->scroll_tree_index(), kInvalidNodeId);
9459 EXPECT_NE(test->clip_tree_index(), kInvalidNodeId);
9460 EXPECT_NE(test->transform_tree_index(), kInvalidNodeId);
9624 } 9461 }
9625 9462
9626 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { 9463 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) {
9627 LayerImpl* root = root_layer_for_testing(); 9464 LayerImpl* root = root_layer_for_testing();
9628 LayerImpl* clip_layer = AddChild<LayerImpl>(root); 9465 LayerImpl* clip_layer = AddChild<LayerImpl>(root);
9629 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); 9466 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer);
9630 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); 9467 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1);
9631 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); 9468 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2);
9632 9469
9633 root->SetBounds(gfx::Size(30, 30)); 9470 root->SetBounds(gfx::Size(30, 30));
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
10206 10043
10207 // Check child layer draw properties. 10044 // Check child layer draw properties.
10208 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); 10045 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect());
10209 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); 10046 EXPECT_EQ(gfx::Transform(), child->DrawTransform());
10210 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); 10047 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect());
10211 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); 10048 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect());
10212 } 10049 }
10213 10050
10214 } // namespace 10051 } // namespace
10215 } // namespace cc 10052 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698