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() && !layer->TransformIsAnimating()) | |
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 // TODO(ajuma): Correctly process subtrees with singular transform for the | |
510 // case where we may animate to a non-singular transform and wish to | |
511 // pre-raster. | |
ajuma
2014/04/16 19:24:49
This TODO should move to the previous function (th
avallee
2014/04/16 19:33:25
Done.
| |
512 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating()) | |
513 return true; | |
514 | |
504 // When we need to do a readback/copy of a layer's output, we can not skip | 515 // When we need to do a readback/copy of a layer's output, we can not skip |
505 // it or any of its ancestors. | 516 // it or any of its ancestors. |
506 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 517 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
507 return false; | 518 return false; |
508 | 519 |
509 // If the layer is not drawn, then skip it and its subtree. | 520 // If the layer is not drawn, then skip it and its subtree. |
510 if (!layer_is_drawn) | 521 if (!layer_is_drawn) |
511 return true; | 522 return true; |
512 | 523 |
513 // If the opacity is being animated then the opacity on the main thread is | 524 // 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 | 1169 |
1159 // Recursively walks the layer tree to compute any information that is needed | 1170 // Recursively walks the layer tree to compute any information that is needed |
1160 // before doing the main recursion. | 1171 // before doing the main recursion. |
1161 template <typename LayerType> | 1172 template <typename LayerType> |
1162 static void PreCalculateMetaInformation( | 1173 static void PreCalculateMetaInformation( |
1163 LayerType* layer, | 1174 LayerType* layer, |
1164 PreCalculateMetaInformationRecursiveData* recursive_data) { | 1175 PreCalculateMetaInformationRecursiveData* recursive_data) { |
1165 bool has_delegated_content = layer->HasDelegatedContent(); | 1176 bool has_delegated_content = layer->HasDelegatedContent(); |
1166 int num_descendants_that_draw_content = 0; | 1177 int num_descendants_that_draw_content = 0; |
1167 | 1178 |
1179 if (!layer->transform_is_invertible()) { | |
1180 // Layers with singular transforms should not be drawn, the whole subtree | |
1181 // can be skipped. | |
1182 return; | |
1183 } | |
1184 | |
1168 if (has_delegated_content) { | 1185 if (has_delegated_content) { |
1169 // Layers with delegated content need to be treated as if they have as | 1186 // 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. | 1187 // 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 | 1188 // Since we don't know this number right now, we choose one that acts like |
1172 // infinity for our purposes. | 1189 // infinity for our purposes. |
1173 num_descendants_that_draw_content = 1000; | 1190 num_descendants_that_draw_content = 1000; |
1174 } | 1191 } |
1175 | 1192 |
1176 layer->draw_properties().sorted_for_recursion = false; | 1193 layer->draw_properties().sorted_for_recursion = false; |
1177 layer->draw_properties().has_child_with_a_scroll_parent = false; | 1194 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 | 2532 // 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 | 2533 // 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 | 2534 // was not clipped in such a way that the hit point actually should not hit |
2518 // the layer. | 2535 // the layer. |
2519 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2536 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2520 return false; | 2537 return false; |
2521 | 2538 |
2522 return true; | 2539 return true; |
2523 } | 2540 } |
2524 } // namespace cc | 2541 } // namespace cc |
OLD | NEW |