| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/draw_property_utils.h" | 5 #include "cc/trees/draw_property_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const TransformTree& tree) { | 306 const TransformTree& tree) { |
| 307 return true; | 307 return true; |
| 308 } | 308 } |
| 309 | 309 |
| 310 template <typename LayerType> | 310 template <typename LayerType> |
| 311 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { | 311 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { |
| 312 return layer->transform_is_invertible() || | 312 return layer->transform_is_invertible() || |
| 313 layer->HasPotentiallyRunningTransformAnimation(); | 313 layer->HasPotentiallyRunningTransformAnimation(); |
| 314 } | 314 } |
| 315 | 315 |
| 316 static inline bool LayerShouldBeSkipped(LayerImpl* layer, | |
| 317 bool layer_is_drawn, | |
| 318 const TransformTree& transform_tree) { | |
| 319 const TransformNode* transform_node = | |
| 320 transform_tree.Node(layer->transform_tree_index()); | |
| 321 const EffectTree& effect_tree = transform_tree.property_trees()->effect_tree; | |
| 322 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | |
| 323 // If the layer transform is not invertible, it should not be drawn. | |
| 324 // TODO(ajuma): Correctly process subtrees with singular transform for the | |
| 325 // case where we may animate to a non-singular transform and wish to | |
| 326 // pre-raster. | |
| 327 bool has_inherited_invertible_or_animated_transform = | |
| 328 (transform_node->data.is_invertible && | |
| 329 transform_node->data.ancestors_are_invertible) || | |
| 330 transform_node->data.to_screen_is_animated; | |
| 331 if (!has_inherited_invertible_or_animated_transform) | |
| 332 return true; | |
| 333 | |
| 334 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 335 // it or any of its ancestors. | |
| 336 if (effect_node->data.num_copy_requests_in_subtree > 0) | |
| 337 return false; | |
| 338 | |
| 339 // If the layer is not drawn, then skip it and its subtree. | |
| 340 if (!effect_node->data.is_drawn) | |
| 341 return true; | |
| 342 | |
| 343 if (effect_node->data.hidden_by_backface_visibility) | |
| 344 return true; | |
| 345 | |
| 346 // If layer is on the pending tree and opacity is being animated then | |
| 347 // this subtree can't be skipped as we need to create, prioritize and | |
| 348 // include tiles for this layer when deciding if tree can be activated. | |
| 349 if (!transform_tree.property_trees()->is_active && | |
| 350 effect_node->data.to_screen_opacity_is_animated) | |
| 351 return false; | |
| 352 | |
| 353 // If layer has a background filter, don't skip the layer, even it the | |
| 354 // opacity is 0. | |
| 355 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 356 return false; | |
| 357 | |
| 358 // The opacity of a layer always applies to its children (either implicitly | |
| 359 // via a render surface or explicitly if the parent preserves 3D), so the | |
| 360 // entire subtree can be skipped if this layer is fully transparent. | |
| 361 return !effect_node->data.screen_space_opacity; | |
| 362 } | |
| 363 | |
| 364 static inline bool SubtreeShouldBeSkipped(Layer* layer, | 316 static inline bool SubtreeShouldBeSkipped(Layer* layer, |
| 365 bool layer_is_drawn, | 317 bool layer_is_drawn, |
| 366 const TransformTree& tree) { | 318 const TransformTree& tree) { |
| 367 // If the layer transform is not invertible, it should not be drawn. | 319 // If the layer transform is not invertible, it should not be drawn. |
| 368 if (!layer->transform_is_invertible() && | 320 if (!layer->transform_is_invertible() && |
| 369 !layer->HasPotentiallyRunningTransformAnimation()) | 321 !layer->HasPotentiallyRunningTransformAnimation()) |
| 370 return true; | 322 return true; |
| 371 | 323 |
| 372 // When we need to do a readback/copy of a layer's output, we can not skip | 324 // When we need to do a readback/copy of a layer's output, we can not skip |
| 373 // it or any of its ancestors. | 325 // it or any of its ancestors. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 393 // should not be trusted. | 345 // should not be trusted. |
| 394 // In particular, it should not cause the subtree to be skipped. | 346 // In particular, it should not cause the subtree to be skipped. |
| 395 // Similarly, for layers that might animate opacity using an impl-only | 347 // Similarly, for layers that might animate opacity using an impl-only |
| 396 // animation, their subtree should also not be skipped. | 348 // animation, their subtree should also not be skipped. |
| 397 return !layer->EffectiveOpacity() && | 349 return !layer->EffectiveOpacity() && |
| 398 !layer->HasPotentiallyRunningOpacityAnimation() && | 350 !layer->HasPotentiallyRunningOpacityAnimation() && |
| 399 !layer->OpacityCanAnimateOnImplThread(); | 351 !layer->OpacityCanAnimateOnImplThread(); |
| 400 } | 352 } |
| 401 | 353 |
| 402 template <typename LayerType> | 354 template <typename LayerType> |
| 403 static bool LayerNeedsUpdate(LayerType* layer, | 355 static bool LayerNeedsUpdateInternal(LayerType* layer, |
| 404 bool layer_is_drawn, | 356 bool layer_is_drawn, |
| 405 const TransformTree& tree) { | 357 const TransformTree& tree) { |
| 406 // Layers can be skipped if any of these conditions are met. | 358 // Layers can be skipped if any of these conditions are met. |
| 407 // - is not drawn due to it or one of its ancestors being hidden (or having | 359 // - is not drawn due to it or one of its ancestors being hidden (or having |
| 408 // no copy requests). | 360 // no copy requests). |
| 409 // - does not draw content. | 361 // - does not draw content. |
| 410 // - is transparent. | 362 // - is transparent. |
| 411 // - has empty bounds | 363 // - has empty bounds |
| 412 // - the layer is not double-sided, but its back face is visible. | 364 // - the layer is not double-sided, but its back face is visible. |
| 413 // | 365 // |
| 414 // Some additional conditions need to be computed at a later point after the | 366 // Some additional conditions need to be computed at a later point after the |
| 415 // recursion is finished. | 367 // recursion is finished. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 if (can_render_to_separate_surface) | 741 if (can_render_to_separate_surface) |
| 790 ValidateRenderSurfaceForLayer(layer); | 742 ValidateRenderSurfaceForLayer(layer); |
| 791 #endif | 743 #endif |
| 792 } | 744 } |
| 793 LayerImplList update_layer_list; | 745 LayerImplList update_layer_list; |
| 794 ComputeVisibleRectsInternal(root_layer, property_trees, | 746 ComputeVisibleRectsInternal(root_layer, property_trees, |
| 795 can_render_to_separate_surface, | 747 can_render_to_separate_surface, |
| 796 &update_layer_list, visible_layer_list); | 748 &update_layer_list, visible_layer_list); |
| 797 } | 749 } |
| 798 | 750 |
| 751 bool LayerShouldBeSkipped(LayerImpl* layer, |
| 752 bool layer_is_drawn, |
| 753 const TransformTree& transform_tree) { |
| 754 const TransformNode* transform_node = |
| 755 transform_tree.Node(layer->transform_tree_index()); |
| 756 const EffectTree& effect_tree = transform_tree.property_trees()->effect_tree; |
| 757 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); |
| 758 // If the layer transform is not invertible, it should not be drawn. |
| 759 // TODO(ajuma): Correctly process subtrees with singular transform for the |
| 760 // case where we may animate to a non-singular transform and wish to |
| 761 // pre-raster. |
| 762 bool has_inherited_invertible_or_animated_transform = |
| 763 (transform_node->data.is_invertible && |
| 764 transform_node->data.ancestors_are_invertible) || |
| 765 transform_node->data.to_screen_is_animated; |
| 766 if (!has_inherited_invertible_or_animated_transform) |
| 767 return true; |
| 768 |
| 769 // When we need to do a readback/copy of a layer's output, we can not skip |
| 770 // it or any of its ancestors. |
| 771 if (effect_node->data.num_copy_requests_in_subtree > 0) |
| 772 return false; |
| 773 |
| 774 // If the layer is not drawn, then skip it and its subtree. |
| 775 if (!effect_node->data.is_drawn) |
| 776 return true; |
| 777 |
| 778 if (effect_node->data.hidden_by_backface_visibility) |
| 779 return true; |
| 780 |
| 781 // If layer is on the pending tree and opacity is being animated then |
| 782 // this subtree can't be skipped as we need to create, prioritize and |
| 783 // include tiles for this layer when deciding if tree can be activated. |
| 784 if (!transform_tree.property_trees()->is_active && |
| 785 effect_node->data.to_screen_opacity_is_animated) |
| 786 return false; |
| 787 |
| 788 // If layer has a background filter, don't skip the layer, even it the |
| 789 // opacity is 0. |
| 790 if (effect_node->data.node_or_ancestor_has_background_filters) |
| 791 return false; |
| 792 |
| 793 // The opacity of a layer always applies to its children (either implicitly |
| 794 // via a render surface or explicitly if the parent preserves 3D), so the |
| 795 // entire subtree can be skipped if this layer is fully transparent. |
| 796 return !effect_node->data.screen_space_opacity; |
| 797 } |
| 798 |
| 799 bool LayerNeedsUpdate(Layer* layer, |
| 800 bool layer_is_drawn, |
| 801 const TransformTree& tree) { |
| 802 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); |
| 803 } |
| 804 |
| 805 bool LayerNeedsUpdate(LayerImpl* layer, |
| 806 bool layer_is_drawn, |
| 807 const TransformTree& tree) { |
| 808 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); |
| 809 } |
| 810 |
| 799 gfx::Transform DrawTransform(const LayerImpl* layer, | 811 gfx::Transform DrawTransform(const LayerImpl* layer, |
| 800 const TransformTree& tree) { | 812 const TransformTree& tree) { |
| 801 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 813 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 802 gfx::Transform xform; | 814 gfx::Transform xform; |
| 803 const bool owns_non_root_surface = | 815 const bool owns_non_root_surface = |
| 804 !IsRootLayer(layer) && layer->has_render_surface(); | 816 !IsRootLayer(layer) && layer->has_render_surface(); |
| 805 if (!owns_non_root_surface) { | 817 if (!owns_non_root_surface) { |
| 806 // If you're not the root, or you don't own a surface, you need to apply | 818 // If you're not the root, or you don't own a surface, you need to apply |
| 807 // your local offset. | 819 // your local offset. |
| 808 xform = node->data.to_target; | 820 xform = node->data.to_target; |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1179 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1168 const Layer* overscroll_elasticity_layer, | 1180 const Layer* overscroll_elasticity_layer, |
| 1169 const gfx::Vector2dF& elastic_overscroll) { | 1181 const gfx::Vector2dF& elastic_overscroll) { |
| 1170 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1182 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1171 elastic_overscroll); | 1183 elastic_overscroll); |
| 1172 } | 1184 } |
| 1173 | 1185 |
| 1174 } // namespace draw_property_utils | 1186 } // namespace draw_property_utils |
| 1175 | 1187 |
| 1176 } // namespace cc | 1188 } // namespace cc |
| OLD | NEW |