| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if (IsRootLayer(layer)) | 133 if (IsRootLayer(layer)) |
| 134 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); | 134 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); |
| 135 } | 135 } |
| 136 | 136 |
| 137 static void PreCalculateMetaInformationInternalForTesting( | 137 static void PreCalculateMetaInformationInternalForTesting( |
| 138 LayerImpl* layer, | 138 LayerImpl* layer, |
| 139 PreCalculateMetaInformationRecursiveData* recursive_data) { | 139 PreCalculateMetaInformationRecursiveData* recursive_data) { |
| 140 if (layer->test_properties()->clip_parent) | 140 if (layer->test_properties()->clip_parent) |
| 141 recursive_data->num_unclipped_descendants++; | 141 recursive_data->num_unclipped_descendants++; |
| 142 | 142 |
| 143 for (size_t i = 0; i < layer->children().size(); ++i) { | 143 for (size_t i = 0; i < layer->test_properties()->children.size(); ++i) { |
| 144 LayerImpl* child_layer = layer->child_at(i); | 144 LayerImpl* child_layer = layer->test_properties()->children[i]; |
| 145 | 145 |
| 146 PreCalculateMetaInformationRecursiveData data_for_child; | 146 PreCalculateMetaInformationRecursiveData data_for_child; |
| 147 PreCalculateMetaInformationInternalForTesting(child_layer, &data_for_child); | 147 PreCalculateMetaInformationInternalForTesting(child_layer, &data_for_child); |
| 148 recursive_data->Merge(data_for_child); | 148 recursive_data->Merge(data_for_child); |
| 149 } | 149 } |
| 150 | 150 |
| 151 if (layer->test_properties()->clip_children) { | 151 if (layer->test_properties()->clip_children) { |
| 152 size_t num_clip_children = layer->test_properties()->clip_children->size(); | 152 size_t num_clip_children = layer->test_properties()->clip_children->size(); |
| 153 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 153 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
| 154 recursive_data->num_unclipped_descendants -= num_clip_children; | 154 recursive_data->num_unclipped_descendants -= num_clip_children; |
| 155 } | 155 } |
| 156 | 156 |
| 157 layer->test_properties()->num_unclipped_descendants = | 157 layer->test_properties()->num_unclipped_descendants = |
| 158 recursive_data->num_unclipped_descendants; | 158 recursive_data->num_unclipped_descendants; |
| 159 // TODO(enne): this should be synced from the main thread, so is only | 159 // TODO(enne): this should be synced from the main thread, so is only |
| 160 // for tests constructing layers on the compositor thread. | 160 // for tests constructing layers on the compositor thread. |
| 161 layer->test_properties()->num_descendants_that_draw_content = | 161 layer->test_properties()->num_descendants_that_draw_content = |
| 162 recursive_data->num_descendants_that_draw_content; | 162 recursive_data->num_descendants_that_draw_content; |
| 163 | 163 |
| 164 if (layer->DrawsContent()) | 164 if (layer->DrawsContent()) |
| 165 recursive_data->num_descendants_that_draw_content++; | 165 recursive_data->num_descendants_that_draw_content++; |
| 166 } | 166 } |
| 167 | 167 |
| 168 static LayerImplList& Children(LayerImpl* layer) { |
| 169 return layer->test_properties()->children; |
| 170 } |
| 171 |
| 172 static const LayerList& Children(Layer* layer) { |
| 173 return layer->children(); |
| 174 } |
| 175 |
| 176 static LayerImpl* ChildAt(LayerImpl* layer, int index) { |
| 177 return layer->test_properties()->children[index]; |
| 178 } |
| 179 |
| 180 static Layer* ChildAt(Layer* layer, int index) { |
| 181 return layer->child_at(index); |
| 182 } |
| 183 |
| 168 static Layer* ScrollParent(Layer* layer) { | 184 static Layer* ScrollParent(Layer* layer) { |
| 169 return layer->scroll_parent(); | 185 return layer->scroll_parent(); |
| 170 } | 186 } |
| 171 | 187 |
| 172 static LayerImpl* ScrollParent(LayerImpl* layer) { | 188 static LayerImpl* ScrollParent(LayerImpl* layer) { |
| 173 return layer->test_properties()->scroll_parent; | 189 return layer->test_properties()->scroll_parent; |
| 174 } | 190 } |
| 175 | 191 |
| 176 static std::set<Layer*>* ScrollChildren(Layer* layer) { | 192 static std::set<Layer*>* ScrollChildren(Layer* layer) { |
| 177 return layer->scroll_children(); | 193 return layer->scroll_children(); |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1071 bool created_transform_node = AddTransformNodeIfNeeded( | 1087 bool created_transform_node = AddTransformNodeIfNeeded( |
| 1072 data_from_parent, layer, created_render_surface, &data_for_children); | 1088 data_from_parent, layer, created_render_surface, &data_for_children); |
| 1073 AddClipNodeIfNeeded(data_from_parent, layer, created_render_surface, | 1089 AddClipNodeIfNeeded(data_from_parent, layer, created_render_surface, |
| 1074 created_transform_node, &data_for_children); | 1090 created_transform_node, &data_for_children); |
| 1075 | 1091 |
| 1076 AddScrollNodeIfNeeded(data_from_parent, layer, &data_for_children); | 1092 AddScrollNodeIfNeeded(data_from_parent, layer, &data_for_children); |
| 1077 | 1093 |
| 1078 SetBackfaceVisibilityTransform(layer, created_transform_node); | 1094 SetBackfaceVisibilityTransform(layer, created_transform_node); |
| 1079 SetSafeOpaqueBackgroundColor(data_from_parent, layer, &data_for_children); | 1095 SetSafeOpaqueBackgroundColor(data_from_parent, layer, &data_for_children); |
| 1080 | 1096 |
| 1081 for (size_t i = 0; i < layer->children().size(); ++i) { | 1097 for (size_t i = 0; i < Children(layer).size(); ++i) { |
| 1082 SetLayerPropertyChangedForChild(layer, layer->child_at(i)); | 1098 LayerType* current_child = ChildAt(layer, i); |
| 1083 if (!ScrollParent(layer->child_at(i))) { | 1099 SetLayerPropertyChangedForChild(layer, current_child); |
| 1100 if (!ScrollParent(current_child)) { |
| 1084 DataForRecursionFromChild<LayerType> data_from_child; | 1101 DataForRecursionFromChild<LayerType> data_from_child; |
| 1085 BuildPropertyTreesInternal(layer->child_at(i), data_for_children, | 1102 BuildPropertyTreesInternal(current_child, data_for_children, |
| 1086 &data_from_child); | 1103 &data_from_child); |
| 1087 data_to_parent->Merge(data_from_child); | 1104 data_to_parent->Merge(data_from_child); |
| 1088 } else { | 1105 } else { |
| 1089 // The child should be included in its scroll parent's list of scroll | 1106 // The child should be included in its scroll parent's list of scroll |
| 1090 // children. | 1107 // children. |
| 1091 DCHECK(ScrollChildren(ScrollParent(layer->child_at(i))) | 1108 DCHECK(ScrollChildren(ScrollParent(current_child))->count(current_child)); |
| 1092 ->count(layer->child_at(i))); | |
| 1093 } | 1109 } |
| 1094 } | 1110 } |
| 1095 | 1111 |
| 1096 if (ScrollChildren(layer)) { | 1112 if (ScrollChildren(layer)) { |
| 1097 for (LayerType* scroll_child : *ScrollChildren(layer)) { | 1113 for (LayerType* scroll_child : *ScrollChildren(layer)) { |
| 1098 DCHECK_EQ(ScrollParent(scroll_child), layer); | 1114 DCHECK_EQ(ScrollParent(scroll_child), layer); |
| 1099 DataForRecursionFromChild<LayerType> data_from_child; | 1115 DataForRecursionFromChild<LayerType> data_from_child; |
| 1100 DCHECK(scroll_child->parent()); | 1116 DCHECK(scroll_child->parent()); |
| 1101 data_for_children.effect_tree_parent = | 1117 data_for_children.effect_tree_parent = |
| 1102 scroll_child->parent()->effect_tree_index(); | 1118 scroll_child->parent()->effect_tree_index(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 if (SkColorGetA(color) != 255) | 1342 if (SkColorGetA(color) != 255) |
| 1327 color = SkColorSetA(color, 255); | 1343 color = SkColorSetA(color, 255); |
| 1328 BuildPropertyTreesTopLevelInternal( | 1344 BuildPropertyTreesTopLevelInternal( |
| 1329 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1345 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 1330 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1346 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 1331 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1347 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
| 1332 device_transform, property_trees, color); | 1348 device_transform, property_trees, color); |
| 1333 } | 1349 } |
| 1334 | 1350 |
| 1335 } // namespace cc | 1351 } // namespace cc |
| OLD | NEW |