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 655b4052a8b367f8383098c71a96960e13165a13..5d5995ca46bd358ffcc435337cfcf2970fc0d5e0 100644 |
| --- a/cc/trees/layer_tree_host_common.cc |
| +++ b/cc/trees/layer_tree_host_common.cc |
| @@ -1129,6 +1129,39 @@ static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface( |
| return layer->render_surface(); |
| } |
| +template <typename LayerTypePtr> |
| +static inline void MarkLayerWithRenderSurfaceLayerListId( |
| + LayerTypePtr layer, |
| + int current_render_surface_layer_list_id) { |
| + layer->draw_properties().last_drawn_render_surface_layer_list_id = |
| + current_render_surface_layer_list_id; |
| + if (layer->mask_layer()) { |
| + layer->mask_layer() |
| + ->draw_properties() |
| + .last_drawn_render_surface_layer_list_id = |
| + current_render_surface_layer_list_id; |
| + } |
| + if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
| + layer->replica_layer() |
| + ->mask_layer() |
| + ->draw_properties() |
| + .last_drawn_render_surface_layer_list_id = |
| + current_render_surface_layer_list_id; |
| + } |
| +} |
| + |
| +template <typename LayerListType> |
| +static inline void MarkLayerListWithRenderSurfaceLayerListId( |
| + LayerListType* layer_list, |
| + int current_render_surface_layer_list_id) { |
| + for (typename LayerListType::iterator it = layer_list->begin(); |
| + it != layer_list->end(); |
| + ++it) { |
| + MarkLayerWithRenderSurfaceLayerListId(*it, |
| + current_render_surface_layer_list_id); |
| + } |
| +} |
| + |
| template <typename LayerType> |
| static inline void RemoveSurfaceForEarlyExit( |
| LayerType* layer_to_remove, |
| @@ -1141,10 +1174,17 @@ static inline void RemoveSurfaceForEarlyExit( |
| // things to crash. So here we proactively remove any additional |
| // layers from the end of the list. |
| while (render_surface_layer_list->back() != layer_to_remove) { |
| + MarkLayerListWithRenderSurfaceLayerListId( |
| + &render_surface_layer_list->back()->render_surface()->layer_list(), 0); |
| + MarkLayerWithRenderSurfaceLayerListId(render_surface_layer_list->back(), 0); |
| + |
| render_surface_layer_list->back()->ClearRenderSurfaceLayerList(); |
| render_surface_layer_list->pop_back(); |
| } |
| DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); |
| + MarkLayerListWithRenderSurfaceLayerListId( |
| + &layer_to_remove->render_surface()->layer_list(), 0); |
| + MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); |
| render_surface_layer_list->pop_back(); |
| layer_to_remove->ClearRenderSurfaceLayerList(); |
| } |
| @@ -1423,8 +1463,8 @@ static void CalculateDrawPropertiesInternal( |
| const DataForRecursion<LayerType>& data_from_ancestor, |
| typename LayerType::RenderSurfaceListType* render_surface_layer_list, |
| typename LayerType::LayerListType* layer_list, |
| - std::vector<AccumulatedSurfaceState<LayerType> >* |
| - accumulated_surface_state) { |
| + std::vector<AccumulatedSurfaceState<LayerType> >* accumulated_surface_state, |
| + int current_render_surface_layer_list_id) { |
| // This function computes the new matrix transformations recursively for this |
| // layer and all its descendants. It also computes the appropriate render |
| // surfaces. |
| @@ -2011,8 +2051,11 @@ static void CalculateDrawPropertiesInternal( |
| // and should be included in the sorting process. |
| size_t sorting_start_index = descendants.size(); |
| - if (!LayerShouldBeSkipped(layer, layer_is_drawn)) |
| + if (!LayerShouldBeSkipped(layer, layer_is_drawn)) { |
| + MarkLayerWithRenderSurfaceLayerListId(layer, |
|
enne (OOO)
2014/05/07 00:12:11
This is a little weird because it also adds the ma
vmpstr
2014/05/07 17:35:58
You mean this could just be marking the layer and
enne (OOO)
2014/05/07 17:41:17
Yeah, the masks get marked twice. It's not a huge
danakj
2014/05/07 17:43:05
Ya there's really no reason to mark the masks here
|
| + current_render_surface_layer_list_id); |
| descendants.push_back(layer); |
| + } |
| // Any layers that are appended after this point may need to be sorted if we |
| // visit the children out of order. |
| @@ -2072,15 +2115,29 @@ static void CalculateDrawPropertiesInternal( |
| child->draw_properties().index_of_first_render_surface_layer_list_addition = |
| render_surface_layer_list->size(); |
| - CalculateDrawPropertiesInternal<LayerType>(child, |
| - globals, |
| - data_for_children, |
| - render_surface_layer_list, |
| - &descendants, |
| - accumulated_surface_state); |
| + CalculateDrawPropertiesInternal<LayerType>( |
| + child, |
| + globals, |
| + data_for_children, |
| + render_surface_layer_list, |
| + &descendants, |
| + accumulated_surface_state, |
| + current_render_surface_layer_list_id); |
| if (child->render_surface() && |
| !child->render_surface()->layer_list().empty() && |
| !child->render_surface()->content_rect().IsEmpty()) { |
| + // This child will contribute its render surface, which means |
| + // we need to mark just the mask layer (and replica mask layer) |
| + // with the id. |
| + if (child->mask_layer()) { |
| + MarkLayerWithRenderSurfaceLayerListId( |
| + child->mask_layer(), current_render_surface_layer_list_id); |
| + } |
| + if (child->replica_layer() && child->replica_layer()->mask_layer()) { |
| + MarkLayerWithRenderSurfaceLayerListId( |
| + child->replica_layer()->mask_layer(), |
| + current_render_surface_layer_list_id); |
| + } |
| descendants.push_back(child); |
| } |
| @@ -2328,12 +2385,14 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| PreCalculateMetaInformationRecursiveData recursive_data; |
| PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; |
| - CalculateDrawPropertiesInternal<Layer>(inputs->root_layer, |
| - globals, |
| - data_for_recursion, |
| - inputs->render_surface_layer_list, |
| - &dummy_layer_list, |
| - &accumulated_surface_state); |
| + CalculateDrawPropertiesInternal<Layer>( |
| + inputs->root_layer, |
| + globals, |
| + data_for_recursion, |
| + inputs->render_surface_layer_list, |
| + &dummy_layer_list, |
| + &accumulated_surface_state, |
| + inputs->current_render_surface_layer_list_id); |
| // The dummy layer list should not have been used. |
| DCHECK_EQ(0u, dummy_layer_list.size()); |
| @@ -2356,12 +2415,14 @@ void LayerTreeHostCommon::CalculateDrawProperties( |
| PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
| std::vector<AccumulatedSurfaceState<LayerImpl> > |
| accumulated_surface_state; |
| - CalculateDrawPropertiesInternal<LayerImpl>(inputs->root_layer, |
| - globals, |
| - data_for_recursion, |
| - inputs->render_surface_layer_list, |
| - &dummy_layer_list, |
| - &accumulated_surface_state); |
| + CalculateDrawPropertiesInternal<LayerImpl>( |
| + inputs->root_layer, |
| + globals, |
| + data_for_recursion, |
| + inputs->render_surface_layer_list, |
| + &dummy_layer_list, |
| + &accumulated_surface_state, |
| + inputs->current_render_surface_layer_list_id); |
| // The dummy layer list should not have been used. |
| DCHECK_EQ(0u, dummy_layer_list.size()); |