| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 } | 206 } |
| 207 | 207 |
| 208 static size_t NumUnclippedDescendants(Layer* layer) { | 208 static size_t NumUnclippedDescendants(Layer* layer) { |
| 209 return layer->num_unclipped_descendants(); | 209 return layer->num_unclipped_descendants(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 static size_t NumUnclippedDescendants(LayerImpl* layer) { | 212 static size_t NumUnclippedDescendants(LayerImpl* layer) { |
| 213 return layer->test_properties()->num_unclipped_descendants; | 213 return layer->test_properties()->num_unclipped_descendants; |
| 214 } | 214 } |
| 215 | 215 |
| 216 static Layer* MaskLayer(Layer* layer) { |
| 217 return layer->mask_layer(); |
| 218 } |
| 219 |
| 220 static LayerImpl* MaskLayer(LayerImpl* layer) { |
| 221 return layer->test_properties()->mask_layer; |
| 222 } |
| 223 |
| 224 static Layer* ReplicaLayer(Layer* layer) { |
| 225 return layer->replica_layer(); |
| 226 } |
| 227 |
| 228 static LayerImpl* ReplicaLayer(LayerImpl* layer) { |
| 229 return layer->test_properties()->replica_layer; |
| 230 } |
| 231 |
| 216 template <typename LayerType> | 232 template <typename LayerType> |
| 217 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, | 233 static LayerType* GetTransformParent(const DataForRecursion<LayerType>& data, |
| 218 LayerType* layer) { | 234 LayerType* layer) { |
| 219 return PositionConstraint(layer).is_fixed_position() | 235 return PositionConstraint(layer).is_fixed_position() |
| 220 ? data.transform_fixed_parent | 236 ? data.transform_fixed_parent |
| 221 : data.transform_tree_parent; | 237 : data.transform_tree_parent; |
| 222 } | 238 } |
| 223 | 239 |
| 224 template <typename LayerType> | 240 template <typename LayerType> |
| 225 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, | 241 static ClipNode* GetClipParent(const DataForRecursion<LayerType>& data, |
| 226 LayerType* layer) { | 242 LayerType* layer) { |
| 227 const bool inherits_clip = !ClipParent(layer); | 243 const bool inherits_clip = !ClipParent(layer); |
| 228 const int id = inherits_clip ? data.clip_tree_parent | 244 const int id = inherits_clip ? data.clip_tree_parent |
| 229 : ClipParent(layer)->clip_tree_index(); | 245 : ClipParent(layer)->clip_tree_index(); |
| 230 return data.property_trees->clip_tree.Node(id); | 246 return data.property_trees->clip_tree.Node(id); |
| 231 } | 247 } |
| 232 | 248 |
| 233 template <typename LayerType> | 249 template <typename LayerType> |
| 234 static bool LayerClipsSubtree(LayerType* layer) { | 250 static bool LayerClipsSubtree(LayerType* layer) { |
| 235 return layer->masks_to_bounds() || layer->mask_layer(); | 251 return layer->masks_to_bounds() || MaskLayer(layer); |
| 236 } | 252 } |
| 237 | 253 |
| 238 template <typename LayerType> | 254 template <typename LayerType> |
| 239 static int GetScrollParentId(const DataForRecursion<LayerType>& data, | 255 static int GetScrollParentId(const DataForRecursion<LayerType>& data, |
| 240 LayerType* layer) { | 256 LayerType* layer) { |
| 241 const bool inherits_scroll = !ScrollParent(layer); | 257 const bool inherits_scroll = !ScrollParent(layer); |
| 242 const int id = inherits_scroll ? data.scroll_tree_parent | 258 const int id = inherits_scroll ? data.scroll_tree_parent |
| 243 : ScrollParent(layer)->scroll_tree_index(); | 259 : ScrollParent(layer)->scroll_tree_index(); |
| 244 return id; | 260 return id; |
| 245 } | 261 } |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 bool axis_aligned) { | 739 bool axis_aligned) { |
| 724 const bool preserves_2d_axis_alignment = | 740 const bool preserves_2d_axis_alignment = |
| 725 (current_transform * layer->transform()).Preserves2dAxisAlignment() && | 741 (current_transform * layer->transform()).Preserves2dAxisAlignment() && |
| 726 axis_aligned && layer->AnimationsPreserveAxisAlignment(); | 742 axis_aligned && layer->AnimationsPreserveAxisAlignment(); |
| 727 const bool is_root = !layer->parent(); | 743 const bool is_root = !layer->parent(); |
| 728 if (is_root) | 744 if (is_root) |
| 729 return true; | 745 return true; |
| 730 | 746 |
| 731 // If the layer uses a mask and the layer is not a replica layer. | 747 // If the layer uses a mask and the layer is not a replica layer. |
| 732 // TODO(weiliangc): After slimming paint there won't be replica layers. | 748 // TODO(weiliangc): After slimming paint there won't be replica layers. |
| 733 if (layer->mask_layer() && layer->parent()->replica_layer() != layer) { | 749 if (MaskLayer(layer) && ReplicaLayer(layer->parent()) != layer) { |
| 734 return true; | 750 return true; |
| 735 } | 751 } |
| 736 | 752 |
| 737 // If the layer has a reflection. | 753 // If the layer has a reflection. |
| 738 if (layer->replica_layer()) { | 754 if (ReplicaLayer(layer)) { |
| 739 return true; | 755 return true; |
| 740 } | 756 } |
| 741 | 757 |
| 742 // If the layer uses a CSS filter. | 758 // If the layer uses a CSS filter. |
| 743 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { | 759 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { |
| 744 return true; | 760 return true; |
| 745 } | 761 } |
| 746 | 762 |
| 747 // If the layer will use a CSS filter. In this case, the animation | 763 // If the layer will use a CSS filter. In this case, the animation |
| 748 // will start and add a filter to this layer, so it needs a surface. | 764 // will start and add a filter to this layer, so it needs a surface. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 | 891 |
| 876 node.data.opacity = Opacity(layer); | 892 node.data.opacity = Opacity(layer); |
| 877 node.data.has_render_surface = should_create_render_surface; | 893 node.data.has_render_surface = should_create_render_surface; |
| 878 node.data.has_copy_request = HasCopyRequest(layer); | 894 node.data.has_copy_request = HasCopyRequest(layer); |
| 879 node.data.has_background_filters = !layer->background_filters().IsEmpty(); | 895 node.data.has_background_filters = !layer->background_filters().IsEmpty(); |
| 880 node.data.has_potential_opacity_animation = has_potential_opacity_animation; | 896 node.data.has_potential_opacity_animation = has_potential_opacity_animation; |
| 881 node.data.double_sided = DoubleSided(layer); | 897 node.data.double_sided = DoubleSided(layer); |
| 882 node.data.subtree_hidden = HideLayerAndSubtree(layer); | 898 node.data.subtree_hidden = HideLayerAndSubtree(layer); |
| 883 node.data.is_currently_animating_opacity = layer->OpacityIsAnimating(); | 899 node.data.is_currently_animating_opacity = layer->OpacityIsAnimating(); |
| 884 | 900 |
| 901 EffectTree& effect_tree = data_for_children->property_trees->effect_tree; |
| 902 if (MaskLayer(layer)) { |
| 903 node.data.mask_layer_id = MaskLayer(layer)->id(); |
| 904 effect_tree.AddMaskOrReplicaLayerId(node.data.mask_layer_id); |
| 905 } |
| 906 if (ReplicaLayer(layer)) { |
| 907 node.data.replica_layer_id = ReplicaLayer(layer)->id(); |
| 908 effect_tree.AddMaskOrReplicaLayerId(node.data.replica_layer_id); |
| 909 if (MaskLayer(ReplicaLayer(layer))) { |
| 910 node.data.replica_mask_layer_id = MaskLayer(ReplicaLayer(layer))->id(); |
| 911 effect_tree.AddMaskOrReplicaLayerId(node.data.replica_mask_layer_id); |
| 912 } |
| 913 } |
| 914 |
| 885 if (!is_root) { | 915 if (!is_root) { |
| 886 // The effect node's transform id is used only when we create a render | 916 // The effect node's transform id is used only when we create a render |
| 887 // surface. So, we can leave the default value when we don't create a render | 917 // surface. So, we can leave the default value when we don't create a render |
| 888 // surface. | 918 // surface. |
| 889 if (should_create_render_surface) { | 919 if (should_create_render_surface) { |
| 890 // In this case, we will create a transform node, so it's safe to use the | 920 // In this case, we will create a transform node, so it's safe to use the |
| 891 // next available id from the transform tree as this effect node's | 921 // next available id from the transform tree as this effect node's |
| 892 // transform id. | 922 // transform id. |
| 893 node.data.transform_id = | 923 node.data.transform_id = |
| 894 data_from_ancestor.property_trees->transform_tree.next_available_id(); | 924 data_from_ancestor.property_trees->transform_tree.next_available_id(); |
| 895 node.data.has_unclipped_descendants = | 925 node.data.has_unclipped_descendants = |
| 896 (NumUnclippedDescendants(layer) != 0); | 926 (NumUnclippedDescendants(layer) != 0); |
| 897 } | 927 } |
| 898 node.data.clip_id = data_from_ancestor.clip_tree_parent; | 928 node.data.clip_id = data_from_ancestor.clip_tree_parent; |
| 899 } else { | 929 } else { |
| 900 // Root render surface acts the unbounded and untransformed to draw content | 930 // Root render surface acts the unbounded and untransformed to draw content |
| 901 // into. Transform node created from root layer (includes device scale | 931 // into. Transform node created from root layer (includes device scale |
| 902 // factor) and clip node created from root layer (include viewports) applies | 932 // factor) and clip node created from root layer (include viewports) applies |
| 903 // to root render surface's content, but not root render surface itself. | 933 // to root render surface's content, but not root render surface itself. |
| 904 node.data.transform_id = kRootPropertyTreeNodeId; | 934 node.data.transform_id = kRootPropertyTreeNodeId; |
| 905 node.data.clip_id = kViewportClipTreeNodeId; | 935 node.data.clip_id = kViewportClipTreeNodeId; |
| 906 } | 936 } |
| 907 data_for_children->effect_tree_parent = | 937 data_for_children->effect_tree_parent = effect_tree.Insert(node, parent_id); |
| 908 data_for_children->property_trees->effect_tree.Insert(node, parent_id); | |
| 909 int node_id = data_for_children->effect_tree_parent; | 938 int node_id = data_for_children->effect_tree_parent; |
| 910 layer->SetEffectTreeIndex(node_id); | 939 layer->SetEffectTreeIndex(node_id); |
| 911 data_for_children->property_trees->effect_id_to_index_map[layer->id()] = | 940 data_for_children->property_trees->effect_id_to_index_map[layer->id()] = |
| 912 data_for_children->effect_tree_parent; | 941 data_for_children->effect_tree_parent; |
| 913 | 942 |
| 914 std::vector<std::unique_ptr<CopyOutputRequest>> layer_copy_requests; | 943 std::vector<std::unique_ptr<CopyOutputRequest>> layer_copy_requests; |
| 915 TakeCopyRequests(layer, &layer_copy_requests); | 944 TakeCopyRequests(layer, &layer_copy_requests); |
| 916 for (auto& it : layer_copy_requests) { | 945 for (auto& it : layer_copy_requests) { |
| 917 data_for_children->property_trees->effect_tree.AddCopyRequest( | 946 effect_tree.AddCopyRequest(node_id, std::move(it)); |
| 918 node_id, std::move(it)); | |
| 919 } | 947 } |
| 920 layer_copy_requests.clear(); | 948 layer_copy_requests.clear(); |
| 921 | 949 |
| 922 if (should_create_render_surface) { | 950 if (should_create_render_surface) { |
| 923 data_for_children->compound_transform_since_render_target = | 951 data_for_children->compound_transform_since_render_target = |
| 924 gfx::Transform(); | 952 gfx::Transform(); |
| 925 data_for_children->axis_align_since_render_target = true; | 953 data_for_children->axis_align_since_render_target = true; |
| 926 } | 954 } |
| 927 return should_create_render_surface; | 955 return should_create_render_surface; |
| 928 } | 956 } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 data_for_children.effect_tree_parent = | 1149 data_for_children.effect_tree_parent = |
| 1122 scroll_child->parent()->effect_tree_index(); | 1150 scroll_child->parent()->effect_tree_index(); |
| 1123 data_for_children.render_target = | 1151 data_for_children.render_target = |
| 1124 scroll_child->parent()->effect_tree_index(); | 1152 scroll_child->parent()->effect_tree_index(); |
| 1125 BuildPropertyTreesInternal(scroll_child, data_for_children, | 1153 BuildPropertyTreesInternal(scroll_child, data_for_children, |
| 1126 &data_from_child); | 1154 &data_from_child); |
| 1127 data_to_parent->Merge(data_from_child); | 1155 data_to_parent->Merge(data_from_child); |
| 1128 } | 1156 } |
| 1129 } | 1157 } |
| 1130 | 1158 |
| 1131 if (layer->has_replica()) { | 1159 if (ReplicaLayer(layer)) { |
| 1132 DataForRecursionFromChild<LayerType> data_from_child; | 1160 DataForRecursionFromChild<LayerType> data_from_child; |
| 1133 BuildPropertyTreesInternal(layer->replica_layer(), data_for_children, | 1161 BuildPropertyTreesInternal(ReplicaLayer(layer), data_for_children, |
| 1134 &data_from_child); | 1162 &data_from_child); |
| 1135 data_to_parent->Merge(data_from_child); | 1163 data_to_parent->Merge(data_from_child); |
| 1136 } | 1164 } |
| 1137 | 1165 |
| 1138 if (layer->mask_layer()) { | 1166 if (MaskLayer(layer)) { |
| 1139 layer->mask_layer()->set_property_tree_sequence_number( | 1167 MaskLayer(layer)->set_property_tree_sequence_number( |
| 1140 data_from_parent.property_trees->sequence_number); | 1168 data_from_parent.property_trees->sequence_number); |
| 1141 layer->mask_layer()->set_offset_to_transform_parent( | 1169 MaskLayer(layer)->set_offset_to_transform_parent( |
| 1142 layer->offset_to_transform_parent()); | 1170 layer->offset_to_transform_parent()); |
| 1143 layer->mask_layer()->SetTransformTreeIndex(layer->transform_tree_index()); | 1171 MaskLayer(layer)->SetTransformTreeIndex(layer->transform_tree_index()); |
| 1144 layer->mask_layer()->SetClipTreeIndex(layer->clip_tree_index()); | 1172 MaskLayer(layer)->SetClipTreeIndex(layer->clip_tree_index()); |
| 1145 layer->mask_layer()->SetEffectTreeIndex(layer->effect_tree_index()); | 1173 MaskLayer(layer)->SetEffectTreeIndex(layer->effect_tree_index()); |
| 1146 layer->mask_layer()->SetScrollTreeIndex(layer->scroll_tree_index()); | 1174 MaskLayer(layer)->SetScrollTreeIndex(layer->scroll_tree_index()); |
| 1147 } | 1175 } |
| 1148 | 1176 |
| 1149 EffectNode* effect_node = data_for_children.property_trees->effect_tree.Node( | 1177 EffectNode* effect_node = data_for_children.property_trees->effect_tree.Node( |
| 1150 data_for_children.effect_tree_parent); | 1178 data_for_children.effect_tree_parent); |
| 1151 | 1179 |
| 1152 if (effect_node->owner_id == layer->id()) { | 1180 if (effect_node->owner_id == layer->id()) { |
| 1153 if (effect_node->data.has_copy_request) | 1181 if (effect_node->data.has_copy_request) |
| 1154 data_to_parent->num_copy_requests_in_subtree++; | 1182 data_to_parent->num_copy_requests_in_subtree++; |
| 1155 effect_node->data.num_copy_requests_in_subtree = | 1183 effect_node->data.num_copy_requests_in_subtree = |
| 1156 data_to_parent->num_copy_requests_in_subtree; | 1184 data_to_parent->num_copy_requests_in_subtree; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 if (SkColorGetA(color) != 255) | 1374 if (SkColorGetA(color) != 255) |
| 1347 color = SkColorSetA(color, 255); | 1375 color = SkColorSetA(color, 255); |
| 1348 BuildPropertyTreesTopLevelInternal( | 1376 BuildPropertyTreesTopLevelInternal( |
| 1349 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1377 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1350 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1378 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1351 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1379 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1352 device_transform, property_trees, color); | 1380 device_transform, property_trees, color); |
| 1353 } | 1381 } |
| 1354 | 1382 |
| 1355 } // namespace cc | 1383 } // namespace cc |
| OLD | NEW |