OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/property_tree_builder.h" | 5 #include "cc/trees/property_tree_builder.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 448 |
449 data_for_children->clip_tree_parent = | 449 data_for_children->clip_tree_parent = |
450 data_for_children->property_trees->clip_tree.Insert(node, parent_id); | 450 data_for_children->property_trees->clip_tree.Insert(node, parent_id); |
451 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = | 451 data_for_children->property_trees->clip_id_to_index_map[layer->id()] = |
452 data_for_children->clip_tree_parent; | 452 data_for_children->clip_tree_parent; |
453 } | 453 } |
454 | 454 |
455 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); | 455 layer->SetClipTreeIndex(data_for_children->clip_tree_parent); |
456 } | 456 } |
457 | 457 |
| 458 static inline int SortingContextId(Layer* layer) { |
| 459 return layer->sorting_context_id(); |
| 460 } |
| 461 |
| 462 static inline int SortingContextId(LayerImpl* layer) { |
| 463 return layer->test_properties()->sorting_context_id; |
| 464 } |
| 465 |
| 466 static inline bool Is3dSorted(Layer* layer) { |
| 467 return layer->Is3dSorted(); |
| 468 } |
| 469 |
| 470 static inline bool Is3dSorted(LayerImpl* layer) { |
| 471 return layer->test_properties()->sorting_context_id != 0; |
| 472 } |
| 473 |
458 template <typename LayerType> | 474 template <typename LayerType> |
459 static inline bool IsAtBoundaryOf3dRenderingContext(LayerType* layer) { | 475 static inline bool IsAtBoundaryOf3dRenderingContext(LayerType* layer) { |
460 return Parent(layer) | 476 return Parent(layer) |
461 ? Parent(layer)->sorting_context_id() != | 477 ? SortingContextId(Parent(layer)) != SortingContextId(layer) |
462 layer->sorting_context_id() | 478 : Is3dSorted(layer); |
463 : layer->Is3dSorted(); | |
464 } | 479 } |
465 | 480 |
466 static inline gfx::Point3F TransformOrigin(Layer* layer) { | 481 static inline gfx::Point3F TransformOrigin(Layer* layer) { |
467 return layer->transform_origin(); | 482 return layer->transform_origin(); |
468 } | 483 } |
469 | 484 |
470 static inline gfx::Point3F TransformOrigin(LayerImpl* layer) { | 485 static inline gfx::Point3F TransformOrigin(LayerImpl* layer) { |
471 return layer->test_properties()->transform_origin; | 486 return layer->test_properties()->transform_origin; |
472 } | 487 } |
473 | 488 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 TransformNode* node = | 619 TransformNode* node = |
605 data_for_children->property_trees->transform_tree.back(); | 620 data_for_children->property_trees->transform_tree.back(); |
606 layer->SetTransformTreeIndex(node->id); | 621 layer->SetTransformTreeIndex(node->id); |
607 data_for_children->property_trees->transform_id_to_index_map[layer->id()] = | 622 data_for_children->property_trees->transform_id_to_index_map[layer->id()] = |
608 node->id; | 623 node->id; |
609 | 624 |
610 node->scrolls = is_scrollable; | 625 node->scrolls = is_scrollable; |
611 node->should_be_snapped = is_snapped; | 626 node->should_be_snapped = is_snapped; |
612 node->flattens_inherited_transform = data_for_children->should_flatten; | 627 node->flattens_inherited_transform = data_for_children->should_flatten; |
613 | 628 |
614 node->sorting_context_id = layer->sorting_context_id(); | 629 node->sorting_context_id = SortingContextId(layer); |
615 | 630 |
616 if (layer == data_from_ancestor.page_scale_layer) | 631 if (layer == data_from_ancestor.page_scale_layer) |
617 data_for_children->in_subtree_of_page_scale_layer = true; | 632 data_for_children->in_subtree_of_page_scale_layer = true; |
618 node->in_subtree_of_page_scale_layer = | 633 node->in_subtree_of_page_scale_layer = |
619 data_for_children->in_subtree_of_page_scale_layer; | 634 data_for_children->in_subtree_of_page_scale_layer; |
620 | 635 |
621 // Surfaces inherently flatten transforms. | 636 // Surfaces inherently flatten transforms. |
622 data_for_children->should_flatten = | 637 data_for_children->should_flatten = |
623 ShouldFlattenTransform(layer) || has_surface; | 638 ShouldFlattenTransform(layer) || has_surface; |
624 DCHECK_GT(data_from_ancestor.property_trees->effect_tree.size(), 0u); | 639 DCHECK_GT(data_from_ancestor.property_trees->effect_tree.size(), 0u); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 static inline bool ForceRenderSurface(Layer* layer) { | 781 static inline bool ForceRenderSurface(Layer* layer) { |
767 return layer->force_render_surface_for_testing(); | 782 return layer->force_render_surface_for_testing(); |
768 } | 783 } |
769 | 784 |
770 static inline bool ForceRenderSurface(LayerImpl* layer) { | 785 static inline bool ForceRenderSurface(LayerImpl* layer) { |
771 return layer->test_properties()->force_render_surface; | 786 return layer->test_properties()->force_render_surface; |
772 } | 787 } |
773 | 788 |
774 template <typename LayerType> | 789 template <typename LayerType> |
775 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | 790 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { |
776 return layer->Is3dSorted() && Parent(layer) && Parent(layer)->Is3dSorted() && | 791 return Is3dSorted(layer) && Parent(layer) && Is3dSorted(Parent(layer)) && |
777 (Parent(layer)->sorting_context_id() == layer->sorting_context_id()); | 792 (SortingContextId(Parent(layer)) == SortingContextId(layer)); |
778 } | 793 } |
779 | 794 |
780 static inline bool IsRootForIsolatedGroup(Layer* layer) { | 795 static inline bool IsRootForIsolatedGroup(Layer* layer) { |
781 return layer->is_root_for_isolated_group(); | 796 return layer->is_root_for_isolated_group(); |
782 } | 797 } |
783 | 798 |
784 static inline bool IsRootForIsolatedGroup(LayerImpl* layer) { | 799 static inline bool IsRootForIsolatedGroup(LayerImpl* layer) { |
785 return false; | 800 return false; |
786 } | 801 } |
787 | 802 |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 Parent(layer)->use_local_transform_for_backface_visibility()); | 1204 Parent(layer)->use_local_transform_for_backface_visibility()); |
1190 layer->SetShouldCheckBackfaceVisibility( | 1205 layer->SetShouldCheckBackfaceVisibility( |
1191 Parent(layer)->should_check_backface_visibility()); | 1206 Parent(layer)->should_check_backface_visibility()); |
1192 } else { | 1207 } else { |
1193 // The current W3C spec on CSS transforms says that backface visibility | 1208 // The current W3C spec on CSS transforms says that backface visibility |
1194 // should be determined differently depending on whether the layer is in a | 1209 // should be determined differently depending on whether the layer is in a |
1195 // "3d rendering context" or not. For Chromium code, we can determine | 1210 // "3d rendering context" or not. For Chromium code, we can determine |
1196 // whether we are in a 3d rendering context by checking if the parent | 1211 // whether we are in a 3d rendering context by checking if the parent |
1197 // preserves 3d. | 1212 // preserves 3d. |
1198 const bool use_local_transform = | 1213 const bool use_local_transform = |
1199 !layer->Is3dSorted() || | 1214 !Is3dSorted(layer) || |
1200 (layer->Is3dSorted() && is_at_boundary_of_3d_rendering_context); | 1215 (Is3dSorted(layer) && is_at_boundary_of_3d_rendering_context); |
1201 layer->SetUseLocalTransformForBackfaceVisibility(use_local_transform); | 1216 layer->SetUseLocalTransformForBackfaceVisibility(use_local_transform); |
1202 | 1217 |
1203 // A double-sided layer's backface can been shown when its visibile. | 1218 // A double-sided layer's backface can been shown when its visibile. |
1204 if (DoubleSided(layer)) | 1219 if (DoubleSided(layer)) |
1205 layer->SetShouldCheckBackfaceVisibility(false); | 1220 layer->SetShouldCheckBackfaceVisibility(false); |
1206 // The backface of a layer that uses local transform for backface visibility | 1221 // The backface of a layer that uses local transform for backface visibility |
1207 // is not visible when it does not create a transform node as its local | 1222 // is not visible when it does not create a transform node as its local |
1208 // transform is identity or 2d translation and is not animating. | 1223 // transform is identity or 2d translation and is not animating. |
1209 else if (use_local_transform && !created_transform_node) | 1224 else if (use_local_transform && !created_transform_node) |
1210 layer->SetShouldCheckBackfaceVisibility(false); | 1225 layer->SetShouldCheckBackfaceVisibility(false); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 color = SkColorSetA(color, 255); | 1517 color = SkColorSetA(color, 255); |
1503 BuildPropertyTreesTopLevelInternal( | 1518 BuildPropertyTreesTopLevelInternal( |
1504 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1519 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1505 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1520 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1506 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1521 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1507 device_transform, property_trees, color); | 1522 device_transform, property_trees, color); |
1508 property_trees->ResetCachedData(); | 1523 property_trees->ResetCachedData(); |
1509 } | 1524 } |
1510 | 1525 |
1511 } // namespace cc | 1526 } // namespace cc |
OLD | NEW |