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 d483cc697bd76d44e0b7d9353dbb0974c6fdfc5d..8c5fda1861f113dc328f7b91760c435b41906464 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) { |
| + 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, |
| @@ -454,9 +460,7 @@ static bool LayerShouldBeSkipped(LayerType* layer, |
| // 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) |
| + if (!layer->DrawsContent() && !LayerCanAcceptInput(layer)) |
| return true; |
|
danakj
2013/10/07 16:29:13
Can you add skipping layers that have draw-opacity
sadrul
2013/10/07 17:16:49
I have updated the code here to look at layer->dra
danakj
2013/10/07 17:37:35
I meant that this function doesn't use draw proper
sadrul
2013/10/07 18:37:24
Ah, I see. Done. (needed both |accumulated_draw_op
danakj
2013/10/07 19:02:36
Oh right, inside a surface the opacity goes back t
|
| return false; |
| @@ -481,9 +485,10 @@ static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, |
| // 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(); |
| + // entire subtree can be skipped if this layer is fully transparent, and none |
| + // of layers in the subtree has event handlers. |
| + return !layer->opacity() && |
| + !layer->draw_properties().layer_or_descendant_has_event_handler; |
| } |
| static inline bool SubtreeShouldBeSkipped(Layer* layer, |
| @@ -503,9 +508,9 @@ static inline bool SubtreeShouldBeSkipped(Layer* layer, |
| // 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(); |
| + !layer->OpacityCanAnimateOnImplThread() && |
| + !layer->draw_properties().layer_or_descendant_has_event_handler; |
| } |
| // Called on each layer that could be drawn after all information from |
| @@ -1014,15 +1019,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; |
| } |
| @@ -1084,6 +1093,9 @@ 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 = |
| @@ -1092,6 +1104,8 @@ static void PreCalculateMetaInformation( |
| descendants_can_clip_selves; |
| 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) { |