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

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

Issue 1865693003: cc : Remove subtree skipping in LayerTreeHostCommon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 bool layer_is_drawn; 534 bool layer_is_drawn;
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( 541 draw_property_utils::LayerShouldBeSkipped(
542 layer, layer_is_drawn, property_trees->transform_tree)) { 542 layer, layer_is_drawn, property_trees->transform_tree)) {
543 layer->draw_properties().render_target = nullptr; 543 layer->draw_properties().render_target = nullptr;
544 return; 544 } else {
545 } 545 bool render_to_separate_surface =
546 IsRootLayer(layer) ||
547 (can_render_to_separate_surface && layer->render_surface());
546 548
547 bool render_to_separate_surface = 549 if (render_to_separate_surface) {
548 IsRootLayer(layer) || 550 DCHECK(layer->render_surface()) << IsRootLayer(layer)
549 (can_render_to_separate_surface && layer->render_surface()); 551 << can_render_to_separate_surface
552 << layer->has_render_surface();
553 layer->draw_properties().render_target = layer;
550 554
551 if (render_to_separate_surface) { 555 if (layer->mask_layer())
552 DCHECK(layer->render_surface()) << IsRootLayer(layer) 556 layer->mask_layer()->draw_properties().render_target = layer;
553 << can_render_to_separate_surface
554 << layer->has_render_surface();
555 layer->draw_properties().render_target = layer;
556 557
557 if (layer->mask_layer()) 558 if (layer->replica_layer() && layer->replica_layer()->mask_layer())
558 layer->mask_layer()->draw_properties().render_target = layer; 559 layer->replica_layer()->mask_layer()->draw_properties().render_target =
560 layer;
559 561
560 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) 562 } else {
561 layer->replica_layer()->mask_layer()->draw_properties().render_target = 563 DCHECK(!IsRootLayer(layer));
562 layer; 564 layer->draw_properties().render_target = layer->parent()->render_target();
563 565 }
564 } else {
565 DCHECK(!IsRootLayer(layer));
566 layer->draw_properties().render_target = layer->parent()->render_target();
567 } 566 }
568 for (size_t i = 0; i < layer->children().size(); ++i) { 567 for (size_t i = 0; i < layer->children().size(); ++i) {
569 CalculateRenderTarget( 568 CalculateRenderTarget(
570 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), 569 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i),
571 property_trees, layer_is_drawn, can_render_to_separate_surface); 570 property_trees, layer_is_drawn, can_render_to_separate_surface);
572 } 571 }
573 } 572 }
574 573
575 void CalculateRenderSurfaceLayerList( 574 void CalculateRenderSurfaceLayerList(
576 LayerImpl* layer, 575 LayerImpl* layer,
(...skipping 25 matching lines...) Expand all
602 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index()) 601 layer_is_drawn = property_trees->effect_tree.Node(layer->effect_tree_index())
603 ->data.is_drawn; 602 ->data.is_drawn;
604 603
605 // The root layer cannot be skipped. 604 // The root layer cannot be skipped.
606 if (!IsRootLayer(layer) && 605 if (!IsRootLayer(layer) &&
607 draw_property_utils::LayerShouldBeSkipped( 606 draw_property_utils::LayerShouldBeSkipped(
608 layer, layer_is_drawn, property_trees->transform_tree)) { 607 layer, layer_is_drawn, property_trees->transform_tree)) {
609 if (layer->render_surface()) 608 if (layer->render_surface())
610 layer->ClearRenderSurfaceLayerList(); 609 layer->ClearRenderSurfaceLayerList();
611 layer->draw_properties().render_target = nullptr; 610 layer->draw_properties().render_target = nullptr;
611 for (auto* child_layer : layer->children()) {
612 CalculateRenderSurfaceLayerList(
613 child_layer, property_trees, render_surface_layer_list, descendants,
614 nearest_occlusion_immune_ancestor, layer_is_drawn,
615 can_render_to_separate_surface, current_render_surface_layer_list_id,
616 max_texture_size);
617 }
612 return; 618 return;
613 } 619 }
614 620
615 bool render_to_separate_surface = 621 bool render_to_separate_surface =
616 IsRootLayer(layer) || 622 IsRootLayer(layer) ||
617 (can_render_to_separate_surface && layer->render_surface()); 623 (can_render_to_separate_surface && layer->render_surface());
618 624
619 if (render_to_separate_surface) { 625 if (render_to_separate_surface) {
620 DCHECK(layer->render_surface()); 626 DCHECK(layer->render_surface());
621 draw_property_utils::ComputeSurfaceDrawProperties(property_trees, 627 draw_property_utils::ComputeSurfaceDrawProperties(property_trees,
(...skipping 26 matching lines...) Expand all
648 } 654 }
649 layer->render_surface()->SetNearestOcclusionImmuneAncestor( 655 layer->render_surface()->SetNearestOcclusionImmuneAncestor(
650 nearest_occlusion_immune_ancestor); 656 nearest_occlusion_immune_ancestor);
651 layer->ClearRenderSurfaceLayerList(); 657 layer->ClearRenderSurfaceLayerList();
652 658
653 render_surface_layer_list->push_back(layer); 659 render_surface_layer_list->push_back(layer);
654 660
655 descendants = &(layer->render_surface()->layer_list()); 661 descendants = &(layer->render_surface()->layer_list());
656 } 662 }
657 663
658 size_t descendants_size = descendants->size();
659
660 bool layer_should_be_skipped = !draw_property_utils::LayerNeedsUpdate( 664 bool layer_should_be_skipped = !draw_property_utils::LayerNeedsUpdate(
661 layer, layer_is_drawn, property_trees->transform_tree); 665 layer, layer_is_drawn, property_trees->transform_tree);
662 if (!layer_should_be_skipped) { 666 if (!layer_should_be_skipped) {
ajuma 2016/04/07 15:19:56 Please add a DCHECK here that we're either renderi
jaydasika 2016/04/07 17:00:55 Done.
663 MarkLayerWithRenderSurfaceLayerListId(layer, 667 MarkLayerWithRenderSurfaceLayerListId(layer,
664 current_render_surface_layer_list_id); 668 current_render_surface_layer_list_id);
665 descendants->push_back(layer); 669 descendants->push_back(layer);
666 } 670 }
667 671
668 672
669 // Clear the old accumulated content rect of surface. 673 // Clear the old accumulated content rect of surface.
670 if (render_to_separate_surface) 674 if (render_to_separate_surface)
671 layer->render_surface()->SetAccumulatedContentRect(gfx::Rect()); 675 layer->render_surface()->SetAccumulatedContentRect(gfx::Rect());
672 676
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 735 }
732 // The RenderSurfaceImpl backing texture cannot exceed the maximum 736 // The RenderSurfaceImpl backing texture cannot exceed the maximum
733 // supported texture size. 737 // supported texture size.
734 surface_content_rect.set_width( 738 surface_content_rect.set_width(
735 std::min(surface_content_rect.width(), max_texture_size)); 739 std::min(surface_content_rect.width(), max_texture_size));
736 surface_content_rect.set_height( 740 surface_content_rect.set_height(
737 std::min(surface_content_rect.height(), max_texture_size)); 741 std::min(surface_content_rect.height(), max_texture_size));
738 layer->render_surface()->SetContentRect(surface_content_rect); 742 layer->render_surface()->SetContentRect(surface_content_rect);
739 } 743 }
740 const LayerImpl* parent_target = layer->parent()->render_target(); 744 const LayerImpl* parent_target = layer->parent()->render_target();
741 if (!IsRootLayer(parent_target)) { 745 if (parent_target && !IsRootLayer(parent_target)) {
jaydasika 2016/04/07 00:32:21 Adding this because layers with copy requests may
ajuma 2016/04/07 15:19:56 Can this happen now, or only after the layer skipp
jaydasika 2016/04/07 17:00:55 Cannot happen now.
742 gfx::Rect surface_content_rect = 746 gfx::Rect surface_content_rect =
743 parent_target->render_surface()->accumulated_content_rect(); 747 parent_target->render_surface()->accumulated_content_rect();
744 if (render_to_separate_surface) { 748 if (render_to_separate_surface) {
745 // If the layer owns a surface, then the content rect is in the wrong 749 // If the layer owns a surface, then the content rect is in the wrong
746 // space. Instead, we will use the surface's DrawableContentRect which 750 // space. Instead, we will use the surface's DrawableContentRect which
747 // is in target space as required. We also need to clip it with the 751 // is in target space as required. We also need to clip it with the
748 // target's clip if the target is clipped. 752 // target's clip if the target is clipped.
749 surface_content_rect.Union(gfx::ToEnclosedRect( 753 surface_content_rect.Union(gfx::ToEnclosedRect(
750 layer->render_surface()->DrawableContentRect())); 754 layer->render_surface()->DrawableContentRect()));
751 if (parent_target->is_clipped()) 755 if (parent_target->is_clipped())
752 surface_content_rect.Intersect(parent_target->clip_rect()); 756 surface_content_rect.Intersect(parent_target->clip_rect());
753 } else if (layer->DrawsContent()) { 757 } else if (layer->DrawsContent()) {
754 surface_content_rect.Union(layer->drawable_content_rect()); 758 surface_content_rect.Union(layer->drawable_content_rect());
755 } 759 }
756 parent_target->render_surface()->SetAccumulatedContentRect( 760 parent_target->render_surface()->SetAccumulatedContentRect(
757 surface_content_rect); 761 surface_content_rect);
758 } 762 }
759 } else { 763 } else {
760 // The root layer's surface content rect is always the entire viewport. 764 // The root layer's surface content rect is always the entire viewport.
761 gfx::Rect viewport = 765 gfx::Rect viewport =
762 gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip()); 766 gfx::ToEnclosingRect(property_trees->clip_tree.ViewportClip());
763 layer->render_surface()->SetContentRect(viewport); 767 layer->render_surface()->SetContentRect(viewport);
764 } 768 }
765 769
766 if (render_to_separate_surface && !IsRootLayer(layer) && 770 if (render_to_separate_surface && !IsRootLayer(layer) &&
767 layer->render_surface()->DrawableContentRect().IsEmpty()) { 771 layer->render_surface()->DrawableContentRect().IsEmpty()) {
768 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list); 772 RemoveSurfaceForEarlyExit(layer, render_surface_layer_list);
769 return;
770 }
771
772 // If neither this layer nor any of its children were added, early out.
773 if (descendants_size == descendants->size()) {
774 DCHECK(!render_to_separate_surface || IsRootLayer(layer));
775 return;
776 } 773 }
777 } 774 }
778 775
779 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer, 776 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer,
780 LayerImpl* mask_layer) { 777 LayerImpl* mask_layer) {
781 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties(); 778 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties();
782 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds()); 779 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds());
783 mask_layer_draw_properties.target_space_transform = 780 mask_layer_draw_properties.target_space_transform =
784 layer->draw_properties().target_space_transform; 781 layer->draw_properties().target_space_transform;
785 mask_layer_draw_properties.screen_space_transform = 782 mask_layer_draw_properties.screen_space_transform =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 } 863 }
867 864
868 if (should_measure_property_tree_performance) { 865 if (should_measure_property_tree_performance) {
869 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 866 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
870 "LayerTreeHostCommon::CalculateDrawProperties"); 867 "LayerTreeHostCommon::CalculateDrawProperties");
871 } 868 }
872 869
873 DCHECK(inputs->can_render_to_separate_surface == 870 DCHECK(inputs->can_render_to_separate_surface ==
874 inputs->property_trees->non_root_surfaces_enabled); 871 inputs->property_trees->non_root_surfaces_enabled);
875 const bool subtree_visible_from_ancestor = true; 872 const bool subtree_visible_from_ancestor = true;
876 for (auto* layer : *inputs->root_layer->layer_tree_impl())
877 layer->draw_properties().render_target = nullptr;
878 CalculateRenderTarget(inputs->root_layer, inputs->property_trees, 873 CalculateRenderTarget(inputs->root_layer, inputs->property_trees,
879 subtree_visible_from_ancestor, 874 subtree_visible_from_ancestor,
880 inputs->can_render_to_separate_surface); 875 inputs->can_render_to_separate_surface);
881 for (LayerImpl* layer : visible_layer_list) { 876 for (LayerImpl* layer : visible_layer_list) {
882 draw_property_utils::ComputeLayerDrawProperties( 877 draw_property_utils::ComputeLayerDrawProperties(
883 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text, 878 layer, inputs->property_trees, inputs->layers_always_allowed_lcd_text,
884 inputs->can_use_lcd_text); 879 inputs->can_use_lcd_text);
885 if (layer->mask_layer()) 880 if (layer->mask_layer())
886 ComputeMaskLayerDrawProperties(layer, layer->mask_layer()); 881 ComputeMaskLayerDrawProperties(layer, layer->mask_layer());
887 LayerImpl* replica_mask_layer = 882 LayerImpl* replica_mask_layer =
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 988
994 PropertyTrees* GetPropertyTrees(Layer* layer) { 989 PropertyTrees* GetPropertyTrees(Layer* layer) {
995 return layer->layer_tree_host()->property_trees(); 990 return layer->layer_tree_host()->property_trees();
996 } 991 }
997 992
998 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 993 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
999 return layer->layer_tree_impl()->property_trees(); 994 return layer->layer_tree_impl()->property_trees();
1000 } 995 }
1001 996
1002 } // namespace cc 997 } // 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