| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 template class PropertyTree<ClipNode>; | 129 template class PropertyTree<ClipNode>; |
| 130 template class PropertyTree<EffectNode>; | 130 template class PropertyTree<EffectNode>; |
| 131 template class PropertyTree<ScrollNode>; | 131 template class PropertyTree<ScrollNode>; |
| 132 | 132 |
| 133 TransformNodeData::TransformNodeData() | 133 TransformNodeData::TransformNodeData() |
| 134 : target_id(-1), | 134 : target_id(-1), |
| 135 content_target_id(-1), | 135 content_target_id(-1), |
| 136 source_node_id(-1), | 136 source_node_id(-1), |
| 137 sorting_context_id(0), | 137 sorting_context_id(0), |
| 138 needs_local_transform_update(true), | 138 needs_local_transform_update(true), |
| 139 node_and_ancestors_are_animated_or_invertible(true), |
| 139 is_invertible(true), | 140 is_invertible(true), |
| 140 ancestors_are_invertible(true), | 141 ancestors_are_invertible(true), |
| 141 is_animated(false), | 142 is_animated(false), |
| 142 to_screen_is_potentially_animated(false), | 143 to_screen_is_potentially_animated(false), |
| 143 has_only_translation_animations(true), | 144 has_only_translation_animations(true), |
| 144 to_screen_has_scale_animation(false), | 145 to_screen_has_scale_animation(false), |
| 145 flattens_inherited_transform(false), | 146 flattens_inherited_transform(false), |
| 146 node_and_ancestors_are_flat(true), | 147 node_and_ancestors_are_flat(true), |
| 147 node_and_ancestors_have_only_integer_translation(true), | 148 node_and_ancestors_have_only_integer_translation(true), |
| 148 scrolls(false), | 149 scrolls(false), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 167 bool TransformNodeData::operator==(const TransformNodeData& other) const { | 168 bool TransformNodeData::operator==(const TransformNodeData& other) const { |
| 168 return pre_local == other.pre_local && local == other.local && | 169 return pre_local == other.pre_local && local == other.local && |
| 169 post_local == other.post_local && to_parent == other.to_parent && | 170 post_local == other.post_local && to_parent == other.to_parent && |
| 170 to_target == other.to_target && from_target == other.from_target && | 171 to_target == other.to_target && from_target == other.from_target && |
| 171 to_screen == other.to_screen && from_screen == other.from_screen && | 172 to_screen == other.to_screen && from_screen == other.from_screen && |
| 172 target_id == other.target_id && | 173 target_id == other.target_id && |
| 173 content_target_id == other.content_target_id && | 174 content_target_id == other.content_target_id && |
| 174 source_node_id == other.source_node_id && | 175 source_node_id == other.source_node_id && |
| 175 sorting_context_id == other.sorting_context_id && | 176 sorting_context_id == other.sorting_context_id && |
| 176 needs_local_transform_update == other.needs_local_transform_update && | 177 needs_local_transform_update == other.needs_local_transform_update && |
| 178 node_and_ancestors_are_animated_or_invertible == |
| 179 other.node_and_ancestors_are_animated_or_invertible && |
| 177 is_invertible == other.is_invertible && | 180 is_invertible == other.is_invertible && |
| 178 ancestors_are_invertible == other.ancestors_are_invertible && | 181 ancestors_are_invertible == other.ancestors_are_invertible && |
| 179 is_animated == other.is_animated && | 182 is_animated == other.is_animated && |
| 180 to_screen_is_potentially_animated == | 183 to_screen_is_potentially_animated == |
| 181 other.to_screen_is_potentially_animated && | 184 other.to_screen_is_potentially_animated && |
| 182 has_only_translation_animations == | 185 has_only_translation_animations == |
| 183 other.has_only_translation_animations && | 186 other.has_only_translation_animations && |
| 184 to_screen_has_scale_animation == other.to_screen_has_scale_animation && | 187 to_screen_has_scale_animation == other.to_screen_has_scale_animation && |
| 185 flattens_inherited_transform == other.flattens_inherited_transform && | 188 flattens_inherited_transform == other.flattens_inherited_transform && |
| 186 node_and_ancestors_are_flat == other.node_and_ancestors_are_flat && | 189 node_and_ancestors_are_flat == other.node_and_ancestors_are_flat && |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 TransformToProto(to_screen, data->mutable_to_screen()); | 252 TransformToProto(to_screen, data->mutable_to_screen()); |
| 250 TransformToProto(from_screen, data->mutable_from_screen()); | 253 TransformToProto(from_screen, data->mutable_from_screen()); |
| 251 | 254 |
| 252 data->set_target_id(target_id); | 255 data->set_target_id(target_id); |
| 253 data->set_content_target_id(content_target_id); | 256 data->set_content_target_id(content_target_id); |
| 254 data->set_source_node_id(source_node_id); | 257 data->set_source_node_id(source_node_id); |
| 255 data->set_sorting_context_id(sorting_context_id); | 258 data->set_sorting_context_id(sorting_context_id); |
| 256 | 259 |
| 257 data->set_needs_local_transform_update(needs_local_transform_update); | 260 data->set_needs_local_transform_update(needs_local_transform_update); |
| 258 | 261 |
| 262 data->set_node_and_ancestors_are_animated_or_invertible( |
| 263 node_and_ancestors_are_animated_or_invertible); |
| 264 |
| 259 data->set_is_invertible(is_invertible); | 265 data->set_is_invertible(is_invertible); |
| 260 data->set_ancestors_are_invertible(ancestors_are_invertible); | 266 data->set_ancestors_are_invertible(ancestors_are_invertible); |
| 261 | 267 |
| 262 data->set_is_animated(is_animated); | 268 data->set_is_animated(is_animated); |
| 263 data->set_to_screen_is_potentially_animated( | 269 data->set_to_screen_is_potentially_animated( |
| 264 to_screen_is_potentially_animated); | 270 to_screen_is_potentially_animated); |
| 265 data->set_has_only_translation_animations(has_only_translation_animations); | 271 data->set_has_only_translation_animations(has_only_translation_animations); |
| 266 data->set_to_screen_has_scale_animation(to_screen_has_scale_animation); | 272 data->set_to_screen_has_scale_animation(to_screen_has_scale_animation); |
| 267 | 273 |
| 268 data->set_flattens_inherited_transform(flattens_inherited_transform); | 274 data->set_flattens_inherited_transform(flattens_inherited_transform); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 to_screen = ProtoToTransform(data.to_screen()); | 322 to_screen = ProtoToTransform(data.to_screen()); |
| 317 from_screen = ProtoToTransform(data.from_screen()); | 323 from_screen = ProtoToTransform(data.from_screen()); |
| 318 | 324 |
| 319 target_id = data.target_id(); | 325 target_id = data.target_id(); |
| 320 content_target_id = data.content_target_id(); | 326 content_target_id = data.content_target_id(); |
| 321 source_node_id = data.source_node_id(); | 327 source_node_id = data.source_node_id(); |
| 322 sorting_context_id = data.sorting_context_id(); | 328 sorting_context_id = data.sorting_context_id(); |
| 323 | 329 |
| 324 needs_local_transform_update = data.needs_local_transform_update(); | 330 needs_local_transform_update = data.needs_local_transform_update(); |
| 325 | 331 |
| 332 node_and_ancestors_are_animated_or_invertible = |
| 333 data.node_and_ancestors_are_animated_or_invertible(); |
| 334 |
| 326 is_invertible = data.is_invertible(); | 335 is_invertible = data.is_invertible(); |
| 327 ancestors_are_invertible = data.ancestors_are_invertible(); | 336 ancestors_are_invertible = data.ancestors_are_invertible(); |
| 328 | 337 |
| 329 is_animated = data.is_animated(); | 338 is_animated = data.is_animated(); |
| 330 to_screen_is_potentially_animated = data.to_screen_is_potentially_animated(); | 339 to_screen_is_potentially_animated = data.to_screen_is_potentially_animated(); |
| 331 has_only_translation_animations = data.has_only_translation_animations(); | 340 has_only_translation_animations = data.has_only_translation_animations(); |
| 332 to_screen_has_scale_animation = data.to_screen_has_scale_animation(); | 341 to_screen_has_scale_animation = data.to_screen_has_scale_animation(); |
| 333 | 342 |
| 334 flattens_inherited_transform = data.flattens_inherited_transform(); | 343 flattens_inherited_transform = data.flattens_inherited_transform(); |
| 335 node_and_ancestors_are_flat = data.node_and_ancestors_are_flat(); | 344 node_and_ancestors_are_flat = data.node_and_ancestors_are_flat(); |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 UpdateLocalTransform(node); | 692 UpdateLocalTransform(node); |
| 684 else | 693 else |
| 685 UndoSnapping(node); | 694 UndoSnapping(node); |
| 686 UpdateScreenSpaceTransform(node, parent_node, target_node); | 695 UpdateScreenSpaceTransform(node, parent_node, target_node); |
| 687 UpdateSublayerScale(node); | 696 UpdateSublayerScale(node); |
| 688 UpdateTargetSpaceTransform(node, target_node); | 697 UpdateTargetSpaceTransform(node, target_node); |
| 689 UpdateAnimationProperties(node, parent_node); | 698 UpdateAnimationProperties(node, parent_node); |
| 690 UpdateSnapping(node); | 699 UpdateSnapping(node); |
| 691 UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node); | 700 UpdateNodeAndAncestorsHaveIntegerTranslations(node, parent_node); |
| 692 UpdateTransformChanged(node, parent_node, source_node); | 701 UpdateTransformChanged(node, parent_node, source_node); |
| 702 UpdateNodeAndAncestorsAreAnimatedOrInvertible(node, parent_node); |
| 693 } | 703 } |
| 694 | 704 |
| 695 bool TransformTree::IsDescendant(int desc_id, int source_id) const { | 705 bool TransformTree::IsDescendant(int desc_id, int source_id) const { |
| 696 while (desc_id != source_id) { | 706 while (desc_id != source_id) { |
| 697 if (desc_id < 0) | 707 if (desc_id < 0) |
| 698 return false; | 708 return false; |
| 699 desc_id = Node(desc_id)->parent_id; | 709 desc_id = Node(desc_id)->parent_id; |
| 700 } | 710 } |
| 701 return true; | 711 return true; |
| 702 } | 712 } |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 if (parent_node && parent_node->data.transform_changed) { | 1065 if (parent_node && parent_node->data.transform_changed) { |
| 1056 node->data.transform_changed = true; | 1066 node->data.transform_changed = true; |
| 1057 return; | 1067 return; |
| 1058 } | 1068 } |
| 1059 | 1069 |
| 1060 if (source_node && source_node->id != parent_node->id && | 1070 if (source_node && source_node->id != parent_node->id && |
| 1061 source_to_parent_updates_allowed_ && source_node->data.transform_changed) | 1071 source_to_parent_updates_allowed_ && source_node->data.transform_changed) |
| 1062 node->data.transform_changed = true; | 1072 node->data.transform_changed = true; |
| 1063 } | 1073 } |
| 1064 | 1074 |
| 1075 void TransformTree::UpdateNodeAndAncestorsAreAnimatedOrInvertible( |
| 1076 TransformNode* node, |
| 1077 TransformNode* parent_node) { |
| 1078 if (!parent_node) { |
| 1079 node->data.node_and_ancestors_are_animated_or_invertible = |
| 1080 node->data.is_animated || node->data.is_invertible; |
| 1081 return; |
| 1082 } |
| 1083 if (!parent_node->data.node_and_ancestors_are_animated_or_invertible) { |
| 1084 node->data.node_and_ancestors_are_animated_or_invertible = false; |
| 1085 return; |
| 1086 } |
| 1087 bool is_invertible = node->data.is_invertible; |
| 1088 // Even when the current node's transform and the parent's screen space |
| 1089 // transform are invertible, the current node's screen space transform can |
| 1090 // become uninvertible due to floating-point arithmetic. |
| 1091 if (!node->data.ancestors_are_invertible && |
| 1092 parent_node->data.ancestors_are_invertible) |
| 1093 is_invertible = false; |
| 1094 node->data.node_and_ancestors_are_animated_or_invertible = |
| 1095 node->data.is_animated || is_invertible; |
| 1096 } |
| 1097 |
| 1065 void TransformTree::SetDeviceTransform(const gfx::Transform& transform, | 1098 void TransformTree::SetDeviceTransform(const gfx::Transform& transform, |
| 1066 gfx::PointF root_position) { | 1099 gfx::PointF root_position) { |
| 1067 gfx::Transform root_post_local = transform; | 1100 gfx::Transform root_post_local = transform; |
| 1068 TransformNode* node = Node(1); | 1101 TransformNode* node = Node(1); |
| 1069 root_post_local.Scale(node->data.post_local_scale_factor, | 1102 root_post_local.Scale(node->data.post_local_scale_factor, |
| 1070 node->data.post_local_scale_factor); | 1103 node->data.post_local_scale_factor); |
| 1071 root_post_local.Translate(root_position.x(), root_position.y()); | 1104 root_post_local.Translate(root_position.x(), root_position.y()); |
| 1072 if (node->data.post_local == root_post_local) | 1105 if (node->data.post_local == root_post_local) |
| 1073 return; | 1106 return; |
| 1074 | 1107 |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1920 break; | 1953 break; |
| 1921 case ALL_TREES: | 1954 case ALL_TREES: |
| 1922 transform_tree.ResetChangeTracking(); | 1955 transform_tree.ResetChangeTracking(); |
| 1923 effect_tree.ResetChangeTracking(); | 1956 effect_tree.ResetChangeTracking(); |
| 1924 } | 1957 } |
| 1925 changed = false; | 1958 changed = false; |
| 1926 full_tree_damaged = false; | 1959 full_tree_damaged = false; |
| 1927 } | 1960 } |
| 1928 | 1961 |
| 1929 } // namespace cc | 1962 } // namespace cc |
| OLD | NEW |