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

Side by Side Diff: cc/trees/property_tree.cc

Issue 1144993004: cc: Make impl-thread property trees handle fixed-position layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@EnablePropertyTreeVerificationOnImpl
Patch Set: Add DCHECK Created 5 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
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <set> 5 #include <set>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/trees/property_tree.h" 10 #include "cc/trees/property_tree.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 template <typename T> 14 template <typename T>
15 PropertyTree<T>::PropertyTree() 15 PropertyTree<T>::PropertyTree()
16 : needs_update_(false) { 16 : needs_update_(false) {
17 nodes_.push_back(T()); 17 nodes_.push_back(T());
18 back()->id = 0; 18 back()->id = 0;
19 back()->parent_id = -1; 19 back()->parent_id = -1;
20 } 20 }
21 21
22 template <typename T> 22 template <typename T>
23 PropertyTree<T>::~PropertyTree() { 23 PropertyTree<T>::~PropertyTree() {
24 } 24 }
25 25
26 TransformTree::TransformTree() : source_to_parent_updates_allowed_(true) {
27 }
28
26 template <typename T> 29 template <typename T>
27 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) { 30 int PropertyTree<T>::Insert(const T& tree_node, int parent_id) {
28 DCHECK_GT(nodes_.size(), 0u); 31 DCHECK_GT(nodes_.size(), 0u);
29 nodes_.push_back(tree_node); 32 nodes_.push_back(tree_node);
30 T& node = nodes_.back(); 33 T& node = nodes_.back();
31 node.parent_id = parent_id; 34 node.parent_id = parent_id;
32 node.id = static_cast<int>(nodes_.size()) - 1; 35 node.id = static_cast<int>(nodes_.size()) - 1;
33 return node.id; 36 return node.id;
34 } 37 }
35 38
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 1.f / source_node->data.sublayer_scale.y()); 133 1.f / source_node->data.sublayer_scale.y());
131 return success; 134 return success;
132 } 135 }
133 136
134 bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const { 137 bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const {
135 gfx::Transform transform; 138 gfx::Transform transform;
136 return ComputeTransform(source_id, dest_id, &transform) && 139 return ComputeTransform(source_id, dest_id, &transform) &&
137 transform.Preserves2dAxisAlignment(); 140 transform.Preserves2dAxisAlignment();
138 } 141 }
139 142
143 bool TransformTree::NeedsSourceToParentUpdate(TransformNode* node) {
144 return (source_to_parent_updates_allowed() &&
145 node->parent_id != node->data.source_node_id);
146 }
147
140 void TransformTree::UpdateTransforms(int id) { 148 void TransformTree::UpdateTransforms(int id) {
141 TransformNode* node = Node(id); 149 TransformNode* node = Node(id);
142 TransformNode* parent_node = parent(node); 150 TransformNode* parent_node = parent(node);
143 TransformNode* target_node = Node(node->data.target_id); 151 TransformNode* target_node = Node(node->data.target_id);
144 if (node->data.needs_local_transform_update || 152 if (node->data.needs_local_transform_update ||
145 node->parent_id != node->data.source_node_id) 153 NeedsSourceToParentUpdate(node))
146 UpdateLocalTransform(node); 154 UpdateLocalTransform(node);
147 UpdateScreenSpaceTransform(node, parent_node, target_node); 155 UpdateScreenSpaceTransform(node, parent_node, target_node);
148 UpdateSublayerScale(node); 156 UpdateSublayerScale(node);
149 UpdateTargetSpaceTransform(node, target_node); 157 UpdateTargetSpaceTransform(node, target_node);
150 UpdateIsAnimated(node, parent_node); 158 UpdateIsAnimated(node, parent_node);
151 UpdateSnapping(node); 159 UpdateSnapping(node);
152 } 160 }
153 161
154 bool TransformTree::IsDescendant(int desc_id, int source_id) const { 162 bool TransformTree::IsDescendant(int desc_id, int source_id) const {
155 while (desc_id != source_id) { 163 while (desc_id != source_id) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 gfx::Transform dest_to_source; 275 gfx::Transform dest_to_source;
268 CombineTransformsBetween(dest_id, source_id, &dest_to_source); 276 CombineTransformsBetween(dest_id, source_id, &dest_to_source);
269 gfx::Transform source_to_dest; 277 gfx::Transform source_to_dest;
270 bool all_are_invertible = dest_to_source.GetInverse(&source_to_dest); 278 bool all_are_invertible = dest_to_source.GetInverse(&source_to_dest);
271 transform->PreconcatTransform(source_to_dest); 279 transform->PreconcatTransform(source_to_dest);
272 return all_are_invertible; 280 return all_are_invertible;
273 } 281 }
274 282
275 void TransformTree::UpdateLocalTransform(TransformNode* node) { 283 void TransformTree::UpdateLocalTransform(TransformNode* node) {
276 gfx::Transform transform = node->data.post_local; 284 gfx::Transform transform = node->data.post_local;
277 gfx::Vector2dF source_to_parent; 285 if (NeedsSourceToParentUpdate(node)) {
278 if (node->parent_id != node->data.source_node_id) {
279 gfx::Transform to_parent; 286 gfx::Transform to_parent;
280 ComputeTransform(node->data.source_node_id, node->parent_id, &to_parent); 287 ComputeTransform(node->data.source_node_id, node->parent_id, &to_parent);
281 source_to_parent = to_parent.To2dTranslation(); 288 node->data.source_to_parent = to_parent.To2dTranslation();
282 } 289 }
283 transform.Translate(source_to_parent.x() - node->data.scroll_offset.x(), 290 transform.Translate(
284 source_to_parent.y() - node->data.scroll_offset.y()); 291 node->data.source_to_parent.x() - node->data.scroll_offset.x(),
292 node->data.source_to_parent.y() - node->data.scroll_offset.y());
285 transform.PreconcatTransform(node->data.local); 293 transform.PreconcatTransform(node->data.local);
286 transform.PreconcatTransform(node->data.pre_local); 294 transform.PreconcatTransform(node->data.pre_local);
287 node->data.set_to_parent(transform); 295 node->data.set_to_parent(transform);
288 node->data.needs_local_transform_update = false; 296 node->data.needs_local_transform_update = false;
289 } 297 }
290 298
291 void TransformTree::UpdateScreenSpaceTransform(TransformNode* node, 299 void TransformTree::UpdateScreenSpaceTransform(TransformNode* node,
292 TransformNode* parent_node, 300 TransformNode* parent_node,
293 TransformNode* target_node) { 301 TransformNode* target_node) {
294 if (!parent_node) { 302 if (!parent_node) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 node->data.from_screen.matrix().postTranslate(-translation.x(), 388 node->data.from_screen.matrix().postTranslate(-translation.x(),
381 -translation.y(), 0); 389 -translation.y(), 0);
382 390
383 node->data.scroll_snap = translation; 391 node->data.scroll_snap = translation;
384 } 392 }
385 393
386 PropertyTrees::PropertyTrees() : needs_rebuild(true), sequence_number(0) { 394 PropertyTrees::PropertyTrees() : needs_rebuild(true), sequence_number(0) {
387 } 395 }
388 396
389 } // namespace cc 397 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698