| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 192 } |
| 193 page_scale_delta = proto.page_scale_delta(); | 193 page_scale_delta = proto.page_scale_delta(); |
| 194 elastic_overscroll_delta = ProtoToVector2dF(proto.elastic_overscroll_delta()); | 194 elastic_overscroll_delta = ProtoToVector2dF(proto.elastic_overscroll_delta()); |
| 195 top_controls_delta = proto.top_controls_delta(); | 195 top_controls_delta = proto.top_controls_delta(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 static inline bool IsRootLayer(const Layer* layer) { | 198 static inline bool IsRootLayer(const Layer* layer) { |
| 199 return !layer->parent(); | 199 return !layer->parent(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 template <typename LayerType> | 202 static bool HasInvertibleOrAnimatedTransform(Layer* layer) { |
| 203 static bool HasInvertibleOrAnimatedTransform(LayerType* layer) { | |
| 204 return layer->transform_is_invertible() || | 203 return layer->transform_is_invertible() || |
| 205 layer->HasPotentiallyRunningTransformAnimation(); | 204 layer->HasPotentiallyRunningTransformAnimation(); |
| 206 } | 205 } |
| 207 | 206 |
| 207 static bool HasInvertibleOrAnimatedTransformForTesting(LayerImpl* layer) { |
| 208 return layer->transform().IsInvertible() || |
| 209 layer->HasPotentiallyRunningTransformAnimation(); |
| 210 } |
| 211 |
| 208 static inline void MarkLayerWithRenderSurfaceLayerListId( | 212 static inline void MarkLayerWithRenderSurfaceLayerListId( |
| 209 LayerImpl* layer, | 213 LayerImpl* layer, |
| 210 int current_render_surface_layer_list_id) { | 214 int current_render_surface_layer_list_id) { |
| 211 layer->draw_properties().last_drawn_render_surface_layer_list_id = | 215 layer->draw_properties().last_drawn_render_surface_layer_list_id = |
| 212 current_render_surface_layer_list_id; | 216 current_render_surface_layer_list_id; |
| 213 } | 217 } |
| 214 | 218 |
| 215 static inline void MarkMasksWithRenderSurfaceLayerListId( | 219 static inline void MarkMasksWithRenderSurfaceLayerListId( |
| 216 LayerImpl* layer, | 220 LayerImpl* layer, |
| 217 int current_render_surface_layer_list_id) { | 221 int current_render_surface_layer_list_id) { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 if (IsRootLayer(layer)) | 322 if (IsRootLayer(layer)) |
| 319 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); | 323 layer->layer_tree_host()->SetNeedsMetaInfoRecomputation(false); |
| 320 } | 324 } |
| 321 | 325 |
| 322 static void PreCalculateMetaInformationInternalForTesting( | 326 static void PreCalculateMetaInformationInternalForTesting( |
| 323 LayerImpl* layer, | 327 LayerImpl* layer, |
| 324 PreCalculateMetaInformationRecursiveData* recursive_data) { | 328 PreCalculateMetaInformationRecursiveData* recursive_data) { |
| 325 if (layer->clip_parent()) | 329 if (layer->clip_parent()) |
| 326 recursive_data->num_unclipped_descendants++; | 330 recursive_data->num_unclipped_descendants++; |
| 327 | 331 |
| 328 if (!HasInvertibleOrAnimatedTransform(layer)) { | 332 if (!HasInvertibleOrAnimatedTransformForTesting(layer)) { |
| 329 // Layers with singular transforms should not be drawn, the whole subtree | 333 // Layers with singular transforms should not be drawn, the whole subtree |
| 330 // can be skipped. | 334 // can be skipped. |
| 331 return; | 335 return; |
| 332 } | 336 } |
| 333 | 337 |
| 334 for (size_t i = 0; i < layer->children().size(); ++i) { | 338 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 335 LayerImpl* child_layer = layer->child_at(i); | 339 LayerImpl* child_layer = layer->child_at(i); |
| 336 | 340 |
| 337 PreCalculateMetaInformationRecursiveData data_for_child; | 341 PreCalculateMetaInformationRecursiveData data_for_child; |
| 338 PreCalculateMetaInformationInternalForTesting(child_layer, &data_for_child); | 342 PreCalculateMetaInformationInternalForTesting(child_layer, &data_for_child); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 350 | 354 |
| 351 if (!layer->touch_event_handler_region().IsEmpty()) | 355 if (!layer->touch_event_handler_region().IsEmpty()) |
| 352 recursive_data->num_layer_or_descendants_with_touch_handler++; | 356 recursive_data->num_layer_or_descendants_with_touch_handler++; |
| 353 | 357 |
| 354 layer->draw_properties().num_unclipped_descendants = | 358 layer->draw_properties().num_unclipped_descendants = |
| 355 recursive_data->num_unclipped_descendants; | 359 recursive_data->num_unclipped_descendants; |
| 356 layer->set_layer_or_descendant_has_touch_handler( | 360 layer->set_layer_or_descendant_has_touch_handler( |
| 357 (recursive_data->num_layer_or_descendants_with_touch_handler != 0)); | 361 (recursive_data->num_layer_or_descendants_with_touch_handler != 0)); |
| 358 // TODO(enne): this should be synced from the main thread, so is only | 362 // TODO(enne): this should be synced from the main thread, so is only |
| 359 // for tests constructing layers on the compositor thread. | 363 // for tests constructing layers on the compositor thread. |
| 360 layer->SetNumDescendantsThatDrawContent( | 364 layer->test_properties()->num_descendants_that_draw_content = |
| 361 recursive_data->num_descendants_that_draw_content); | 365 recursive_data->num_descendants_that_draw_content; |
| 362 | 366 |
| 363 if (layer->DrawsContent()) | 367 if (layer->DrawsContent()) |
| 364 recursive_data->num_descendants_that_draw_content++; | 368 recursive_data->num_descendants_that_draw_content++; |
| 365 } | 369 } |
| 366 | 370 |
| 367 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { | 371 void LayerTreeHostCommon::PreCalculateMetaInformation(Layer* root_layer) { |
| 368 PreCalculateMetaInformationRecursiveData recursive_data; | 372 PreCalculateMetaInformationRecursiveData recursive_data; |
| 369 PreCalculateMetaInformationInternal(root_layer, &recursive_data); | 373 PreCalculateMetaInformationInternal(root_layer, &recursive_data); |
| 370 } | 374 } |
| 371 | 375 |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 | 867 |
| 864 PropertyTrees* GetPropertyTrees(Layer* layer) { | 868 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 865 return layer->layer_tree_host()->property_trees(); | 869 return layer->layer_tree_host()->property_trees(); |
| 866 } | 870 } |
| 867 | 871 |
| 868 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 872 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 869 return layer->layer_tree_impl()->property_trees(); | 873 return layer->layer_tree_impl()->property_trees(); |
| 870 } | 874 } |
| 871 | 875 |
| 872 } // namespace cc | 876 } // namespace cc |
| OLD | NEW |