| 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/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 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 NumLayerOrDescendantsThatDrawContentRecursive(child_layer); | 656 NumLayerOrDescendantsThatDrawContentRecursive(child_layer); |
| 657 } | 657 } |
| 658 return num_descendants_that_draw_content; | 658 return num_descendants_that_draw_content; |
| 659 } | 659 } |
| 660 | 660 |
| 661 static inline float EffectiveOpacity(Layer* layer) { | 661 static inline float EffectiveOpacity(Layer* layer) { |
| 662 return layer->EffectiveOpacity(); | 662 return layer->EffectiveOpacity(); |
| 663 } | 663 } |
| 664 | 664 |
| 665 static inline float EffectiveOpacity(LayerImpl* layer) { | 665 static inline float EffectiveOpacity(LayerImpl* layer) { |
| 666 return layer->test_properties()->hide_layer_and_subtree | 666 return layer->test_properties()->opacity; |
| 667 ? 0.f | |
| 668 : layer->test_properties()->opacity; | |
| 669 } | 667 } |
| 670 | 668 |
| 671 static inline float Opacity(Layer* layer) { | 669 static inline float Opacity(Layer* layer) { |
| 672 return layer->opacity(); | 670 return layer->opacity(); |
| 673 } | 671 } |
| 674 | 672 |
| 675 static inline float Opacity(LayerImpl* layer) { | 673 static inline float Opacity(LayerImpl* layer) { |
| 676 return layer->test_properties()->opacity; | 674 return layer->test_properties()->opacity; |
| 677 } | 675 } |
| 678 | 676 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 698 | 696 |
| 699 static inline const FilterOperations& BackgroundFilters(LayerImpl* layer) { | 697 static inline const FilterOperations& BackgroundFilters(LayerImpl* layer) { |
| 700 return layer->test_properties()->background_filters; | 698 return layer->test_properties()->background_filters; |
| 701 } | 699 } |
| 702 | 700 |
| 703 static inline bool HideLayerAndSubtree(Layer* layer) { | 701 static inline bool HideLayerAndSubtree(Layer* layer) { |
| 704 return layer->hide_layer_and_subtree(); | 702 return layer->hide_layer_and_subtree(); |
| 705 } | 703 } |
| 706 | 704 |
| 707 static inline bool HideLayerAndSubtree(LayerImpl* layer) { | 705 static inline bool HideLayerAndSubtree(LayerImpl* layer) { |
| 708 return layer->test_properties()->hide_layer_and_subtree; | 706 return false; |
| 709 } | 707 } |
| 710 | 708 |
| 711 static inline bool HasCopyRequest(Layer* layer) { | 709 static inline bool HasCopyRequest(Layer* layer) { |
| 712 return layer->HasCopyRequest(); | 710 return layer->HasCopyRequest(); |
| 713 } | 711 } |
| 714 | 712 |
| 715 static inline bool HasCopyRequest(LayerImpl* layer) { | 713 static inline bool HasCopyRequest(LayerImpl* layer) { |
| 716 return !layer->test_properties()->copy_requests.empty(); | 714 return !layer->test_properties()->copy_requests.empty(); |
| 717 } | 715 } |
| 718 | 716 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 copy_requests->push_back(std::move(request)); | 836 copy_requests->push_back(std::move(request)); |
| 839 layer->test_properties()->copy_requests.clear(); | 837 layer->test_properties()->copy_requests.clear(); |
| 840 } | 838 } |
| 841 | 839 |
| 842 static void SetSubtreeHasCopyRequest(Layer* layer, | 840 static void SetSubtreeHasCopyRequest(Layer* layer, |
| 843 bool subtree_has_copy_request) { | 841 bool subtree_has_copy_request) { |
| 844 layer->SetSubtreeHasCopyRequest(subtree_has_copy_request); | 842 layer->SetSubtreeHasCopyRequest(subtree_has_copy_request); |
| 845 } | 843 } |
| 846 | 844 |
| 847 static void SetSubtreeHasCopyRequest(LayerImpl* layer, | 845 static void SetSubtreeHasCopyRequest(LayerImpl* layer, |
| 848 bool subtree_has_copy_request) { | 846 bool subtree_has_copy_request) {} |
| 849 layer->test_properties()->subtree_has_copy_request = subtree_has_copy_request; | |
| 850 } | |
| 851 | 847 |
| 852 static bool SubtreeHasCopyRequest(Layer* layer) { | 848 static bool SubtreeHasCopyRequest(Layer* layer) { |
| 853 return layer->SubtreeHasCopyRequest(); | 849 return layer->SubtreeHasCopyRequest(); |
| 854 } | 850 } |
| 855 | 851 |
| 856 static bool SubtreeHasCopyRequest(LayerImpl* layer) { | 852 static bool SubtreeHasCopyRequest(LayerImpl* layer) { |
| 857 return layer->test_properties()->subtree_has_copy_request; | 853 return false; |
| 858 } | 854 } |
| 859 | 855 |
| 860 template <typename LayerType> | 856 template <typename LayerType> |
| 861 bool UpdateSubtreeHasCopyRequestRecursive(LayerType* layer) { | 857 bool UpdateSubtreeHasCopyRequestRecursive(LayerType* layer) { |
| 862 bool subtree_has_copy_request = false; | 858 bool subtree_has_copy_request = false; |
| 863 if (HasCopyRequest(layer)) | 859 if (HasCopyRequest(layer)) |
| 864 subtree_has_copy_request = true; | 860 subtree_has_copy_request = true; |
| 865 for (size_t i = 0; i < Children(layer).size(); ++i) { | 861 for (size_t i = 0; i < Children(layer).size(); ++i) { |
| 866 LayerType* current_child = ChildAt(layer, i); | 862 LayerType* current_child = ChildAt(layer, i); |
| 867 subtree_has_copy_request |= | 863 subtree_has_copy_request |= |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1129 } | 1125 } |
| 1130 | 1126 |
| 1131 static void SetLayerPropertyChangedForChild(Layer* parent, Layer* child) { | 1127 static void SetLayerPropertyChangedForChild(Layer* parent, Layer* child) { |
| 1132 if (parent->subtree_property_changed()) | 1128 if (parent->subtree_property_changed()) |
| 1133 child->SetSubtreePropertyChanged(); | 1129 child->SetSubtreePropertyChanged(); |
| 1134 } | 1130 } |
| 1135 | 1131 |
| 1136 static void SetLayerPropertyChangedForChild(LayerImpl* parent, | 1132 static void SetLayerPropertyChangedForChild(LayerImpl* parent, |
| 1137 LayerImpl* child) {} | 1133 LayerImpl* child) {} |
| 1138 | 1134 |
| 1135 static bool SubtreeIsHidden(Layer* layer) { |
| 1136 return !SubtreeHasCopyRequest(layer) && layer->parent() && |
| 1137 layer->hide_layer_and_subtree(); |
| 1138 } |
| 1139 |
| 1140 static bool SubtreeIsHidden(LayerImpl* layer) { |
| 1141 return false; |
| 1142 } |
| 1143 |
| 1144 static void SetIsHidden(Layer* layer, bool is_hidden) { |
| 1145 layer->SetIsHidden(is_hidden); |
| 1146 if (MaskLayer(layer)) |
| 1147 MaskLayer(layer)->SetIsHidden(is_hidden); |
| 1148 } |
| 1149 |
| 1150 static void SetIsHidden(LayerImpl* layer, bool is_hidden) {} |
| 1151 |
| 1152 template <typename LayerType> |
| 1153 void AddPropertyTreeNodesIfNeeded( |
| 1154 LayerType* layer, |
| 1155 const DataForRecursion<LayerType>& data_from_parent, |
| 1156 DataForRecursion<LayerType>* data_for_children) { |
| 1157 DCHECK(!data_for_children->is_hidden); |
| 1158 layer->set_property_tree_sequence_number( |
| 1159 data_from_parent.property_trees->sequence_number); |
| 1160 bool created_render_surface = |
| 1161 AddEffectNodeIfNeeded(data_from_parent, layer, data_for_children); |
| 1162 |
| 1163 if (created_render_surface) |
| 1164 data_for_children->render_target = data_for_children->effect_tree_parent; |
| 1165 |
| 1166 bool created_transform_node = AddTransformNodeIfNeeded( |
| 1167 data_from_parent, layer, created_render_surface, data_for_children); |
| 1168 AddClipNodeIfNeeded(data_from_parent, layer, created_transform_node, |
| 1169 data_for_children); |
| 1170 |
| 1171 AddScrollNodeIfNeeded(data_from_parent, layer, data_for_children); |
| 1172 |
| 1173 SetBackfaceVisibilityTransform(layer, created_transform_node); |
| 1174 SetSafeOpaqueBackgroundColor(data_from_parent, layer, data_for_children); |
| 1175 } |
| 1176 |
| 1139 template <typename LayerType> | 1177 template <typename LayerType> |
| 1140 void BuildPropertyTreesInternal( | 1178 void BuildPropertyTreesInternal( |
| 1141 LayerType* layer, | 1179 LayerType* layer, |
| 1142 const DataForRecursion<LayerType>& data_from_parent) { | 1180 const DataForRecursion<LayerType>& data_from_parent) { |
| 1143 layer->set_property_tree_sequence_number( | |
| 1144 data_from_parent.property_trees->sequence_number); | |
| 1145 | |
| 1146 DataForRecursion<LayerType> data_for_children(data_from_parent); | 1181 DataForRecursion<LayerType> data_for_children(data_from_parent); |
| 1147 | 1182 |
| 1148 bool created_render_surface = | 1183 data_for_children.is_hidden = |
| 1149 AddEffectNodeIfNeeded(data_from_parent, layer, &data_for_children); | 1184 data_from_parent.is_hidden || SubtreeIsHidden(layer); |
| 1150 | 1185 |
| 1151 if (created_render_surface) | 1186 SetIsHidden(layer, data_for_children.is_hidden); |
| 1152 data_for_children.render_target = data_for_children.effect_tree_parent; | |
| 1153 | 1187 |
| 1154 bool created_transform_node = AddTransformNodeIfNeeded( | 1188 // We do not create property tree nodes for hidden layers. |
| 1155 data_from_parent, layer, created_render_surface, &data_for_children); | 1189 if (!data_for_children.is_hidden) |
| 1156 AddClipNodeIfNeeded(data_from_parent, layer, created_transform_node, | 1190 AddPropertyTreeNodesIfNeeded(layer, data_from_parent, &data_for_children); |
| 1157 &data_for_children); | |
| 1158 | |
| 1159 AddScrollNodeIfNeeded(data_from_parent, layer, &data_for_children); | |
| 1160 | |
| 1161 SetBackfaceVisibilityTransform(layer, created_transform_node); | |
| 1162 SetSafeOpaqueBackgroundColor(data_from_parent, layer, &data_for_children); | |
| 1163 | 1191 |
| 1164 for (size_t i = 0; i < Children(layer).size(); ++i) { | 1192 for (size_t i = 0; i < Children(layer).size(); ++i) { |
| 1165 LayerType* current_child = ChildAt(layer, i); | 1193 LayerType* current_child = ChildAt(layer, i); |
| 1166 SetLayerPropertyChangedForChild(layer, current_child); | 1194 SetLayerPropertyChangedForChild(layer, current_child); |
| 1167 if (!ScrollParent(current_child)) { | 1195 if (!ScrollParent(current_child)) { |
| 1168 BuildPropertyTreesInternal(current_child, data_for_children); | 1196 BuildPropertyTreesInternal(current_child, data_for_children); |
| 1169 } else { | 1197 } else { |
| 1170 // The child should be included in its scroll parent's list of scroll | 1198 // The child should be included in its scroll parent's list of scroll |
| 1171 // children. | 1199 // children. |
| 1172 DCHECK(ScrollChildren(ScrollParent(current_child))->count(current_child)); | 1200 DCHECK(ScrollChildren(ScrollParent(current_child))->count(current_child)); |
| 1173 } | 1201 } |
| 1174 } | 1202 } |
| 1175 | 1203 |
| 1176 if (ScrollChildren(layer)) { | 1204 if (ScrollChildren(layer)) { |
| 1177 for (LayerType* scroll_child : *ScrollChildren(layer)) { | 1205 for (LayerType* scroll_child : *ScrollChildren(layer)) { |
| 1178 DCHECK_EQ(ScrollParent(scroll_child), layer); | 1206 DCHECK_EQ(ScrollParent(scroll_child), layer); |
| 1179 DCHECK(Parent(scroll_child)); | 1207 DCHECK(Parent(scroll_child)); |
| 1180 data_for_children.effect_tree_parent = | 1208 data_for_children.effect_tree_parent = |
| 1181 Parent(scroll_child)->effect_tree_index(); | 1209 Parent(scroll_child)->effect_tree_index(); |
| 1182 data_for_children.render_target = | 1210 data_for_children.render_target = |
| 1183 Parent(scroll_child)->effect_tree_index(); | 1211 Parent(scroll_child)->effect_tree_index(); |
| 1184 BuildPropertyTreesInternal(scroll_child, data_for_children); | 1212 BuildPropertyTreesInternal(scroll_child, data_for_children); |
| 1185 } | 1213 } |
| 1186 } | 1214 } |
| 1187 | 1215 |
| 1216 if (data_for_children.is_hidden) |
| 1217 return; |
| 1218 |
| 1188 if (MaskLayer(layer)) { | 1219 if (MaskLayer(layer)) { |
| 1189 MaskLayer(layer)->set_property_tree_sequence_number( | 1220 MaskLayer(layer)->set_property_tree_sequence_number( |
| 1190 data_from_parent.property_trees->sequence_number); | 1221 data_from_parent.property_trees->sequence_number); |
| 1191 MaskLayer(layer)->set_offset_to_transform_parent( | 1222 MaskLayer(layer)->set_offset_to_transform_parent( |
| 1192 layer->offset_to_transform_parent()); | 1223 layer->offset_to_transform_parent()); |
| 1193 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); | 1224 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); |
| 1194 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); | 1225 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); |
| 1195 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); | 1226 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); |
| 1196 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); | 1227 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); |
| 1197 } | 1228 } |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1411 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1381 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1412 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1382 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1413 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1383 device_transform, property_trees, color); | 1414 device_transform, property_trees, color); |
| 1384 property_trees->effect_tree.CreateOrReuseRenderSurfaces( | 1415 property_trees->effect_tree.CreateOrReuseRenderSurfaces( |
| 1385 &render_surfaces, root_layer->layer_tree_impl()); | 1416 &render_surfaces, root_layer->layer_tree_impl()); |
| 1386 property_trees->ResetCachedData(); | 1417 property_trees->ResetCachedData(); |
| 1387 } | 1418 } |
| 1388 | 1419 |
| 1389 } // namespace cc | 1420 } // namespace cc |
| OLD | NEW |