| 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_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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 layer_impl->layer_tree_impl()) | 96 layer_impl->layer_tree_impl()) |
| 97 .starting_animation_scale; | 97 .starting_animation_scale; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void ExecuteCalculateDrawProperties(Layer* root_layer, | 100 void ExecuteCalculateDrawProperties(Layer* root_layer, |
| 101 float device_scale_factor, | 101 float device_scale_factor, |
| 102 float page_scale_factor, | 102 float page_scale_factor, |
| 103 Layer* page_scale_layer, | 103 Layer* page_scale_layer, |
| 104 Layer* inner_viewport_scroll_layer, | 104 Layer* inner_viewport_scroll_layer, |
| 105 Layer* outer_viewport_scroll_layer) { | 105 Layer* outer_viewport_scroll_layer) { |
| 106 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | |
| 107 | |
| 108 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f)); | 106 EXPECT_TRUE(page_scale_layer || (page_scale_factor == 1.f)); |
| 109 gfx::Size device_viewport_size = | 107 gfx::Size device_viewport_size = |
| 110 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 108 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 111 root_layer->bounds().height() * device_scale_factor); | 109 root_layer->bounds().height() * device_scale_factor); |
| 112 | 110 |
| 113 // We are probably not testing what is intended if the root_layer bounds are | 111 // We are probably not testing what is intended if the root_layer bounds are |
| 114 // empty. | 112 // empty. |
| 115 DCHECK(!root_layer->bounds().IsEmpty()); | 113 DCHECK(!root_layer->bounds().IsEmpty()); |
| 116 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( | 114 LayerTreeHostCommon::CalcDrawPropsMainInputsForTesting inputs( |
| 117 root_layer, device_viewport_size); | 115 root_layer, device_viewport_size); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 LayerType* outer_viewport_scroll_layer = nullptr; | 175 LayerType* outer_viewport_scroll_layer = nullptr; |
| 178 ExecuteCalculateDrawProperties( | 176 ExecuteCalculateDrawProperties( |
| 179 root_layer, device_scale_factor, 1.f, page_scale_application_layer, | 177 root_layer, device_scale_factor, 1.f, page_scale_application_layer, |
| 180 inner_viewport_scroll_layer, outer_viewport_scroll_layer); | 178 inner_viewport_scroll_layer, outer_viewport_scroll_layer); |
| 181 } | 179 } |
| 182 | 180 |
| 183 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } | 181 const LayerList* GetUpdateLayerList() { return &update_layer_list_; } |
| 184 | 182 |
| 185 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(Layer* root_layer) { | 183 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(Layer* root_layer) { |
| 186 DCHECK(root_layer->layer_tree_host()); | 184 DCHECK(root_layer->layer_tree_host()); |
| 187 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | |
| 188 | |
| 189 bool can_render_to_separate_surface = true; | 185 bool can_render_to_separate_surface = true; |
| 190 | 186 |
| 191 const Layer* page_scale_layer = | 187 const Layer* page_scale_layer = |
| 192 root_layer->layer_tree_host()->page_scale_layer(); | 188 root_layer->layer_tree_host()->page_scale_layer(); |
| 193 Layer* inner_viewport_scroll_layer = | 189 Layer* inner_viewport_scroll_layer = |
| 194 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); | 190 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); |
| 195 Layer* outer_viewport_scroll_layer = | 191 Layer* outer_viewport_scroll_layer = |
| 196 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); | 192 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); |
| 197 const Layer* overscroll_elasticity_layer = | 193 const Layer* overscroll_elasticity_layer = |
| 198 root_layer->layer_tree_host()->overscroll_elasticity_layer(); | 194 root_layer->layer_tree_host()->overscroll_elasticity_layer(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 214 draw_property_utils::UpdatePropertyTrees(root_layer->layer_tree_host(), | 210 draw_property_utils::UpdatePropertyTrees(root_layer->layer_tree_host(), |
| 215 property_trees, | 211 property_trees, |
| 216 can_render_to_separate_surface); | 212 can_render_to_separate_surface); |
| 217 draw_property_utils::FindLayersThatNeedUpdates( | 213 draw_property_utils::FindLayersThatNeedUpdates( |
| 218 root_layer->layer_tree_host(), property_trees, &update_layer_list_); | 214 root_layer->layer_tree_host(), property_trees, &update_layer_list_); |
| 219 } | 215 } |
| 220 | 216 |
| 221 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( | 217 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( |
| 222 LayerImpl* root_layer) { | 218 LayerImpl* root_layer) { |
| 223 DCHECK(root_layer->layer_tree_impl()); | 219 DCHECK(root_layer->layer_tree_impl()); |
| 224 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); | |
| 225 | |
| 226 bool can_render_to_separate_surface = true; | 220 bool can_render_to_separate_surface = true; |
| 227 | 221 |
| 228 const LayerImpl* page_scale_layer = nullptr; | 222 const LayerImpl* page_scale_layer = nullptr; |
| 229 LayerImpl* inner_viewport_scroll_layer = | 223 LayerImpl* inner_viewport_scroll_layer = |
| 230 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); | 224 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); |
| 231 LayerImpl* outer_viewport_scroll_layer = | 225 LayerImpl* outer_viewport_scroll_layer = |
| 232 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); | 226 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); |
| 233 const LayerImpl* overscroll_elasticity_layer = | 227 const LayerImpl* overscroll_elasticity_layer = |
| 234 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); | 228 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); |
| 235 gfx::Vector2dF elastic_overscroll = | 229 gfx::Vector2dF elastic_overscroll = |
| (...skipping 3767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4003 | 3997 |
| 4004 ExecuteCalculateDrawProperties(root); | 3998 ExecuteCalculateDrawProperties(root); |
| 4005 EXPECT_EQ(gfx::Rect(20, 20), render_surface1->visible_layer_rect()); | 3999 EXPECT_EQ(gfx::Rect(20, 20), render_surface1->visible_layer_rect()); |
| 4006 EXPECT_EQ(gfx::Rect(50, 50), clip_child->visible_layer_rect()); | 4000 EXPECT_EQ(gfx::Rect(50, 50), clip_child->visible_layer_rect()); |
| 4007 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->visible_layer_rect()); | 4001 EXPECT_EQ(gfx::Rect(50, 50), render_surface2->visible_layer_rect()); |
| 4008 } | 4002 } |
| 4009 | 4003 |
| 4010 TEST_F(LayerTreeHostCommonTest, ClipRectOfSurfaceWhoseParentIsAClipChild) { | 4004 TEST_F(LayerTreeHostCommonTest, ClipRectOfSurfaceWhoseParentIsAClipChild) { |
| 4011 LayerImpl* root = root_layer_for_testing(); | 4005 LayerImpl* root = root_layer_for_testing(); |
| 4012 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 4006 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 4013 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); | 4007 LayerImpl* clip_layer = AddChild<LayerImpl>(clip_parent); |
| 4008 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 4014 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); | 4009 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); |
| 4015 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); | 4010 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_child); |
| 4016 | 4011 |
| 4017 root->SetBounds(gfx::Size(100, 100)); | 4012 root->SetBounds(gfx::Size(100, 100)); |
| 4018 | 4013 |
| 4019 clip_parent->SetPosition(gfx::PointF(2.f, 2.f)); | 4014 clip_parent->SetPosition(gfx::PointF(2.f, 2.f)); |
| 4020 clip_parent->SetBounds(gfx::Size(50, 50)); | 4015 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 4021 clip_parent->test_properties()->clip_children = | 4016 clip_parent->test_properties()->clip_children = |
| 4022 base::MakeUnique<std::set<LayerImpl*>>(); | 4017 base::MakeUnique<std::set<LayerImpl*>>(); |
| 4023 clip_parent->test_properties()->clip_children->insert(clip_child); | 4018 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 4024 | 4019 |
| 4020 clip_layer->SetBounds(gfx::Size(50, 50)); |
| 4021 |
| 4025 render_surface1->SetBounds(gfx::Size(20, 20)); | 4022 render_surface1->SetBounds(gfx::Size(20, 20)); |
| 4026 render_surface1->SetDrawsContent(true); | 4023 render_surface1->SetDrawsContent(true); |
| 4027 render_surface1->test_properties()->force_render_surface = true; | 4024 render_surface1->test_properties()->force_render_surface = true; |
| 4028 | 4025 |
| 4029 clip_child->SetBounds(gfx::Size(60, 60)); | 4026 clip_child->SetBounds(gfx::Size(60, 60)); |
| 4030 clip_child->SetDrawsContent(true); | 4027 clip_child->SetDrawsContent(true); |
| 4031 clip_child->test_properties()->clip_parent = clip_parent; | 4028 clip_child->test_properties()->clip_parent = clip_parent; |
| 4032 | 4029 |
| 4033 render_surface2->SetBounds(gfx::Size(60, 60)); | 4030 render_surface2->SetBounds(gfx::Size(60, 60)); |
| 4034 render_surface2->SetDrawsContent(true); | 4031 render_surface2->SetDrawsContent(true); |
| 4035 render_surface2->test_properties()->force_render_surface = true; | 4032 render_surface2->test_properties()->force_render_surface = true; |
| 4036 | 4033 |
| 4037 clip_parent->SetMasksToBounds(true); | 4034 clip_parent->SetMasksToBounds(true); |
| 4035 clip_layer->SetMasksToBounds(true); |
| 4038 render_surface1->SetMasksToBounds(true); | 4036 render_surface1->SetMasksToBounds(true); |
| 4039 | 4037 |
| 4040 float device_scale_factor = 1.f; | 4038 float device_scale_factor = 1.f; |
| 4041 ExecuteCalculateDrawProperties(root, device_scale_factor); | 4039 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 4042 EXPECT_EQ(gfx::Rect(50, 50), | 4040 EXPECT_EQ(gfx::Rect(50, 50), |
| 4043 render_surface2->GetRenderSurface()->clip_rect()); | 4041 render_surface2->GetRenderSurface()->clip_rect()); |
| 4044 device_scale_factor = 2.f; | 4042 device_scale_factor = 2.f; |
| 4045 ExecuteCalculateDrawProperties(root, device_scale_factor); | 4043 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 4046 EXPECT_EQ(gfx::Rect(100, 100), | 4044 EXPECT_EQ(gfx::Rect(100, 100), |
| 4047 render_surface2->GetRenderSurface()->clip_rect()); | 4045 render_surface2->GetRenderSurface()->clip_rect()); |
| (...skipping 1760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5808 render_surface2->SetBounds(gfx::Size(10, 10)); | 5806 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5809 render_surface2->test_properties()->force_render_surface = true; | 5807 render_surface2->test_properties()->force_render_surface = true; |
| 5810 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); | 5808 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5811 clip_child->SetBounds(gfx::Size(60, 60)); | 5809 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5812 ExecuteCalculateDrawProperties(root); | 5810 ExecuteCalculateDrawProperties(root); |
| 5813 | 5811 |
| 5814 EXPECT_TRUE(root->GetRenderSurface()); | 5812 EXPECT_TRUE(root->GetRenderSurface()); |
| 5815 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 5813 EXPECT_TRUE(render_surface1->GetRenderSurface()); |
| 5816 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 5814 EXPECT_TRUE(render_surface2->GetRenderSurface()); |
| 5817 | 5815 |
| 5818 // Since the render surfaces could have expanded, they should not clip (their | 5816 // render_surface1 should apply the clip from clip_parent. Though there is a |
| 5819 // bounds would no longer be reliable). We should resort to layer clipping | 5817 // clip child, render_surface1 can apply the clip as there are no clips |
| 5820 // in this case. | 5818 // between the clip parent and render_surface1 |
| 5821 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5819 EXPECT_EQ(gfx::Rect(1, 1, 40, 40), |
| 5822 render_surface1->GetRenderSurface()->clip_rect()); | 5820 render_surface1->GetRenderSurface()->clip_rect()); |
| 5823 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped()); | 5821 EXPECT_TRUE(render_surface1->GetRenderSurface()->is_clipped()); |
| 5822 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); |
| 5823 EXPECT_FALSE(render_surface1->is_clipped()); |
| 5824 |
| 5825 // render_surface2 could have expanded, as there is a clip between |
| 5826 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). |
| 5827 // So, it should not be clipped (their bounds would no longer be reliable). |
| 5828 // We should resort to layer clipping in this case. |
| 5824 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5829 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 5825 render_surface2->GetRenderSurface()->clip_rect()); | 5830 render_surface2->GetRenderSurface()->clip_rect()); |
| 5826 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); | 5831 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); |
| 5827 | 5832 |
| 5828 // NB: clip rects are in target space. | |
| 5829 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect()); | |
| 5830 EXPECT_TRUE(render_surface1->is_clipped()); | |
| 5831 | |
| 5832 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5833 // This value is inherited from the clipping ancestor layer, 'intervening'. |
| 5833 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); | 5834 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); |
| 5834 EXPECT_TRUE(render_surface2->is_clipped()); | 5835 EXPECT_TRUE(render_surface2->is_clipped()); |
| 5835 | 5836 |
| 5836 // The content rects of both render surfaces should both have expanded to | 5837 // The content rects of render_surface2 should have expanded to contain the |
| 5837 // contain the clip child. | 5838 // clip child. |
| 5838 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), | 5839 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), |
| 5839 render_surface1->GetRenderSurface()->content_rect()); | 5840 render_surface1->GetRenderSurface()->content_rect()); |
| 5840 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40), | 5841 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), |
| 5841 render_surface2->GetRenderSurface()->content_rect()); | 5842 render_surface2->GetRenderSurface()->content_rect()); |
| 5842 | 5843 |
| 5843 // The clip child should have inherited the clip parent's clip (projected to | 5844 // The clip child should have inherited the clip parent's clip (projected to |
| 5844 // the right space, of course), and should have the correctly sized visible | 5845 // the right space, of course), but as render_surface1 already applies that |
| 5845 // content rect. | 5846 // clip, clip_child need not apply it again. |
| 5846 EXPECT_EQ(gfx::Rect(-1, -1, 40, 40), clip_child->clip_rect()); | 5847 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); |
| 5847 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect()); | 5848 EXPECT_EQ(gfx::Rect(9, 9, 40, 40), clip_child->visible_layer_rect()); |
| 5848 EXPECT_TRUE(clip_child->is_clipped()); | 5849 EXPECT_FALSE(clip_child->is_clipped()); |
| 5849 } | 5850 } |
| 5850 | 5851 |
| 5851 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { | 5852 TEST_F(LayerTreeHostCommonTest, ClipParentScrolledInterveningLayer) { |
| 5852 // Ensure that intervening render surfaces are not a problem, even if there | 5853 // Ensure that intervening render surfaces are not a problem, even if there |
| 5853 // is a scroll involved. Note, we do _not_ have to consider any other sort | 5854 // is a scroll involved. Note, we do _not_ have to consider any other sort |
| 5854 // of transform. | 5855 // of transform. |
| 5855 // | 5856 // |
| 5856 // root (a render surface) | 5857 // root (a render surface) |
| 5857 // + clip_parent (masks to bounds) | 5858 // + clip_parent (masks to bounds) |
| 5858 // + render_surface1 (sets opacity) | 5859 // + render_surface1 (sets opacity) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5891 render_surface2->SetBounds(gfx::Size(10, 10)); | 5892 render_surface2->SetBounds(gfx::Size(10, 10)); |
| 5892 render_surface2->test_properties()->force_render_surface = true; | 5893 render_surface2->test_properties()->force_render_surface = true; |
| 5893 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); | 5894 clip_child->SetPosition(gfx::PointF(-10.f, -10.f)); |
| 5894 clip_child->SetBounds(gfx::Size(60, 60)); | 5895 clip_child->SetBounds(gfx::Size(60, 60)); |
| 5895 ExecuteCalculateDrawProperties(root); | 5896 ExecuteCalculateDrawProperties(root); |
| 5896 | 5897 |
| 5897 EXPECT_TRUE(root->GetRenderSurface()); | 5898 EXPECT_TRUE(root->GetRenderSurface()); |
| 5898 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 5899 EXPECT_TRUE(render_surface1->GetRenderSurface()); |
| 5899 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 5900 EXPECT_TRUE(render_surface2->GetRenderSurface()); |
| 5900 | 5901 |
| 5901 // Since the render surfaces could have expanded, they should not clip (their | 5902 // render_surface1 should apply the clip from clip_parent. Though there is a |
| 5902 // bounds would no longer be reliable). We should resort to layer clipping | 5903 // clip child, render_surface1 can apply the clip as there are no clips |
| 5903 // in this case. | 5904 // between the clip parent and render_surface1 |
| 5904 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5905 EXPECT_EQ(gfx::Rect(3, 3, 40, 40), |
| 5905 render_surface1->GetRenderSurface()->clip_rect()); | 5906 render_surface1->GetRenderSurface()->clip_rect()); |
| 5906 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped()); | 5907 EXPECT_TRUE(render_surface1->GetRenderSurface()->is_clipped()); |
| 5908 EXPECT_EQ(gfx::Rect(), render_surface1->clip_rect()); |
| 5909 EXPECT_FALSE(render_surface1->is_clipped()); |
| 5910 |
| 5911 // render_surface2 could have expanded, as there is a clip between |
| 5912 // clip_child's clip (clip_parent) and render_surface2's clip (intervening). |
| 5913 // So, it should not be clipped (their bounds would no longer be reliable). |
| 5914 // We should resort to layer clipping in this case. |
| 5907 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 5915 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 5908 render_surface2->GetRenderSurface()->clip_rect()); | 5916 render_surface2->GetRenderSurface()->clip_rect()); |
| 5909 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); | 5917 EXPECT_FALSE(render_surface2->GetRenderSurface()->is_clipped()); |
| 5910 | |
| 5911 // NB: clip rects are in target space. | |
| 5912 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), render_surface1->clip_rect()); | |
| 5913 EXPECT_TRUE(render_surface1->is_clipped()); | |
| 5914 | |
| 5915 // This value is inherited from the clipping ancestor layer, 'intervening'. | 5918 // This value is inherited from the clipping ancestor layer, 'intervening'. |
| 5916 EXPECT_EQ(gfx::Rect(2, 2, 3, 3), render_surface2->clip_rect()); | 5919 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface2->clip_rect()); |
| 5917 EXPECT_TRUE(render_surface2->is_clipped()); | 5920 EXPECT_TRUE(render_surface2->is_clipped()); |
| 5918 | 5921 |
| 5919 // The content rects of both render surfaces should both have expanded to | 5922 // The content rects of render_surface2 should have expanded to contain the |
| 5920 // contain the clip child. | 5923 // clip child. |
| 5921 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), | 5924 EXPECT_EQ(gfx::Rect(0, 0, 40, 40), |
| 5922 render_surface1->GetRenderSurface()->content_rect()); | 5925 render_surface1->GetRenderSurface()->content_rect()); |
| 5923 EXPECT_EQ(gfx::Rect(2, 2, 40, 40), | 5926 EXPECT_EQ(gfx::Rect(-10, -10, 60, 60), |
| 5924 render_surface2->GetRenderSurface()->content_rect()); | 5927 render_surface2->GetRenderSurface()->content_rect()); |
| 5925 | 5928 |
| 5926 // The clip child should have inherited the clip parent's clip (projected to | 5929 // The clip child should have inherited the clip parent's clip (projected to |
| 5927 // the right space, of course), and should have the correctly sized visible | 5930 // the right space, of course), but as render_surface1 already applies that |
| 5928 // content rect. | 5931 // clip, clip_child need not apply it again. |
| 5929 EXPECT_EQ(gfx::Rect(2, 2, 40, 40), clip_child->clip_rect()); | 5932 EXPECT_EQ(gfx::Rect(), clip_child->clip_rect()); |
| 5930 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect()); | 5933 EXPECT_EQ(gfx::Rect(12, 12, 40, 40), clip_child->visible_layer_rect()); |
| 5931 EXPECT_TRUE(clip_child->is_clipped()); | 5934 EXPECT_FALSE(clip_child->is_clipped()); |
| 5932 } | 5935 } |
| 5933 | 5936 |
| 5934 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { | 5937 TEST_F(LayerTreeHostCommonTest, DescendantsOfClipChildren) { |
| 5935 // Ensures that descendants of the clip child inherit the correct clip. | 5938 // Ensures that descendants of the clip child inherit the correct clip. |
| 5936 // | 5939 // |
| 5937 // root (a render surface) | 5940 // root (a render surface) |
| 5938 // + clip_parent (masks to bounds) | 5941 // + clip_parent (masks to bounds) |
| 5939 // + intervening (masks to bounds) | 5942 // + intervening (masks to bounds) |
| 5940 // + clip_child | 5943 // + clip_child |
| 5941 // + child | 5944 // + child |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5973 EXPECT_TRUE(child->is_clipped()); | 5976 EXPECT_TRUE(child->is_clipped()); |
| 5974 } | 5977 } |
| 5975 | 5978 |
| 5976 TEST_F(LayerTreeHostCommonTest, | 5979 TEST_F(LayerTreeHostCommonTest, |
| 5977 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { | 5980 SurfacesShouldBeUnaffectedByNonDescendantClipChildren) { |
| 5978 // Ensures that non-descendant clip children in the tree do not affect | 5981 // Ensures that non-descendant clip children in the tree do not affect |
| 5979 // render surfaces. | 5982 // render surfaces. |
| 5980 // | 5983 // |
| 5981 // root (a render surface) | 5984 // root (a render surface) |
| 5982 // + clip_parent (masks to bounds) | 5985 // + clip_parent (masks to bounds) |
| 5983 // + render_surface1 | 5986 // + clip_layer (masks to bounds) |
| 5984 // + clip_child | 5987 // + render_surface1 |
| 5985 // + render_surface2 | 5988 // + clip_child |
| 5986 // + non_clip_child | 5989 // + render_surface2 |
| 5990 // + non_clip_child |
| 5987 // | 5991 // |
| 5988 // In this example render_surface2 should be unaffected by clip_child. | 5992 // In this example render_surface2 should be unaffected by clip_child. |
| 5989 LayerImpl* root = root_layer_for_testing(); | 5993 LayerImpl* root = root_layer_for_testing(); |
| 5990 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 5994 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
| 5991 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_parent); | 5995 LayerImpl* clip_layer = AddChild<LayerImpl>(clip_parent); |
| 5996 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 5992 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); | 5997 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface1); |
| 5993 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_parent); | 5998 LayerImpl* render_surface2 = AddChild<LayerImpl>(clip_layer); |
| 5994 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2); | 5999 LayerImpl* non_clip_child = AddChild<LayerImpl>(render_surface2); |
| 5995 | 6000 |
| 5996 clip_child->test_properties()->clip_parent = clip_parent; | 6001 clip_child->test_properties()->clip_parent = clip_parent; |
| 5997 clip_parent->test_properties()->clip_children = | 6002 clip_parent->test_properties()->clip_children = |
| 5998 base::MakeUnique<std::set<LayerImpl*>>(); | 6003 base::MakeUnique<std::set<LayerImpl*>>(); |
| 5999 clip_parent->test_properties()->clip_children->insert(clip_child); | 6004 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 6000 | 6005 |
| 6001 clip_parent->SetMasksToBounds(true); | 6006 clip_parent->SetMasksToBounds(true); |
| 6002 render_surface1->SetMasksToBounds(true); | 6007 clip_layer->SetMasksToBounds(true); |
| 6003 | 6008 |
| 6004 render_surface1->SetDrawsContent(true); | 6009 render_surface1->SetDrawsContent(true); |
| 6005 clip_child->SetDrawsContent(true); | 6010 clip_child->SetDrawsContent(true); |
| 6006 render_surface2->SetDrawsContent(true); | 6011 render_surface2->SetDrawsContent(true); |
| 6007 non_clip_child->SetDrawsContent(true); | 6012 non_clip_child->SetDrawsContent(true); |
| 6008 | 6013 |
| 6009 root->SetBounds(gfx::Size(15, 15)); | 6014 root->SetBounds(gfx::Size(15, 15)); |
| 6010 clip_parent->SetBounds(gfx::Size(10, 10)); | 6015 clip_parent->SetBounds(gfx::Size(10, 10)); |
| 6016 clip_layer->SetBounds(gfx::Size(10, 10)); |
| 6011 render_surface1->SetPosition(gfx::PointF(5, 5)); | 6017 render_surface1->SetPosition(gfx::PointF(5, 5)); |
| 6012 render_surface1->SetBounds(gfx::Size(5, 5)); | 6018 render_surface1->SetBounds(gfx::Size(5, 5)); |
| 6013 render_surface1->test_properties()->force_render_surface = true; | 6019 render_surface1->test_properties()->force_render_surface = true; |
| 6014 render_surface2->SetBounds(gfx::Size(5, 5)); | 6020 render_surface2->SetBounds(gfx::Size(5, 5)); |
| 6015 render_surface2->test_properties()->force_render_surface = true; | 6021 render_surface2->test_properties()->force_render_surface = true; |
| 6016 clip_child->SetPosition(gfx::PointF(-1, 1)); | 6022 clip_child->SetPosition(gfx::PointF(-1, 1)); |
| 6017 clip_child->SetBounds(gfx::Size(10, 10)); | 6023 clip_child->SetBounds(gfx::Size(10, 10)); |
| 6018 non_clip_child->SetBounds(gfx::Size(5, 5)); | 6024 non_clip_child->SetBounds(gfx::Size(5, 5)); |
| 6019 | 6025 |
| 6020 ExecuteCalculateDrawProperties(root); | 6026 ExecuteCalculateDrawProperties(root); |
| 6021 | 6027 |
| 6022 EXPECT_TRUE(root->GetRenderSurface()); | 6028 EXPECT_TRUE(root->GetRenderSurface()); |
| 6023 EXPECT_TRUE(render_surface1->GetRenderSurface()); | 6029 EXPECT_TRUE(render_surface1->GetRenderSurface()); |
| 6024 EXPECT_TRUE(render_surface2->GetRenderSurface()); | 6030 EXPECT_TRUE(render_surface2->GetRenderSurface()); |
| 6025 | 6031 |
| 6026 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), render_surface1->clip_rect()); | 6032 EXPECT_EQ(gfx::Rect(-5, -5, 10, 10), render_surface1->clip_rect()); |
| 6027 EXPECT_TRUE(render_surface1->is_clipped()); | 6033 EXPECT_TRUE(render_surface1->is_clipped()); |
| 6028 | 6034 |
| 6029 // The render surface should not clip (it has unclipped descendants), instead | 6035 // The render surface should not clip (it has unclipped descendants), instead |
| 6030 // it should rely on layer clipping. | 6036 // it should rely on layer clipping. |
| 6031 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), | 6037 EXPECT_EQ(gfx::Rect(0, 0, 0, 0), |
| 6032 render_surface1->GetRenderSurface()->clip_rect()); | 6038 render_surface1->GetRenderSurface()->clip_rect()); |
| 6033 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped()); | 6039 EXPECT_FALSE(render_surface1->GetRenderSurface()->is_clipped()); |
| 6034 | 6040 |
| 6035 // That said, it should have grown to accomodate the unclipped descendant and | 6041 // That said, it should have grown to accomodate the unclipped descendant and |
| 6036 // its own size. | 6042 // its own size. |
| 6037 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5), | 6043 EXPECT_EQ(gfx::Rect(-1, 0, 6, 5), |
| 6038 render_surface1->GetRenderSurface()->content_rect()); | 6044 render_surface1->GetRenderSurface()->content_rect()); |
| 6039 | 6045 |
| 6040 // This render surface should clip. It has no unclipped descendants. | 6046 // This render surface should clip. It has no unclipped descendants. |
| 6041 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), | 6047 EXPECT_EQ(gfx::Rect(0, 0, 10, 10), |
| 6042 render_surface2->GetRenderSurface()->clip_rect()); | 6048 render_surface2->GetRenderSurface()->clip_rect()); |
| 6043 EXPECT_TRUE(render_surface2->GetRenderSurface()->is_clipped()); | 6049 EXPECT_TRUE(render_surface2->GetRenderSurface()->is_clipped()); |
| 6044 EXPECT_FALSE(render_surface2->is_clipped()); | 6050 EXPECT_FALSE(render_surface2->is_clipped()); |
| 6045 | 6051 |
| 6046 // It also shouldn't have grown to accomodate the clip child. | 6052 // It also shouldn't have grown to accomodate the clip child. |
| 6047 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), | 6053 EXPECT_EQ(gfx::Rect(0, 0, 5, 5), |
| 6048 render_surface2->GetRenderSurface()->content_rect()); | 6054 render_surface2->GetRenderSurface()->content_rect()); |
| 6049 | |
| 6050 // Sanity check our num_unclipped_descendants values. | |
| 6051 EXPECT_EQ(1u, render_surface1->test_properties()->num_unclipped_descendants); | |
| 6052 EXPECT_EQ(0u, render_surface2->test_properties()->num_unclipped_descendants); | |
| 6053 } | 6055 } |
| 6054 | 6056 |
| 6055 TEST_F(LayerTreeHostCommonTest, | 6057 TEST_F(LayerTreeHostCommonTest, |
| 6056 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { | 6058 CreateRenderSurfaceWhenFlattenInsideRenderingContext) { |
| 6057 // Verifies that Render Surfaces are created at the edge of rendering context. | 6059 // Verifies that Render Surfaces are created at the edge of rendering context. |
| 6058 | 6060 |
| 6059 LayerImpl* root = root_layer_for_testing(); | 6061 LayerImpl* root = root_layer_for_testing(); |
| 6060 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); | 6062 LayerImpl* child1 = AddChildToRoot<LayerImpl>(); |
| 6061 LayerImpl* child2 = AddChild<LayerImpl>(child1); | 6063 LayerImpl* child2 = AddChild<LayerImpl>(child1); |
| 6062 LayerImpl* child3 = AddChild<LayerImpl>(child2); | 6064 LayerImpl* child3 = AddChild<LayerImpl>(child2); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6117 child3->test_properties()->sorting_context_id = 1; | 6119 child3->test_properties()->sorting_context_id = 1; |
| 6118 | 6120 |
| 6119 child2->test_properties()->AddChild(std::move(child3)); | 6121 child2->test_properties()->AddChild(std::move(child3)); |
| 6120 child1->test_properties()->AddChild(std::move(child2)); | 6122 child1->test_properties()->AddChild(std::move(child2)); |
| 6121 root->test_properties()->AddChild(std::move(child1)); | 6123 root->test_properties()->AddChild(std::move(child1)); |
| 6122 LayerImpl* root_layer = root.get(); | 6124 LayerImpl* root_layer = root.get(); |
| 6123 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); | 6125 root_layer->layer_tree_impl()->SetRootLayerForTesting(std::move(root)); |
| 6124 | 6126 |
| 6125 { | 6127 { |
| 6126 LayerImplList render_surface_layer_list; | 6128 LayerImplList render_surface_layer_list; |
| 6127 FakeLayerTreeHostImpl::RecursiveUpdateNumChildren(root_layer); | |
| 6128 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 6129 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 6129 root_layer, root_layer->bounds(), &render_surface_layer_list); | 6130 root_layer, root_layer->bounds(), &render_surface_layer_list); |
| 6130 inputs.can_render_to_separate_surface = true; | 6131 inputs.can_render_to_separate_surface = true; |
| 6131 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 6132 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 6132 | 6133 |
| 6133 EXPECT_EQ(2u, render_surface_layer_list.size()); | 6134 EXPECT_EQ(2u, render_surface_layer_list.size()); |
| 6134 | 6135 |
| 6135 int count_represents_target_render_surface = 0; | 6136 int count_represents_target_render_surface = 0; |
| 6136 int count_represents_contributing_render_surface = 0; | 6137 int count_represents_contributing_render_surface = 0; |
| 6137 int count_represents_itself = 0; | 6138 int count_represents_itself = 0; |
| (...skipping 3619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9757 child->SetClipParent(root.get()); | 9758 child->SetClipParent(root.get()); |
| 9758 | 9759 |
| 9759 root->AddChild(parent); | 9760 root->AddChild(parent); |
| 9760 parent->AddChild(child); | 9761 parent->AddChild(child); |
| 9761 host()->SetRootLayer(root); | 9762 host()->SetRootLayer(root); |
| 9762 | 9763 |
| 9763 child->RequestCopyOfOutput( | 9764 child->RequestCopyOfOutput( |
| 9764 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); | 9765 CopyOutputRequest::CreateRequest(base::Bind(&EmptyCopyOutputCallback))); |
| 9765 | 9766 |
| 9766 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 9767 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9767 EXPECT_EQ(parent->num_unclipped_descendants(), 1u); | 9768 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 9768 | 9769 |
| 9769 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | |
| 9770 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); | 9770 ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList(root.get()); |
| 9771 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); | 9771 EXPECT_GT(root->num_copy_requests_in_target_subtree(), 0); |
| 9772 } | 9772 } |
| 9773 | 9773 |
| 9774 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { | 9774 TEST_F(LayerTreeHostCommonTest, ResetPropertyTreeIndices) { |
| 9775 scoped_refptr<Layer> root = Layer::Create(); | 9775 scoped_refptr<Layer> root = Layer::Create(); |
| 9776 root->SetBounds(gfx::Size(800, 800)); | 9776 root->SetBounds(gfx::Size(800, 800)); |
| 9777 | 9777 |
| 9778 gfx::Transform translate_z; | 9778 gfx::Transform translate_z; |
| 9779 translate_z.Translate3d(0, 0, 10); | 9779 translate_z.Translate3d(0, 0, 10); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9889 | 9889 |
| 9890 gfx::Transform translate; | 9890 gfx::Transform translate; |
| 9891 translate.Translate(2.0, 2.0); | 9891 translate.Translate(2.0, 2.0); |
| 9892 | 9892 |
| 9893 root->SetBounds(gfx::Size(30, 30)); | 9893 root->SetBounds(gfx::Size(30, 30)); |
| 9894 clip_parent->test_properties()->transform = translate; | 9894 clip_parent->test_properties()->transform = translate; |
| 9895 clip_parent->SetBounds(gfx::Size(30, 30)); | 9895 clip_parent->SetBounds(gfx::Size(30, 30)); |
| 9896 clip_parent->SetMasksToBounds(true); | 9896 clip_parent->SetMasksToBounds(true); |
| 9897 between_clip_parent_and_child->test_properties()->transform = translate; | 9897 between_clip_parent_and_child->test_properties()->transform = translate; |
| 9898 between_clip_parent_and_child->SetBounds(gfx::Size(30, 30)); | 9898 between_clip_parent_and_child->SetBounds(gfx::Size(30, 30)); |
| 9899 between_clip_parent_and_child->SetMasksToBounds(true); |
| 9899 render_surface->SetBounds(gfx::Size(30, 30)); | 9900 render_surface->SetBounds(gfx::Size(30, 30)); |
| 9900 render_surface->test_properties()->force_render_surface = true; | 9901 render_surface->test_properties()->force_render_surface = true; |
| 9901 test_layer->SetBounds(gfx::Size(30, 30)); | 9902 test_layer->SetBounds(gfx::Size(30, 30)); |
| 9902 test_layer->SetDrawsContent(true); | 9903 test_layer->SetDrawsContent(true); |
| 9903 | 9904 |
| 9904 render_surface->test_properties()->clip_parent = clip_parent; | 9905 render_surface->test_properties()->clip_parent = clip_parent; |
| 9905 clip_parent->test_properties()->clip_children = | 9906 clip_parent->test_properties()->clip_children = |
| 9906 base::MakeUnique<std::set<LayerImpl*>>(); | 9907 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9907 clip_parent->test_properties()->clip_children->insert(render_surface); | 9908 clip_parent->test_properties()->clip_children->insert(render_surface); |
| 9908 | 9909 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10008 EXPECT_FALSE(clip_child->is_clipped()); | 10009 EXPECT_FALSE(clip_child->is_clipped()); |
| 10009 } | 10010 } |
| 10010 | 10011 |
| 10011 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) { | 10012 TEST_F(LayerTreeHostCommonTest, RenderSurfaceContentRectWithMultipleSurfaces) { |
| 10012 // Tests the value of render surface content rect when we have multiple types | 10013 // Tests the value of render surface content rect when we have multiple types |
| 10013 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and | 10014 // of surfaces : unclipped surfaces, surfaces with unclipped surfaces and |
| 10014 // clipped surfaces. | 10015 // clipped surfaces. |
| 10015 LayerImpl* root = root_layer_for_testing(); | 10016 LayerImpl* root = root_layer_for_testing(); |
| 10016 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); | 10017 LayerImpl* unclipped_surface = AddChildToRoot<LayerImpl>(); |
| 10017 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); | 10018 LayerImpl* clip_parent = AddChild<LayerImpl>(unclipped_surface); |
| 10018 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 10019 LayerImpl* clip_layer = AddChild<LayerImpl>(clip_parent); |
| 10020 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_layer); |
| 10019 LayerImpl* unclipped_desc_surface2 = | 10021 LayerImpl* unclipped_desc_surface2 = |
| 10020 AddChild<LayerImpl>(unclipped_desc_surface); | 10022 AddChild<LayerImpl>(unclipped_desc_surface); |
| 10021 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2); | 10023 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface2); |
| 10022 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); | 10024 LayerImpl* clipped_surface = AddChild<LayerImpl>(clip_child); |
| 10023 | 10025 |
| 10024 root->SetBounds(gfx::Size(80, 80)); | 10026 root->SetBounds(gfx::Size(80, 80)); |
| 10025 unclipped_surface->SetBounds(gfx::Size(50, 50)); | 10027 unclipped_surface->SetBounds(gfx::Size(50, 50)); |
| 10026 unclipped_surface->SetMasksToBounds(true); | 10028 unclipped_surface->SetMasksToBounds(true); |
| 10027 unclipped_surface->SetDrawsContent(true); | 10029 unclipped_surface->SetDrawsContent(true); |
| 10028 unclipped_surface->test_properties()->force_render_surface = true; | 10030 unclipped_surface->test_properties()->force_render_surface = true; |
| 10029 clip_parent->SetBounds(gfx::Size(50, 50)); | 10031 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 10030 clip_parent->SetMasksToBounds(true); | 10032 clip_parent->SetMasksToBounds(true); |
| 10033 clip_layer->SetMasksToBounds(true); |
| 10034 clip_layer->SetBounds(gfx::Size(100, 100)); |
| 10031 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | 10035 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 10032 unclipped_desc_surface->SetMasksToBounds(true); | |
| 10033 unclipped_desc_surface->SetDrawsContent(true); | 10036 unclipped_desc_surface->SetDrawsContent(true); |
| 10034 unclipped_desc_surface->test_properties()->force_render_surface = true; | 10037 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 10035 unclipped_desc_surface2->SetBounds(gfx::Size(60, 60)); | 10038 unclipped_desc_surface2->SetBounds(gfx::Size(60, 60)); |
| 10036 unclipped_desc_surface2->SetDrawsContent(true); | 10039 unclipped_desc_surface2->SetDrawsContent(true); |
| 10037 unclipped_desc_surface2->test_properties()->force_render_surface = true; | 10040 unclipped_desc_surface2->test_properties()->force_render_surface = true; |
| 10038 clip_child->SetBounds(gfx::Size(100, 100)); | 10041 clip_child->SetBounds(gfx::Size(100, 100)); |
| 10039 clipped_surface->SetBounds(gfx::Size(70, 70)); | 10042 clipped_surface->SetBounds(gfx::Size(70, 70)); |
| 10040 clipped_surface->SetDrawsContent(true); | 10043 clipped_surface->SetDrawsContent(true); |
| 10041 clipped_surface->test_properties()->force_render_surface = true; | 10044 clipped_surface->test_properties()->force_render_surface = true; |
| 10042 | 10045 |
| 10043 clip_child->test_properties()->clip_parent = clip_parent; | 10046 clip_child->test_properties()->clip_parent = clip_parent; |
| 10044 clip_parent->test_properties()->clip_children = | 10047 clip_parent->test_properties()->clip_children = |
| 10045 base::MakeUnique<std::set<LayerImpl*>>(); | 10048 base::MakeUnique<std::set<LayerImpl*>>(); |
| 10046 clip_parent->test_properties()->clip_children->insert(clip_child); | 10049 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 10047 | 10050 |
| 10048 ExecuteCalculateDrawProperties(root); | 10051 ExecuteCalculateDrawProperties(root); |
| 10049 EXPECT_EQ(gfx::Rect(50, 50), | 10052 EXPECT_EQ(gfx::Rect(50, 50), |
| 10050 unclipped_surface->GetRenderSurface()->content_rect()); | 10053 unclipped_surface->GetRenderSurface()->content_rect()); |
| 10051 EXPECT_EQ(gfx::Rect(50, 50), | 10054 EXPECT_EQ(gfx::Rect(50, 50), |
| 10052 unclipped_desc_surface->GetRenderSurface()->content_rect()); | 10055 unclipped_desc_surface->GetRenderSurface()->content_rect()); |
| 10053 EXPECT_EQ(gfx::Rect(50, 50), | 10056 EXPECT_EQ(gfx::Rect(60, 60), |
| 10054 unclipped_desc_surface2->GetRenderSurface()->content_rect()); | 10057 unclipped_desc_surface2->GetRenderSurface()->content_rect()); |
| 10055 EXPECT_EQ(gfx::Rect(50, 50), | 10058 EXPECT_EQ(gfx::Rect(50, 50), |
| 10056 clipped_surface->GetRenderSurface()->content_rect()); | 10059 clipped_surface->GetRenderSurface()->content_rect()); |
| 10057 } | 10060 } |
| 10058 | 10061 |
| 10059 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { | 10062 TEST_F(LayerTreeHostCommonTest, ClipBetweenClipChildTargetAndClipParentTarget) { |
| 10060 // Tests the value of render surface content rect when we have a layer that | 10063 // Tests the value of render surface content rect when we have a layer that |
| 10061 // clips between the clip parent's target and clip child's target. | 10064 // clips between the clip parent's target and clip child's target. |
| 10062 LayerImpl* root = root_layer_for_testing(); | 10065 LayerImpl* root = root_layer_for_testing(); |
| 10063 LayerImpl* surface = AddChildToRoot<LayerImpl>(); | 10066 LayerImpl* surface = AddChildToRoot<LayerImpl>(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10154 | 10157 |
| 10155 ExecuteCalculateDrawProperties(root); | 10158 ExecuteCalculateDrawProperties(root); |
| 10156 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 10159 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
| 10157 test_layer->ScreenSpaceTransform()); | 10160 test_layer->ScreenSpaceTransform()); |
| 10158 } | 10161 } |
| 10159 | 10162 |
| 10160 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) { | 10163 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) { |
| 10161 LayerImpl* root = root_layer_for_testing(); | 10164 LayerImpl* root = root_layer_for_testing(); |
| 10162 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | 10165 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 10163 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | 10166 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 10164 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | 10167 LayerImpl* clip_parent_child = AddChild<LayerImpl>(clip_parent); |
| 10168 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent_child); |
| 10165 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | 10169 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 10166 | 10170 |
| 10167 root->SetBounds(gfx::Size(100, 100)); | 10171 root->SetBounds(gfx::Size(100, 100)); |
| 10168 clip_layer->SetBounds(gfx::Size(20, 20)); | 10172 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 10169 clip_layer->SetMasksToBounds(true); | 10173 clip_layer->SetMasksToBounds(true); |
| 10170 clip_parent->SetBounds(gfx::Size(50, 50)); | 10174 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 10175 clip_parent_child->SetBounds(gfx::Size(20, 20)); |
| 10176 clip_parent_child->SetMasksToBounds(true); |
| 10171 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | 10177 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 10172 unclipped_desc_surface->SetDrawsContent(true); | 10178 unclipped_desc_surface->SetDrawsContent(true); |
| 10173 unclipped_desc_surface->test_properties()->force_render_surface = true; | 10179 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 10174 clip_child->SetBounds(gfx::Size(100, 100)); | 10180 clip_child->SetBounds(gfx::Size(100, 100)); |
| 10175 clip_child->SetDrawsContent(true); | 10181 clip_child->SetDrawsContent(true); |
| 10176 gfx::Transform translate; | 10182 gfx::Transform translate; |
| 10177 translate.Translate(10, 10); | 10183 translate.Translate(10, 10); |
| 10178 unclipped_desc_surface->test_properties()->transform = translate; | 10184 unclipped_desc_surface->test_properties()->transform = translate; |
| 10179 | 10185 |
| 10180 clip_child->test_properties()->clip_parent = clip_parent; | 10186 clip_child->test_properties()->clip_parent = clip_parent; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10258 EXPECT_TRUE(test->IsHidden()); | 10264 EXPECT_TRUE(test->IsHidden()); |
| 10259 | 10265 |
| 10260 hidden->test_properties()->hide_layer_and_subtree = false; | 10266 hidden->test_properties()->hide_layer_and_subtree = false; |
| 10261 root->layer_tree_impl()->property_trees()->needs_rebuild = true; | 10267 root->layer_tree_impl()->property_trees()->needs_rebuild = true; |
| 10262 ExecuteCalculateDrawProperties(root); | 10268 ExecuteCalculateDrawProperties(root); |
| 10263 EXPECT_FALSE(test->IsHidden()); | 10269 EXPECT_FALSE(test->IsHidden()); |
| 10264 } | 10270 } |
| 10265 | 10271 |
| 10266 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { | 10272 TEST_F(LayerTreeHostCommonTest, TwoUnclippedRenderSurfaces) { |
| 10267 LayerImpl* root = root_layer_for_testing(); | 10273 LayerImpl* root = root_layer_for_testing(); |
| 10268 LayerImpl* render_surface1 = AddChild<LayerImpl>(root); | 10274 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 10275 LayerImpl* render_surface1 = AddChild<LayerImpl>(clip_layer); |
| 10269 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); | 10276 LayerImpl* render_surface2 = AddChild<LayerImpl>(render_surface1); |
| 10270 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); | 10277 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface2); |
| 10271 | 10278 |
| 10272 root->SetBounds(gfx::Size(30, 30)); | 10279 root->SetBounds(gfx::Size(30, 30)); |
| 10273 root->SetMasksToBounds(true); | 10280 root->SetMasksToBounds(true); |
| 10281 clip_layer->SetBounds(gfx::Size(30, 30)); |
| 10282 clip_layer->SetMasksToBounds(true); |
| 10274 render_surface1->SetPosition(gfx::PointF(10, 10)); | 10283 render_surface1->SetPosition(gfx::PointF(10, 10)); |
| 10275 render_surface1->SetBounds(gfx::Size(30, 30)); | 10284 render_surface1->SetBounds(gfx::Size(30, 30)); |
| 10276 render_surface1->SetDrawsContent(true); | 10285 render_surface1->SetDrawsContent(true); |
| 10277 render_surface1->test_properties()->force_render_surface = true; | 10286 render_surface1->test_properties()->force_render_surface = true; |
| 10278 render_surface2->SetBounds(gfx::Size(30, 30)); | 10287 render_surface2->SetBounds(gfx::Size(30, 30)); |
| 10279 render_surface2->SetDrawsContent(true); | 10288 render_surface2->SetDrawsContent(true); |
| 10280 render_surface2->test_properties()->force_render_surface = true; | 10289 render_surface2->test_properties()->force_render_surface = true; |
| 10281 clip_child->SetBounds(gfx::Size(30, 30)); | 10290 clip_child->SetBounds(gfx::Size(30, 30)); |
| 10291 clip_child->SetDrawsContent(true); |
| 10282 | 10292 |
| 10283 clip_child->test_properties()->clip_parent = root; | 10293 clip_child->test_properties()->clip_parent = root; |
| 10284 root->test_properties()->clip_children = | 10294 root->test_properties()->clip_children = |
| 10285 base::MakeUnique<std::set<LayerImpl*>>(); | 10295 base::MakeUnique<std::set<LayerImpl*>>(); |
| 10286 root->test_properties()->clip_children->insert(clip_child); | 10296 root->test_properties()->clip_children->insert(clip_child); |
| 10287 | 10297 |
| 10288 ExecuteCalculateDrawProperties(root); | 10298 ExecuteCalculateDrawProperties(root); |
| 10289 | 10299 |
| 10290 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); | 10300 EXPECT_EQ(gfx::Rect(-10, -10, 30, 30), render_surface2->clip_rect()); |
| 10291 } | 10301 } |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10806 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10816 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10807 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10817 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10808 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10818 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10809 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10819 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10810 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10820 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10811 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10821 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10812 } | 10822 } |
| 10813 | 10823 |
| 10814 } // namespace | 10824 } // namespace |
| 10815 } // namespace cc | 10825 } // namespace cc |
| OLD | NEW |