| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 Layer* layer) { | 371 Layer* layer) { |
| 372 UpdateRenderSurfaceForLayer(effect_tree, true, layer); | 372 UpdateRenderSurfaceForLayer(effect_tree, true, layer); |
| 373 | 373 |
| 374 for (size_t i = 0; i < layer->children().size(); ++i) { | 374 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 375 UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i)); | 375 UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i)); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 } // namespace | 379 } // namespace |
| 380 | 380 |
| 381 static inline bool LayerShouldBeSkipped(Layer* layer, | 381 template <typename LayerType> |
| 382 bool layer_is_drawn, | 382 static inline bool LayerShouldBeSkippedInternal( |
| 383 const TransformTree& transform_tree, | 383 LayerType* layer, |
| 384 const EffectTree& effect_tree) { | 384 bool layer_is_drawn, |
| 385 const TransformTree& transform_tree, |
| 386 const EffectTree& effect_tree) { |
| 385 const TransformNode* transform_node = | 387 const TransformNode* transform_node = |
| 386 transform_tree.Node(layer->transform_tree_index()); | 388 transform_tree.Node(layer->transform_tree_index()); |
| 387 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | 389 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); |
| 388 | 390 |
| 389 // If the layer transform is not invertible, it should not be drawn. | 391 if (effect_node->data.has_render_surface && |
| 390 if (!transform_node->data.node_and_ancestors_are_animated_or_invertible) | 392 effect_node->data.num_copy_requests_in_subtree > 0) |
| 391 return true; | |
| 392 | |
| 393 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 394 // it or any of its ancestors. | |
| 395 if (effect_node->data.num_copy_requests_in_subtree > 0) | |
| 396 return false; | 393 return false; |
| 397 | 394 // If the layer transform is not invertible, it should be skipped. |
| 398 // If the layer is not drawn, then skip it and its subtree. | 395 // TODO(ajuma): Correctly process subtrees with singular transform for the |
| 399 if (!effect_node->data.is_drawn) | 396 // case where we may animate to a non-singular transform and wish to |
| 400 return true; | 397 // pre-raster. |
| 401 | 398 return !transform_node->data.node_and_ancestors_are_animated_or_invertible || |
| 402 if (!transform_node->data.to_screen_is_potentially_animated && | 399 effect_node->data.hidden_by_backface_visibility || |
| 403 effect_node->data.hidden_by_backface_visibility) | 400 !effect_node->data.is_drawn; |
| 404 return true; | |
| 405 | |
| 406 // If layer has a background filter, don't skip the layer, even it the | |
| 407 // opacity is 0. | |
| 408 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 409 return false; | |
| 410 | |
| 411 // If the opacity is being animated then the opacity on the main thread is | |
| 412 // unreliable (since the impl thread may be using a different opacity), so it | |
| 413 // should not be trusted. | |
| 414 // In particular, it should not cause the subtree to be skipped. | |
| 415 // Similarly, for layers that might animate opacity using an impl-only | |
| 416 // animation, their subtree should also not be skipped. | |
| 417 return !effect_node->data.screen_space_opacity && | |
| 418 !effect_node->data.to_screen_opacity_is_animated; | |
| 419 } | 401 } |
| 420 | 402 |
| 421 bool LayerShouldBeSkipped(LayerImpl* layer, | 403 bool LayerShouldBeSkipped(LayerImpl* layer, |
| 422 bool layer_is_drawn, | 404 bool layer_is_drawn, |
| 423 const TransformTree& transform_tree, | 405 const TransformTree& transform_tree, |
| 424 const EffectTree& effect_tree) { | 406 const EffectTree& effect_tree) { |
| 425 const TransformNode* transform_node = | 407 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, |
| 426 transform_tree.Node(layer->transform_tree_index()); | 408 effect_tree); |
| 427 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | 409 } |
| 428 // If the layer transform is not invertible, it should not be drawn. | |
| 429 // TODO(ajuma): Correctly process subtrees with singular transform for the | |
| 430 // case where we may animate to a non-singular transform and wish to | |
| 431 // pre-raster. | |
| 432 if (!transform_node->data.node_and_ancestors_are_animated_or_invertible) | |
| 433 return true; | |
| 434 | 410 |
| 435 // When we need to do a readback/copy of a layer's output, we can not skip | 411 bool LayerShouldBeSkipped(Layer* layer, |
| 436 // it or any of its ancestors. | 412 bool layer_is_drawn, |
| 437 if (effect_node->data.num_copy_requests_in_subtree > 0) | 413 const TransformTree& transform_tree, |
| 438 return false; | 414 const EffectTree& effect_tree) { |
| 439 | 415 return LayerShouldBeSkippedInternal(layer, layer_is_drawn, transform_tree, |
| 440 // If the layer is not drawn, then skip it and its subtree. | 416 effect_tree); |
| 441 if (!effect_node->data.is_drawn) | |
| 442 return true; | |
| 443 | |
| 444 if (effect_node->data.hidden_by_backface_visibility) | |
| 445 return true; | |
| 446 | |
| 447 // If layer is on the pending tree and opacity is being animated then | |
| 448 // this subtree can't be skipped as we need to create, prioritize and | |
| 449 // include tiles for this layer when deciding if tree can be activated. | |
| 450 if (!transform_tree.property_trees()->is_active && | |
| 451 effect_node->data.to_screen_opacity_is_animated) | |
| 452 return false; | |
| 453 | |
| 454 // If layer has a background filter, don't skip the layer, even it the | |
| 455 // opacity is 0. | |
| 456 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 457 return false; | |
| 458 | |
| 459 // The opacity of a layer always applies to its children (either implicitly | |
| 460 // via a render surface or explicitly if the parent preserves 3D), so the | |
| 461 // entire subtree can be skipped if this layer is fully transparent. | |
| 462 return !effect_node->data.screen_space_opacity; | |
| 463 } | 417 } |
| 464 | 418 |
| 465 void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host, | 419 void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host, |
| 466 const TransformTree& transform_tree, | 420 const TransformTree& transform_tree, |
| 467 const EffectTree& effect_tree, | 421 const EffectTree& effect_tree, |
| 468 LayerList* update_layer_list) { | 422 LayerList* update_layer_list) { |
| 469 LayerTreeHostCommon::CallFunctionForEveryLayer( | 423 LayerTreeHostCommon::CallFunctionForEveryLayer( |
| 470 layer_tree_host, | 424 layer_tree_host, |
| 471 [&](Layer* layer) { | 425 [&](Layer* layer) { |
| 472 bool layer_is_drawn = | 426 bool layer_is_drawn = |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1112 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1159 const Layer* overscroll_elasticity_layer, | 1113 const Layer* overscroll_elasticity_layer, |
| 1160 const gfx::Vector2dF& elastic_overscroll) { | 1114 const gfx::Vector2dF& elastic_overscroll) { |
| 1161 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1115 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1162 elastic_overscroll); | 1116 elastic_overscroll); |
| 1163 } | 1117 } |
| 1164 | 1118 |
| 1165 } // namespace draw_property_utils | 1119 } // namespace draw_property_utils |
| 1166 | 1120 |
| 1167 } // namespace cc | 1121 } // namespace cc |
| OLD | NEW |