| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // case where we may animate to a non-singular transform and wish to | 637 // case where we may animate to a non-singular transform and wish to |
| 638 // pre-raster. | 638 // pre-raster. |
| 639 if (!HasInvertibleOrAnimatedTransform(layer)) | 639 if (!HasInvertibleOrAnimatedTransform(layer)) |
| 640 return true; | 640 return true; |
| 641 | 641 |
| 642 // When we need to do a readback/copy of a layer's output, we can not skip | 642 // When we need to do a readback/copy of a layer's output, we can not skip |
| 643 // it or any of its ancestors. | 643 // it or any of its ancestors. |
| 644 if (layer->num_copy_requests_in_target_subtree() > 0) | 644 if (layer->num_copy_requests_in_target_subtree() > 0) |
| 645 return false; | 645 return false; |
| 646 | 646 |
| 647 // We cannot skip the the subtree if a descendant has a wheel or touch handler | 647 // We cannot skip the the subtree if a descendant has a touch handler |
| 648 // or the hit testing code will break (it requires fresh transforms, etc). | 648 // or the hit testing code will break (it requires fresh transforms, etc). |
| 649 if (layer->layer_or_descendant_has_input_handler()) | 649 if (layer->layer_or_descendant_has_touch_handler()) |
| 650 return false; | 650 return false; |
| 651 | 651 |
| 652 // If the layer is not drawn, then skip it and its subtree. | 652 // If the layer is not drawn, then skip it and its subtree. |
| 653 if (!layer_is_drawn) | 653 if (!layer_is_drawn) |
| 654 return true; | 654 return true; |
| 655 | 655 |
| 656 // If layer is on the pending tree and opacity is being animated then | 656 // If layer is on the pending tree and opacity is being animated then |
| 657 // this subtree can't be skipped as we need to create, prioritize and | 657 // this subtree can't be skipped as we need to create, prioritize and |
| 658 // include tiles for this layer when deciding if tree can be activated. | 658 // include tiles for this layer when deciding if tree can be activated. |
| 659 if (layer->layer_tree_impl()->IsPendingTree() && | 659 if (layer->layer_tree_impl()->IsPendingTree() && |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 MarkLayerListWithRenderSurfaceLayerListId( | 1051 MarkLayerListWithRenderSurfaceLayerListId( |
| 1052 &layer_to_remove->render_surface()->layer_list(), 0); | 1052 &layer_to_remove->render_surface()->layer_list(), 0); |
| 1053 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); | 1053 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); |
| 1054 render_surface_layer_list->pop_back(); | 1054 render_surface_layer_list->pop_back(); |
| 1055 layer_to_remove->ClearRenderSurfaceLayerList(); | 1055 layer_to_remove->ClearRenderSurfaceLayerList(); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 struct PreCalculateMetaInformationRecursiveData { | 1058 struct PreCalculateMetaInformationRecursiveData { |
| 1059 size_t num_unclipped_descendants; | 1059 size_t num_unclipped_descendants; |
| 1060 int num_layer_or_descendants_with_copy_request; | 1060 int num_layer_or_descendants_with_copy_request; |
| 1061 int num_layer_or_descendants_with_input_handler; | 1061 int num_layer_or_descendants_with_touch_handler; |
| 1062 int num_descendants_that_draw_content; | 1062 int num_descendants_that_draw_content; |
| 1063 | 1063 |
| 1064 PreCalculateMetaInformationRecursiveData() | 1064 PreCalculateMetaInformationRecursiveData() |
| 1065 : num_unclipped_descendants(0), | 1065 : num_unclipped_descendants(0), |
| 1066 num_layer_or_descendants_with_copy_request(0), | 1066 num_layer_or_descendants_with_copy_request(0), |
| 1067 num_layer_or_descendants_with_input_handler(0), | 1067 num_layer_or_descendants_with_touch_handler(0), |
| 1068 num_descendants_that_draw_content(0) {} | 1068 num_descendants_that_draw_content(0) {} |
| 1069 | 1069 |
| 1070 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1070 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
| 1071 num_layer_or_descendants_with_copy_request += | 1071 num_layer_or_descendants_with_copy_request += |
| 1072 data.num_layer_or_descendants_with_copy_request; | 1072 data.num_layer_or_descendants_with_copy_request; |
| 1073 num_layer_or_descendants_with_input_handler += | 1073 num_layer_or_descendants_with_touch_handler += |
| 1074 data.num_layer_or_descendants_with_input_handler; | 1074 data.num_layer_or_descendants_with_touch_handler; |
| 1075 num_unclipped_descendants += data.num_unclipped_descendants; | 1075 num_unclipped_descendants += data.num_unclipped_descendants; |
| 1076 num_descendants_that_draw_content += data.num_descendants_that_draw_content; | 1076 num_descendants_that_draw_content += data.num_descendants_that_draw_content; |
| 1077 } | 1077 } |
| 1078 }; | 1078 }; |
| 1079 | 1079 |
| 1080 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { | 1080 static bool IsMetaInformationRecomputationNeeded(Layer* layer) { |
| 1081 return layer->layer_tree_host()->needs_meta_info_recomputation(); | 1081 return layer->layer_tree_host()->needs_meta_info_recomputation(); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { | 1084 static void UpdateMetaInformationSequenceNumber(Layer* root_layer) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | 1121 |
| 1122 if (layer->clip_children()) { | 1122 if (layer->clip_children()) { |
| 1123 size_t num_clip_children = layer->clip_children()->size(); | 1123 size_t num_clip_children = layer->clip_children()->size(); |
| 1124 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 1124 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
| 1125 recursive_data->num_unclipped_descendants -= num_clip_children; | 1125 recursive_data->num_unclipped_descendants -= num_clip_children; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 if (layer->HasCopyRequest()) | 1128 if (layer->HasCopyRequest()) |
| 1129 recursive_data->num_layer_or_descendants_with_copy_request++; | 1129 recursive_data->num_layer_or_descendants_with_copy_request++; |
| 1130 | 1130 |
| 1131 if (!layer->touch_event_handler_region().IsEmpty() || | 1131 if (!layer->touch_event_handler_region().IsEmpty()) |
| 1132 layer->have_wheel_event_handlers()) | 1132 recursive_data->num_layer_or_descendants_with_touch_handler++; |
| 1133 recursive_data->num_layer_or_descendants_with_input_handler++; | |
| 1134 | 1133 |
| 1135 layer->set_num_unclipped_descendants( | 1134 layer->set_num_unclipped_descendants( |
| 1136 recursive_data->num_unclipped_descendants); | 1135 recursive_data->num_unclipped_descendants); |
| 1137 | 1136 |
| 1138 if (IsRootLayer(layer)) | 1137 if (IsRootLayer(layer)) |
| 1139 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); | 1138 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); |
| 1140 } | 1139 } |
| 1141 | 1140 |
| 1142 static void PreCalculateMetaInformationInternal( | 1141 static void PreCalculateMetaInformationInternal( |
| 1143 LayerImpl* layer, | 1142 LayerImpl* layer, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1169 | 1168 |
| 1170 if (layer->clip_children()) { | 1169 if (layer->clip_children()) { |
| 1171 size_t num_clip_children = layer->clip_children()->size(); | 1170 size_t num_clip_children = layer->clip_children()->size(); |
| 1172 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 1171 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
| 1173 recursive_data->num_unclipped_descendants -= num_clip_children; | 1172 recursive_data->num_unclipped_descendants -= num_clip_children; |
| 1174 } | 1173 } |
| 1175 | 1174 |
| 1176 if (layer->HasCopyRequest()) | 1175 if (layer->HasCopyRequest()) |
| 1177 recursive_data->num_layer_or_descendants_with_copy_request++; | 1176 recursive_data->num_layer_or_descendants_with_copy_request++; |
| 1178 | 1177 |
| 1179 if (!layer->touch_event_handler_region().IsEmpty() || | 1178 if (!layer->touch_event_handler_region().IsEmpty()) |
| 1180 layer->have_wheel_event_handlers()) | 1179 recursive_data->num_layer_or_descendants_with_touch_handler++; |
| 1181 recursive_data->num_layer_or_descendants_with_input_handler++; | |
| 1182 | 1180 |
| 1183 layer->draw_properties().num_unclipped_descendants = | 1181 layer->draw_properties().num_unclipped_descendants = |
| 1184 recursive_data->num_unclipped_descendants; | 1182 recursive_data->num_unclipped_descendants; |
| 1185 layer->set_layer_or_descendant_has_input_handler( | 1183 layer->set_layer_or_descendant_has_touch_handler( |
| 1186 (recursive_data->num_layer_or_descendants_with_input_handler != 0)); | 1184 (recursive_data->num_layer_or_descendants_with_touch_handler != 0)); |
| 1187 // TODO(enne): this should be synced from the main thread, so is only | 1185 // TODO(enne): this should be synced from the main thread, so is only |
| 1188 // for tests constructing layers on the compositor thread. | 1186 // for tests constructing layers on the compositor thread. |
| 1189 layer->SetNumDescendantsThatDrawContent( | 1187 layer->SetNumDescendantsThatDrawContent( |
| 1190 recursive_data->num_descendants_that_draw_content); | 1188 recursive_data->num_descendants_that_draw_content); |
| 1191 | 1189 |
| 1192 if (layer->DrawsContent()) | 1190 if (layer->DrawsContent()) |
| 1193 recursive_data->num_descendants_that_draw_content++; | 1191 recursive_data->num_descendants_that_draw_content++; |
| 1194 } | 1192 } |
| 1195 | 1193 |
| 1196 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { | 1194 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2853 | 2851 |
| 2854 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2852 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 2855 return layer->layer_tree_host()->property_trees(); | 2853 return layer->layer_tree_host()->property_trees(); |
| 2856 } | 2854 } |
| 2857 | 2855 |
| 2858 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2856 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 2859 return layer->layer_tree_impl()->property_trees(); | 2857 return layer->layer_tree_impl()->property_trees(); |
| 2860 } | 2858 } |
| 2861 | 2859 |
| 2862 } // namespace cc | 2860 } // namespace cc |
| OLD | NEW |