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

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

Issue 1947683007: cc : Add subtree is hidden bool to effect tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « cc/trees/property_tree.cc ('k') | 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 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/property_tree_builder.h" 5 #include "cc/trees/property_tree_builder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 } 660 }
661 661
662 static inline int NumDescendantsThatDrawContent(Layer* layer) { 662 static inline int NumDescendantsThatDrawContent(Layer* layer) {
663 return layer->NumDescendantsThatDrawContent(); 663 return layer->NumDescendantsThatDrawContent();
664 } 664 }
665 665
666 static inline int NumDescendantsThatDrawContent(LayerImpl* layer) { 666 static inline int NumDescendantsThatDrawContent(LayerImpl* layer) {
667 return layer->test_properties()->num_descendants_that_draw_content; 667 return layer->test_properties()->num_descendants_that_draw_content;
668 } 668 }
669 669
670 static inline float EffectiveOpacity(Layer* layer) {
671 return layer->EffectiveOpacity();
672 }
673
674 static inline float EffectiveOpacity(LayerImpl* layer) {
675 return layer->test_properties()->hide_layer_and_subtree ? 0.f
676 : layer->opacity();
677 }
678
679 static inline bool HideLayerAndSubtree(Layer* layer) {
680 return layer->hide_layer_and_subtree();
681 }
682
683 static inline bool HideLayerAndSubtree(LayerImpl* layer) {
684 return layer->test_properties()->hide_layer_and_subtree;
685 }
686
670 template <typename LayerType> 687 template <typename LayerType>
671 bool ShouldCreateRenderSurface(LayerType* layer, 688 bool ShouldCreateRenderSurface(LayerType* layer,
672 gfx::Transform current_transform, 689 gfx::Transform current_transform,
673 bool axis_aligned) { 690 bool axis_aligned) {
674 const bool preserves_2d_axis_alignment = 691 const bool preserves_2d_axis_alignment =
675 (current_transform * layer->transform()).Preserves2dAxisAlignment() && 692 (current_transform * layer->transform()).Preserves2dAxisAlignment() &&
676 axis_aligned && layer->AnimationsPreserveAxisAlignment(); 693 axis_aligned && layer->AnimationsPreserveAxisAlignment();
677 const bool is_root = !layer->parent(); 694 const bool is_root = !layer->parent();
678 if (is_root) 695 if (is_root)
679 return true; 696 return true;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 752
736 // If the layer has some translucency and does not have a preserves-3d 753 // If the layer has some translucency and does not have a preserves-3d
737 // transform style. This condition only needs a render surface if two or more 754 // transform style. This condition only needs a render surface if two or more
738 // layers in the subtree overlap. But checking layer overlaps is unnecessarily 755 // layers in the subtree overlap. But checking layer overlaps is unnecessarily
739 // costly so instead we conservatively create a surface whenever at least two 756 // costly so instead we conservatively create a surface whenever at least two
740 // layers draw content for this subtree. 757 // layers draw content for this subtree.
741 bool at_least_two_layers_in_subtree_draw_content = 758 bool at_least_two_layers_in_subtree_draw_content =
742 num_descendants_that_draw_content > 0 && 759 num_descendants_that_draw_content > 0 &&
743 (layer->DrawsContent() || num_descendants_that_draw_content > 1); 760 (layer->DrawsContent() || num_descendants_that_draw_content > 1);
744 761
745 if (layer->EffectiveOpacity() != 1.f && ShouldFlattenTransform(layer) && 762 if (EffectiveOpacity(layer) != 1.f && ShouldFlattenTransform(layer) &&
746 at_least_two_layers_in_subtree_draw_content) { 763 at_least_two_layers_in_subtree_draw_content) {
747 TRACE_EVENT_INSTANT0( 764 TRACE_EVENT_INSTANT0(
748 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity", 765 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface opacity",
749 TRACE_EVENT_SCOPE_THREAD); 766 TRACE_EVENT_SCOPE_THREAD);
750 DCHECK(!is_root); 767 DCHECK(!is_root);
751 return true; 768 return true;
752 } 769 }
753 // If the layer has isolation. 770 // If the layer has isolation.
754 // TODO(rosca): to be optimized - create separate rendering surface only when 771 // TODO(rosca): to be optimized - create separate rendering surface only when
755 // the blending descendants might have access to the content behind this layer 772 // the blending descendants might have access to the content behind this layer
(...skipping 16 matching lines...) Expand all
772 789
773 return false; 790 return false;
774 } 791 }
775 792
776 template <typename LayerType> 793 template <typename LayerType>
777 bool AddEffectNodeIfNeeded( 794 bool AddEffectNodeIfNeeded(
778 const DataForRecursion<LayerType>& data_from_ancestor, 795 const DataForRecursion<LayerType>& data_from_ancestor,
779 LayerType* layer, 796 LayerType* layer,
780 DataForRecursion<LayerType>* data_for_children) { 797 DataForRecursion<LayerType>* data_for_children) {
781 const bool is_root = !layer->parent(); 798 const bool is_root = !layer->parent();
782 const bool has_transparency = layer->EffectiveOpacity() != 1.f; 799 const bool has_transparency = EffectiveOpacity(layer) != 1.f;
783 const bool has_animated_opacity = IsAnimatingOpacity(layer); 800 const bool has_animated_opacity = IsAnimatingOpacity(layer);
784 const bool should_create_render_surface = ShouldCreateRenderSurface( 801 const bool should_create_render_surface = ShouldCreateRenderSurface(
785 layer, data_from_ancestor.compound_transform_since_render_target, 802 layer, data_from_ancestor.compound_transform_since_render_target,
786 data_from_ancestor.axis_align_since_render_target); 803 data_from_ancestor.axis_align_since_render_target);
787 data_for_children->axis_align_since_render_target &= 804 data_for_children->axis_align_since_render_target &=
788 layer->AnimationsPreserveAxisAlignment(); 805 layer->AnimationsPreserveAxisAlignment();
789 806
790 bool requires_node = is_root || has_transparency || has_animated_opacity || 807 bool requires_node = is_root || has_transparency || has_animated_opacity ||
791 should_create_render_surface; 808 should_create_render_surface;
792 809
793 int parent_id = data_from_ancestor.effect_tree_parent; 810 int parent_id = data_from_ancestor.effect_tree_parent;
794 811
795 if (!requires_node) { 812 if (!requires_node) {
796 layer->SetEffectTreeIndex(parent_id); 813 layer->SetEffectTreeIndex(parent_id);
797 data_for_children->effect_tree_parent = parent_id; 814 data_for_children->effect_tree_parent = parent_id;
798 data_for_children->compound_transform_since_render_target *= 815 data_for_children->compound_transform_since_render_target *=
799 layer->transform(); 816 layer->transform();
800 return false; 817 return false;
801 } 818 }
802 819
803 EffectNode node; 820 EffectNode node;
804 node.owner_id = layer->id(); 821 node.owner_id = layer->id();
805 node.data.opacity = layer->EffectiveOpacity(); 822 node.data.opacity = layer->opacity();
806 node.data.has_render_surface = should_create_render_surface; 823 node.data.has_render_surface = should_create_render_surface;
807 node.data.has_copy_request = layer->HasCopyRequest(); 824 node.data.has_copy_request = layer->HasCopyRequest();
808 node.data.has_background_filters = !layer->background_filters().IsEmpty(); 825 node.data.has_background_filters = !layer->background_filters().IsEmpty();
809 node.data.has_animated_opacity = has_animated_opacity; 826 node.data.has_animated_opacity = has_animated_opacity;
810 node.data.double_sided = DoubleSided(layer); 827 node.data.double_sided = DoubleSided(layer);
828 node.data.subtree_hidden = HideLayerAndSubtree(layer);
811 829
812 if (!is_root) { 830 if (!is_root) {
813 // The effect node's transform id is used only when we create a render 831 // The effect node's transform id is used only when we create a render
814 // surface. So, we can leave the default value when we don't create a render 832 // surface. So, we can leave the default value when we don't create a render
815 // surface. 833 // surface.
816 if (should_create_render_surface) { 834 if (should_create_render_surface) {
817 // In this case, we will create a transform node, so it's safe to use the 835 // In this case, we will create a transform node, so it's safe to use the
818 // next available id from the transform tree as this effect node's 836 // next available id from the transform tree as this effect node's
819 // transform id. 837 // transform id.
820 node.data.transform_id = 838 node.data.transform_id =
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 if (SkColorGetA(color) != 255) 1262 if (SkColorGetA(color) != 255)
1245 color = SkColorSetA(color, 255); 1263 color = SkColorSetA(color, 255);
1246 BuildPropertyTreesTopLevelInternal( 1264 BuildPropertyTreesTopLevelInternal(
1247 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1265 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1248 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1266 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1249 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1267 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1250 device_transform, property_trees, color); 1268 device_transform, property_trees, color);
1251 } 1269 }
1252 1270
1253 } // namespace cc 1271 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698