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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 203 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
204 elastic_overscroll, page_scale_factor, device_scale_factor, | 204 elastic_overscroll, page_scale_factor, device_scale_factor, |
205 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); | 205 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); |
206 draw_property_utils::UpdatePropertyTrees(property_trees, | 206 draw_property_utils::UpdatePropertyTrees(property_trees, |
207 can_render_to_separate_surface); | 207 can_render_to_separate_surface); |
208 draw_property_utils::FindLayersThatNeedUpdates( | 208 draw_property_utils::FindLayersThatNeedUpdates( |
209 root_layer->GetLayerTree(), property_trees->transform_tree, | 209 root_layer->GetLayerTree(), property_trees->transform_tree, |
210 property_trees->effect_tree, &update_layer_list_); | 210 property_trees->effect_tree, &update_layer_list_); |
211 } | 211 } |
212 | 212 |
213 void ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) { | 213 void ExecuteCalculateDrawPropertiesWithPropertyTrees( |
| 214 LayerImpl* root_layer, |
| 215 bool skip_verify_visible_rect_calculations = false) { |
214 DCHECK(root_layer->layer_tree_impl()); | 216 DCHECK(root_layer->layer_tree_impl()); |
215 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); | 217 PropertyTreeBuilder::PreCalculateMetaInformationForTesting(root_layer); |
216 | 218 |
217 bool can_render_to_separate_surface = true; | 219 bool can_render_to_separate_surface = true; |
218 | 220 |
219 LayerImpl* page_scale_layer = nullptr; | 221 LayerImpl* page_scale_layer = nullptr; |
220 LayerImpl* inner_viewport_scroll_layer = | 222 LayerImpl* inner_viewport_scroll_layer = |
221 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); | 223 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); |
222 LayerImpl* outer_viewport_scroll_layer = | 224 LayerImpl* outer_viewport_scroll_layer = |
223 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); | 225 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); |
224 LayerImpl* overscroll_elasticity_layer = | 226 LayerImpl* overscroll_elasticity_layer = |
225 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); | 227 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); |
226 gfx::Vector2dF elastic_overscroll = | 228 gfx::Vector2dF elastic_overscroll = |
227 root_layer->layer_tree_impl()->elastic_overscroll()->Current( | 229 root_layer->layer_tree_impl()->elastic_overscroll()->Current( |
228 root_layer->layer_tree_impl()->IsActiveTree()); | 230 root_layer->layer_tree_impl()->IsActiveTree()); |
229 float page_scale_factor = 1.f; | 231 float page_scale_factor = 1.f; |
230 float device_scale_factor = 1.f; | 232 float device_scale_factor = 1.f; |
231 gfx::Size device_viewport_size = | 233 gfx::Size device_viewport_size = |
232 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 234 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
233 root_layer->bounds().height() * device_scale_factor); | 235 root_layer->bounds().height() * device_scale_factor); |
234 update_layer_list_impl_.reset(new LayerImplList); | 236 update_layer_list_impl_.reset(new LayerImplList); |
235 root_layer->layer_tree_impl()->BuildLayerListForTesting(); | 237 root_layer->layer_tree_impl()->BuildLayerListForTesting(); |
236 bool verify_visible_rect_calculations = true; | 238 PropertyTrees* property_trees = |
| 239 root_layer->layer_tree_impl()->property_trees(); |
237 draw_property_utils::BuildPropertyTreesAndComputeVisibleRects( | 240 draw_property_utils::BuildPropertyTreesAndComputeVisibleRects( |
238 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 241 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
239 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 242 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
240 elastic_overscroll, page_scale_factor, device_scale_factor, | 243 elastic_overscroll, page_scale_factor, device_scale_factor, |
241 gfx::Rect(device_viewport_size), gfx::Transform(), | 244 gfx::Rect(device_viewport_size), gfx::Transform(), |
242 can_render_to_separate_surface, verify_visible_rect_calculations, | 245 can_render_to_separate_surface, property_trees, |
243 root_layer->layer_tree_impl()->property_trees(), | |
244 update_layer_list_impl_.get()); | 246 update_layer_list_impl_.get()); |
| 247 draw_property_utils::VerifyClipTreeCalculations(*update_layer_list_impl_, |
| 248 property_trees); |
| 249 if (!skip_verify_visible_rect_calculations) |
| 250 draw_property_utils::VerifyVisibleRectsCalculations( |
| 251 *update_layer_list_impl_, property_trees); |
245 } | 252 } |
246 | 253 |
247 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces( | 254 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces( |
248 LayerImpl* root_layer) { | 255 LayerImpl* root_layer) { |
249 gfx::Size device_viewport_size = | 256 gfx::Size device_viewport_size = |
250 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); | 257 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); |
251 render_surface_layer_list_impl_.reset(new LayerImplList); | 258 render_surface_layer_list_impl_.reset(new LayerImplList); |
252 | 259 |
253 DCHECK(!root_layer->bounds().IsEmpty()); | 260 DCHECK(!root_layer->bounds().IsEmpty()); |
254 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 261 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 gfx::Transform grand_child_transform; | 1189 gfx::Transform grand_child_transform; |
1183 grand_child_transform.RotateAboutYAxis(90.0); | 1190 grand_child_transform.RotateAboutYAxis(90.0); |
1184 | 1191 |
1185 root->SetBounds(gfx::Size(200, 200)); | 1192 root->SetBounds(gfx::Size(200, 200)); |
1186 child->test_properties()->transform = child_transform; | 1193 child->test_properties()->transform = child_transform; |
1187 child->SetBounds(gfx::Size(10, 10)); | 1194 child->SetBounds(gfx::Size(10, 10)); |
1188 grand_child->test_properties()->transform = grand_child_transform; | 1195 grand_child->test_properties()->transform = grand_child_transform; |
1189 grand_child->SetBounds(gfx::Size(100, 100)); | 1196 grand_child->SetBounds(gfx::Size(100, 100)); |
1190 grand_child->test_properties()->should_flatten_transform = false; | 1197 grand_child->test_properties()->should_flatten_transform = false; |
1191 grand_child->SetDrawsContent(true); | 1198 grand_child->SetDrawsContent(true); |
1192 ExecuteCalculateDrawProperties(root); | 1199 float device_scale_factor = 1.f; |
| 1200 float page_scale_factor = 1.f; |
| 1201 LayerImpl* page_scale_layer = nullptr; |
| 1202 // Visible rects computed by combining clips in target space and root space |
| 1203 // don't match because of rotation transforms. So, we skip |
| 1204 // verify_visible_rect_calculations. |
| 1205 bool skip_verify_visible_rect_calculations = true; |
| 1206 ExecuteCalculateDrawProperties(root, device_scale_factor, page_scale_factor, |
| 1207 page_scale_layer, |
| 1208 skip_verify_visible_rect_calculations); |
1193 | 1209 |
1194 // Mapping grand_child's bounds to target space produces a non-empty rect | 1210 // Mapping grand_child's bounds to target space produces a non-empty rect |
1195 // that is fully contained within the target's bounds, so grand_child should | 1211 // that is fully contained within the target's bounds, so grand_child should |
1196 // be considered fully visible. | 1212 // be considered fully visible. |
1197 EXPECT_EQ(gfx::Rect(grand_child->bounds()), | 1213 EXPECT_EQ(gfx::Rect(grand_child->bounds()), |
1198 grand_child->visible_layer_rect()); | 1214 grand_child->visible_layer_rect()); |
1199 } | 1215 } |
1200 | 1216 |
1201 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) { | 1217 TEST_F(LayerTreeHostCommonTest, TransformsForDegenerateIntermediateLayer) { |
1202 // A layer that is empty in one axis, but not the other, was accidentally | 1218 // A layer that is empty in one axis, but not the other, was accidentally |
(...skipping 6778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7981 | 7997 |
7982 // The singular transform on |animated| is flattened when inherited by | 7998 // The singular transform on |animated| is flattened when inherited by |
7983 // |surface|, and this happens to make it invertible. | 7999 // |surface|, and this happens to make it invertible. |
7984 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); | 8000 EXPECT_EQ(gfx::Rect(2, 2), surface->visible_layer_rect()); |
7985 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); | 8001 EXPECT_EQ(gfx::Rect(2, 2), descendant_of_animation->visible_layer_rect()); |
7986 | 8002 |
7987 gfx::Transform zero_matrix; | 8003 gfx::Transform zero_matrix; |
7988 zero_matrix.Scale3d(0.f, 0.f, 0.f); | 8004 zero_matrix.Scale3d(0.f, 0.f, 0.f); |
7989 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( | 8005 root->layer_tree_impl()->property_trees()->transform_tree.OnTransformAnimated( |
7990 zero_matrix, animated->transform_tree_index(), root->layer_tree_impl()); | 8006 zero_matrix, animated->transform_tree_index(), root->layer_tree_impl()); |
7991 ExecuteCalculateDrawPropertiesWithPropertyTrees(root); | 8007 // While computing visible rects by combining clips in screen space, we set |
| 8008 // the entire layer as visible if the screen space transform is singular. This |
| 8009 // is not always true when we combine clips in target space because if the |
| 8010 // intersection of combined_clip in taret space with layer_rect projected to |
| 8011 // target space is empty, we set it to an empty rect. |
| 8012 bool skip_verify_visible_rect_calculations = true; |
| 8013 ExecuteCalculateDrawPropertiesWithPropertyTrees( |
| 8014 root, skip_verify_visible_rect_calculations); |
7992 | 8015 |
7993 // The animated layer maps to the empty rect in clipped target space, so is | 8016 // The animated layer maps to the empty rect in clipped target space, so is |
7994 // treated as having an empty visible rect. | 8017 // treated as having an empty visible rect. |
7995 EXPECT_EQ(gfx::Rect(), animated->visible_layer_rect()); | 8018 EXPECT_EQ(gfx::Rect(), animated->visible_layer_rect()); |
7996 | 8019 |
| 8020 // The animated layer will be treated as fully visible when we combine clips |
| 8021 // in screen space. |
| 8022 gfx::Rect visible_rect = draw_property_utils::ComputeLayerVisibleRectDynamic( |
| 8023 root->layer_tree_impl()->property_trees(), animated); |
| 8024 EXPECT_EQ(gfx::Rect(120, 120), visible_rect); |
| 8025 |
7997 // This time, flattening does not make |animated|'s transform invertible. This | 8026 // This time, flattening does not make |animated|'s transform invertible. This |
7998 // means the clip cannot be projected into |surface|'s space, so we treat | 8027 // means the clip cannot be projected into |surface|'s space, so we treat |
7999 // |surface| and layers that draw into it as having empty visible rect. | 8028 // |surface| and layers that draw into it as having empty visible rect. |
8000 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect()); | 8029 EXPECT_EQ(gfx::Rect(), surface->visible_layer_rect()); |
8001 EXPECT_EQ(gfx::Rect(), descendant_of_animation->visible_layer_rect()); | 8030 EXPECT_EQ(gfx::Rect(), descendant_of_animation->visible_layer_rect()); |
8002 } | 8031 } |
8003 | 8032 |
8004 // Verify that having animated opacity but current opacity 1 still creates | 8033 // Verify that having animated opacity but current opacity 1 still creates |
8005 // a render surface. | 8034 // a render surface. |
8006 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) { | 8035 TEST_F(LayerTreeHostCommonTest, AnimatedOpacityCreatesRenderSurface) { |
(...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9839 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 9868 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
9840 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 9869 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
9841 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 9870 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
9842 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 9871 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
9843 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 9872 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
9844 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 9873 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
9845 } | 9874 } |
9846 | 9875 |
9847 } // namespace | 9876 } // namespace |
9848 } // namespace cc | 9877 } // namespace cc |
OLD | NEW |