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 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 | 590 |
591 if (!layer_tree_host_) | 591 if (!layer_tree_host_) |
592 return; | 592 return; |
593 | 593 |
594 SetSubtreePropertyChanged(); | 594 SetSubtreePropertyChanged(); |
595 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | 595 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
596 if (TransformNode* transform_node = | 596 if (TransformNode* transform_node = |
597 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { | 597 property_trees->transform_tree.UpdateNodeFromOwningLayerId(id())) { |
598 DCHECK_EQ(transform_tree_index(), transform_node->id); | 598 DCHECK_EQ(transform_tree_index(), transform_node->id); |
599 transform_node->update_post_local_transform(position, transform_origin()); | 599 transform_node->update_post_local_transform(position, transform_origin()); |
600 if (transform_node->sticky_position_constraint_id >= 0) { | |
601 StickyPositionNodeData* sticky_data = | |
602 property_trees->transform_tree.StickyPositionData( | |
603 transform_tree_index()); | |
604 // TODO(smcgruer): Pass main thread sticky-shifting offsets of | |
605 // non-promoted ancestors, or promote all ancestor sticky elements. | |
606 // See http://crbug.com/702229 | |
607 sticky_data->main_thread_offset = | |
608 position.OffsetFromOrigin() - | |
609 sticky_data->constraints.parent_relative_sticky_box_offset | |
610 .OffsetFromOrigin(); | |
611 } | |
612 transform_node->needs_local_transform_update = true; | 600 transform_node->needs_local_transform_update = true; |
613 transform_node->transform_changed = true; | 601 transform_node->transform_changed = true; |
614 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); | 602 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
615 } | 603 } |
616 | 604 |
617 SetNeedsCommit(); | 605 SetNeedsCommit(); |
618 } | 606 } |
619 | 607 |
620 bool Layer::IsContainerForFixedPositionLayers() const { | 608 bool Layer::IsContainerForFixedPositionLayers() const { |
621 return inputs_.is_container_for_fixed_position_layers; | 609 return inputs_.is_container_for_fixed_position_layers; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 void Layer::SetStickyPositionConstraint( | 1089 void Layer::SetStickyPositionConstraint( |
1102 const LayerStickyPositionConstraint& constraint) { | 1090 const LayerStickyPositionConstraint& constraint) { |
1103 DCHECK(IsPropertyChangeAllowed()); | 1091 DCHECK(IsPropertyChangeAllowed()); |
1104 if (inputs_.sticky_position_constraint == constraint) | 1092 if (inputs_.sticky_position_constraint == constraint) |
1105 return; | 1093 return; |
1106 inputs_.sticky_position_constraint = constraint; | 1094 inputs_.sticky_position_constraint = constraint; |
1107 SetPropertyTreesNeedRebuild(); | 1095 SetPropertyTreesNeedRebuild(); |
1108 SetNeedsCommit(); | 1096 SetNeedsCommit(); |
1109 } | 1097 } |
1110 | 1098 |
| 1099 void Layer::SetStickyMainThreadOffset(const gfx::Size& offset) { |
| 1100 DCHECK(IsPropertyChangeAllowed()); |
| 1101 if (inputs_.sticky_main_thread_offset == offset) |
| 1102 return; |
| 1103 inputs_.sticky_main_thread_offset = offset; |
| 1104 |
| 1105 if (!layer_tree_host_) |
| 1106 return; |
| 1107 |
| 1108 SetSubtreePropertyChanged(); |
| 1109 PropertyTrees* property_trees = layer_tree_host_->property_trees(); |
| 1110 if (TransformNode* transform_node = |
| 1111 property_trees->transform_tree.FindNodeFromElementId( |
| 1112 inputs_.element_id)) { |
| 1113 DCHECK_EQ(transform_tree_index(), transform_node->id); |
| 1114 transform_node->sticky_main_thread_offset = |
| 1115 gfx::Vector2dF(offset.width(), offset.height()); |
| 1116 transform_node->needs_local_transform_update = true; |
| 1117 transform_node->transform_changed = true; |
| 1118 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true); |
| 1119 } |
| 1120 |
| 1121 SetNeedsCommit(); |
| 1122 } |
| 1123 |
1111 static void RunCopyCallbackOnMainThread( | 1124 static void RunCopyCallbackOnMainThread( |
1112 std::unique_ptr<CopyOutputRequest> request, | 1125 std::unique_ptr<CopyOutputRequest> request, |
1113 std::unique_ptr<CopyOutputResult> result) { | 1126 std::unique_ptr<CopyOutputResult> result) { |
1114 request->SendResult(std::move(result)); | 1127 request->SendResult(std::move(result)); |
1115 } | 1128 } |
1116 | 1129 |
1117 static void PostCopyCallbackToMainThread( | 1130 static void PostCopyCallbackToMainThread( |
1118 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1131 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
1119 std::unique_ptr<CopyOutputRequest> request, | 1132 std::unique_ptr<CopyOutputRequest> request, |
1120 std::unique_ptr<CopyOutputResult> result) { | 1133 std::unique_ptr<CopyOutputResult> result) { |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1425 ->subtree_has_copy_request; | 1438 ->subtree_has_copy_request; |
1426 } | 1439 } |
1427 | 1440 |
1428 gfx::Transform Layer::ScreenSpaceTransform() const { | 1441 gfx::Transform Layer::ScreenSpaceTransform() const { |
1429 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1442 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1430 return draw_property_utils::ScreenSpaceTransform( | 1443 return draw_property_utils::ScreenSpaceTransform( |
1431 this, layer_tree_host_->property_trees()->transform_tree); | 1444 this, layer_tree_host_->property_trees()->transform_tree); |
1432 } | 1445 } |
1433 | 1446 |
1434 } // namespace cc | 1447 } // namespace cc |
OLD | NEW |