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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 return false; | 337 return false; |
338 | 338 |
339 // If layer has a background filter, don't skip the layer, even it the | 339 // If layer has a background filter, don't skip the layer, even it the |
340 // opacity is 0. | 340 // opacity is 0. |
341 if (!layer->background_filters().IsEmpty()) | 341 if (!layer->background_filters().IsEmpty()) |
342 return false; | 342 return false; |
343 | 343 |
344 // The opacity of a layer always applies to its children (either implicitly | 344 // The opacity of a layer always applies to its children (either implicitly |
345 // via a render surface or explicitly if the parent preserves 3D), so the | 345 // via a render surface or explicitly if the parent preserves 3D), so the |
346 // entire subtree can be skipped if this layer is fully transparent. | 346 // entire subtree can be skipped if this layer is fully transparent. |
347 return !layer->EffectiveOpacity(); | 347 return !layer->opacity(); |
348 } | 348 } |
349 | 349 |
350 static inline bool SubtreeShouldBeSkipped(Layer* layer, | 350 static inline bool SubtreeShouldBeSkipped(Layer* layer, |
351 bool layer_is_drawn, | 351 bool layer_is_drawn, |
352 const TransformTree& tree) { | 352 const TransformTree& tree) { |
353 // If the layer transform is not invertible, it should not be drawn. | 353 // If the layer transform is not invertible, it should not be drawn. |
354 if (!layer->transform_is_invertible() && | 354 if (!layer->transform_is_invertible() && |
355 !layer->HasPotentiallyRunningTransformAnimation()) | 355 !layer->HasPotentiallyRunningTransformAnimation()) |
356 return true; | 356 return true; |
357 | 357 |
(...skipping 15 matching lines...) Expand all Loading... |
373 // opacity is 0. | 373 // opacity is 0. |
374 if (!layer->background_filters().IsEmpty()) | 374 if (!layer->background_filters().IsEmpty()) |
375 return false; | 375 return false; |
376 | 376 |
377 // If the opacity is being animated then the opacity on the main thread is | 377 // If the opacity is being animated then the opacity on the main thread is |
378 // unreliable (since the impl thread may be using a different opacity), so it | 378 // unreliable (since the impl thread may be using a different opacity), so it |
379 // should not be trusted. | 379 // should not be trusted. |
380 // In particular, it should not cause the subtree to be skipped. | 380 // In particular, it should not cause the subtree to be skipped. |
381 // Similarly, for layers that might animate opacity using an impl-only | 381 // Similarly, for layers that might animate opacity using an impl-only |
382 // animation, their subtree should also not be skipped. | 382 // animation, their subtree should also not be skipped. |
383 return !layer->EffectiveOpacity() && | 383 return !layer->opacity() && !layer->HasPotentiallyRunningOpacityAnimation() && |
384 !layer->HasPotentiallyRunningOpacityAnimation() && | |
385 !layer->OpacityCanAnimateOnImplThread(); | 384 !layer->OpacityCanAnimateOnImplThread(); |
386 } | 385 } |
387 | 386 |
388 template <typename LayerType> | 387 template <typename LayerType> |
389 static bool LayerShouldBeSkipped(LayerType* layer, | 388 static bool LayerShouldBeSkipped(LayerType* layer, |
390 bool layer_is_drawn, | 389 bool layer_is_drawn, |
391 const TransformTree& tree) { | 390 const TransformTree& tree) { |
392 // Layers can be skipped if any of these conditions are met. | 391 // Layers can be skipped if any of these conditions are met. |
393 // - is not drawn due to it or one of its ancestors being hidden (or having | 392 // - is not drawn due to it or one of its ancestors being hidden (or having |
394 // no copy requests). | 393 // no copy requests). |
(...skipping 29 matching lines...) Expand all Loading... |
424 TransformToScreenIsKnown(backface_test_layer, tree) && | 423 TransformToScreenIsKnown(backface_test_layer, tree) && |
425 IsLayerBackFaceVisible(backface_test_layer, tree)) | 424 IsLayerBackFaceVisible(backface_test_layer, tree)) |
426 return true; | 425 return true; |
427 | 426 |
428 return false; | 427 return false; |
429 } | 428 } |
430 | 429 |
431 template <typename LayerType> | 430 template <typename LayerType> |
432 void FindLayersThatNeedUpdates( | 431 void FindLayersThatNeedUpdates( |
433 LayerType* layer, | 432 LayerType* layer, |
434 const TransformTree& transform_tree, | 433 const TransformTree& tree, |
435 const EffectTree& effect_tree, | 434 bool subtree_is_visible_from_ancestor, |
436 typename LayerType::LayerListType* update_layer_list, | 435 typename LayerType::LayerListType* update_layer_list, |
437 std::vector<LayerType*>* visible_layer_list) { | 436 std::vector<LayerType*>* visible_layer_list) { |
438 DCHECK_GE(layer->effect_tree_index(), 0); | |
439 bool layer_is_drawn = | 437 bool layer_is_drawn = |
440 effect_tree.Node(layer->effect_tree_index())->data.is_drawn; | 438 layer->HasCopyRequest() || |
| 439 (subtree_is_visible_from_ancestor && !layer->hide_layer_and_subtree()); |
441 | 440 |
442 if (layer->parent() && | 441 if (layer->parent() && SubtreeShouldBeSkipped(layer, layer_is_drawn, tree)) |
443 SubtreeShouldBeSkipped(layer, layer_is_drawn, transform_tree)) | |
444 return; | 442 return; |
445 | 443 |
446 if (!LayerShouldBeSkipped(layer, layer_is_drawn, transform_tree)) { | 444 if (!LayerShouldBeSkipped(layer, layer_is_drawn, tree)) { |
447 visible_layer_list->push_back(layer); | 445 visible_layer_list->push_back(layer); |
448 update_layer_list->push_back(layer); | 446 update_layer_list->push_back(layer); |
449 } | 447 } |
450 | 448 |
451 // Append mask layers to the update layer list. They don't have valid visible | 449 // Append mask layers to the update layer list. They don't have valid visible |
452 // rects, so need to get added after the above calculation. Replica layers | 450 // rects, so need to get added after the above calculation. Replica layers |
453 // don't need to be updated. | 451 // don't need to be updated. |
454 if (LayerType* mask_layer = layer->mask_layer()) | 452 if (LayerType* mask_layer = layer->mask_layer()) |
455 update_layer_list->push_back(mask_layer); | 453 update_layer_list->push_back(mask_layer); |
456 if (LayerType* replica_layer = layer->replica_layer()) { | 454 if (LayerType* replica_layer = layer->replica_layer()) { |
457 if (LayerType* mask_layer = replica_layer->mask_layer()) | 455 if (LayerType* mask_layer = replica_layer->mask_layer()) |
458 update_layer_list->push_back(mask_layer); | 456 update_layer_list->push_back(mask_layer); |
459 } | 457 } |
460 | 458 |
461 for (size_t i = 0; i < layer->children().size(); ++i) { | 459 for (size_t i = 0; i < layer->children().size(); ++i) { |
462 FindLayersThatNeedUpdates(layer->child_at(i), transform_tree, effect_tree, | 460 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn, |
463 update_layer_list, visible_layer_list); | 461 update_layer_list, visible_layer_list); |
464 } | 462 } |
465 } | 463 } |
466 | 464 |
467 template <typename LayerType> | 465 template <typename LayerType> |
468 void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree, | 466 void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree, |
469 LayerType* layer) { | 467 LayerType* layer) { |
470 EffectNode* node = effect_tree->Node(layer->effect_tree_index()); | 468 EffectNode* node = effect_tree->Node(layer->effect_tree_index()); |
471 | 469 |
472 if (node->owner_id == layer->id() && node->data.has_render_surface) | 470 if (node->owner_id == layer->id() && node->data.has_render_surface) |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; | 672 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
675 property_trees->transform_tree.set_needs_update(true); | 673 property_trees->transform_tree.set_needs_update(true); |
676 } | 674 } |
677 if (property_trees->transform_tree.needs_update()) | 675 if (property_trees->transform_tree.needs_update()) |
678 property_trees->clip_tree.set_needs_update(true); | 676 property_trees->clip_tree.set_needs_update(true); |
679 ComputeTransforms(&property_trees->transform_tree); | 677 ComputeTransforms(&property_trees->transform_tree); |
680 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, | 678 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, |
681 can_render_to_separate_surface); | 679 can_render_to_separate_surface); |
682 ComputeEffects(&property_trees->effect_tree); | 680 ComputeEffects(&property_trees->effect_tree); |
683 | 681 |
| 682 const bool subtree_is_visible_from_ancestor = true; |
684 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, | 683 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, |
685 property_trees->effect_tree, update_layer_list, | 684 subtree_is_visible_from_ancestor, update_layer_list, |
686 visible_layer_list); | 685 visible_layer_list); |
687 CalculateVisibleRects<LayerType>( | 686 CalculateVisibleRects<LayerType>( |
688 *visible_layer_list, property_trees->clip_tree, | 687 *visible_layer_list, property_trees->clip_tree, |
689 property_trees->transform_tree, can_render_to_separate_surface); | 688 property_trees->transform_tree, can_render_to_separate_surface); |
690 } | 689 } |
691 | 690 |
692 void BuildPropertyTreesAndComputeVisibleRects( | 691 void BuildPropertyTreesAndComputeVisibleRects( |
693 Layer* root_layer, | 692 Layer* root_layer, |
694 const Layer* page_scale_layer, | 693 const Layer* page_scale_layer, |
695 const Layer* inner_viewport_scroll_layer, | 694 const Layer* inner_viewport_scroll_layer, |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1176 |
1178 void UpdateElasticOverscrollInPropertyTrees( | 1177 void UpdateElasticOverscrollInPropertyTrees( |
1179 PropertyTrees* property_trees, | 1178 PropertyTrees* property_trees, |
1180 const Layer* overscroll_elasticity_layer, | 1179 const Layer* overscroll_elasticity_layer, |
1181 const gfx::Vector2dF& elastic_overscroll) { | 1180 const gfx::Vector2dF& elastic_overscroll) { |
1182 UpdateElasticOverscrollInPropertyTreesInternal( | 1181 UpdateElasticOverscrollInPropertyTreesInternal( |
1183 property_trees, overscroll_elasticity_layer, elastic_overscroll); | 1182 property_trees, overscroll_elasticity_layer, elastic_overscroll); |
1184 } | 1183 } |
1185 | 1184 |
1186 } // namespace cc | 1185 } // namespace cc |
OLD | NEW |