| 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 | 10 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 return jitter; | 522 return jitter; |
| 523 } | 523 } |
| 524 | 524 |
| 525 enum PropertyTreeOption { | 525 enum PropertyTreeOption { |
| 526 BUILD_PROPERTY_TREES_IF_NEEDED, | 526 BUILD_PROPERTY_TREES_IF_NEEDED, |
| 527 DONT_BUILD_PROPERTY_TREES | 527 DONT_BUILD_PROPERTY_TREES |
| 528 }; | 528 }; |
| 529 | 529 |
| 530 static void MarkMasksAndAddChildToDescendantsIfRequired( |
| 531 LayerImpl* child_layer, |
| 532 LayerImplList* descendants, |
| 533 const int current_render_surface_layer_list_id) { |
| 534 // If the child is its own render target, then it has a render surface. |
| 535 if (child_layer->has_render_surface() && |
| 536 child_layer->render_target() == child_layer->render_surface() && |
| 537 !child_layer->render_surface()->layer_list().empty() && |
| 538 !child_layer->render_surface()->content_rect().IsEmpty()) { |
| 539 // This child will contribute its render surface, which means |
| 540 // we need to mark just the mask layer (and replica mask layer) |
| 541 // with the id. |
| 542 MarkMasksWithRenderSurfaceLayerListId(child_layer, |
| 543 current_render_surface_layer_list_id); |
| 544 descendants->push_back(child_layer); |
| 545 } |
| 546 } |
| 547 |
| 548 static void SetLayerOrDescendantIsDrawnIfRequired(LayerImpl* layer, |
| 549 LayerImpl* child_layer) { |
| 550 if (child_layer->layer_or_descendant_is_drawn()) { |
| 551 layer->set_layer_or_descendant_is_drawn(true); |
| 552 } |
| 553 } |
| 554 |
| 530 void CalculateRenderSurfaceLayerList( | 555 void CalculateRenderSurfaceLayerList( |
| 531 LayerImpl* layer, | 556 LayerImpl* layer, |
| 532 PropertyTrees* property_trees, | 557 PropertyTrees* property_trees, |
| 533 LayerImplList* render_surface_layer_list, | 558 LayerImplList* render_surface_layer_list, |
| 534 LayerImplList* descendants, | 559 LayerImplList* descendants, |
| 535 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, | 560 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, |
| 536 bool subtree_visible_from_ancestor, | 561 bool subtree_visible_from_ancestor, |
| 537 const bool can_render_to_separate_surface, | 562 const bool can_render_to_separate_surface, |
| 538 const int current_render_surface_layer_list_id, | 563 const int current_render_surface_layer_list_id, |
| 539 const int max_texture_size) { | 564 const int max_texture_size) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 557 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index()) | 582 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index()) |
| 558 ->data.is_drawn; | 583 ->data.is_drawn; |
| 559 | 584 |
| 560 // The root layer cannot be skipped. | 585 // The root layer cannot be skipped. |
| 561 if (!IsRootLayer(layer) && | 586 if (!IsRootLayer(layer) && |
| 562 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn, | 587 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn, |
| 563 property_trees->transform_tree, | 588 property_trees->transform_tree, |
| 564 property_trees->effect_tree)) { | 589 property_trees->effect_tree)) { |
| 565 if (layer->render_surface()) | 590 if (layer->render_surface()) |
| 566 layer->ClearRenderSurfaceLayerList(); | 591 layer->ClearRenderSurfaceLayerList(); |
| 592 for (auto* child_layer : layer->children()) { |
| 593 CalculateRenderSurfaceLayerList( |
| 594 child_layer, property_trees, render_surface_layer_list, descendants, |
| 595 nearest_occlusion_immune_ancestor, layer_is_drawn, |
| 596 can_render_to_separate_surface, current_render_surface_layer_list_id, |
| 597 max_texture_size); |
| 598 |
| 599 MarkMasksAndAddChildToDescendantsIfRequired( |
| 600 child_layer, descendants, current_render_surface_layer_list_id); |
| 601 SetLayerOrDescendantIsDrawnIfRequired(layer, child_layer); |
| 602 } |
| 567 return; | 603 return; |
| 568 } | 604 } |
| 569 | 605 |
| 570 bool render_to_separate_surface = | 606 bool render_to_separate_surface = |
| 571 IsRootLayer(layer) || | 607 IsRootLayer(layer) || |
| 572 (can_render_to_separate_surface && layer->render_surface()); | 608 (can_render_to_separate_surface && layer->render_surface()); |
| 573 | 609 |
| 574 if (render_to_separate_surface) { | 610 if (render_to_separate_surface) { |
| 575 DCHECK(layer->render_surface()); | 611 DCHECK(layer->render_surface()); |
| 576 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, | 612 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 if (render_to_separate_surface) | 661 if (render_to_separate_surface) |
| 626 layer->render_surface()->ClearAccumulatedContentRect(); | 662 layer->render_surface()->ClearAccumulatedContentRect(); |
| 627 | 663 |
| 628 for (auto* child_layer : layer->children()) { | 664 for (auto* child_layer : layer->children()) { |
| 629 CalculateRenderSurfaceLayerList( | 665 CalculateRenderSurfaceLayerList( |
| 630 child_layer, property_trees, render_surface_layer_list, descendants, | 666 child_layer, property_trees, render_surface_layer_list, descendants, |
| 631 nearest_occlusion_immune_ancestor, layer_is_drawn, | 667 nearest_occlusion_immune_ancestor, layer_is_drawn, |
| 632 can_render_to_separate_surface, current_render_surface_layer_list_id, | 668 can_render_to_separate_surface, current_render_surface_layer_list_id, |
| 633 max_texture_size); | 669 max_texture_size); |
| 634 | 670 |
| 635 // If the child is its own render target, then it has a render surface. | 671 MarkMasksAndAddChildToDescendantsIfRequired( |
| 636 if (child_layer->has_render_surface() && | 672 child_layer, descendants, current_render_surface_layer_list_id); |
| 637 child_layer->render_target() == child_layer->render_surface() && | 673 SetLayerOrDescendantIsDrawnIfRequired(layer, child_layer); |
| 638 !child_layer->render_surface()->layer_list().empty() && | |
| 639 !child_layer->render_surface()->content_rect().IsEmpty()) { | |
| 640 // This child will contribute its render surface, which means | |
| 641 // we need to mark just the mask layer (and replica mask layer) | |
| 642 // with the id. | |
| 643 MarkMasksWithRenderSurfaceLayerListId( | |
| 644 child_layer, current_render_surface_layer_list_id); | |
| 645 descendants->push_back(child_layer); | |
| 646 } | |
| 647 | |
| 648 if (child_layer->layer_or_descendant_is_drawn()) { | |
| 649 bool layer_or_descendant_is_drawn = true; | |
| 650 layer->set_layer_or_descendant_is_drawn(layer_or_descendant_is_drawn); | |
| 651 } | |
| 652 } | 674 } |
| 653 | 675 |
| 654 if (render_to_separate_surface && !IsRootLayer(layer) && | 676 if (render_to_separate_surface && !IsRootLayer(layer) && |
| 655 layer->render_surface()->layer_list().empty()) { | 677 layer->render_surface()->layer_list().empty()) { |
| 656 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); | 678 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); |
| 657 return; | 679 return; |
| 658 } | 680 } |
| 659 | 681 |
| 660 // The render surface's content rect is the union of drawable content rects | 682 // The render surface's content rect is the union of drawable content rects |
| 661 // of the layers that draw into the surface. If the render surface is clipped, | 683 // of the layers that draw into the surface. If the render surface is clipped, |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 | 951 |
| 930 PropertyTrees* GetPropertyTrees(Layer* layer) { | 952 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 931 return layer->layer_tree_host()->property_trees(); | 953 return layer->layer_tree_host()->property_trees(); |
| 932 } | 954 } |
| 933 | 955 |
| 934 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 956 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 935 return layer->layer_tree_impl()->property_trees(); | 957 return layer->layer_tree_impl()->property_trees(); |
| 936 } | 958 } |
| 937 | 959 |
| 938 } // namespace cc | 960 } // namespace cc |
| OLD | NEW |