| 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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 return true; | 576 return true; |
| 577 } | 577 } |
| 578 | 578 |
| 579 // If the layer uses a CSS filter. | 579 // If the layer uses a CSS filter. |
| 580 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { | 580 if (!layer->filters().IsEmpty() || !layer->background_filters().IsEmpty()) { |
| 581 DCHECK(!is_root); | 581 DCHECK(!is_root); |
| 582 return true; | 582 return true; |
| 583 } | 583 } |
| 584 | 584 |
| 585 int num_descendants_that_draw_content = | 585 int num_descendants_that_draw_content = |
| 586 layer->draw_properties().num_descendants_that_draw_content; | 586 layer->NumDescendantsThatDrawContent(); |
| 587 | 587 |
| 588 // If the layer flattens its subtree, but it is treated as a 3D object by its | 588 // If the layer flattens its subtree, but it is treated as a 3D object by its |
| 589 // parent (i.e. parent participates in a 3D rendering context). | 589 // parent (i.e. parent participates in a 3D rendering context). |
| 590 if (LayerIsInExisting3DRenderingContext(layer) && | 590 if (LayerIsInExisting3DRenderingContext(layer) && |
| 591 layer->should_flatten_transform() && | 591 layer->should_flatten_transform() && |
| 592 num_descendants_that_draw_content > 0) { | 592 num_descendants_that_draw_content > 0) { |
| 593 TRACE_EVENT_INSTANT0( | 593 TRACE_EVENT_INSTANT0( |
| 594 "cc", | 594 "cc", |
| 595 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", | 595 "LayerTreeHostCommon::SubtreeShouldRenderToSeparateSurface flattening", |
| 596 TRACE_EVENT_SCOPE_THREAD); | 596 TRACE_EVENT_SCOPE_THREAD); |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 data.num_unclipped_descendants; | 1235 data.num_unclipped_descendants; |
| 1236 } | 1236 } |
| 1237 }; | 1237 }; |
| 1238 | 1238 |
| 1239 // Recursively walks the layer tree to compute any information that is needed | 1239 // Recursively walks the layer tree to compute any information that is needed |
| 1240 // before doing the main recursion. | 1240 // before doing the main recursion. |
| 1241 template <typename LayerType> | 1241 template <typename LayerType> |
| 1242 static void PreCalculateMetaInformation( | 1242 static void PreCalculateMetaInformation( |
| 1243 LayerType* layer, | 1243 LayerType* layer, |
| 1244 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1244 PreCalculateMetaInformationRecursiveData* recursive_data) { |
| 1245 bool has_delegated_content = layer->HasDelegatedContent(); | |
| 1246 int num_descendants_that_draw_content = 0; | |
| 1247 | 1245 |
| 1248 layer->draw_properties().sorted_for_recursion = false; | 1246 layer->draw_properties().sorted_for_recursion = false; |
| 1249 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1247 layer->draw_properties().has_child_with_a_scroll_parent = false; |
| 1250 | 1248 |
| 1251 if (!HasInvertibleOrAnimatedTransform(layer)) { | 1249 if (!HasInvertibleOrAnimatedTransform(layer)) { |
| 1252 // Layers with singular transforms should not be drawn, the whole subtree | 1250 // Layers with singular transforms should not be drawn, the whole subtree |
| 1253 // can be skipped. | 1251 // can be skipped. |
| 1254 return; | 1252 return; |
| 1255 } | 1253 } |
| 1256 | 1254 |
| 1257 if (has_delegated_content) { | |
| 1258 // Layers with delegated content need to be treated as if they have as | |
| 1259 // many children as the number of layers they own delegated quads for. | |
| 1260 // Since we don't know this number right now, we choose one that acts like | |
| 1261 // infinity for our purposes. | |
| 1262 num_descendants_that_draw_content = 1000; | |
| 1263 } | |
| 1264 | |
| 1265 if (layer->clip_parent()) | 1255 if (layer->clip_parent()) |
| 1266 recursive_data->num_unclipped_descendants++; | 1256 recursive_data->num_unclipped_descendants++; |
| 1267 | 1257 |
| 1268 for (size_t i = 0; i < layer->children().size(); ++i) { | 1258 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 1269 LayerType* child_layer = | 1259 LayerType* child_layer = |
| 1270 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); | 1260 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); |
| 1271 | 1261 |
| 1272 PreCalculateMetaInformationRecursiveData data_for_child; | 1262 PreCalculateMetaInformationRecursiveData data_for_child; |
| 1273 PreCalculateMetaInformation(child_layer, &data_for_child); | 1263 PreCalculateMetaInformation(child_layer, &data_for_child); |
| 1274 | 1264 |
| 1275 num_descendants_that_draw_content += child_layer->DrawsContent() ? 1 : 0; | |
| 1276 num_descendants_that_draw_content += | |
| 1277 child_layer->draw_properties().num_descendants_that_draw_content; | |
| 1278 | |
| 1279 if (child_layer->scroll_parent()) | 1265 if (child_layer->scroll_parent()) |
| 1280 layer->draw_properties().has_child_with_a_scroll_parent = true; | 1266 layer->draw_properties().has_child_with_a_scroll_parent = true; |
| 1281 recursive_data->Merge(data_for_child); | 1267 recursive_data->Merge(data_for_child); |
| 1282 } | 1268 } |
| 1283 | 1269 |
| 1284 if (layer->clip_children()) { | 1270 if (layer->clip_children()) { |
| 1285 int num_clip_children = layer->clip_children()->size(); | 1271 int num_clip_children = layer->clip_children()->size(); |
| 1286 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 1272 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
| 1287 recursive_data->num_unclipped_descendants -= num_clip_children; | 1273 recursive_data->num_unclipped_descendants -= num_clip_children; |
| 1288 } | 1274 } |
| 1289 | 1275 |
| 1290 if (layer->HasCopyRequest()) | 1276 if (layer->HasCopyRequest()) |
| 1291 recursive_data->layer_or_descendant_has_copy_request = true; | 1277 recursive_data->layer_or_descendant_has_copy_request = true; |
| 1292 | 1278 |
| 1293 if (!layer->touch_event_handler_region().IsEmpty() || | 1279 if (!layer->touch_event_handler_region().IsEmpty() || |
| 1294 layer->have_wheel_event_handlers()) | 1280 layer->have_wheel_event_handlers()) |
| 1295 recursive_data->layer_or_descendant_has_input_handler = true; | 1281 recursive_data->layer_or_descendant_has_input_handler = true; |
| 1296 | 1282 |
| 1297 layer->draw_properties().num_descendants_that_draw_content = | |
| 1298 num_descendants_that_draw_content; | |
| 1299 layer->draw_properties().num_unclipped_descendants = | 1283 layer->draw_properties().num_unclipped_descendants = |
| 1300 recursive_data->num_unclipped_descendants; | 1284 recursive_data->num_unclipped_descendants; |
| 1301 layer->draw_properties().layer_or_descendant_has_copy_request = | 1285 layer->draw_properties().layer_or_descendant_has_copy_request = |
| 1302 recursive_data->layer_or_descendant_has_copy_request; | 1286 recursive_data->layer_or_descendant_has_copy_request; |
| 1303 layer->draw_properties().layer_or_descendant_has_input_handler = | 1287 layer->draw_properties().layer_or_descendant_has_input_handler = |
| 1304 recursive_data->layer_or_descendant_has_input_handler; | 1288 recursive_data->layer_or_descendant_has_input_handler; |
| 1305 } | 1289 } |
| 1306 | 1290 |
| 1307 static void RoundTranslationComponents(gfx::Transform* transform) { | 1291 static void RoundTranslationComponents(gfx::Transform* transform) { |
| 1308 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); | 1292 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); |
| (...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 inputs->current_render_surface_layer_list_id); | 2469 inputs->current_render_surface_layer_list_id); |
| 2486 | 2470 |
| 2487 // The dummy layer list should not have been used. | 2471 // The dummy layer list should not have been used. |
| 2488 DCHECK_EQ(0u, dummy_layer_list.size()); | 2472 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2489 // A root layer render_surface should always exist after | 2473 // A root layer render_surface should always exist after |
| 2490 // CalculateDrawProperties. | 2474 // CalculateDrawProperties. |
| 2491 DCHECK(inputs->root_layer->render_surface()); | 2475 DCHECK(inputs->root_layer->render_surface()); |
| 2492 } | 2476 } |
| 2493 | 2477 |
| 2494 } // namespace cc | 2478 } // namespace cc |
| OLD | NEW |