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 <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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 | 67 |
68 if (source_id > dest_id) { | 68 if (source_id > dest_id) { |
69 DCHECK(IsDescendant(source_id, dest_id)); | 69 DCHECK(IsDescendant(source_id, dest_id)); |
70 return CombineTransformsBetween(source_id, dest_id, transform); | 70 return CombineTransformsBetween(source_id, dest_id, transform); |
71 } | 71 } |
72 | 72 |
73 DCHECK(IsDescendant(dest_id, source_id)); | 73 DCHECK(IsDescendant(dest_id, source_id)); |
74 return CombineInversesBetween(source_id, dest_id, transform); | 74 return CombineInversesBetween(source_id, dest_id, transform); |
75 } | 75 } |
76 | 76 |
77 bool TransformTree::ComputeTransformWithDestinationSublayerScale( | |
78 int source_id, | |
79 int dest_id, | |
80 gfx::Transform* transform) const { | |
Ian Vollick
2015/04/10 17:10:39
Thank you very much for adding these. Would it mak
ajuma
2015/04/10 17:19:49
It looks like that method only applies sublayer sc
| |
81 bool success = ComputeTransform(source_id, dest_id, transform); | |
82 | |
83 const TransformNode* dest_node = Node(dest_id); | |
84 if (!dest_node->data.needs_sublayer_scale) | |
85 return success; | |
86 | |
87 transform->matrix().postScale(dest_node->data.sublayer_scale.x(), | |
88 dest_node->data.sublayer_scale.y(), 1.f); | |
89 return success; | |
90 } | |
91 | |
92 bool TransformTree::ComputeTransformWithSourceSublayerScale( | |
93 int source_id, | |
94 int dest_id, | |
95 gfx::Transform* transform) const { | |
96 bool success = ComputeTransform(source_id, dest_id, transform); | |
97 | |
98 const TransformNode* source_node = Node(source_id); | |
99 if (!source_node->data.needs_sublayer_scale) | |
100 return success; | |
101 | |
102 transform->Scale(1.f / source_node->data.sublayer_scale.x(), | |
103 1.f / source_node->data.sublayer_scale.y()); | |
104 return success; | |
105 } | |
106 | |
77 bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const { | 107 bool TransformTree::Are2DAxisAligned(int source_id, int dest_id) const { |
78 gfx::Transform transform; | 108 gfx::Transform transform; |
79 return ComputeTransform(source_id, dest_id, &transform) && | 109 return ComputeTransform(source_id, dest_id, &transform) && |
80 transform.Preserves2dAxisAlignment(); | 110 transform.Preserves2dAxisAlignment(); |
81 } | 111 } |
82 | 112 |
83 void TransformTree::UpdateTransforms(int id) { | 113 void TransformTree::UpdateTransforms(int id) { |
84 TransformNode* node = Node(id); | 114 TransformNode* node = Node(id); |
85 TransformNode* parent_node = parent(node); | 115 TransformNode* parent_node = parent(node); |
86 TransformNode* target_node = Node(node->data.target_id); | 116 TransformNode* target_node = Node(node->data.target_id); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 // The sublayer scale depends on the screen space transform, so update it too. | 258 // The sublayer scale depends on the screen space transform, so update it too. |
229 node->data.sublayer_scale = | 259 node->data.sublayer_scale = |
230 node->data.needs_sublayer_scale | 260 node->data.needs_sublayer_scale |
231 ? MathUtil::ComputeTransform2dScaleComponents( | 261 ? MathUtil::ComputeTransform2dScaleComponents( |
232 node->data.to_screen, node->data.layer_scale_factor) | 262 node->data.to_screen, node->data.layer_scale_factor) |
233 : gfx::Vector2dF(1.0f, 1.0f); | 263 : gfx::Vector2dF(1.0f, 1.0f); |
234 } | 264 } |
235 | 265 |
236 void TransformTree::UpdateTargetSpaceTransform(TransformNode* node, | 266 void TransformTree::UpdateTargetSpaceTransform(TransformNode* node, |
237 TransformNode* target_node) { | 267 TransformNode* target_node) { |
238 node->data.to_target.MakeIdentity(); | |
239 if (node->data.needs_sublayer_scale) { | 268 if (node->data.needs_sublayer_scale) { |
269 node->data.to_target.MakeIdentity(); | |
240 node->data.to_target.Scale(node->data.sublayer_scale.x(), | 270 node->data.to_target.Scale(node->data.sublayer_scale.x(), |
241 node->data.sublayer_scale.y()); | 271 node->data.sublayer_scale.y()); |
242 } else { | 272 } else { |
243 const bool target_is_root_surface = target_node->id == 1; | 273 const bool target_is_root_surface = target_node->id == 1; |
244 // In order to include the root transform for the root surface, we walk up | 274 // In order to include the root transform for the root surface, we walk up |
245 // to the root of the transform tree in ComputeTransform. | 275 // to the root of the transform tree in ComputeTransform. |
246 int target_id = target_is_root_surface ? 0 : target_node->id; | 276 int target_id = target_is_root_surface ? 0 : target_node->id; |
247 if (target_node) { | 277 ComputeTransformWithDestinationSublayerScale(node->id, target_id, |
248 node->data.to_target.Scale(target_node->data.sublayer_scale.x(), | 278 &node->data.to_target); |
249 target_node->data.sublayer_scale.y()); | |
250 } | |
251 | |
252 gfx::Transform unscaled_target_transform; | |
253 ComputeTransform(node->id, target_id, &unscaled_target_transform); | |
254 node->data.to_target.PreconcatTransform(unscaled_target_transform); | |
255 } | 279 } |
256 | 280 |
257 if (!node->data.to_target.GetInverse(&node->data.from_target)) | 281 if (!node->data.to_target.GetInverse(&node->data.from_target)) |
258 node->data.ancestors_are_invertible = false; | 282 node->data.ancestors_are_invertible = false; |
259 } | 283 } |
260 | 284 |
261 void TransformTree::UpdateIsAnimated(TransformNode* node, | 285 void TransformTree::UpdateIsAnimated(TransformNode* node, |
262 TransformNode* parent_node) { | 286 TransformNode* parent_node) { |
263 if (parent_node) { | 287 if (parent_node) { |
264 node->data.to_screen_is_animated = | 288 node->data.to_screen_is_animated = |
(...skipping 30 matching lines...) Expand all Loading... | |
295 node->data.from_target.matrix().postTranslate(-translation.x(), | 319 node->data.from_target.matrix().postTranslate(-translation.x(), |
296 -translation.y(), 0); | 320 -translation.y(), 0); |
297 node->data.to_screen.Translate(translation.x(), translation.y()); | 321 node->data.to_screen.Translate(translation.x(), translation.y()); |
298 node->data.from_screen.matrix().postTranslate(-translation.x(), | 322 node->data.from_screen.matrix().postTranslate(-translation.x(), |
299 -translation.y(), 0); | 323 -translation.y(), 0); |
300 | 324 |
301 node->data.scroll_snap = translation; | 325 node->data.scroll_snap = translation; |
302 } | 326 } |
303 | 327 |
304 } // namespace cc | 328 } // namespace cc |
OLD | NEW |