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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 }; | 74 }; |
75 | 75 |
76 static LayerPositionConstraint PositionConstraint(Layer* layer) { | 76 static LayerPositionConstraint PositionConstraint(Layer* layer) { |
77 return layer->position_constraint(); | 77 return layer->position_constraint(); |
78 } | 78 } |
79 | 79 |
80 static LayerPositionConstraint PositionConstraint(LayerImpl* layer) { | 80 static LayerPositionConstraint PositionConstraint(LayerImpl* layer) { |
81 return layer->test_properties()->position_constraint; | 81 return layer->test_properties()->position_constraint; |
82 } | 82 } |
83 | 83 |
| 84 static LayerStickyPositionConstraint StickyPositionConstraint(Layer* layer) { |
| 85 return layer->sticky_position_constraint(); |
| 86 } |
| 87 |
| 88 static LayerStickyPositionConstraint StickyPositionConstraint( |
| 89 LayerImpl* layer) { |
| 90 return layer->test_properties()->sticky_position_constraint; |
| 91 } |
| 92 |
84 struct PreCalculateMetaInformationRecursiveData { | 93 struct PreCalculateMetaInformationRecursiveData { |
85 size_t num_unclipped_descendants; | 94 size_t num_unclipped_descendants; |
86 int num_descendants_that_draw_content; | 95 int num_descendants_that_draw_content; |
87 | 96 |
88 PreCalculateMetaInformationRecursiveData() | 97 PreCalculateMetaInformationRecursiveData() |
89 : num_unclipped_descendants(0), | 98 : num_unclipped_descendants(0), |
90 num_descendants_that_draw_content(0) {} | 99 num_descendants_that_draw_content(0) {} |
91 | 100 |
92 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 101 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
93 num_unclipped_descendants += data.num_unclipped_descendants; | 102 num_unclipped_descendants += data.num_unclipped_descendants; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 const DataForRecursion<LayerType>& data_from_ancestor, | 493 const DataForRecursion<LayerType>& data_from_ancestor, |
485 LayerType* layer, | 494 LayerType* layer, |
486 bool created_render_surface, | 495 bool created_render_surface, |
487 DataForRecursion<LayerType>* data_for_children) { | 496 DataForRecursion<LayerType>* data_for_children) { |
488 const bool is_root = !Parent(layer); | 497 const bool is_root = !Parent(layer); |
489 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; | 498 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; |
490 const bool is_overscroll_elasticity_layer = | 499 const bool is_overscroll_elasticity_layer = |
491 layer == data_from_ancestor.overscroll_elasticity_layer; | 500 layer == data_from_ancestor.overscroll_elasticity_layer; |
492 const bool is_scrollable = layer->scrollable(); | 501 const bool is_scrollable = layer->scrollable(); |
493 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); | 502 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); |
| 503 const bool is_sticky = StickyPositionConstraint(layer).is_sticky; |
494 | 504 |
495 const bool has_significant_transform = | 505 const bool has_significant_transform = |
496 !Transform(layer).IsIdentityOr2DTranslation(); | 506 !Transform(layer).IsIdentityOr2DTranslation(); |
497 | 507 |
498 const bool has_potentially_animated_transform = | 508 const bool has_potentially_animated_transform = |
499 HasPotentiallyRunningTransformAnimation(layer); | 509 HasPotentiallyRunningTransformAnimation(layer); |
500 | 510 |
501 // A transform node is needed even for a finished animation, since differences | 511 // A transform node is needed even for a finished animation, since differences |
502 // in the timing of animation state updates can mean that an animation that's | 512 // in the timing of animation state updates can mean that an animation that's |
503 // in the Finished state at tree-building time on the main thread is still in | 513 // in the Finished state at tree-building time on the main thread is still in |
(...skipping 14 matching lines...) Expand all Loading... |
518 Parent(layer)->effect_tree_index() != | 528 Parent(layer)->effect_tree_index() != |
519 ScrollParent(layer)->effect_tree_index(); | 529 ScrollParent(layer)->effect_tree_index(); |
520 | 530 |
521 const bool is_at_boundary_of_3d_rendering_context = | 531 const bool is_at_boundary_of_3d_rendering_context = |
522 IsAtBoundaryOf3dRenderingContext(layer); | 532 IsAtBoundaryOf3dRenderingContext(layer); |
523 | 533 |
524 bool requires_node = is_root || is_scrollable || has_significant_transform || | 534 bool requires_node = is_root || is_scrollable || has_significant_transform || |
525 has_any_transform_animation || has_surface || is_fixed || | 535 has_any_transform_animation || has_surface || is_fixed || |
526 is_page_scale_layer || is_overscroll_elasticity_layer || | 536 is_page_scale_layer || is_overscroll_elasticity_layer || |
527 has_proxied_transform_related_property || | 537 has_proxied_transform_related_property || |
528 scroll_child_has_different_target || | 538 scroll_child_has_different_target || is_sticky || |
529 is_at_boundary_of_3d_rendering_context; | 539 is_at_boundary_of_3d_rendering_context; |
530 | 540 |
531 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); | 541 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); |
532 DCHECK(is_root || transform_parent); | 542 DCHECK(is_root || transform_parent); |
533 | 543 |
534 int parent_index = kRootPropertyTreeNodeId; | 544 int parent_index = kRootPropertyTreeNodeId; |
535 if (transform_parent) | 545 if (transform_parent) |
536 parent_index = transform_parent->transform_tree_index(); | 546 parent_index = transform_parent->transform_tree_index(); |
537 | 547 |
538 int source_index = parent_index; | 548 int source_index = parent_index; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 node->affected_by_outer_viewport_bounds_delta_y) { | 695 node->affected_by_outer_viewport_bounds_delta_y) { |
686 data_for_children->property_trees->transform_tree | 696 data_for_children->property_trees->transform_tree |
687 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); | 697 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); |
688 } | 698 } |
689 } | 699 } |
690 } | 700 } |
691 | 701 |
692 node->local = Transform(layer); | 702 node->local = Transform(layer); |
693 node->update_pre_local_transform(TransformOrigin(layer)); | 703 node->update_pre_local_transform(TransformOrigin(layer)); |
694 | 704 |
| 705 if (StickyPositionConstraint(layer).is_sticky) { |
| 706 StickyPositionNodeData* sticky_data = |
| 707 data_for_children->property_trees->transform_tree.StickyPositionData( |
| 708 node->id); |
| 709 sticky_data->constraints = StickyPositionConstraint(layer); |
| 710 sticky_data->scroll_ancestor = GetScrollParentId(data_from_ancestor, layer); |
| 711 sticky_data->main_thread_offset = |
| 712 layer->position().OffsetFromOrigin() - |
| 713 sticky_data->constraints.scroll_container_relative_sticky_box_rect |
| 714 .OffsetFromOrigin(); |
| 715 } |
| 716 |
695 node->needs_local_transform_update = true; | 717 node->needs_local_transform_update = true; |
696 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); | 718 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); |
697 | 719 |
698 layer->set_offset_to_transform_parent(gfx::Vector2dF()); | 720 layer->set_offset_to_transform_parent(gfx::Vector2dF()); |
699 | 721 |
700 // Flattening (if needed) will be handled by |node|. | 722 // Flattening (if needed) will be handled by |node|. |
701 layer->set_should_flatten_transform_from_property_tree(false); | 723 layer->set_should_flatten_transform_from_property_tree(false); |
702 | 724 |
703 node->owner_id = layer->id(); | 725 node->owner_id = layer->id(); |
704 | 726 |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 color = SkColorSetA(color, 255); | 1501 color = SkColorSetA(color, 255); |
1480 BuildPropertyTreesTopLevelInternal( | 1502 BuildPropertyTreesTopLevelInternal( |
1481 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 1503 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
1482 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 1504 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
1483 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, | 1505 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, |
1484 device_transform, property_trees, color); | 1506 device_transform, property_trees, color); |
1485 property_trees->ResetCachedData(); | 1507 property_trees->ResetCachedData(); |
1486 } | 1508 } |
1487 | 1509 |
1488 } // namespace cc | 1510 } // namespace cc |
OLD | NEW |