OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 | 604 |
605 SetSubtreePropertyChanged(); | 605 SetSubtreePropertyChanged(); |
606 PropertyTrees* property_trees = layer_tree_->property_trees(); | 606 PropertyTrees* property_trees = layer_tree_->property_trees(); |
607 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 607 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
608 id())) { | 608 id())) { |
609 DCHECK_EQ(transform_tree_index(), | 609 DCHECK_EQ(transform_tree_index(), |
610 property_trees->transform_id_to_index_map[id()]); | 610 property_trees->transform_id_to_index_map[id()]); |
611 TransformNode* transform_node = | 611 TransformNode* transform_node = |
612 property_trees->transform_tree.Node(transform_tree_index()); | 612 property_trees->transform_tree.Node(transform_tree_index()); |
613 transform_node->update_post_local_transform(position, transform_origin()); | 613 transform_node->update_post_local_transform(position, transform_origin()); |
| 614 if (transform_node->sticky_position_constraint_id >= 0) { |
| 615 StickyPositionNodeData* sticky_data = |
| 616 property_trees->transform_tree.StickyPositionData( |
| 617 transform_tree_index()); |
| 618 sticky_data->main_thread_offset = |
| 619 position.OffsetFromOrigin() - |
| 620 sticky_data->constraints.absolute_sticky_box_rect.OffsetFromOrigin(); |
| 621 } |
614 transform_node->needs_local_transform_update = true; | 622 transform_node->needs_local_transform_update = true; |
615 transform_node->transform_changed = true; | 623 transform_node->transform_changed = true; |
616 layer_tree_->property_trees()->transform_tree.set_needs_update(true); | 624 layer_tree_->property_trees()->transform_tree.set_needs_update(true); |
617 SetNeedsCommitNoRebuild(); | 625 SetNeedsCommitNoRebuild(); |
618 return; | 626 return; |
619 } | 627 } |
620 | 628 |
621 SetNeedsCommit(); | 629 SetNeedsCommit(); |
622 } | 630 } |
623 | 631 |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 } | 1110 } |
1103 | 1111 |
1104 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { | 1112 void Layer::SetPositionConstraint(const LayerPositionConstraint& constraint) { |
1105 DCHECK(IsPropertyChangeAllowed()); | 1113 DCHECK(IsPropertyChangeAllowed()); |
1106 if (inputs_.position_constraint == constraint) | 1114 if (inputs_.position_constraint == constraint) |
1107 return; | 1115 return; |
1108 inputs_.position_constraint = constraint; | 1116 inputs_.position_constraint = constraint; |
1109 SetNeedsCommit(); | 1117 SetNeedsCommit(); |
1110 } | 1118 } |
1111 | 1119 |
| 1120 void Layer::SetStickyPositionConstraint( |
| 1121 const LayerStickyPositionConstraint& constraint) { |
| 1122 DCHECK(IsPropertyChangeAllowed()); |
| 1123 if (inputs_.sticky_position_constraint == constraint) |
| 1124 return; |
| 1125 inputs_.sticky_position_constraint = constraint; |
| 1126 SetNeedsCommit(); |
| 1127 } |
| 1128 |
1112 static void RunCopyCallbackOnMainThread( | 1129 static void RunCopyCallbackOnMainThread( |
1113 std::unique_ptr<CopyOutputRequest> request, | 1130 std::unique_ptr<CopyOutputRequest> request, |
1114 std::unique_ptr<CopyOutputResult> result) { | 1131 std::unique_ptr<CopyOutputResult> result) { |
1115 request->SendResult(std::move(result)); | 1132 request->SendResult(std::move(result)); |
1116 } | 1133 } |
1117 | 1134 |
1118 static void PostCopyCallbackToMainThread( | 1135 static void PostCopyCallbackToMainThread( |
1119 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1136 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
1120 std::unique_ptr<CopyOutputRequest> request, | 1137 std::unique_ptr<CopyOutputRequest> request, |
1121 std::unique_ptr<CopyOutputResult> result) { | 1138 std::unique_ptr<CopyOutputResult> result) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 layer->SetMasksToBounds(inputs_.masks_to_bounds); | 1177 layer->SetMasksToBounds(inputs_.masks_to_bounds); |
1161 layer->set_main_thread_scrolling_reasons( | 1178 layer->set_main_thread_scrolling_reasons( |
1162 inputs_.main_thread_scrolling_reasons); | 1179 inputs_.main_thread_scrolling_reasons); |
1163 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); | 1180 layer->SetNonFastScrollableRegion(inputs_.non_fast_scrollable_region); |
1164 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); | 1181 layer->SetTouchEventHandlerRegion(inputs_.touch_event_handler_region); |
1165 layer->SetContentsOpaque(inputs_.contents_opaque); | 1182 layer->SetContentsOpaque(inputs_.contents_opaque); |
1166 layer->SetPosition(inputs_.position); | 1183 layer->SetPosition(inputs_.position); |
1167 layer->set_should_flatten_transform_from_property_tree( | 1184 layer->set_should_flatten_transform_from_property_tree( |
1168 should_flatten_transform_from_property_tree_); | 1185 should_flatten_transform_from_property_tree_); |
1169 layer->set_draw_blend_mode(draw_blend_mode_); | 1186 layer->set_draw_blend_mode(draw_blend_mode_); |
| 1187 layer->SetStickyPositionConstraint(inputs_.sticky_position_constraint); |
1170 layer->SetUseParentBackfaceVisibility(inputs_.use_parent_backface_visibility); | 1188 layer->SetUseParentBackfaceVisibility(inputs_.use_parent_backface_visibility); |
1171 layer->SetUseLocalTransformForBackfaceVisibility( | 1189 layer->SetUseLocalTransformForBackfaceVisibility( |
1172 use_local_transform_for_backface_visibility_); | 1190 use_local_transform_for_backface_visibility_); |
1173 layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_); | 1191 layer->SetShouldCheckBackfaceVisibility(should_check_backface_visibility_); |
1174 layer->Set3dSortingContextId(inputs_.sorting_context_id); | 1192 layer->Set3dSortingContextId(inputs_.sorting_context_id); |
1175 | 1193 |
1176 layer->SetScrollClipLayer(inputs_.scroll_clip_layer_id); | 1194 layer->SetScrollClipLayer(inputs_.scroll_clip_layer_id); |
1177 layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); | 1195 layer->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); |
1178 layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); | 1196 layer->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); |
1179 layer->SetElementId(inputs_.element_id); | 1197 layer->SetElementId(inputs_.element_id); |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1900 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1883 return draw_property_utils::ScreenSpaceTransform( | 1901 return draw_property_utils::ScreenSpaceTransform( |
1884 this, layer_tree_->property_trees()->transform_tree); | 1902 this, layer_tree_->property_trees()->transform_tree); |
1885 } | 1903 } |
1886 | 1904 |
1887 LayerTree* Layer::GetLayerTree() const { | 1905 LayerTree* Layer::GetLayerTree() const { |
1888 return layer_tree_; | 1906 return layer_tree_; |
1889 } | 1907 } |
1890 | 1908 |
1891 } // namespace cc | 1909 } // namespace cc |
OLD | NEW |