Chromium Code Reviews| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 292 |
| 293 // We use layer's transform to determine back face visibility when its the | 293 // We use layer's transform to determine back face visibility when its the |
| 294 // root of a new rendering context. | 294 // root of a new rendering context. |
| 295 return layer->transform().IsBackFaceVisible(); | 295 return layer->transform().IsBackFaceVisible(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 static inline bool TransformToScreenIsKnown(Layer* layer, | 298 static inline bool TransformToScreenIsKnown(Layer* layer, |
| 299 int transform_tree_index, | 299 int transform_tree_index, |
| 300 const TransformTree& tree) { | 300 const TransformTree& tree) { |
| 301 const TransformNode* node = tree.Node(transform_tree_index); | 301 const TransformNode* node = tree.Node(transform_tree_index); |
| 302 return !node->data.to_screen_is_animated; | 302 return !node->data.to_screen_is_potentially_animated; |
| 303 } | 303 } |
| 304 | 304 |
| 305 static inline bool TransformToScreenIsKnown(LayerImpl* layer, | 305 static inline bool TransformToScreenIsKnown(LayerImpl* layer, |
| 306 int transform_tree_index, | 306 int transform_tree_index, |
| 307 const TransformTree& tree) { | 307 const TransformTree& tree) { |
| 308 return true; | 308 return true; |
| 309 } | 309 } |
| 310 | 310 |
| 311 template <typename LayerType> | 311 template <typename LayerType> |
| 312 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { | 312 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { |
| 313 return layer->transform_is_invertible() || | 313 return layer->transform_is_invertible() || |
| 314 layer->HasPotentiallyRunningTransformAnimation(); | 314 layer->HasPotentiallyRunningTransformAnimation(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 static inline bool SubtreeShouldBeSkipped(Layer* layer, | |
| 318 bool layer_is_drawn, | |
| 319 const TransformTree& tree) { | |
| 320 // If the layer transform is not invertible, it should not be drawn. | |
| 321 if (!layer->transform_is_invertible() && | |
| 322 !layer->HasPotentiallyRunningTransformAnimation()) | |
| 323 return true; | |
| 324 | |
| 325 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 326 // it or any of its ancestors. | |
| 327 if (layer->num_copy_requests_in_target_subtree() > 0) | |
| 328 return false; | |
| 329 | |
| 330 // If the layer is not drawn, then skip it and its subtree. | |
| 331 if (!layer_is_drawn) | |
| 332 return true; | |
| 333 | |
| 334 if (layer->has_render_surface() && !layer->double_sided() && | |
| 335 !layer->HasPotentiallyRunningTransformAnimation() && | |
| 336 IsSurfaceBackFaceVisible(layer, tree)) | |
| 337 return true; | |
| 338 | |
| 339 // If layer has a background filter, don't skip the layer, even it the | |
| 340 // opacity is 0. | |
| 341 if (!layer->background_filters().IsEmpty()) | |
| 342 return false; | |
| 343 | |
| 344 // If the opacity is being animated then the opacity on the main thread is | |
| 345 // unreliable (since the impl thread may be using a different opacity), so it | |
| 346 // should not be trusted. | |
| 347 // In particular, it should not cause the subtree to be skipped. | |
| 348 // Similarly, for layers that might animate opacity using an impl-only | |
| 349 // animation, their subtree should also not be skipped. | |
| 350 return !layer->EffectiveOpacity() && | |
| 351 !layer->HasPotentiallyRunningOpacityAnimation() && | |
| 352 !layer->OpacityCanAnimateOnImplThread(); | |
| 353 } | |
| 354 | |
| 355 template <typename LayerType> | 317 template <typename LayerType> |
| 356 static bool LayerNeedsUpdateInternal(LayerType* layer, | 318 static bool LayerNeedsUpdateInternal(LayerType* layer, |
| 357 bool layer_is_drawn, | 319 bool layer_is_drawn, |
| 358 const TransformTree& tree) { | 320 const TransformTree& tree) { |
| 359 // Layers can be skipped if any of these conditions are met. | 321 // Layers can be skipped if any of these conditions are met. |
| 360 // - is not drawn due to it or one of its ancestors being hidden (or having | 322 // - is not drawn due to it or one of its ancestors being hidden (or having |
| 361 // no copy requests). | 323 // no copy requests). |
| 362 // - does not draw content. | 324 // - does not draw content. |
| 363 // - is transparent. | 325 // - is transparent. |
| 364 // - has empty bounds | 326 // - has empty bounds |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 387 // backface is not visible. | 349 // backface is not visible. |
| 388 if (TransformToScreenIsKnown(layer, backface_transform_id, tree) && | 350 if (TransformToScreenIsKnown(layer, backface_transform_id, tree) && |
| 389 !HasSingularTransform(backface_transform_id, tree) && | 351 !HasSingularTransform(backface_transform_id, tree) && |
| 390 IsLayerBackFaceVisible(layer, backface_transform_id, tree)) | 352 IsLayerBackFaceVisible(layer, backface_transform_id, tree)) |
| 391 return false; | 353 return false; |
| 392 } | 354 } |
| 393 | 355 |
| 394 return true; | 356 return true; |
| 395 } | 357 } |
| 396 | 358 |
| 397 void FindLayersThatNeedUpdates(LayerImpl* layer, | 359 void FindLayersThatNeedUpdates(LayerTreeImpl* layer_tree_impl, |
| 398 const TransformTree& transform_tree, | 360 const TransformTree& transform_tree, |
| 399 const EffectTree& effect_tree, | 361 const EffectTree& effect_tree, |
| 400 LayerImplList* update_layer_list, | 362 LayerImplList* update_layer_list, |
| 401 std::vector<LayerImpl*>* visible_layer_list) { | 363 std::vector<LayerImpl*>* visible_layer_list) { |
| 402 DCHECK_GE(layer->effect_tree_index(), 0); | 364 for (auto* layer_impl : *layer_tree_impl) { |
| 403 for (auto* layer_impl : *layer->layer_tree_impl()) { | |
| 404 bool layer_is_drawn = | 365 bool layer_is_drawn = |
| 405 effect_tree.Node(layer->effect_tree_index())->data.is_drawn; | 366 effect_tree.Node(layer_impl->effect_tree_index())->data.is_drawn; |
| 406 | 367 |
| 407 if (!IsRootLayer(layer_impl) && | 368 if (!IsRootLayer(layer_impl) && |
| 408 LayerShouldBeSkipped(layer_impl, layer_is_drawn, transform_tree)) | 369 LayerShouldBeSkipped(layer_impl, layer_is_drawn, transform_tree, |
| 370 effect_tree)) | |
| 409 continue; | 371 continue; |
| 410 | 372 |
| 411 if (LayerNeedsUpdate(layer_impl, layer_is_drawn, transform_tree)) { | 373 if (LayerNeedsUpdate(layer_impl, layer_is_drawn, transform_tree)) { |
| 412 visible_layer_list->push_back(layer_impl); | 374 visible_layer_list->push_back(layer_impl); |
| 413 update_layer_list->push_back(layer_impl); | 375 update_layer_list->push_back(layer_impl); |
| 414 } | 376 } |
| 415 | 377 |
| 416 if (LayerImpl* mask_layer = layer->mask_layer()) | 378 if (LayerImpl* mask_layer = layer_impl->mask_layer()) |
| 417 update_layer_list->push_back(mask_layer); | 379 update_layer_list->push_back(mask_layer); |
| 418 if (LayerImpl* replica_layer = layer->replica_layer()) { | 380 if (LayerImpl* replica_layer = layer_impl->replica_layer()) { |
| 419 if (LayerImpl* mask_layer = replica_layer->mask_layer()) | 381 if (LayerImpl* mask_layer = replica_layer->mask_layer()) |
| 420 update_layer_list->push_back(mask_layer); | 382 update_layer_list->push_back(mask_layer); |
| 421 } | 383 } |
| 422 } | 384 } |
| 423 } | 385 } |
| 424 | 386 |
| 425 template <typename LayerType> | 387 template <typename LayerType> |
| 426 void UpdateRenderSurfaceForLayer(EffectTree* effect_tree, | 388 void UpdateRenderSurfaceForLayer(EffectTree* effect_tree, |
| 427 bool non_root_surfaces_enabled, | 389 bool non_root_surfaces_enabled, |
| 428 LayerType* layer) { | 390 LayerType* layer) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 442 Layer* layer) { | 404 Layer* layer) { |
| 443 UpdateRenderSurfaceForLayer(effect_tree, true, layer); | 405 UpdateRenderSurfaceForLayer(effect_tree, true, layer); |
| 444 | 406 |
| 445 for (size_t i = 0; i < layer->children().size(); ++i) { | 407 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 446 UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i)); | 408 UpdateRenderSurfacesForLayersRecursive(effect_tree, layer->child_at(i)); |
| 447 } | 409 } |
| 448 } | 410 } |
| 449 | 411 |
| 450 } // namespace | 412 } // namespace |
| 451 | 413 |
| 414 static inline bool LayerShouldBeSkipped(Layer* layer, | |
| 415 bool layer_is_drawn, | |
| 416 const TransformTree& transform_tree, | |
| 417 const EffectTree& effect_tree) { | |
| 418 const TransformNode* transform_node = | |
| 419 transform_tree.Node(layer->transform_tree_index()); | |
| 420 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | |
| 421 | |
| 422 // If the layer transform is not invertible, it should not be drawn. | |
| 423 bool has_inherited_invertible_or_animated_transform = | |
| 424 (transform_node->data.is_invertible && | |
| 425 transform_node->data.ancestors_are_invertible) || | |
| 426 transform_node->data.to_screen_is_potentially_animated; | |
| 427 if (!has_inherited_invertible_or_animated_transform) | |
| 428 return true; | |
| 429 | |
| 430 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 431 // it or any of its ancestors. | |
| 432 if (effect_node->data.num_copy_requests_in_subtree > 0) | |
| 433 return false; | |
| 434 | |
| 435 // If the layer is not drawn, then skip it and its subtree. | |
| 436 if (!effect_node->data.is_drawn) | |
| 437 return true; | |
| 438 | |
| 439 if (!transform_node->data.to_screen_is_potentially_animated && | |
| 440 effect_node->data.hidden_by_backface_visibility) | |
| 441 return true; | |
| 442 | |
| 443 // If layer has a background filter, don't skip the layer, even it the | |
| 444 // opacity is 0. | |
| 445 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 446 return false; | |
| 447 | |
| 448 // If the opacity is being animated then the opacity on the main thread is | |
| 449 // unreliable (since the impl thread may be using a different opacity), so it | |
| 450 // should not be trusted. | |
| 451 // In particular, it should not cause the subtree to be skipped. | |
| 452 // Similarly, for layers that might animate opacity using an impl-only | |
| 453 // animation, their subtree should also not be skipped. | |
| 454 return !effect_node->data.screen_space_opacity && | |
| 455 !effect_node->data.to_screen_opacity_is_animated; | |
| 456 //! effect_node->data.to_screen_opacity_can_animate_on_impl; | |
|
ajuma
2016/04/07 18:46:47
Nit: this line should be deleted
| |
| 457 } | |
| 458 | |
| 459 bool LayerShouldBeSkipped(LayerImpl* layer, | |
| 460 bool layer_is_drawn, | |
| 461 const TransformTree& transform_tree, | |
| 462 const EffectTree& effect_tree) { | |
| 463 const TransformNode* transform_node = | |
| 464 transform_tree.Node(layer->transform_tree_index()); | |
| 465 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | |
| 466 // If the layer transform is not invertible, it should not be drawn. | |
| 467 // TODO(ajuma): Correctly process subtrees with singular transform for the | |
| 468 // case where we may animate to a non-singular transform and wish to | |
| 469 // pre-raster. | |
| 470 bool has_inherited_invertible_or_animated_transform = | |
| 471 (transform_node->data.is_invertible && | |
| 472 transform_node->data.ancestors_are_invertible) || | |
| 473 transform_node->data.to_screen_is_potentially_animated; | |
| 474 if (!has_inherited_invertible_or_animated_transform) | |
| 475 return true; | |
| 476 | |
| 477 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 478 // it or any of its ancestors. | |
| 479 if (effect_node->data.num_copy_requests_in_subtree > 0) | |
| 480 return false; | |
| 481 | |
| 482 // If the layer is not drawn, then skip it and its subtree. | |
| 483 if (!effect_node->data.is_drawn) | |
| 484 return true; | |
| 485 | |
| 486 if (effect_node->data.hidden_by_backface_visibility) | |
| 487 return true; | |
| 488 | |
| 489 // If layer is on the pending tree and opacity is being animated then | |
| 490 // this subtree can't be skipped as we need to create, prioritize and | |
| 491 // include tiles for this layer when deciding if tree can be activated. | |
| 492 if (!transform_tree.property_trees()->is_active && | |
| 493 effect_node->data.to_screen_opacity_is_animated) | |
| 494 return false; | |
| 495 | |
| 496 // If layer has a background filter, don't skip the layer, even it the | |
| 497 // opacity is 0. | |
| 498 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 499 return false; | |
| 500 | |
| 501 // The opacity of a layer always applies to its children (either implicitly | |
| 502 // via a render surface or explicitly if the parent preserves 3D), so the | |
| 503 // entire subtree can be skipped if this layer is fully transparent. | |
| 504 return !effect_node->data.screen_space_opacity; | |
| 505 } | |
| 506 | |
| 507 void FindLayersThatNeedUpdates(LayerTreeHost* layer_tree_host, | |
| 508 const TransformTree& transform_tree, | |
| 509 const EffectTree& effect_tree, | |
| 510 LayerList* update_layer_list) { | |
| 511 LayerTreeHostCommon::CallFunctionForEveryLayer( | |
| 512 layer_tree_host, | |
| 513 [&](Layer* layer) { | |
| 514 bool layer_is_drawn = | |
| 515 effect_tree.Node(layer->effect_tree_index())->data.is_drawn; | |
| 516 | |
| 517 if (!IsRootLayer(layer) && | |
| 518 LayerShouldBeSkipped(layer, layer_is_drawn, transform_tree, | |
| 519 effect_tree)) | |
| 520 return; | |
| 521 | |
| 522 if (LayerNeedsUpdate(layer, layer_is_drawn, transform_tree)) { | |
| 523 update_layer_list->push_back(layer); | |
| 524 } | |
| 525 | |
| 526 // Append mask layers to the update layer list. They don't have valid | |
| 527 // visible | |
| 528 // rects, so need to get added after the above calculation. Replica | |
| 529 // layers | |
| 530 // don't need to be updated. | |
| 531 if (Layer* mask_layer = layer->mask_layer()) | |
| 532 update_layer_list->push_back(mask_layer); | |
| 533 if (Layer* replica_layer = layer->replica_layer()) { | |
| 534 if (Layer* mask_layer = replica_layer->mask_layer()) | |
| 535 update_layer_list->push_back(mask_layer); | |
| 536 } | |
| 537 }, | |
| 538 CallFunctionLayerType::BASIC_LAYER); | |
| 539 } | |
| 540 | |
| 452 static void ResetIfHasNanCoordinate(gfx::RectF* rect) { | 541 static void ResetIfHasNanCoordinate(gfx::RectF* rect) { |
| 453 if (std::isnan(rect->x()) || std::isnan(rect->y()) || | 542 if (std::isnan(rect->x()) || std::isnan(rect->y()) || |
| 454 std::isnan(rect->right()) || std::isnan(rect->bottom())) | 543 std::isnan(rect->right()) || std::isnan(rect->bottom())) |
| 455 *rect = gfx::RectF(); | 544 *rect = gfx::RectF(); |
| 456 } | 545 } |
| 457 | 546 |
| 458 void ComputeClips(ClipTree* clip_tree, | 547 void ComputeClips(ClipTree* clip_tree, |
| 459 const TransformTree& transform_tree, | 548 const TransformTree& transform_tree, |
| 460 bool non_root_surfaces_enabled) { | 549 bool non_root_surfaces_enabled) { |
| 461 if (!clip_tree->needs_update()) | 550 if (!clip_tree->needs_update()) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; | 709 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
| 621 property_trees->transform_tree.set_needs_update(true); | 710 property_trees->transform_tree.set_needs_update(true); |
| 622 } | 711 } |
| 623 if (property_trees->transform_tree.needs_update()) | 712 if (property_trees->transform_tree.needs_update()) |
| 624 property_trees->clip_tree.set_needs_update(true); | 713 property_trees->clip_tree.set_needs_update(true); |
| 625 ComputeTransforms(&property_trees->transform_tree); | 714 ComputeTransforms(&property_trees->transform_tree); |
| 626 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, | 715 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, |
| 627 can_render_to_separate_surface); | 716 can_render_to_separate_surface); |
| 628 ComputeEffects(&property_trees->effect_tree); | 717 ComputeEffects(&property_trees->effect_tree); |
| 629 | 718 |
| 630 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, | 719 FindLayersThatNeedUpdates( |
| 631 property_trees->effect_tree, update_layer_list, | 720 root_layer->layer_tree_impl(), property_trees->transform_tree, |
| 632 visible_layer_list); | 721 property_trees->effect_tree, update_layer_list, visible_layer_list); |
| 633 CalculateVisibleRects<LayerImpl>( | 722 CalculateVisibleRects<LayerImpl>( |
| 634 *visible_layer_list, property_trees->clip_tree, | 723 *visible_layer_list, property_trees->clip_tree, |
| 635 property_trees->transform_tree, can_render_to_separate_surface); | 724 property_trees->transform_tree, can_render_to_separate_surface); |
| 636 } | 725 } |
| 637 | 726 |
| 638 void UpdateRenderSurfaces(Layer* root_layer, PropertyTrees* property_trees) { | 727 void UpdateRenderSurfaces(Layer* root_layer, PropertyTrees* property_trees) { |
| 639 UpdateRenderSurfacesForLayersRecursive(&property_trees->effect_tree, | 728 UpdateRenderSurfacesForLayersRecursive(&property_trees->effect_tree, |
| 640 root_layer); | 729 root_layer); |
| 641 #if DCHECK_IS_ON() | 730 #if DCHECK_IS_ON() |
| 642 ValidateRenderSurfacesRecursive(root_layer); | 731 ValidateRenderSurfacesRecursive(root_layer); |
| 643 #endif | 732 #endif |
| 644 } | 733 } |
| 645 | 734 |
| 646 void UpdatePropertyTrees(PropertyTrees* property_trees, | 735 void UpdatePropertyTrees(PropertyTrees* property_trees, |
| 647 bool can_render_to_separate_surface) { | 736 bool can_render_to_separate_surface) { |
| 648 if (property_trees->non_root_surfaces_enabled != | 737 if (property_trees->non_root_surfaces_enabled != |
| 649 can_render_to_separate_surface) { | 738 can_render_to_separate_surface) { |
| 650 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; | 739 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; |
| 651 property_trees->transform_tree.set_needs_update(true); | 740 property_trees->transform_tree.set_needs_update(true); |
| 652 } | 741 } |
| 653 if (property_trees->transform_tree.needs_update()) | 742 if (property_trees->transform_tree.needs_update()) |
| 654 property_trees->clip_tree.set_needs_update(true); | 743 property_trees->clip_tree.set_needs_update(true); |
| 655 ComputeTransforms(&property_trees->transform_tree); | 744 ComputeTransforms(&property_trees->transform_tree); |
| 656 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, | 745 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, |
| 657 can_render_to_separate_surface); | 746 can_render_to_separate_surface); |
| 658 ComputeEffects(&property_trees->effect_tree); | 747 ComputeEffects(&property_trees->effect_tree); |
| 659 } | 748 } |
| 660 | 749 |
| 661 void FindLayersThatNeedUpdates(Layer* layer, | |
| 662 const TransformTree& transform_tree, | |
| 663 const EffectTree& effect_tree, | |
| 664 LayerList* update_layer_list) { | |
| 665 DCHECK_GE(layer->effect_tree_index(), 0); | |
| 666 bool layer_is_drawn = | |
| 667 effect_tree.Node(layer->effect_tree_index())->data.is_drawn; | |
| 668 | |
| 669 if (!IsRootLayer(layer) && | |
| 670 SubtreeShouldBeSkipped(layer, layer_is_drawn, transform_tree)) | |
| 671 return; | |
| 672 | |
| 673 if (LayerNeedsUpdate(layer, layer_is_drawn, transform_tree)) | |
| 674 update_layer_list->push_back(layer); | |
| 675 if (Layer* mask_layer = layer->mask_layer()) | |
| 676 update_layer_list->push_back(mask_layer); | |
| 677 if (Layer* replica_layer = layer->replica_layer()) { | |
| 678 if (Layer* mask_layer = replica_layer->mask_layer()) | |
| 679 update_layer_list->push_back(mask_layer); | |
| 680 } | |
| 681 | |
| 682 for (size_t i = 0; i < layer->children().size(); ++i) { | |
| 683 FindLayersThatNeedUpdates(layer->child_at(i), transform_tree, effect_tree, | |
| 684 update_layer_list); | |
| 685 } | |
| 686 } | |
| 687 | |
| 688 void ComputeVisibleRectsForTesting(PropertyTrees* property_trees, | 750 void ComputeVisibleRectsForTesting(PropertyTrees* property_trees, |
| 689 bool can_render_to_separate_surface, | 751 bool can_render_to_separate_surface, |
| 690 LayerList* update_layer_list) { | 752 LayerList* update_layer_list) { |
| 691 CalculateVisibleRects<Layer>(*update_layer_list, property_trees->clip_tree, | 753 CalculateVisibleRects<Layer>(*update_layer_list, property_trees->clip_tree, |
| 692 property_trees->transform_tree, | 754 property_trees->transform_tree, |
| 693 can_render_to_separate_surface); | 755 can_render_to_separate_surface); |
| 694 } | 756 } |
| 695 | 757 |
| 696 void BuildPropertyTreesAndComputeVisibleRects( | 758 void BuildPropertyTreesAndComputeVisibleRects( |
| 697 LayerImpl* root_layer, | 759 LayerImpl* root_layer, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 727 if (can_render_to_separate_surface) | 789 if (can_render_to_separate_surface) |
| 728 ValidateRenderSurfaceForLayer(layer); | 790 ValidateRenderSurfaceForLayer(layer); |
| 729 #endif | 791 #endif |
| 730 } | 792 } |
| 731 LayerImplList update_layer_list; | 793 LayerImplList update_layer_list; |
| 732 ComputeVisibleRectsInternal(root_layer, property_trees, | 794 ComputeVisibleRectsInternal(root_layer, property_trees, |
| 733 can_render_to_separate_surface, | 795 can_render_to_separate_surface, |
| 734 &update_layer_list, visible_layer_list); | 796 &update_layer_list, visible_layer_list); |
| 735 } | 797 } |
| 736 | 798 |
| 737 bool LayerShouldBeSkipped(LayerImpl* layer, | |
| 738 bool layer_is_drawn, | |
| 739 const TransformTree& transform_tree) { | |
| 740 const TransformNode* transform_node = | |
| 741 transform_tree.Node(layer->transform_tree_index()); | |
| 742 const EffectTree& effect_tree = transform_tree.property_trees()->effect_tree; | |
| 743 const EffectNode* effect_node = effect_tree.Node(layer->effect_tree_index()); | |
| 744 // If the layer transform is not invertible, it should not be drawn. | |
| 745 // TODO(ajuma): Correctly process subtrees with singular transform for the | |
| 746 // case where we may animate to a non-singular transform and wish to | |
| 747 // pre-raster. | |
| 748 bool has_inherited_invertible_or_animated_transform = | |
| 749 (transform_node->data.is_invertible && | |
| 750 transform_node->data.ancestors_are_invertible) || | |
| 751 transform_node->data.to_screen_is_animated; | |
| 752 if (!has_inherited_invertible_or_animated_transform) | |
| 753 return true; | |
| 754 | |
| 755 // When we need to do a readback/copy of a layer's output, we can not skip | |
| 756 // it or any of its ancestors. | |
| 757 if (effect_node->data.num_copy_requests_in_subtree > 0) | |
| 758 return false; | |
| 759 | |
| 760 // If the layer is not drawn, then skip it and its subtree. | |
| 761 if (!effect_node->data.is_drawn) | |
| 762 return true; | |
| 763 | |
| 764 if (effect_node->data.hidden_by_backface_visibility) | |
| 765 return true; | |
| 766 | |
| 767 // If layer is on the pending tree and opacity is being animated then | |
| 768 // this subtree can't be skipped as we need to create, prioritize and | |
| 769 // include tiles for this layer when deciding if tree can be activated. | |
| 770 if (!transform_tree.property_trees()->is_active && | |
| 771 effect_node->data.to_screen_opacity_is_animated) | |
| 772 return false; | |
| 773 | |
| 774 // If layer has a background filter, don't skip the layer, even it the | |
| 775 // opacity is 0. | |
| 776 if (effect_node->data.node_or_ancestor_has_background_filters) | |
| 777 return false; | |
| 778 | |
| 779 // The opacity of a layer always applies to its children (either implicitly | |
| 780 // via a render surface or explicitly if the parent preserves 3D), so the | |
| 781 // entire subtree can be skipped if this layer is fully transparent. | |
| 782 return !effect_node->data.screen_space_opacity; | |
| 783 } | |
| 784 | |
| 785 bool LayerNeedsUpdate(Layer* layer, | 799 bool LayerNeedsUpdate(Layer* layer, |
| 786 bool layer_is_drawn, | 800 bool layer_is_drawn, |
| 787 const TransformTree& tree) { | 801 const TransformTree& tree) { |
| 788 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); | 802 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); |
| 789 } | 803 } |
| 790 | 804 |
| 791 bool LayerNeedsUpdate(LayerImpl* layer, | 805 bool LayerNeedsUpdate(LayerImpl* layer, |
| 792 bool layer_is_drawn, | 806 bool layer_is_drawn, |
| 793 const TransformTree& tree) { | 807 const TransformTree& tree) { |
| 794 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); | 808 return LayerNeedsUpdateInternal(layer, layer_is_drawn, tree); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 layer->draw_properties().screen_space_transform = | 1026 layer->draw_properties().screen_space_transform = |
| 1013 ScreenSpaceTransformInternal(layer, transform_node); | 1027 ScreenSpaceTransformInternal(layer, transform_node); |
| 1014 if (property_trees->non_root_surfaces_enabled) { | 1028 if (property_trees->non_root_surfaces_enabled) { |
| 1015 layer->draw_properties().target_space_transform = | 1029 layer->draw_properties().target_space_transform = |
| 1016 DrawTransform(layer, property_trees->transform_tree); | 1030 DrawTransform(layer, property_trees->transform_tree); |
| 1017 } else { | 1031 } else { |
| 1018 layer->draw_properties().target_space_transform = | 1032 layer->draw_properties().target_space_transform = |
| 1019 layer->draw_properties().screen_space_transform; | 1033 layer->draw_properties().screen_space_transform; |
| 1020 } | 1034 } |
| 1021 layer->draw_properties().screen_space_transform_is_animating = | 1035 layer->draw_properties().screen_space_transform_is_animating = |
| 1022 transform_node->data.to_screen_is_animated; | 1036 transform_node->data.to_screen_is_potentially_animated; |
| 1023 if (layer->layer_tree_impl() | 1037 if (layer->layer_tree_impl() |
| 1024 ->settings() | 1038 ->settings() |
| 1025 .layer_transforms_should_scale_layer_contents) { | 1039 .layer_transforms_should_scale_layer_contents) { |
| 1026 layer->draw_properties().maximum_animation_contents_scale = | 1040 layer->draw_properties().maximum_animation_contents_scale = |
| 1027 transform_node->data.combined_maximum_animation_target_scale; | 1041 transform_node->data.combined_maximum_animation_target_scale; |
| 1028 layer->draw_properties().starting_animation_contents_scale = | 1042 layer->draw_properties().starting_animation_contents_scale = |
| 1029 transform_node->data.combined_starting_animation_scale; | 1043 transform_node->data.combined_starting_animation_scale; |
| 1030 } else { | 1044 } else { |
| 1031 layer->draw_properties().maximum_animation_contents_scale = 0.f; | 1045 layer->draw_properties().maximum_animation_contents_scale = 0.f; |
| 1032 layer->draw_properties().starting_animation_contents_scale = 0.f; | 1046 layer->draw_properties().starting_animation_contents_scale = 0.f; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1179 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1166 const Layer* overscroll_elasticity_layer, | 1180 const Layer* overscroll_elasticity_layer, |
| 1167 const gfx::Vector2dF& elastic_overscroll) { | 1181 const gfx::Vector2dF& elastic_overscroll) { |
| 1168 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1182 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1169 elastic_overscroll); | 1183 elastic_overscroll); |
| 1170 } | 1184 } |
| 1171 | 1185 |
| 1172 } // namespace draw_property_utils | 1186 } // namespace draw_property_utils |
| 1173 | 1187 |
| 1174 } // namespace cc | 1188 } // namespace cc |
| OLD | NEW |