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..a4da899bc366896f95df764bdf3130ed12ea4620 100644 |
--- a/cc/trees/layer_tree_host_common.cc |
+++ b/cc/trees/layer_tree_host_common.cc |
@@ -1130,6 +1130,46 @@ static inline typename LayerType::RenderSurfaceType* CreateOrReuseRenderSurface( |
} |
template <typename LayerType> |
+static inline void MarkLayerWithFrameNumber( |
danakj
2014/05/05 19:25:41
"FrameNumber" seems like a misnomer here
vmpstr
2014/05/05 20:50:34
Done.
|
+ LayerType* layer, |
+ int current_calculate_draw_properties_count) { |
+ layer->draw_properties().last_valid_render_surface_list_count = |
+ current_calculate_draw_properties_count; |
+ if (layer->mask_layer()) { |
+ layer->mask_layer() |
+ ->draw_properties() |
+ .last_valid_render_surface_list_count = |
+ current_calculate_draw_properties_count; |
+ } |
+ if (layer->replica_layer() && layer->replica_layer()->mask_layer()) { |
danakj
2014/05/05 19:25:41
can you mark the replica layer too (it doesn't hav
vmpstr
2014/05/05 20:50:34
Done.
|
+ layer->replica_layer() |
+ ->mask_layer() |
+ ->draw_properties() |
+ .last_valid_render_surface_list_count = |
+ current_calculate_draw_properties_count; |
+ } |
+} |
+ |
+template <typename LayerType> |
+static inline void MarkLayerWithFrameNumber( |
+ scoped_refptr<LayerType> layer, |
danakj
2014/05/05 19:25:41
Does the templated method above not handle this ca
vmpstr
2014/05/05 20:50:34
No, the signature is LayerType*, and scoped_refptr
|
+ int current_calculate_draw_properties_count) { |
+ MarkLayerWithFrameNumber(layer.get(), |
+ current_calculate_draw_properties_count); |
+} |
+ |
+template <typename LayerListType> |
+static inline void MarkLayerListWithFrameNumber( |
+ LayerListType* layer_list, |
+ int current_calculate_draw_properties_count) { |
+ for (typename LayerListType::iterator it = layer_list->begin(); |
+ it != layer_list->end(); |
+ ++it) { |
+ MarkLayerWithFrameNumber(*it, current_calculate_draw_properties_count); |
+ } |
+} |
+ |
+template <typename LayerType> |
static inline void RemoveSurfaceForEarlyExit( |
LayerType* layer_to_remove, |
typename LayerType::RenderSurfaceListType* render_surface_layer_list) { |
@@ -1142,9 +1182,15 @@ static inline void RemoveSurfaceForEarlyExit( |
// layers from the end of the list. |
while (render_surface_layer_list->back() != layer_to_remove) { |
render_surface_layer_list->back()->ClearRenderSurfaceLayerList(); |
+ MarkLayerListWithFrameNumber( |
+ &render_surface_layer_list->back()->render_surface()->layer_list(), 0); |
render_surface_layer_list->pop_back(); |
} |
DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); |
+ |
danakj
2014/05/05 19:25:41
nit: drop extra whitespace?
vmpstr
2014/05/05 20:50:34
Done.
|
+ MarkLayerListWithFrameNumber(&layer_to_remove->render_surface()->layer_list(), |
+ 0); |
+ |
render_surface_layer_list->pop_back(); |
layer_to_remove->ClearRenderSurfaceLayerList(); |
} |
@@ -1423,8 +1469,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_calculate_draw_properties_count) { |
// This function computes the new matrix transformations recursively for this |
// layer and all its descendants. It also computes the appropriate render |
// surfaces. |
@@ -2011,8 +2057,10 @@ 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)) { |
+ MarkLayerWithFrameNumber(layer, current_calculate_draw_properties_count); |
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 +2120,18 @@ 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_calculate_draw_properties_count); |
if (child->render_surface() && |
!child->render_surface()->layer_list().empty() && |
!child->render_surface()->content_rect().IsEmpty()) { |
+ MarkLayerWithFrameNumber(child, current_calculate_draw_properties_count); |
danakj
2014/05/05 19:25:41
then this one won't be needed any more
vmpstr
2014/05/05 20:50:34
I don't follow... The above would only mark the pa
danakj
2014/05/05 21:25:22
This pushes a child that has a render surface. But
|
descendants.push_back(child); |
} |
@@ -2328,12 +2379,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_calculate_draw_properties_count); |
// The dummy layer list should not have been used. |
DCHECK_EQ(0u, dummy_layer_list.size()); |
@@ -2356,12 +2409,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_calculate_draw_properties_count); |
// The dummy layer list should not have been used. |
DCHECK_EQ(0u, dummy_layer_list.size()); |