Chromium Code Reviews| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 } | 1123 } |
| 1128 | 1124 |
| 1129 static void SetLayerPropertyChangedForChild(Layer* parent, Layer* child) { | 1125 static void SetLayerPropertyChangedForChild(Layer* parent, Layer* child) { |
| 1130 if (parent->subtree_property_changed()) | 1126 if (parent->subtree_property_changed()) |
| 1131 child->SetSubtreePropertyChanged(); | 1127 child->SetSubtreePropertyChanged(); |
| 1132 } | 1128 } |
| 1133 | 1129 |
| 1134 static void SetLayerPropertyChangedForChild(LayerImpl* parent, | 1130 static void SetLayerPropertyChangedForChild(LayerImpl* parent, |
| 1135 LayerImpl* child) {} | 1131 LayerImpl* child) {} |
| 1136 | 1132 |
| 1133 static bool SubtreeIsHidden(Layer* layer) { | |
| 1134 return !SubtreeHasCopyRequest(layer) && layer->parent() && | |
| 1135 layer->hide_layer_and_subtree(); | |
| 1136 } | |
| 1137 | |
| 1138 static bool SubtreeIsHidden(LayerImpl* layer) { | |
| 1139 return false; | |
| 1140 } | |
| 1141 | |
| 1142 static void SetIsHidden(Layer* layer, bool is_hidden) { | |
| 1143 layer->SetIsHidden(is_hidden); | |
| 1144 } | |
| 1145 | |
| 1146 static void SetIsHidden(LayerImpl* layer, bool is_hidden) {} | |
| 1147 | |
| 1148 static bool IsSurfaceLayer(Layer* layer) { | |
| 1149 return layer->IsSurfaceLayer(); | |
| 1150 } | |
| 1151 | |
| 1152 static bool IsSurfaceLayer(LayerImpl* layer) { | |
| 1153 return false; | |
| 1154 } | |
| 1155 | |
| 1156 static void AddHiddenSurfaceLayerId(Layer* layer) { | |
| 1157 layer->layer_tree_host()->AddHiddenSurfaceLayerId(layer); | |
| 1158 } | |
| 1159 | |
| 1160 static void AddHiddenSurfaceLayerId(LayerImpl* layer) {} | |
| 1161 | |
| 1162 template <typename LayerType> | |
| 1163 void AddPropertyTreeNodesIfNeeded( | |
| 1164 LayerType* layer, | |
| 1165 const DataForRecursion<LayerType>& data_from_parent, | |
| 1166 DataForRecursion<LayerType>* data_for_children) { | |
| 1167 DCHECK(!data_for_children->is_hidden); | |
| 1168 layer->set_property_tree_sequence_number( | |
| 1169 data_from_parent.property_trees->sequence_number); | |
| 1170 bool created_render_surface = | |
| 1171 AddEffectNodeIfNeeded(data_from_parent, layer, data_for_children); | |
| 1172 | |
| 1173 if (created_render_surface) | |
| 1174 data_for_children->render_target = data_for_children->effect_tree_parent; | |
| 1175 | |
| 1176 bool created_transform_node = AddTransformNodeIfNeeded( | |
| 1177 data_from_parent, layer, created_render_surface, data_for_children); | |
| 1178 AddClipNodeIfNeeded(data_from_parent, layer, created_transform_node, | |
| 1179 data_for_children); | |
| 1180 | |
| 1181 AddScrollNodeIfNeeded(data_from_parent, layer, data_for_children); | |
| 1182 | |
| 1183 SetBackfaceVisibilityTransform(layer, created_transform_node); | |
| 1184 SetSafeOpaqueBackgroundColor(data_from_parent, layer, data_for_children); | |
| 1185 } | |
| 1186 | |
| 1137 template <typename LayerType> | 1187 template <typename LayerType> |
| 1138 void BuildPropertyTreesInternal( | 1188 void BuildPropertyTreesInternal( |
| 1139 LayerType* layer, | 1189 LayerType* layer, |
| 1140 const DataForRecursion<LayerType>& data_from_parent) { | 1190 const DataForRecursion<LayerType>& data_from_parent) { |
| 1141 layer->set_property_tree_sequence_number( | |
| 1142 data_from_parent.property_trees->sequence_number); | |
| 1143 | |
| 1144 DataForRecursion<LayerType> data_for_children(data_from_parent); | 1191 DataForRecursion<LayerType> data_for_children(data_from_parent); |
| 1145 | 1192 |
| 1146 bool created_render_surface = | 1193 data_for_children.is_hidden = |
| 1147 AddEffectNodeIfNeeded(data_from_parent, layer, &data_for_children); | 1194 data_from_parent.is_hidden || SubtreeIsHidden(layer); |
| 1148 | 1195 |
| 1149 if (created_render_surface) | 1196 SetIsHidden(layer, data_for_children.is_hidden); |
| 1150 data_for_children.render_target = data_for_children.effect_tree_parent; | |
| 1151 | 1197 |
| 1152 bool created_transform_node = AddTransformNodeIfNeeded( | 1198 // We do not create property tree nodes for hidden layers. |
| 1153 data_from_parent, layer, created_render_surface, &data_for_children); | 1199 if (!data_for_children.is_hidden) { |
| 1154 AddClipNodeIfNeeded(data_from_parent, layer, created_transform_node, | 1200 AddPropertyTreeNodesIfNeeded(layer, data_from_parent, &data_for_children); |
| 1155 &data_for_children); | 1201 } else if (IsSurfaceLayer(layer)) { |
| 1156 | 1202 AddHiddenSurfaceLayerId(layer); |
| 1157 AddScrollNodeIfNeeded(data_from_parent, layer, &data_for_children); | 1203 } |
| 1158 | |
| 1159 SetBackfaceVisibilityTransform(layer, created_transform_node); | |
| 1160 SetSafeOpaqueBackgroundColor(data_from_parent, layer, &data_for_children); | |
| 1161 | 1204 |
| 1162 for (size_t i = 0; i < Children(layer).size(); ++i) { | 1205 for (size_t i = 0; i < Children(layer).size(); ++i) { |
| 1163 LayerType* current_child = ChildAt(layer, i); | 1206 LayerType* current_child = ChildAt(layer, i); |
| 1164 SetLayerPropertyChangedForChild(layer, current_child); | 1207 SetLayerPropertyChangedForChild(layer, current_child); |
| 1165 if (!ScrollParent(current_child)) { | 1208 if (!ScrollParent(current_child)) { |
| 1166 BuildPropertyTreesInternal(current_child, data_for_children); | 1209 BuildPropertyTreesInternal(current_child, data_for_children); |
| 1167 } else { | 1210 } else { |
| 1168 // The child should be included in its scroll parent's list of scroll | 1211 // The child should be included in its scroll parent's list of scroll |
| 1169 // children. | 1212 // children. |
| 1170 DCHECK(ScrollChildren(ScrollParent(current_child))->count(current_child)); | 1213 DCHECK(ScrollChildren(ScrollParent(current_child))->count(current_child)); |
| 1171 } | 1214 } |
| 1172 } | 1215 } |
| 1173 | 1216 |
| 1174 if (ScrollChildren(layer)) { | 1217 if (ScrollChildren(layer)) { |
| 1175 for (LayerType* scroll_child : *ScrollChildren(layer)) { | 1218 for (LayerType* scroll_child : *ScrollChildren(layer)) { |
| 1176 DCHECK_EQ(ScrollParent(scroll_child), layer); | 1219 DCHECK_EQ(ScrollParent(scroll_child), layer); |
| 1177 DCHECK(Parent(scroll_child)); | 1220 DCHECK(Parent(scroll_child)); |
| 1178 data_for_children.effect_tree_parent = | 1221 data_for_children.effect_tree_parent = |
| 1179 Parent(scroll_child)->effect_tree_index(); | 1222 Parent(scroll_child)->effect_tree_index(); |
| 1180 data_for_children.render_target = | 1223 data_for_children.render_target = |
| 1181 Parent(scroll_child)->effect_tree_index(); | 1224 Parent(scroll_child)->effect_tree_index(); |
| 1182 BuildPropertyTreesInternal(scroll_child, data_for_children); | 1225 BuildPropertyTreesInternal(scroll_child, data_for_children); |
| 1183 } | 1226 } |
| 1184 } | 1227 } |
| 1185 | 1228 |
| 1186 if (MaskLayer(layer)) { | 1229 if (!data_for_children.is_hidden && MaskLayer(layer)) { |
|
enne (OOO)
2017/05/19 22:27:05
Maybe this should early out after the loop through
jaydasika
2017/05/23 00:25:14
Done.
| |
| 1187 MaskLayer(layer)->set_property_tree_sequence_number( | 1230 MaskLayer(layer)->set_property_tree_sequence_number( |
| 1188 data_from_parent.property_trees->sequence_number); | 1231 data_from_parent.property_trees->sequence_number); |
| 1189 MaskLayer(layer)->set_offset_to_transform_parent( | 1232 MaskLayer(layer)->set_offset_to_transform_parent( |
| 1190 layer->offset_to_transform_parent()); | 1233 layer->offset_to_transform_parent()); |
| 1191 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); | 1234 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); |
| 1192 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); | 1235 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); |
| 1193 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); | 1236 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); |
| 1194 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); | 1237 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); |
| 1195 } | 1238 } |
| 1196 } | 1239 } |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1378 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1421 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1379 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1422 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1380 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1423 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1381 device_transform, property_trees, color); | 1424 device_transform, property_trees, color); |
| 1382 property_trees->effect_tree.CreateOrReuseRenderSurfaces( | 1425 property_trees->effect_tree.CreateOrReuseRenderSurfaces( |
| 1383 &render_surfaces, root_layer->layer_tree_impl()); | 1426 &render_surfaces, root_layer->layer_tree_impl()); |
| 1384 property_trees->ResetCachedData(); | 1427 property_trees->ResetCachedData(); |
| 1385 } | 1428 } |
| 1386 | 1429 |
| 1387 } // namespace cc | 1430 } // namespace cc |
| OLD | NEW |