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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() || | 471 bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() || |
472 layer->have_wheel_event_handlers(); | 472 layer->have_wheel_event_handlers(); |
473 if (!layer->DrawsContent() && !can_accept_input) | 473 if (!layer->DrawsContent() && !can_accept_input) |
474 return true; | 474 return true; |
475 | 475 |
476 return false; | 476 return false; |
477 } | 477 } |
478 | 478 |
479 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, | 479 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, |
480 bool layer_is_drawn) { | 480 bool layer_is_drawn) { |
| 481 // If the layer transform is not invertible, it should not be drawn. |
| 482 if (!layer->transform_is_invertible()) |
| 483 return true; |
| 484 |
481 // When we need to do a readback/copy of a layer's output, we can not skip | 485 // When we need to do a readback/copy of a layer's output, we can not skip |
482 // it or any of its ancestors. | 486 // it or any of its ancestors. |
483 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 487 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
484 return false; | 488 return false; |
485 | 489 |
486 // If the layer is not drawn, then skip it and its subtree. | 490 // If the layer is not drawn, then skip it and its subtree. |
487 if (!layer_is_drawn) | 491 if (!layer_is_drawn) |
488 return true; | 492 return true; |
489 | 493 |
490 // If layer is on the pending tree and opacity is being animated then | 494 // If layer is on the pending tree and opacity is being animated then |
491 // this subtree can't be skipped as we need to create, prioritize and | 495 // this subtree can't be skipped as we need to create, prioritize and |
492 // include tiles for this layer when deciding if tree can be activated. | 496 // include tiles for this layer when deciding if tree can be activated. |
493 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) | 497 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) |
494 return false; | 498 return false; |
495 | 499 |
496 // The opacity of a layer always applies to its children (either implicitly | 500 // The opacity of a layer always applies to its children (either implicitly |
497 // via a render surface or explicitly if the parent preserves 3D), so the | 501 // via a render surface or explicitly if the parent preserves 3D), so the |
498 // entire subtree can be skipped if this layer is fully transparent. | 502 // entire subtree can be skipped if this layer is fully transparent. |
499 // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. | 503 // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. |
500 return !layer->opacity(); | 504 return !layer->opacity(); |
501 } | 505 } |
502 | 506 |
503 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { | 507 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { |
| 508 // If the layer transform is not invertible, it should not be drawn. |
| 509 if (!layer->transform_is_invertible()) |
| 510 return true; |
| 511 |
504 // When we need to do a readback/copy of a layer's output, we can not skip | 512 // When we need to do a readback/copy of a layer's output, we can not skip |
505 // it or any of its ancestors. | 513 // it or any of its ancestors. |
506 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 514 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
507 return false; | 515 return false; |
508 | 516 |
509 // If the layer is not drawn, then skip it and its subtree. | 517 // If the layer is not drawn, then skip it and its subtree. |
510 if (!layer_is_drawn) | 518 if (!layer_is_drawn) |
511 return true; | 519 return true; |
512 | 520 |
513 // If the opacity is being animated then the opacity on the main thread is | 521 // If the opacity is being animated then the opacity on the main thread is |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 | 1166 |
1159 // Recursively walks the layer tree to compute any information that is needed | 1167 // Recursively walks the layer tree to compute any information that is needed |
1160 // before doing the main recursion. | 1168 // before doing the main recursion. |
1161 template <typename LayerType> | 1169 template <typename LayerType> |
1162 static void PreCalculateMetaInformation( | 1170 static void PreCalculateMetaInformation( |
1163 LayerType* layer, | 1171 LayerType* layer, |
1164 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1172 PreCalculateMetaInformationRecursiveData* recursive_data) { |
1165 bool has_delegated_content = layer->HasDelegatedContent(); | 1173 bool has_delegated_content = layer->HasDelegatedContent(); |
1166 int num_descendants_that_draw_content = 0; | 1174 int num_descendants_that_draw_content = 0; |
1167 | 1175 |
| 1176 if (!layer->transform_is_invertible()) { |
| 1177 // Layers with singular transforms should not be drawn, the whole subtree |
| 1178 // can be skipped. |
| 1179 return; |
| 1180 } |
| 1181 |
1168 if (has_delegated_content) { | 1182 if (has_delegated_content) { |
1169 // Layers with delegated content need to be treated as if they have as | 1183 // Layers with delegated content need to be treated as if they have as |
1170 // many children as the number of layers they own delegated quads for. | 1184 // many children as the number of layers they own delegated quads for. |
1171 // Since we don't know this number right now, we choose one that acts like | 1185 // Since we don't know this number right now, we choose one that acts like |
1172 // infinity for our purposes. | 1186 // infinity for our purposes. |
1173 num_descendants_that_draw_content = 1000; | 1187 num_descendants_that_draw_content = 1000; |
1174 } | 1188 } |
1175 | 1189 |
1176 layer->draw_properties().sorted_for_recursion = false; | 1190 layer->draw_properties().sorted_for_recursion = false; |
1177 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1191 layer->draw_properties().has_child_with_a_scroll_parent = false; |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2515 // At this point, we think the point does hit the touch event handler region | 2529 // At this point, we think the point does hit the touch event handler region |
2516 // on the layer, but we need to walk up the parents to ensure that the layer | 2530 // on the layer, but we need to walk up the parents to ensure that the layer |
2517 // was not clipped in such a way that the hit point actually should not hit | 2531 // was not clipped in such a way that the hit point actually should not hit |
2518 // the layer. | 2532 // the layer. |
2519 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2533 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2520 return false; | 2534 return false; |
2521 | 2535 |
2522 return true; | 2536 return true; |
2523 } | 2537 } |
2524 } // namespace cc | 2538 } // namespace cc |
OLD | NEW |