| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 1173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 layer->draw_properties().sorted_for_recursion = false; | 1186 layer->draw_properties().sorted_for_recursion = false; |
| 1187 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1187 layer->draw_properties().has_child_with_a_scroll_parent = false; |
| 1188 | 1188 |
| 1189 if (layer->clip_parent()) | 1189 if (layer->clip_parent()) |
| 1190 recursive_data->num_unclipped_descendants++; | 1190 recursive_data->num_unclipped_descendants++; |
| 1191 | 1191 |
| 1192 for (size_t i = 0; i < layer->children().size(); ++i) { | 1192 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 1193 LayerType* child_layer = | 1193 LayerType* child_layer = |
| 1194 LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); | 1194 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); |
| 1195 | 1195 |
| 1196 PreCalculateMetaInformationRecursiveData data_for_child; | 1196 PreCalculateMetaInformationRecursiveData data_for_child; |
| 1197 PreCalculateMetaInformation(child_layer, &data_for_child); | 1197 PreCalculateMetaInformation(child_layer, &data_for_child); |
| 1198 | 1198 |
| 1199 num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; | 1199 num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; |
| 1200 num_descendants_that_draw_content += | 1200 num_descendants_that_draw_content += |
| 1201 child_layer->draw_properties().num_descendants_that_draw_content; | 1201 child_layer->draw_properties().num_descendants_that_draw_content; |
| 1202 | 1202 |
| 1203 if (child_layer->scroll_parent()) | 1203 if (child_layer->scroll_parent()) |
| 1204 layer->draw_properties().has_child_with_a_scroll_parent = true; | 1204 layer->draw_properties().has_child_with_a_scroll_parent = true; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1336 child->draw_properties().sorted_for_recursion = true; | 1336 child->draw_properties().sorted_for_recursion = true; |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 template <typename LayerType> | 1339 template <typename LayerType> |
| 1340 static bool SortChildrenForRecursion(std::vector<LayerType*>* out, | 1340 static bool SortChildrenForRecursion(std::vector<LayerType*>* out, |
| 1341 const LayerType& parent) { | 1341 const LayerType& parent) { |
| 1342 out->reserve(parent.children().size()); | 1342 out->reserve(parent.children().size()); |
| 1343 bool order_changed = false; | 1343 bool order_changed = false; |
| 1344 for (size_t i = 0; i < parent.children().size(); ++i) { | 1344 for (size_t i = 0; i < parent.children().size(); ++i) { |
| 1345 LayerType* current = | 1345 LayerType* current = |
| 1346 LayerTreeHostCommon::get_child_as_raw_ptr(parent.children(), i); | 1346 LayerTreeHostCommon::get_layer_as_raw_ptr(parent.children(), i); |
| 1347 | 1347 |
| 1348 if (current->draw_properties().sorted_for_recursion) { | 1348 if (current->draw_properties().sorted_for_recursion) { |
| 1349 order_changed = true; | 1349 order_changed = true; |
| 1350 continue; | 1350 continue; |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 AddScrollParentChain(out, parent, current); | 1353 AddScrollParentChain(out, parent, current); |
| 1354 } | 1354 } |
| 1355 | 1355 |
| 1356 DCHECK_EQ(parent.children().size(), out->size()); | 1356 DCHECK_EQ(parent.children().size(), out->size()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1386 | 1386 |
| 1387 template <typename LayerType, typename GetIndexAndCountType> | 1387 template <typename LayerType, typename GetIndexAndCountType> |
| 1388 static void SortLayerListContributions( | 1388 static void SortLayerListContributions( |
| 1389 const LayerType& parent, | 1389 const LayerType& parent, |
| 1390 typename LayerType::LayerListType* unsorted, | 1390 typename LayerType::LayerListType* unsorted, |
| 1391 size_t start_index_for_all_contributions, | 1391 size_t start_index_for_all_contributions, |
| 1392 GetIndexAndCountType get_index_and_count) { | 1392 GetIndexAndCountType get_index_and_count) { |
| 1393 typename LayerType::LayerListType buffer; | 1393 typename LayerType::LayerListType buffer; |
| 1394 for (size_t i = 0; i < parent.children().size(); ++i) { | 1394 for (size_t i = 0; i < parent.children().size(); ++i) { |
| 1395 LayerType* child = | 1395 LayerType* child = |
| 1396 LayerTreeHostCommon::get_child_as_raw_ptr(parent.children(), i); | 1396 LayerTreeHostCommon::get_layer_as_raw_ptr(parent.children(), i); |
| 1397 | 1397 |
| 1398 size_t start_index = 0; | 1398 size_t start_index = 0; |
| 1399 size_t count = 0; | 1399 size_t count = 0; |
| 1400 get_index_and_count(child, &start_index, &count); | 1400 get_index_and_count(child, &start_index, &count); |
| 1401 for (size_t j = start_index; j < start_index + count; ++j) | 1401 for (size_t j = start_index; j < start_index + count; ++j) |
| 1402 buffer.push_back(unsorted->at(j)); | 1402 buffer.push_back(unsorted->at(j)); |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 DCHECK_EQ(buffer.size(), | 1405 DCHECK_EQ(buffer.size(), |
| 1406 unsorted->size() - start_index_for_all_contributions); | 1406 unsorted->size() - start_index_for_all_contributions); |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 child_order_changed = SortChildrenForRecursion(&sorted_children, *layer); | 2053 child_order_changed = SortChildrenForRecursion(&sorted_children, *layer); |
| 2054 | 2054 |
| 2055 for (size_t i = 0; i < layer->children().size(); ++i) { | 2055 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 2056 // If one of layer's children has a scroll parent, then we may have to | 2056 // If one of layer's children has a scroll parent, then we may have to |
| 2057 // visit the children out of order. The new order is stored in | 2057 // visit the children out of order. The new order is stored in |
| 2058 // sorted_children. Otherwise, we'll grab the child directly from the | 2058 // sorted_children. Otherwise, we'll grab the child directly from the |
| 2059 // layer's list of children. | 2059 // layer's list of children. |
| 2060 LayerType* child = | 2060 LayerType* child = |
| 2061 layer_draw_properties.has_child_with_a_scroll_parent | 2061 layer_draw_properties.has_child_with_a_scroll_parent |
| 2062 ? sorted_children[i] | 2062 ? sorted_children[i] |
| 2063 : LayerTreeHostCommon::get_child_as_raw_ptr(layer->children(), i); | 2063 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); |
| 2064 | 2064 |
| 2065 child->draw_properties().index_of_first_descendants_addition = | 2065 child->draw_properties().index_of_first_descendants_addition = |
| 2066 descendants.size(); | 2066 descendants.size(); |
| 2067 child->draw_properties().index_of_first_render_surface_layer_list_addition = | 2067 child->draw_properties().index_of_first_render_surface_layer_list_addition = |
| 2068 render_surface_layer_list->size(); | 2068 render_surface_layer_list->size(); |
| 2069 | 2069 |
| 2070 CalculateDrawPropertiesInternal<LayerType>(child, | 2070 CalculateDrawPropertiesInternal<LayerType>(child, |
| 2071 globals, | 2071 globals, |
| 2072 data_for_children, | 2072 data_for_children, |
| 2073 render_surface_layer_list, | 2073 render_surface_layer_list, |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 // At this point, we think the point does hit the touch event handler region | 2576 // At this point, we think the point does hit the touch event handler region |
| 2577 // on the layer, but we need to walk up the parents to ensure that the layer | 2577 // on the layer, but we need to walk up the parents to ensure that the layer |
| 2578 // was not clipped in such a way that the hit point actually should not hit | 2578 // was not clipped in such a way that the hit point actually should not hit |
| 2579 // the layer. | 2579 // the layer. |
| 2580 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2580 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
| 2581 return false; | 2581 return false; |
| 2582 | 2582 |
| 2583 return true; | 2583 return true; |
| 2584 } | 2584 } |
| 2585 } // namespace cc | 2585 } // namespace cc |
| OLD | NEW |