| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 layer_maximum_animated_scale * | 1121 layer_maximum_animated_scale * |
| 1122 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); | 1122 std::max(ancestor_transform_scales.x(), ancestor_transform_scales.y()); |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 template <typename LayerTypePtr> | 1125 template <typename LayerTypePtr> |
| 1126 static inline void MarkLayerWithRenderSurfaceLayerListId( | 1126 static inline void MarkLayerWithRenderSurfaceLayerListId( |
| 1127 LayerTypePtr layer, | 1127 LayerTypePtr layer, |
| 1128 int current_render_surface_layer_list_id) { | 1128 int current_render_surface_layer_list_id) { |
| 1129 layer->draw_properties().last_drawn_render_surface_layer_list_id = | 1129 layer->draw_properties().last_drawn_render_surface_layer_list_id = |
| 1130 current_render_surface_layer_list_id; | 1130 current_render_surface_layer_list_id; |
| 1131 layer->draw_properties().layer_or_descendant_is_drawn = |
| 1132 !!current_render_surface_layer_list_id; |
| 1131 } | 1133 } |
| 1132 | 1134 |
| 1133 template <typename LayerTypePtr> | 1135 template <typename LayerTypePtr> |
| 1134 static inline void MarkMasksWithRenderSurfaceLayerListId( | 1136 static inline void MarkMasksWithRenderSurfaceLayerListId( |
| 1135 LayerTypePtr layer, | 1137 LayerTypePtr layer, |
| 1136 int current_render_surface_layer_list_id) { | 1138 int current_render_surface_layer_list_id) { |
| 1137 if (layer->mask_layer()) { | 1139 if (layer->mask_layer()) { |
| 1138 MarkLayerWithRenderSurfaceLayerListId(layer->mask_layer(), | 1140 MarkLayerWithRenderSurfaceLayerListId(layer->mask_layer(), |
| 1139 current_render_surface_layer_list_id); | 1141 current_render_surface_layer_list_id); |
| 1140 } | 1142 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 PreCalculateMetaInformationRecursiveData() | 1195 PreCalculateMetaInformationRecursiveData() |
| 1194 : layer_or_descendant_has_copy_request(false), | 1196 : layer_or_descendant_has_copy_request(false), |
| 1195 layer_or_descendant_has_input_handler(false), | 1197 layer_or_descendant_has_input_handler(false), |
| 1196 num_unclipped_descendants(0) {} | 1198 num_unclipped_descendants(0) {} |
| 1197 | 1199 |
| 1198 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1200 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
| 1199 layer_or_descendant_has_copy_request |= | 1201 layer_or_descendant_has_copy_request |= |
| 1200 data.layer_or_descendant_has_copy_request; | 1202 data.layer_or_descendant_has_copy_request; |
| 1201 layer_or_descendant_has_input_handler |= | 1203 layer_or_descendant_has_input_handler |= |
| 1202 data.layer_or_descendant_has_input_handler; | 1204 data.layer_or_descendant_has_input_handler; |
| 1203 num_unclipped_descendants += | 1205 num_unclipped_descendants += data.num_unclipped_descendants; |
| 1204 data.num_unclipped_descendants; | |
| 1205 } | 1206 } |
| 1206 }; | 1207 }; |
| 1207 | 1208 |
| 1208 static void ValidateRenderSurface(LayerImpl* layer) { | 1209 static void ValidateRenderSurface(LayerImpl* layer) { |
| 1209 // This test verifies that there are no cases where a LayerImpl needs | 1210 // This test verifies that there are no cases where a LayerImpl needs |
| 1210 // a render surface, but doesn't have one. | 1211 // a render surface, but doesn't have one. |
| 1211 if (layer->render_surface()) | 1212 if (layer->render_surface()) |
| 1212 return; | 1213 return; |
| 1213 | 1214 |
| 1214 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id(); | 1215 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1226 // Recursively walks the layer tree to compute any information that is needed | 1227 // Recursively walks the layer tree to compute any information that is needed |
| 1227 // before doing the main recursion. | 1228 // before doing the main recursion. |
| 1228 template <typename LayerType> | 1229 template <typename LayerType> |
| 1229 static void PreCalculateMetaInformation( | 1230 static void PreCalculateMetaInformation( |
| 1230 LayerType* layer, | 1231 LayerType* layer, |
| 1231 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1232 PreCalculateMetaInformationRecursiveData* recursive_data) { |
| 1232 ValidateRenderSurface(layer); | 1233 ValidateRenderSurface(layer); |
| 1233 | 1234 |
| 1234 layer->draw_properties().sorted_for_recursion = false; | 1235 layer->draw_properties().sorted_for_recursion = false; |
| 1235 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1236 layer->draw_properties().has_child_with_a_scroll_parent = false; |
| 1237 layer->draw_properties().layer_or_descendant_is_drawn = false; |
| 1236 layer->draw_properties().visited = false; | 1238 layer->draw_properties().visited = false; |
| 1237 | 1239 |
| 1238 if (!HasInvertibleOrAnimatedTransform(layer)) { | 1240 if (!HasInvertibleOrAnimatedTransform(layer)) { |
| 1239 // Layers with singular transforms should not be drawn, the whole subtree | 1241 // Layers with singular transforms should not be drawn, the whole subtree |
| 1240 // can be skipped. | 1242 // can be skipped. |
| 1241 return; | 1243 return; |
| 1242 } | 1244 } |
| 1243 | 1245 |
| 1244 if (layer->clip_parent()) | 1246 if (layer->clip_parent()) |
| 1245 recursive_data->num_unclipped_descendants++; | 1247 recursive_data->num_unclipped_descendants++; |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 descendants.push_back(child); | 2207 descendants.push_back(child); |
| 2206 } | 2208 } |
| 2207 | 2209 |
| 2208 child->draw_properties().num_descendants_added = | 2210 child->draw_properties().num_descendants_added = |
| 2209 descendants.size() - | 2211 descendants.size() - |
| 2210 child->draw_properties().index_of_first_descendants_addition; | 2212 child->draw_properties().index_of_first_descendants_addition; |
| 2211 child->draw_properties().num_render_surfaces_added = | 2213 child->draw_properties().num_render_surfaces_added = |
| 2212 render_surface_layer_list->size() - | 2214 render_surface_layer_list->size() - |
| 2213 child->draw_properties() | 2215 child->draw_properties() |
| 2214 .index_of_first_render_surface_layer_list_addition; | 2216 .index_of_first_render_surface_layer_list_addition; |
| 2217 layer_draw_properties.layer_or_descendant_is_drawn |= |
| 2218 child->draw_properties().layer_or_descendant_is_drawn; |
| 2215 } | 2219 } |
| 2216 | 2220 |
| 2217 // Add the unsorted layer list contributions, if necessary. | 2221 // Add the unsorted layer list contributions, if necessary. |
| 2218 if (child_order_changed) { | 2222 if (child_order_changed) { |
| 2219 SortLayerListContributions( | 2223 SortLayerListContributions( |
| 2220 *layer, | 2224 *layer, |
| 2221 GetLayerListForSorting(render_surface_layer_list), | 2225 GetLayerListForSorting(render_surface_layer_list), |
| 2222 render_surface_layer_list_child_sorting_start_index, | 2226 render_surface_layer_list_child_sorting_start_index, |
| 2223 &GetNewRenderSurfacesStartIndexAndCount<LayerType>); | 2227 &GetNewRenderSurfacesStartIndexAndCount<LayerType>); |
| 2224 | 2228 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2586 inputs->current_render_surface_layer_list_id); | 2590 inputs->current_render_surface_layer_list_id); |
| 2587 | 2591 |
| 2588 // The dummy layer list should not have been used. | 2592 // The dummy layer list should not have been used. |
| 2589 DCHECK_EQ(0u, dummy_layer_list.size()); | 2593 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2590 // A root layer render_surface should always exist after | 2594 // A root layer render_surface should always exist after |
| 2591 // CalculateDrawProperties. | 2595 // CalculateDrawProperties. |
| 2592 DCHECK(inputs->root_layer->render_surface()); | 2596 DCHECK(inputs->root_layer->render_surface()); |
| 2593 } | 2597 } |
| 2594 | 2598 |
| 2595 } // namespace cc | 2599 } // namespace cc |
| OLD | NEW |