Chromium Code Reviews| 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 SetPropertyTreesNeedRebuild(); | |
|
smcgruer
2017/05/26 17:14:12
Do we definitely need to rebuild property trees he
yigu
2017/05/26 18:04:21
We don't need to rebuild the tree. Done.
| |
| 1105 SetNeedsCommit(); | |
| 1106 } | |
| 1107 | |
| 1111 static void RunCopyCallbackOnMainThread( | 1108 static void RunCopyCallbackOnMainThread( |
| 1112 std::unique_ptr<CopyOutputRequest> request, | 1109 std::unique_ptr<CopyOutputRequest> request, |
| 1113 std::unique_ptr<CopyOutputResult> result) { | 1110 std::unique_ptr<CopyOutputResult> result) { |
| 1114 request->SendResult(std::move(result)); | 1111 request->SendResult(std::move(result)); |
| 1115 } | 1112 } |
| 1116 | 1113 |
| 1117 static void PostCopyCallbackToMainThread( | 1114 static void PostCopyCallbackToMainThread( |
| 1118 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, | 1115 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| 1119 std::unique_ptr<CopyOutputRequest> request, | 1116 std::unique_ptr<CopyOutputRequest> request, |
| 1120 std::unique_ptr<CopyOutputResult> result) { | 1117 std::unique_ptr<CopyOutputResult> result) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 ->subtree_has_copy_request; | 1424 ->subtree_has_copy_request; |
| 1428 } | 1425 } |
| 1429 | 1426 |
| 1430 gfx::Transform Layer::ScreenSpaceTransform() const { | 1427 gfx::Transform Layer::ScreenSpaceTransform() const { |
| 1431 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1428 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1432 return draw_property_utils::ScreenSpaceTransform( | 1429 return draw_property_utils::ScreenSpaceTransform( |
| 1433 this, layer_tree_host_->property_trees()->transform_tree); | 1430 this, layer_tree_host_->property_trees()->transform_tree); |
| 1434 } | 1431 } |
| 1435 | 1432 |
| 1436 } // namespace cc | 1433 } // namespace cc |
| OLD | NEW |