Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 1872003003: Revert of cc : Remove subtree skipping in LayerTreeHostCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 DCHECK_GE(layer->effect_tree_index(), 0); 535 DCHECK_GE(layer->effect_tree_index(), 0);
536 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index()) 536 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index())
537 ->data.is_drawn; 537 ->data.is_drawn;
538 538
539 // The root layer cannot be skipped. 539 // The root layer cannot be skipped.
540 if (!IsRootLayer(layer) && 540 if (!IsRootLayer(layer) &&
541 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn, 541 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn,
542 property_trees->transform_tree, 542 property_trees->transform_tree,
543 property_trees->effect_tree)) { 543 property_trees->effect_tree)) {
544 layer->draw_properties().render_target = nullptr; 544 layer->draw_properties().render_target = nullptr;
545 return;
546 }
547
548 bool render_to_separate_surface =
549 IsRootLayer(layer) ||
550 (can_render_to_separate_surface && layer->render_surface());
551
552 if (render_to_separate_surface) {
553 DCHECK(layer->render_surface()) << IsRootLayer(layer)
554 << can_render_to_separate_surface
555 << layer->has_render_surface();
556 layer->draw_properties().render_target = layer;
557
558 if (layer->mask_layer())
559 layer->mask_layer()->draw_properties().render_target = layer;
560
561 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
562 layer->replica_layer()->mask_layer()->draw_properties().render_target =
563 layer;
564
545 } else { 565 } else {
546 bool render_to_separate_surface = 566 DCHECK(!IsRootLayer(layer));
547 IsRootLayer(layer) || 567 layer->draw_properties().render_target = layer->parent()->render_target();
548 (can_render_to_separate_surface && layer->render_surface());
549
550 if (render_to_separate_surface) {
551 DCHECK(layer->render_surface()) << IsRootLayer(layer)
552 << can_render_to_separate_surface
553 << layer->has_render_surface();
554 layer->draw_properties().render_target = layer;
555
556 if (layer->mask_layer())
557 layer->mask_layer()->draw_properties().render_target = layer;
558
559 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
560 layer->replica_layer()->mask_layer()->draw_properties().render_target =
561 layer;
562
563 } else {
564 DCHECK(!IsRootLayer(layer));
565 layer->draw_properties().render_target = layer->parent()->render_target();
566 }
567 } 568 }
568 for (size_t i = 0; i < layer->children().size(); ++i) { 569 for (size_t i = 0; i < layer->children().size(); ++i) {
569 CalculateRenderTarget( 570 CalculateRenderTarget(
570 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), 571 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i),
571 property_trees, layer_is_drawn, can_render_to_separate_surface); 572 property_trees, layer_is_drawn, can_render_to_separate_surface);
572 } 573 }
573 } 574 }
574 575
575 void CalculateRenderSurfaceLayerList( 576 void CalculateRenderSurfaceLayerList(
576 LayerImpl* layer, 577 LayerImpl* layer,
(...skipping 26 matching lines...) Expand all
603 ->data.is_drawn; 604 ->data.is_drawn;
604 605
605 // The root layer cannot be skipped. 606 // The root layer cannot be skipped.
606 if (!IsRootLayer(layer) && 607 if (!IsRootLayer(layer) &&
607 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn, 608 draw_property_utils::LayerShouldBeSkipped(layer, layer_is_drawn,
608 property_trees->transform_tree, 609 property_trees->transform_tree,
609 property_trees->effect_tree)) { 610 property_trees->effect_tree)) {
610 if (layer->render_surface()) 611 if (layer->render_surface())
611 layer->ClearRenderSurfaceLayerList(); 612 layer->ClearRenderSurfaceLayerList();
612 layer->draw_properties().render_target = nullptr; 613 layer->draw_properties().render_target = nullptr;
613 for (auto* child_layer : layer->children()) {
614 CalculateRenderSurfaceLayerList(
615 child_layer, property_trees, render_surface_layer_list, descendants,
616 nearest_occlusion_immune_ancestor, layer_is_drawn,
617 can_render_to_separate_surface, current_render_surface_layer_list_id,
618 max_texture_size);
619 }
620 return; 614 return;
621 } 615 }
622 616
623 bool render_to_separate_surface = 617 bool render_to_separate_surface =
624 IsRootLayer(layer) || 618 IsRootLayer(layer) ||
625 (can_render_to_separate_surface && layer->render_surface()); 619 (can_render_to_separate_surface && layer->render_surface());
626 620
627 if (render_to_separate_surface) { 621 if (render_to_separate_surface) {
628 DCHECK(layer->render_surface()); 622 DCHECK(layer->render_surface());
629 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, 623 draw_property_utils::ComputeSurfaceDrawProperties(property_trees,
(...skipping 26 matching lines...) Expand all
656 } 650 }
657 layer->render_surface()->SetNearestOcclusionImmuneAncestor( 651 layer->render_surface()->SetNearestOcclusionImmuneAncestor(
658 nearest_occlusion_immune_ancestor); 652 nearest_occlusion_immune_ancestor);
659 layer->ClearRenderSurfaceLayerList(); 653 layer->ClearRenderSurfaceLayerList();
660 654
661 render_surface_layer_list->push_back(layer); 655 render_surface_layer_list->push_back(layer);
662 656
663 descendants = &(layer->render_surface()->layer_list()); 657 descendants = &(layer->render_surface()->layer_list());
664 } 658 }
665 659
660 size_t descendants_size = descendants->size();
661
666 bool layer_should_be_skipped = !draw_property_utils::LayerNeedsUpdate( 662 bool layer_should_be_skipped = !draw_property_utils::LayerNeedsUpdate(
667 layer, layer_is_drawn, property_trees->transform_tree); 663 layer, layer_is_drawn, property_trees->transform_tree);
668 if (!layer_should_be_skipped) { 664 if (!layer_should_be_skipped) {
669 DCHECK(layer->draw_properties().render_target);
670 MarkLayerWithRenderSurfaceLayerListId(layer, 665 MarkLayerWithRenderSurfaceLayerListId(layer,
671 current_render_surface_layer_list_id); 666 current_render_surface_layer_list_id);
672 descendants->push_back(layer); 667 descendants->push_back(layer);
673 } 668 }
674 669
675 670
676 // Clear the old accumulated content rect of surface. 671 // Clear the old accumulated content rect of surface.
677 if (render_to_separate_surface) 672 if (render_to_separate_surface)
678 layer->render_surface()->SetAccumulatedContentRect(gfx::Rect()); 673 layer->render_surface()->SetAccumulatedContentRect(gfx::Rect());
679 674
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 } 733 }
739 // The RenderSurfaceImpl backing texture cannot exceed the maximum 734 // The RenderSurfaceImpl backing texture cannot exceed the maximum
740 // supported texture size. 735 // supported texture size.
741 surface_content_rect.set_width( 736 surface_content_rect.set_width(
742 std::min(surface_content_rect.width(), max_texture_size)); 737 std::min(surface_content_rect.width(), max_texture_size));
743 surface_content_rect.set_height( 738 surface_content_rect.set_height(
744 std::min(surface_content_rect.height(), max_texture_size)); 739 std::min(surface_content_rect.height(), max_texture_size));
745 layer->render_surface()->SetContentRect(surface_content_rect); 740 layer->render_surface()->SetContentRect(surface_content_rect);
746 } 741 }
747 const LayerImpl* parent_target = layer->parent()->render_target(); 742 const LayerImpl* parent_target = layer->parent()->render_target();
748 if (parent_target && !IsRootLayer(parent_target)) { 743 if (!IsRootLayer(parent_target)) {
749 gfx::Rect surface_content_rect = 744 gfx::Rect surface_content_rect =
750 parent_target->render_surface()->accumulated_content_rect(); 745 parent_target->render_surface()->accumulated_content_rect();
751 if (render_to_separate_surface) { 746 if (render_to_separate_surface) {
752 // If the layer owns a surface, then the content rect is in the wrong 747 // If the layer owns a surface, then the content rect is in the wrong
753 // space. Instead, we will use the surface's DrawableContentRect which 748 // space. Instead, we will use the surface's DrawableContentRect which
754 // is in target space as required. We also need to clip it with the 749 // is in target space as required. We also need to clip it with the
755 // target's clip if the target is clipped. 750 // target's clip if the target is clipped.
756 surface_content_rect.Union(gfx::ToEnclosedRect( 751 surface_content_rect.Union(gfx::ToEnclosedRect(
757 layer->render_surface()->DrawableContentRect())); 752 layer->render_surface()->DrawableContentRect()));
758 if (parent_target->is_clipped()) 753 if (parent_target->is_clipped())
759 surface_content_rect.Intersect(parent_target->clip_rect()); 754 surface_content_rect.Intersect(parent_target->clip_rect());
760 } else if (layer->DrawsContent()) { 755 } else if (layer->DrawsContent()) {
761 surface_content_rect.Union(layer->drawable_content_rect()); 756 surface_content_rect.Union(layer->drawable_content_rect());
762 } 757 }
763 parent_target->render_surface()->SetAccumulatedContentRect( 758 parent_target->render_surface()->SetAccumulatedContentRect(
764 surface_content_rect); 759 surface_content_rect);
765 } 760 }
766 } else { 761 } else {
767 // The root layer's surface content rect is always the entire viewport. 762 // The root layer's surface content rect is always the entire viewport.
768 gfx::Rect viewport = 763 gfx::Rect viewport =
769 gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip()); 764 gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
770 layer->render_surface()->SetContentRect(viewport); 765 layer->render_surface()->SetContentRect(viewport);
771 } 766 }
772 767
773 if (render_to_separate_surface && !IsRootLayer(layer) && 768 if (render_to_separate_surface && !IsRootLayer(layer) &&
774 layer->render_surface()->DrawableContentRect().IsEmpty()) { 769 layer->render_surface()->DrawableContentRect().IsEmpty()) {
775 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 770 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
771 return;
772 }
773
774 // If neither this layer nor any of its children were added, early out.
775 if (descendants_size == descendants->size()) {
776 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
777 return;
776 } 778 }
777 } 779 }
778 780
779 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer, 781 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer,
780 LayerImpl* mask_layer) { 782 LayerImpl* mask_layer) {
781 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties(); 783 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties();
782 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds()); 784 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds());
783 mask_layer_draw_properties.target_space_transform = 785 mask_layer_draw_properties.target_space_transform =
784 layer->draw_properties().target_space_transform; 786 layer->draw_properties().target_space_transform;
785 mask_layer_draw_properties.screen_space_transform = 787 mask_layer_draw_properties.screen_space_transform =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 } 868 }
867 869
868 if (should_measure_property_tree_performance) { 870 if (should_measure_property_tree_performance) {
869 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 871 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
870 "LayerTreeHostCommon::CalculateDrawProperties"); 872 "LayerTreeHostCommon::CalculateDrawProperties");
871 } 873 }
872 874
873 DCHECK(inputs->can_render_to_separate_surface == 875 DCHECK(inputs->can_render_to_separate_surface ==
874 inputs->property_trees->non_root_surfaces_enabled); 876 inputs->property_trees->non_root_surfaces_enabled);
875 const bool subtree_visible_from_ancestor = true; 877 const bool subtree_visible_from_ancestor = true;
878 for (auto* layer : *inputs->root_layer->layer_tree_impl())
879 layer->draw_properties().render_target = nullptr;
876 CalculateRenderTarget(inputs->root_layer, inputs->property_trees, 880 CalculateRenderTarget(inputs->root_layer, inputs->property_trees,
877 subtree_visible_from_ancestor, 881 subtree_visible_from_ancestor,
878 inputs->can_render_to_separate_surface); 882 inputs->can_render_to_separate_surface);
879 for (LayerImpl* layer : visible_layer_list) { 883 for (LayerImpl* layer : visible_layer_list) {
880 draw_property_utils::ComputeLayerDrawProperties( 884 draw_property_utils::ComputeLayerDrawProperties(
881 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, 885 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
882 inputs->can_use_lcd_text); 886 inputs->can_use_lcd_text);
883 if (layer->mask_layer()) 887 if (layer->mask_layer())
884 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); 888 ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
885 LayerImpl* replica_mask_layer = 889 LayerImpl* replica_mask_layer =
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 993
990 PropertyTrees* GetPropertyTrees(Layer* layer) { 994 PropertyTrees* GetPropertyTrees(Layer* layer) {
991 return layer->layer_tree_host()->property_trees(); 995 return layer->layer_tree_host()->property_trees();
992 } 996 }
993 997
994 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 998 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
995 return layer->layer_tree_impl()->property_trees(); 999 return layer->layer_tree_impl()->property_trees();
996 } 1000 }
997 1001
998 } // namespace cc 1002 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698