Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: cc/trees/property_tree_builder.cc

Issue 2251303003: Implement position: sticky updates on compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and add unit test for impl side sticky position update. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 const DataForRecursion<LayerType>& data_from_ancestor, 483 const DataForRecursion<LayerType>& data_from_ancestor,
484 LayerType* layer, 484 LayerType* layer,
485 bool created_render_surface, 485 bool created_render_surface,
486 DataForRecursion<LayerType>* data_for_children) { 486 DataForRecursion<LayerType>* data_for_children) {
487 const bool is_root = !Parent(layer); 487 const bool is_root = !Parent(layer);
488 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer; 488 const bool is_page_scale_layer = layer == data_from_ancestor.page_scale_layer;
489 const bool is_overscroll_elasticity_layer = 489 const bool is_overscroll_elasticity_layer =
490 layer == data_from_ancestor.overscroll_elasticity_layer; 490 layer == data_from_ancestor.overscroll_elasticity_layer;
491 const bool is_scrollable = layer->scrollable(); 491 const bool is_scrollable = layer->scrollable();
492 const bool is_fixed = PositionConstraint(layer).is_fixed_position(); 492 const bool is_fixed = PositionConstraint(layer).is_fixed_position();
493 const bool is_sticky = layer->sticky_position_constraint().is_sticky;
493 494
494 const bool has_significant_transform = 495 const bool has_significant_transform =
495 !Transform(layer).IsIdentityOr2DTranslation(); 496 !Transform(layer).IsIdentityOr2DTranslation();
496 497
497 const bool has_potentially_animated_transform = 498 const bool has_potentially_animated_transform =
498 HasPotentiallyRunningTransformAnimation(layer); 499 HasPotentiallyRunningTransformAnimation(layer);
499 500
500 // A transform node is needed even for a finished animation, since differences 501 // A transform node is needed even for a finished animation, since differences
501 // in the timing of animation state updates can mean that an animation that's 502 // in the timing of animation state updates can mean that an animation that's
502 // in the Finished state at tree-building time on the main thread is still in 503 // in the Finished state at tree-building time on the main thread is still in
(...skipping 14 matching lines...) Expand all
517 Parent(layer)->effect_tree_index() != 518 Parent(layer)->effect_tree_index() !=
518 ScrollParent(layer)->effect_tree_index(); 519 ScrollParent(layer)->effect_tree_index();
519 520
520 const bool is_at_boundary_of_3d_rendering_context = 521 const bool is_at_boundary_of_3d_rendering_context =
521 IsAtBoundaryOf3dRenderingContext(layer); 522 IsAtBoundaryOf3dRenderingContext(layer);
522 523
523 bool requires_node = is_root || is_scrollable || has_significant_transform || 524 bool requires_node = is_root || is_scrollable || has_significant_transform ||
524 has_any_transform_animation || has_surface || is_fixed || 525 has_any_transform_animation || has_surface || is_fixed ||
525 is_page_scale_layer || is_overscroll_elasticity_layer || 526 is_page_scale_layer || is_overscroll_elasticity_layer ||
526 has_proxied_transform_related_property || 527 has_proxied_transform_related_property ||
527 scroll_child_has_different_target || 528 scroll_child_has_different_target || is_sticky ||
528 is_at_boundary_of_3d_rendering_context; 529 is_at_boundary_of_3d_rendering_context;
529 530
530 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer); 531 LayerType* transform_parent = GetTransformParent(data_from_ancestor, layer);
531 DCHECK(is_root || transform_parent); 532 DCHECK(is_root || transform_parent);
532 533
533 int parent_index = kRootPropertyTreeNodeId; 534 int parent_index = kRootPropertyTreeNodeId;
534 if (transform_parent) 535 if (transform_parent)
535 parent_index = transform_parent->transform_tree_index(); 536 parent_index = transform_parent->transform_tree_index();
536 537
537 int source_index = parent_index; 538 int source_index = parent_index;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 node->affected_by_outer_viewport_bounds_delta_y) { 685 node->affected_by_outer_viewport_bounds_delta_y) {
685 data_for_children->property_trees->transform_tree 686 data_for_children->property_trees->transform_tree
686 .AddNodeAffectedByOuterViewportBoundsDelta(node->id); 687 .AddNodeAffectedByOuterViewportBoundsDelta(node->id);
687 } 688 }
688 } 689 }
689 } 690 }
690 691
691 node->local = Transform(layer); 692 node->local = Transform(layer);
692 node->update_pre_local_transform(TransformOrigin(layer)); 693 node->update_pre_local_transform(TransformOrigin(layer));
693 694
695 if (layer->sticky_position_constraint().is_sticky) {
696 StickyPositionNodeData* sticky_data =
697 data_for_children->property_trees->transform_tree.StickyPositionData(
698 node->id);
699 sticky_data->constraints = layer->sticky_position_constraint();
700 sticky_data->scroll_ancestor = GetScrollParentId(data_from_ancestor, layer);
701 sticky_data->main_thread_offset =
702 layer->position().OffsetFromOrigin() -
703 sticky_data->constraints.absolute_sticky_box_rect.OffsetFromOrigin();
704 } else {
705 data_for_children->property_trees->transform_tree.SetNotSticky(node->id);
706 }
707
694 node->needs_local_transform_update = true; 708 node->needs_local_transform_update = true;
695 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id); 709 data_from_ancestor.property_trees->transform_tree.UpdateTransforms(node->id);
696 710
697 layer->set_offset_to_transform_parent(gfx::Vector2dF()); 711 layer->set_offset_to_transform_parent(gfx::Vector2dF());
698 712
699 // Flattening (if needed) will be handled by |node|. 713 // Flattening (if needed) will be handled by |node|.
700 layer->set_should_flatten_transform_from_property_tree(false); 714 layer->set_should_flatten_transform_from_property_tree(false);
701 715
702 node->owner_id = layer->id(); 716 node->owner_id = layer->id();
703 717
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 color = SkColorSetA(color, 255); 1492 color = SkColorSetA(color, 255);
1479 BuildPropertyTreesTopLevelInternal( 1493 BuildPropertyTreesTopLevelInternal(
1480 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1494 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1481 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1495 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1482 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1496 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1483 device_transform, property_trees, color); 1497 device_transform, property_trees, color);
1484 property_trees->ResetCachedData(); 1498 property_trees->ResetCachedData();
1485 } 1499 }
1486 1500
1487 } // namespace cc 1501 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698