| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 gfx::Rect LayerTreeHostCommon::CalculateVisibleRect( | 236 gfx::Rect LayerTreeHostCommon::CalculateVisibleRect( |
| 237 const gfx::Rect& target_surface_rect, | 237 const gfx::Rect& target_surface_rect, |
| 238 const gfx::Rect& layer_bound_rect, | 238 const gfx::Rect& layer_bound_rect, |
| 239 const gfx::Transform& transform) { | 239 const gfx::Transform& transform) { |
| 240 gfx::Rect layer_in_surface_space = | 240 gfx::Rect layer_in_surface_space = |
| 241 MathUtil::MapEnclosingClippedRect(transform, layer_bound_rect); | 241 MathUtil::MapEnclosingClippedRect(transform, layer_bound_rect); |
| 242 return CalculateVisibleRectWithCachedLayerRect( | 242 return CalculateVisibleRectWithCachedLayerRect( |
| 243 target_surface_rect, layer_bound_rect, layer_in_surface_space, transform); | 243 target_surface_rect, layer_bound_rect, layer_in_surface_space, transform); |
| 244 } | 244 } |
| 245 | 245 |
| 246 template <typename LayerType> | 246 static inline bool IsRootLayer(const Layer* layer) { |
| 247 static inline bool IsRootLayer(LayerType* layer) { | |
| 248 return !layer->parent(); | 247 return !layer->parent(); |
| 249 } | 248 } |
| 250 | 249 |
| 250 static inline bool IsRootLayer(const LayerImpl* layer) { |
| 251 return layer->layer_tree_impl()->IsRootLayer(layer); |
| 252 } |
| 253 |
| 251 template <typename LayerType> | 254 template <typename LayerType> |
| 252 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | 255 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { |
| 253 return layer->Is3dSorted() && layer->parent() && | 256 return layer->Is3dSorted() && layer->parent() && |
| 254 layer->parent()->Is3dSorted() && | 257 layer->parent()->Is3dSorted() && |
| 255 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); | 258 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); |
| 256 } | 259 } |
| 257 | 260 |
| 258 static bool IsRootLayerOfNewRenderingContext(LayerImpl* layer) { | 261 static bool IsRootLayerOfNewRenderingContext(LayerImpl* layer) { |
| 259 if (layer->parent()) | 262 if (layer->parent()) |
| 260 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); | 263 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // into this function, so it is safe to omit this check here. | 317 // into this function, so it is safe to omit this check here. |
| 315 | 318 |
| 316 if (!layer_is_drawn) | 319 if (!layer_is_drawn) |
| 317 return true; | 320 return true; |
| 318 | 321 |
| 319 if (!layer->DrawsContent() || layer->bounds().IsEmpty()) | 322 if (!layer->DrawsContent() || layer->bounds().IsEmpty()) |
| 320 return true; | 323 return true; |
| 321 | 324 |
| 322 LayerImpl* backface_test_layer = layer; | 325 LayerImpl* backface_test_layer = layer; |
| 323 if (layer->use_parent_backface_visibility()) { | 326 if (layer->use_parent_backface_visibility()) { |
| 324 DCHECK(layer->parent()); | 327 DCHECK(!IsRootLayer(layer)); |
| 325 DCHECK(!layer->parent()->use_parent_backface_visibility()); | 328 DCHECK(!layer->parent()->use_parent_backface_visibility()); |
| 326 backface_test_layer = layer->parent(); | 329 backface_test_layer = layer->parent(); |
| 327 } | 330 } |
| 328 | 331 |
| 329 // The layer should not be drawn if (1) it is not double-sided and (2) the | 332 // The layer should not be drawn if (1) it is not double-sided and (2) the |
| 330 // back of the layer is known to be facing the screen. | 333 // back of the layer is known to be facing the screen. |
| 331 if (!backface_test_layer->double_sided() && | 334 if (!backface_test_layer->double_sided() && |
| 332 IsLayerBackFaceVisible(backface_test_layer, transform_tree)) | 335 IsLayerBackFaceVisible(backface_test_layer, transform_tree)) |
| 333 return true; | 336 return true; |
| 334 | 337 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 layer->draw_properties().render_target = layer; | 706 layer->draw_properties().render_target = layer; |
| 704 | 707 |
| 705 if (layer->mask_layer()) | 708 if (layer->mask_layer()) |
| 706 layer->mask_layer()->draw_properties().render_target = layer; | 709 layer->mask_layer()->draw_properties().render_target = layer; |
| 707 | 710 |
| 708 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) | 711 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) |
| 709 layer->replica_layer()->mask_layer()->draw_properties().render_target = | 712 layer->replica_layer()->mask_layer()->draw_properties().render_target = |
| 710 layer; | 713 layer; |
| 711 | 714 |
| 712 } else { | 715 } else { |
| 713 DCHECK(layer->parent()); | 716 DCHECK(!IsRootLayer(layer)); |
| 714 layer->draw_properties().render_target = layer->parent()->render_target(); | 717 layer->draw_properties().render_target = layer->parent()->render_target(); |
| 715 } | 718 } |
| 716 | 719 |
| 717 for (size_t i = 0; i < layer->children().size(); ++i) { | 720 for (size_t i = 0; i < layer->children().size(); ++i) { |
| 718 CalculateRenderTarget( | 721 CalculateRenderTarget( |
| 719 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), | 722 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), |
| 720 property_trees, layer_is_drawn, can_render_to_separate_surface); | 723 property_trees, layer_is_drawn, can_render_to_separate_surface); |
| 721 } | 724 } |
| 722 } | 725 } |
| 723 | 726 |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 | 1121 |
| 1119 PropertyTrees* GetPropertyTrees(Layer* layer) { | 1122 PropertyTrees* GetPropertyTrees(Layer* layer) { |
| 1120 return layer->layer_tree_host()->property_trees(); | 1123 return layer->layer_tree_host()->property_trees(); |
| 1121 } | 1124 } |
| 1122 | 1125 |
| 1123 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 1126 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
| 1124 return layer->layer_tree_impl()->property_trees(); | 1127 return layer->layer_tree_impl()->property_trees(); |
| 1125 } | 1128 } |
| 1126 | 1129 |
| 1127 } // namespace cc | 1130 } // namespace cc |
| OLD | NEW |