Chromium Code Reviews| Index: cc/trees/layer_tree_host_common.cc |
| diff --git a/cc/trees/layer_tree_host_common.cc b/cc/trees/layer_tree_host_common.cc |
| index 4095900fae18f839190a3d35ae01406e4a6cd6c4..73ce1d2257898375eb81a007a4725de61d37ecb5 100644 |
| --- a/cc/trees/layer_tree_host_common.cc |
| +++ b/cc/trees/layer_tree_host_common.cc |
| @@ -63,6 +63,12 @@ static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) { |
| return offset; |
| } |
| +template <typename LayerType> |
| +static inline bool LayerCanAcceptInput(LayerType* layer) { |
|
enne (OOO)
2013/10/29 23:54:22
Maybe call this LayerHasEventHandler to be consist
sadrul
2013/10/30 15:44:42
Done.
|
| + return !layer->touch_event_handler_region().IsEmpty() || |
| + layer->have_wheel_event_handlers(); |
| +} |
| + |
| inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( |
| gfx::Rect target_surface_rect, |
| gfx::Rect layer_bound_rect, |
| @@ -437,10 +443,11 @@ static bool LayerShouldBeSkipped(LayerType* layer, |
| bool layer_is_visible) { |
| // Layers can be skipped if any of these conditions are met. |
| // - is not visible due to it or one of its ancestors being hidden. |
| + // - the layer itself and none of its descendants participate in hit testing |
| // - has empty bounds |
| // - the layer is not double-sided, but its back face is visible. |
| // - is transparent |
| - // - does not draw content and does not participate in hit testing. |
| + // - does not draw content |
| // |
| // Some additional conditions need to be computed at a later point after the |
| // recursion is finished. |
| @@ -454,6 +461,9 @@ static bool LayerShouldBeSkipped(LayerType* layer, |
| if (!layer_is_visible) |
| return true; |
| + if (layer->draw_properties().layer_or_descendant_has_event_handler) |
|
enne (OOO)
2013/10/29 23:54:22
I don't think this is sufficient. I feel like wha
sadrul
2013/10/30 05:20:21
I am using DataForRecursion::subtree_has_event_han
|
| + return false; |
| + |
| if (layer->bounds().IsEmpty()) |
| return true; |
| @@ -471,11 +481,8 @@ static bool LayerShouldBeSkipped(LayerType* layer, |
| IsLayerBackFaceVisible(backface_test_layer)) |
| return true; |
| - // The layer is visible to events. If it's subject to hit testing, then |
| - // we can't skip it. |
| - bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() || |
| - layer->have_wheel_event_handlers(); |
| - if (!layer->DrawsContent() && !can_accept_input) |
| + // The layer is visible to events. |
| + if (!layer->DrawsContent()) |
| return true; |
| return false; |
| @@ -498,10 +505,12 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, |
| if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) |
| return false; |
| + if (layer->draw_properties().layer_or_descendant_has_event_handler) |
| + return false; |
| + |
| // The opacity of a layer always applies to its children (either implicitly |
| // via a render surface or explicitly if the parent preserves 3D), so the |
| // entire subtree can be skipped if this layer is fully transparent. |
| - // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. |
| return !layer->opacity(); |
| } |
| @@ -516,13 +525,15 @@ static inline bool SubtreeShouldBeSkipped(Layer* layer, |
| if (!layer_is_visible) |
| return true; |
| + if (layer->draw_properties().layer_or_descendant_has_event_handler) |
| + return false; |
| + |
| // If the opacity is being animated then the opacity on the main thread is |
| // unreliable (since the impl thread may be using a different opacity), so it |
| // should not be trusted. |
| // In particular, it should not cause the subtree to be skipped. |
| // Similarly, for layers that might animate opacity using an impl-only |
| // animation, their subtree should also not be skipped. |
| - // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. |
| return !layer->opacity() && !layer->OpacityIsAnimating() && |
| !layer->OpacityCanAnimateOnImplThread(); |
| } |
| @@ -1018,15 +1029,19 @@ static inline void RemoveSurfaceForEarlyExit( |
| struct PreCalculateMetaInformationRecursiveData { |
| bool layer_or_descendant_has_copy_request; |
| + bool layer_or_descendant_has_event_handler; |
| int num_unclipped_descendants; |
| PreCalculateMetaInformationRecursiveData() |
| : layer_or_descendant_has_copy_request(false), |
| + layer_or_descendant_has_event_handler(false), |
| num_unclipped_descendants(0) {} |
| void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
| layer_or_descendant_has_copy_request |= |
| data.layer_or_descendant_has_copy_request; |
| + layer_or_descendant_has_event_handler |= |
| + data.layer_or_descendant_has_event_handler; |
| num_unclipped_descendants += |
| data.num_unclipped_descendants; |
| } |
| @@ -1080,12 +1095,17 @@ static void PreCalculateMetaInformation( |
| if (layer->HasCopyRequest()) |
| recursive_data->layer_or_descendant_has_copy_request = true; |
| + if (LayerCanAcceptInput(layer)) |
| + recursive_data->layer_or_descendant_has_event_handler = true; |
| + |
| layer->draw_properties().num_descendants_that_draw_content = |
| num_descendants_that_draw_content; |
| layer->draw_properties().num_unclipped_descendants = |
| recursive_data->num_unclipped_descendants; |
| layer->draw_properties().layer_or_descendant_has_copy_request = |
| recursive_data->layer_or_descendant_has_copy_request; |
| + layer->draw_properties().layer_or_descendant_has_event_handler = |
| + recursive_data->layer_or_descendant_has_event_handler; |
| } |
| static void RoundTranslationComponents(gfx::Transform* transform) { |
| @@ -1142,6 +1162,7 @@ struct DataForRecursion { |
| bool in_subtree_of_page_scale_application_layer; |
| bool subtree_can_use_lcd_text; |
| bool subtree_is_visible_from_ancestor; |
| + bool subtree_has_event_handler; |
| }; |
| template <typename LayerType> |
| @@ -1408,6 +1429,9 @@ static void CalculateDrawPropertiesInternal( |
| data_from_ancestor.in_subtree_of_page_scale_application_layer; |
| data_for_children.subtree_can_use_lcd_text = |
| data_from_ancestor.subtree_can_use_lcd_text; |
| + data_for_children.subtree_has_event_handler = |
| + data_from_ancestor.subtree_has_event_handler || |
| + layer->draw_properties().layer_or_descendant_has_event_handler; |
| // Layers with a copy request are always visible, as well as un-hiding their |
| // subtree. Otherise, layers that are marked as hidden will hide themselves |
| @@ -1419,7 +1443,9 @@ static void CalculateDrawPropertiesInternal( |
| layer_is_visible = true; |
| // The root layer cannot skip CalcDrawProperties. |
| - if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_visible)) { |
| + if (!IsRootLayer(layer) && |
| + !data_from_ancestor.subtree_has_event_handler && |
| + SubtreeShouldBeSkipped(layer, layer_is_visible)) { |
| if (layer->render_surface()) |
| layer->ClearRenderSurface(); |
| return; |
| @@ -1847,7 +1873,8 @@ static void CalculateDrawPropertiesInternal( |
| // and should be included in the sorting process. |
| size_t sorting_start_index = descendants.size(); |
| - if (!LayerShouldBeSkipped(layer, layer_is_visible)) |
| + if (data_from_ancestor.subtree_has_event_handler || |
| + !LayerShouldBeSkipped(layer, layer_is_visible)) |
| descendants.push_back(layer); |
| // Any layers that are appended after this point may need to be sorted if we |
| @@ -2145,6 +2172,9 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| PreCalculateMetaInformationRecursiveData recursive_data; |
| PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| + data_for_recursion.subtree_has_event_handler = |
| + inputs->root_layer->draw_properties(). |
| + layer_or_descendant_has_event_handler; |
| std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; |
| CalculateDrawPropertiesInternal<Layer>(inputs->root_layer, |
| globals, |
| @@ -2203,6 +2233,9 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| PreCalculateMetaInformationRecursiveData recursive_data; |
| PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| + data_for_recursion.subtree_has_event_handler = |
| + inputs->root_layer->draw_properties(). |
| + layer_or_descendant_has_event_handler; |
| std::vector<AccumulatedSurfaceState<LayerImpl> > |
| accumulated_surface_state; |
| CalculateDrawPropertiesInternal<LayerImpl>(inputs->root_layer, |