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

Side by Side Diff: cc/layers/layer.cc

Issue 2911463002: Unify the calculation of main thread offset of sticky element (Closed)
Patch Set: Pass in constraints_map instead of ancestor_overflow_layer && nit Created 3 years, 6 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 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
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
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.UpdateNodeFromOwningLayerId(id())) {
chrishtr 2017/06/05 15:23:27 Use element id -> node id map instead. Mapping fro
yigu 2017/06/05 18:16:34 Done.
1112 DCHECK_EQ(transform_tree_index(), transform_node->id);
1113 transform_node->sticky_main_thread_offset =
1114 gfx::Vector2dF(offset.width(), offset.height());
1115 transform_node->needs_local_transform_update = true;
1116 transform_node->transform_changed = true;
1117 layer_tree_host_->property_trees()->transform_tree.set_needs_update(true);
1118 }
1119
1120 SetNeedsCommit();
1121 }
1122
1111 static void RunCopyCallbackOnMainThread( 1123 static void RunCopyCallbackOnMainThread(
1112 std::unique_ptr<CopyOutputRequest> request, 1124 std::unique_ptr<CopyOutputRequest> request,
1113 std::unique_ptr<CopyOutputResult> result) { 1125 std::unique_ptr<CopyOutputResult> result) {
1114 request->SendResult(std::move(result)); 1126 request->SendResult(std::move(result));
1115 } 1127 }
1116 1128
1117 static void PostCopyCallbackToMainThread( 1129 static void PostCopyCallbackToMainThread(
1118 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, 1130 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
1119 std::unique_ptr<CopyOutputRequest> request, 1131 std::unique_ptr<CopyOutputRequest> request,
1120 std::unique_ptr<CopyOutputResult> result) { 1132 std::unique_ptr<CopyOutputResult> result) {
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 ->subtree_has_copy_request; 1439 ->subtree_has_copy_request;
1428 } 1440 }
1429 1441
1430 gfx::Transform Layer::ScreenSpaceTransform() const { 1442 gfx::Transform Layer::ScreenSpaceTransform() const {
1431 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); 1443 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId);
1432 return draw_property_utils::ScreenSpaceTransform( 1444 return draw_property_utils::ScreenSpaceTransform(
1433 this, layer_tree_host_->property_trees()->transform_tree); 1445 this, layer_tree_host_->property_trees()->transform_tree);
1434 } 1446 }
1435 1447
1436 } // namespace cc 1448 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698