OLD | NEW |
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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 template <typename T> | 42 template <typename T> |
43 PropertyTree<T>& PropertyTree<T>::operator=(const PropertyTree<T>&) = default; | 43 PropertyTree<T>& PropertyTree<T>::operator=(const PropertyTree<T>&) = default; |
44 | 44 |
45 TransformTree::TransformTree() | 45 TransformTree::TransformTree() |
46 : source_to_parent_updates_allowed_(true), | 46 : source_to_parent_updates_allowed_(true), |
47 page_scale_factor_(1.f), | 47 page_scale_factor_(1.f), |
48 device_scale_factor_(1.f), | 48 device_scale_factor_(1.f), |
49 device_transform_scale_factor_(1.f) { | 49 device_transform_scale_factor_(1.f) { |
50 cached_data_.push_back(TransformCachedNodeData()); | 50 cached_data_.push_back(TransformCachedNodeData()); |
51 cached_data_[kRootNodeId].target_id = kRootNodeId; | |
52 } | 51 } |
53 | 52 |
54 TransformTree::~TransformTree() = default; | 53 TransformTree::~TransformTree() = default; |
55 TransformTree& TransformTree::operator=(const TransformTree&) = default; | 54 TransformTree& TransformTree::operator=(const TransformTree&) = default; |
56 | 55 |
57 template <typename T> | 56 template <typename T> |
58 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) { | 57 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) { |
59 DCHECK_GT(nodes_.size(), 0u); | 58 DCHECK_GT(nodes_.size(), 0u); |
60 nodes_.push_back(tree_node); | 59 nodes_.push_back(tree_node); |
61 T& node = nodes_.back(); | 60 T& node = nodes_.back(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 void TransformTree::clear() { | 111 void TransformTree::clear() { |
113 PropertyTree<TransformNode>::clear(); | 112 PropertyTree<TransformNode>::clear(); |
114 | 113 |
115 page_scale_factor_ = 1.f; | 114 page_scale_factor_ = 1.f; |
116 device_scale_factor_ = 1.f; | 115 device_scale_factor_ = 1.f; |
117 device_transform_scale_factor_ = 1.f; | 116 device_transform_scale_factor_ = 1.f; |
118 nodes_affected_by_inner_viewport_bounds_delta_.clear(); | 117 nodes_affected_by_inner_viewport_bounds_delta_.clear(); |
119 nodes_affected_by_outer_viewport_bounds_delta_.clear(); | 118 nodes_affected_by_outer_viewport_bounds_delta_.clear(); |
120 cached_data_.clear(); | 119 cached_data_.clear(); |
121 cached_data_.push_back(TransformCachedNodeData()); | 120 cached_data_.push_back(TransformCachedNodeData()); |
122 cached_data_[kRootNodeId].target_id = kRootNodeId; | |
123 sticky_position_data_.clear(); | 121 sticky_position_data_.clear(); |
124 | 122 |
125 #if DCHECK_IS_ON() | 123 #if DCHECK_IS_ON() |
126 TransformTree tree; | 124 TransformTree tree; |
127 // TODO(jaydasika) : Move tests that expect source_to_parent_updates_allowed | 125 // TODO(jaydasika) : Move tests that expect source_to_parent_updates_allowed |
128 // to be true on impl thread to main thread and set it to is_main_thread here. | 126 // to be true on impl thread to main thread and set it to is_main_thread here. |
129 tree.source_to_parent_updates_allowed_ = source_to_parent_updates_allowed_; | 127 tree.source_to_parent_updates_allowed_ = source_to_parent_updates_allowed_; |
130 DCHECK(tree == *this); | 128 DCHECK(tree == *this); |
131 #endif | 129 #endif |
132 } | 130 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 id < static_cast<int>(size()); ++id) { | 203 id < static_cast<int>(size()); ++id) { |
206 TransformNode* node = Node(id); | 204 TransformNode* node = Node(id); |
207 node->transform_changed = false; | 205 node->transform_changed = false; |
208 } | 206 } |
209 } | 207 } |
210 | 208 |
211 void TransformTree::UpdateTransforms(int id) { | 209 void TransformTree::UpdateTransforms(int id) { |
212 TransformNode* node = Node(id); | 210 TransformNode* node = Node(id); |
213 TransformNode* parent_node = parent(node); | 211 TransformNode* parent_node = parent(node); |
214 DCHECK(parent_node); | 212 DCHECK(parent_node); |
215 TransformNode* target_node = Node(TargetId(id)); | |
216 TransformNode* source_node = Node(node->source_node_id); | 213 TransformNode* source_node = Node(node->source_node_id); |
217 // TODO(flackr): Only dirty when scroll offset changes. | 214 // TODO(flackr): Only dirty when scroll offset changes. |
218 if (node->sticky_position_constraint_id >= 0 || | 215 if (node->sticky_position_constraint_id >= 0 || |
219 node->needs_local_transform_update || NeedsSourceToParentUpdate(node)) { | 216 node->needs_local_transform_update || NeedsSourceToParentUpdate(node)) { |
220 UpdateLocalTransform(node); | 217 UpdateLocalTransform(node); |
221 } else { | 218 } else { |
222 UndoSnapping(node); | 219 UndoSnapping(node); |
223 } | 220 } |
224 UpdateScreenSpaceTransform(node, parent_node, target_node); | 221 UpdateScreenSpaceTransform(node, parent_node); |
225 UpdateAnimationProperties(node, parent_node); | 222 UpdateAnimationProperties(node, parent_node); |
226 UpdateSnapping(node); | 223 UpdateSnapping(node); |
227 UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node); | 224 UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node); |
228 UpdateTransformChanged(node, parent_node, source_node); | 225 UpdateTransformChanged(node, parent_node, source_node); |
229 UpdateNodeAndAncestorsAreAnimatedOrInvertible(node, parent_node); | 226 UpdateNodeAndAncestorsAreAnimatedOrInvertible(node, parent_node); |
230 } | 227 } |
231 | 228 |
232 bool TransformTree::IsDescendant(int desc_id, int source_id) const { | 229 bool TransformTree::IsDescendant(int desc_id, int source_id) const { |
233 while (desc_id != source_id) { | 230 while (desc_id != source_id) { |
234 if (desc_id == kInvalidNodeId) | 231 if (desc_id == kInvalidNodeId) |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 fixed_position_adjustment.y()); | 490 fixed_position_adjustment.y()); |
494 transform.Translate(StickyPositionOffset(this, node)); | 491 transform.Translate(StickyPositionOffset(this, node)); |
495 transform.PreconcatTransform(node->local); | 492 transform.PreconcatTransform(node->local); |
496 transform.PreconcatTransform(node->pre_local); | 493 transform.PreconcatTransform(node->pre_local); |
497 | 494 |
498 node->set_to_parent(transform); | 495 node->set_to_parent(transform); |
499 node->needs_local_transform_update = false; | 496 node->needs_local_transform_update = false; |
500 } | 497 } |
501 | 498 |
502 void TransformTree::UpdateScreenSpaceTransform(TransformNode* node, | 499 void TransformTree::UpdateScreenSpaceTransform(TransformNode* node, |
503 TransformNode* parent_node, | 500 TransformNode* parent_node) { |
504 TransformNode* target_node) { | |
505 DCHECK(parent_node); | 501 DCHECK(parent_node); |
506 gfx::Transform to_screen_space_transform = ToScreen(parent_node->id); | 502 gfx::Transform to_screen_space_transform = ToScreen(parent_node->id); |
507 if (node->flattens_inherited_transform) | 503 if (node->flattens_inherited_transform) |
508 to_screen_space_transform.FlattenTo2d(); | 504 to_screen_space_transform.FlattenTo2d(); |
509 to_screen_space_transform.PreconcatTransform(node->to_parent); | 505 to_screen_space_transform.PreconcatTransform(node->to_parent); |
510 node->ancestors_are_invertible = parent_node->ancestors_are_invertible; | 506 node->ancestors_are_invertible = parent_node->ancestors_are_invertible; |
511 node->node_and_ancestors_are_flat = | 507 node->node_and_ancestors_are_flat = |
512 parent_node->node_and_ancestors_are_flat && node->to_parent.IsFlat(); | 508 parent_node->node_and_ancestors_are_flat && node->to_parent.IsFlat(); |
513 SetToScreen(node->id, to_screen_space_transform); | 509 SetToScreen(node->id, to_screen_space_transform); |
514 | 510 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 696 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
701 return cached_data_[node_id].to_screen; | 697 return cached_data_[node_id].to_screen; |
702 } | 698 } |
703 | 699 |
704 void TransformTree::SetToScreen(int node_id, const gfx::Transform& transform) { | 700 void TransformTree::SetToScreen(int node_id, const gfx::Transform& transform) { |
705 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 701 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
706 cached_data_[node_id].to_screen = transform; | 702 cached_data_[node_id].to_screen = transform; |
707 cached_data_[node_id].is_showing_backface = transform.IsBackFaceVisible(); | 703 cached_data_[node_id].is_showing_backface = transform.IsBackFaceVisible(); |
708 } | 704 } |
709 | 705 |
710 int TransformTree::TargetId(int node_id) const { | |
711 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | |
712 return cached_data_[node_id].target_id; | |
713 } | |
714 | |
715 void TransformTree::SetTargetId(int node_id, int target_id) { | |
716 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | |
717 cached_data_[node_id].target_id = target_id; | |
718 } | |
719 | |
720 int TransformTree::ContentTargetId(int node_id) const { | |
721 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | |
722 return cached_data_[node_id].content_target_id; | |
723 } | |
724 | |
725 void TransformTree::SetContentTargetId(int node_id, int content_target_id) { | |
726 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | |
727 cached_data_[node_id].content_target_id = content_target_id; | |
728 } | |
729 | |
730 bool TransformTree::operator==(const TransformTree& other) const { | 706 bool TransformTree::operator==(const TransformTree& other) const { |
731 return PropertyTree::operator==(other) && | 707 return PropertyTree::operator==(other) && |
732 source_to_parent_updates_allowed_ == | 708 source_to_parent_updates_allowed_ == |
733 other.source_to_parent_updates_allowed() && | 709 other.source_to_parent_updates_allowed() && |
734 page_scale_factor_ == other.page_scale_factor() && | 710 page_scale_factor_ == other.page_scale_factor() && |
735 device_scale_factor_ == other.device_scale_factor() && | 711 device_scale_factor_ == other.device_scale_factor() && |
736 device_transform_scale_factor_ == | 712 device_transform_scale_factor_ == |
737 other.device_transform_scale_factor() && | 713 other.device_transform_scale_factor() && |
738 nodes_affected_by_inner_viewport_bounds_delta_ == | 714 nodes_affected_by_inner_viewport_bounds_delta_ == |
739 other.nodes_affected_by_inner_viewport_bounds_delta() && | 715 other.nodes_affected_by_inner_viewport_bounds_delta() && |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 const EffectNode* effect_node = effect_tree.Node(effect_id); | 2079 const EffectNode* effect_node = effect_tree.Node(effect_id); |
2104 | 2080 |
2105 if (effect_node->surface_contents_scale.x() != 0.0 && | 2081 if (effect_node->surface_contents_scale.x() != 0.0 && |
2106 effect_node->surface_contents_scale.y() != 0.0) | 2082 effect_node->surface_contents_scale.y() != 0.0) |
2107 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), | 2083 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), |
2108 1.0 / effect_node->surface_contents_scale.y()); | 2084 1.0 / effect_node->surface_contents_scale.y()); |
2109 return screen_space_transform; | 2085 return screen_space_transform; |
2110 } | 2086 } |
2111 | 2087 |
2112 } // namespace cc | 2088 } // namespace cc |
OLD | NEW |