Chromium Code Reviews| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 node_and_ancestors_are_flat(true), | 172 node_and_ancestors_are_flat(true), |
| 173 node_and_ancestors_have_only_integer_translation(true), | 173 node_and_ancestors_have_only_integer_translation(true), |
| 174 scrolls(false), | 174 scrolls(false), |
| 175 needs_sublayer_scale(false), | 175 needs_sublayer_scale(false), |
| 176 affected_by_inner_viewport_bounds_delta_x(false), | 176 affected_by_inner_viewport_bounds_delta_x(false), |
| 177 affected_by_inner_viewport_bounds_delta_y(false), | 177 affected_by_inner_viewport_bounds_delta_y(false), |
| 178 affected_by_outer_viewport_bounds_delta_x(false), | 178 affected_by_outer_viewport_bounds_delta_x(false), |
| 179 affected_by_outer_viewport_bounds_delta_y(false), | 179 affected_by_outer_viewport_bounds_delta_y(false), |
| 180 in_subtree_of_page_scale_layer(false), | 180 in_subtree_of_page_scale_layer(false), |
| 181 transform_changed(false), | 181 transform_changed(false), |
| 182 post_local_scale_factor(1.0f), | 182 post_local_scale_factor(1.0f) {} |
| 183 local_maximum_animation_target_scale(0.f), | |
| 184 local_starting_animation_scale(0.f), | |
| 185 combined_maximum_animation_target_scale(0.f), | |
| 186 combined_starting_animation_scale(0.f) {} | |
| 187 | 183 |
| 188 TransformNodeData::TransformNodeData(const TransformNodeData& other) = default; | 184 TransformNodeData::TransformNodeData(const TransformNodeData& other) = default; |
| 189 | 185 |
| 190 TransformNodeData::~TransformNodeData() { | 186 TransformNodeData::~TransformNodeData() { |
| 191 } | 187 } |
| 192 | 188 |
| 193 bool TransformNodeData::operator==(const TransformNodeData& other) const { | 189 bool TransformNodeData::operator==(const TransformNodeData& other) const { |
| 194 return pre_local == other.pre_local && local == other.local && | 190 return pre_local == other.pre_local && local == other.local && |
| 195 post_local == other.post_local && to_parent == other.to_parent && | 191 post_local == other.post_local && to_parent == other.to_parent && |
| 196 source_node_id == other.source_node_id && | 192 source_node_id == other.source_node_id && |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 218 affected_by_inner_viewport_bounds_delta_y == | 214 affected_by_inner_viewport_bounds_delta_y == |
| 219 other.affected_by_inner_viewport_bounds_delta_y && | 215 other.affected_by_inner_viewport_bounds_delta_y && |
| 220 affected_by_outer_viewport_bounds_delta_x == | 216 affected_by_outer_viewport_bounds_delta_x == |
| 221 other.affected_by_outer_viewport_bounds_delta_x && | 217 other.affected_by_outer_viewport_bounds_delta_x && |
| 222 affected_by_outer_viewport_bounds_delta_y == | 218 affected_by_outer_viewport_bounds_delta_y == |
| 223 other.affected_by_outer_viewport_bounds_delta_y && | 219 other.affected_by_outer_viewport_bounds_delta_y && |
| 224 in_subtree_of_page_scale_layer == | 220 in_subtree_of_page_scale_layer == |
| 225 other.in_subtree_of_page_scale_layer && | 221 other.in_subtree_of_page_scale_layer && |
| 226 transform_changed == other.transform_changed && | 222 transform_changed == other.transform_changed && |
| 227 post_local_scale_factor == other.post_local_scale_factor && | 223 post_local_scale_factor == other.post_local_scale_factor && |
| 228 local_maximum_animation_target_scale == | |
| 229 other.local_maximum_animation_target_scale && | |
| 230 local_starting_animation_scale == | |
| 231 other.local_starting_animation_scale && | |
| 232 combined_maximum_animation_target_scale == | |
| 233 other.combined_maximum_animation_target_scale && | |
| 234 combined_starting_animation_scale == | |
| 235 other.combined_starting_animation_scale && | |
| 236 sublayer_scale == other.sublayer_scale && | 224 sublayer_scale == other.sublayer_scale && |
| 237 scroll_offset == other.scroll_offset && | 225 scroll_offset == other.scroll_offset && |
| 238 scroll_snap == other.scroll_snap && | 226 scroll_snap == other.scroll_snap && |
| 239 source_offset == other.source_offset && | 227 source_offset == other.source_offset && |
| 240 source_to_parent == other.source_to_parent; | 228 source_to_parent == other.source_to_parent; |
| 241 } | 229 } |
| 242 | 230 |
| 243 void TransformNodeData::update_pre_local_transform( | 231 void TransformNodeData::update_pre_local_transform( |
| 244 const gfx::Point3F& transform_origin) { | 232 const gfx::Point3F& transform_origin) { |
| 245 pre_local.MakeIdentity(); | 233 pre_local.MakeIdentity(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 data->set_affected_by_inner_viewport_bounds_delta_y( | 287 data->set_affected_by_inner_viewport_bounds_delta_y( |
| 300 affected_by_inner_viewport_bounds_delta_y); | 288 affected_by_inner_viewport_bounds_delta_y); |
| 301 data->set_affected_by_outer_viewport_bounds_delta_x( | 289 data->set_affected_by_outer_viewport_bounds_delta_x( |
| 302 affected_by_outer_viewport_bounds_delta_x); | 290 affected_by_outer_viewport_bounds_delta_x); |
| 303 data->set_affected_by_outer_viewport_bounds_delta_y( | 291 data->set_affected_by_outer_viewport_bounds_delta_y( |
| 304 affected_by_outer_viewport_bounds_delta_y); | 292 affected_by_outer_viewport_bounds_delta_y); |
| 305 | 293 |
| 306 data->set_in_subtree_of_page_scale_layer(in_subtree_of_page_scale_layer); | 294 data->set_in_subtree_of_page_scale_layer(in_subtree_of_page_scale_layer); |
| 307 data->set_transform_changed(transform_changed); | 295 data->set_transform_changed(transform_changed); |
| 308 data->set_post_local_scale_factor(post_local_scale_factor); | 296 data->set_post_local_scale_factor(post_local_scale_factor); |
| 309 data->set_local_maximum_animation_target_scale( | |
| 310 local_maximum_animation_target_scale); | |
| 311 data->set_local_starting_animation_scale(local_starting_animation_scale); | |
| 312 data->set_combined_maximum_animation_target_scale( | |
| 313 combined_maximum_animation_target_scale); | |
| 314 data->set_combined_starting_animation_scale( | |
| 315 combined_starting_animation_scale); | |
| 316 | 297 |
| 317 Vector2dFToProto(sublayer_scale, data->mutable_sublayer_scale()); | 298 Vector2dFToProto(sublayer_scale, data->mutable_sublayer_scale()); |
| 318 ScrollOffsetToProto(scroll_offset, data->mutable_scroll_offset()); | 299 ScrollOffsetToProto(scroll_offset, data->mutable_scroll_offset()); |
| 319 Vector2dFToProto(scroll_snap, data->mutable_scroll_snap()); | 300 Vector2dFToProto(scroll_snap, data->mutable_scroll_snap()); |
| 320 Vector2dFToProto(source_offset, data->mutable_source_offset()); | 301 Vector2dFToProto(source_offset, data->mutable_source_offset()); |
| 321 Vector2dFToProto(source_to_parent, data->mutable_source_to_parent()); | 302 Vector2dFToProto(source_to_parent, data->mutable_source_to_parent()); |
| 322 } | 303 } |
| 323 | 304 |
| 324 void TransformNodeData::FromProtobuf(const proto::TreeNode& proto) { | 305 void TransformNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 325 DCHECK(proto.has_transform_node_data()); | 306 DCHECK(proto.has_transform_node_data()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 affected_by_inner_viewport_bounds_delta_y = | 342 affected_by_inner_viewport_bounds_delta_y = |
| 362 data.affected_by_inner_viewport_bounds_delta_y(); | 343 data.affected_by_inner_viewport_bounds_delta_y(); |
| 363 affected_by_outer_viewport_bounds_delta_x = | 344 affected_by_outer_viewport_bounds_delta_x = |
| 364 data.affected_by_outer_viewport_bounds_delta_x(); | 345 data.affected_by_outer_viewport_bounds_delta_x(); |
| 365 affected_by_outer_viewport_bounds_delta_y = | 346 affected_by_outer_viewport_bounds_delta_y = |
| 366 data.affected_by_outer_viewport_bounds_delta_y(); | 347 data.affected_by_outer_viewport_bounds_delta_y(); |
| 367 | 348 |
| 368 in_subtree_of_page_scale_layer = data.in_subtree_of_page_scale_layer(); | 349 in_subtree_of_page_scale_layer = data.in_subtree_of_page_scale_layer(); |
| 369 transform_changed = data.transform_changed(); | 350 transform_changed = data.transform_changed(); |
| 370 post_local_scale_factor = data.post_local_scale_factor(); | 351 post_local_scale_factor = data.post_local_scale_factor(); |
| 371 local_maximum_animation_target_scale = | |
| 372 data.local_maximum_animation_target_scale(); | |
| 373 local_starting_animation_scale = data.local_starting_animation_scale(); | |
| 374 combined_maximum_animation_target_scale = | |
| 375 data.combined_maximum_animation_target_scale(); | |
| 376 combined_starting_animation_scale = data.combined_starting_animation_scale(); | |
| 377 | 352 |
| 378 sublayer_scale = ProtoToVector2dF(data.sublayer_scale()); | 353 sublayer_scale = ProtoToVector2dF(data.sublayer_scale()); |
| 379 scroll_offset = ProtoToScrollOffset(data.scroll_offset()); | 354 scroll_offset = ProtoToScrollOffset(data.scroll_offset()); |
| 380 scroll_snap = ProtoToVector2dF(data.scroll_snap()); | 355 scroll_snap = ProtoToVector2dF(data.scroll_snap()); |
| 381 source_offset = ProtoToVector2dF(data.source_offset()); | 356 source_offset = ProtoToVector2dF(data.source_offset()); |
| 382 source_to_parent = ProtoToVector2dF(data.source_to_parent()); | 357 source_to_parent = ProtoToVector2dF(data.source_to_parent()); |
| 383 } | 358 } |
| 384 | 359 |
| 385 void TransformNodeData::AsValueInto( | 360 void TransformNodeData::AsValueInto( |
| 386 base::trace_event::TracedValue* value) const { | 361 base::trace_event::TracedValue* value) const { |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 | 706 |
| 732 void TransformTree::clear() { | 707 void TransformTree::clear() { |
| 733 PropertyTree<TransformNode>::clear(); | 708 PropertyTree<TransformNode>::clear(); |
| 734 | 709 |
| 735 nodes_affected_by_inner_viewport_bounds_delta_.clear(); | 710 nodes_affected_by_inner_viewport_bounds_delta_.clear(); |
| 736 nodes_affected_by_outer_viewport_bounds_delta_.clear(); | 711 nodes_affected_by_outer_viewport_bounds_delta_.clear(); |
| 737 cached_data_.clear(); | 712 cached_data_.clear(); |
| 738 cached_data_.push_back(TransformCachedNodeData()); | 713 cached_data_.push_back(TransformCachedNodeData()); |
| 739 } | 714 } |
| 740 | 715 |
| 716 void TransformTree::set_needs_update(bool needs_update) { | |
| 717 if (needs_update && !PropertyTree::needs_update()) | |
| 718 property_trees()->UpdateCachedNumber(); | |
| 719 PropertyTree::set_needs_update(needs_update); | |
| 720 } | |
| 721 | |
| 741 bool TransformTree::ComputeTransform(int source_id, | 722 bool TransformTree::ComputeTransform(int source_id, |
| 742 int dest_id, | 723 int dest_id, |
| 743 gfx::Transform* transform) const { | 724 gfx::Transform* transform) const { |
| 744 transform->MakeIdentity(); | 725 transform->MakeIdentity(); |
| 745 | 726 |
| 746 if (source_id == dest_id) | 727 if (source_id == dest_id) |
| 747 return true; | 728 return true; |
| 748 | 729 |
| 749 if (source_id > dest_id) { | 730 if (source_id > dest_id) { |
| 750 return CombineTransformsBetween(source_id, dest_id, transform); | 731 return CombineTransformsBetween(source_id, dest_id, transform); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1053 if (!target_space_transform.GetInverse(&from_target)) | 1034 if (!target_space_transform.GetInverse(&from_target)) |
| 1054 node->data.ancestors_are_invertible = false; | 1035 node->data.ancestors_are_invertible = false; |
| 1055 SetToTarget(node->id, target_space_transform); | 1036 SetToTarget(node->id, target_space_transform); |
| 1056 SetFromTarget(node->id, from_target); | 1037 SetFromTarget(node->id, from_target); |
| 1057 } | 1038 } |
| 1058 | 1039 |
| 1059 void TransformTree::UpdateAnimationProperties(TransformNode* node, | 1040 void TransformTree::UpdateAnimationProperties(TransformNode* node, |
| 1060 TransformNode* parent_node) { | 1041 TransformNode* parent_node) { |
| 1061 bool ancestor_is_animating = false; | 1042 bool ancestor_is_animating = false; |
| 1062 bool ancestor_is_animating_scale = false; | 1043 bool ancestor_is_animating_scale = false; |
| 1063 float ancestor_maximum_target_scale = 0.f; | |
| 1064 float ancestor_starting_animation_scale = 0.f; | |
| 1065 if (parent_node) { | 1044 if (parent_node) { |
| 1066 ancestor_is_animating = parent_node->data.to_screen_is_potentially_animated; | 1045 ancestor_is_animating = parent_node->data.to_screen_is_potentially_animated; |
| 1067 ancestor_is_animating_scale = | 1046 ancestor_is_animating_scale = |
| 1068 parent_node->data.to_screen_has_scale_animation; | 1047 parent_node->data.to_screen_has_scale_animation; |
| 1069 ancestor_maximum_target_scale = | |
| 1070 parent_node->data.combined_maximum_animation_target_scale; | |
| 1071 ancestor_starting_animation_scale = | |
| 1072 parent_node->data.combined_starting_animation_scale; | |
| 1073 } | 1048 } |
| 1074 node->data.to_screen_is_potentially_animated = | 1049 node->data.to_screen_is_potentially_animated = |
| 1075 node->data.has_potential_animation || ancestor_is_animating; | 1050 node->data.has_potential_animation || ancestor_is_animating; |
| 1076 node->data.to_screen_has_scale_animation = | 1051 node->data.to_screen_has_scale_animation = |
| 1077 !node->data.has_only_translation_animations || | 1052 !node->data.has_only_translation_animations || |
| 1078 ancestor_is_animating_scale; | 1053 ancestor_is_animating_scale; |
| 1079 | |
| 1080 // Once we've failed to compute a maximum animated scale at an ancestor, we | |
| 1081 // continue to fail. | |
| 1082 bool failed_at_ancestor = | |
| 1083 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; | |
| 1084 | |
| 1085 // Computing maximum animated scale in the presence of non-scale/translation | |
| 1086 // transforms isn't supported. | |
| 1087 bool failed_for_non_scale_or_translation = | |
| 1088 !ToTarget(node->id).IsScaleOrTranslation(); | |
| 1089 | |
| 1090 // We don't attempt to accumulate animation scale from multiple nodes with | |
| 1091 // scale animations, because of the risk of significant overestimation. For | |
| 1092 // example, one node might be increasing scale from 1 to 10 at the same time | |
| 1093 // as another node is decreasing scale from 10 to 1. Naively combining these | |
| 1094 // scales would produce a scale of 100. | |
| 1095 bool failed_for_multiple_scale_animations = | |
| 1096 ancestor_is_animating_scale && | |
| 1097 !node->data.has_only_translation_animations; | |
| 1098 | |
| 1099 if (failed_at_ancestor || failed_for_non_scale_or_translation || | |
| 1100 failed_for_multiple_scale_animations) { | |
| 1101 node->data.combined_maximum_animation_target_scale = 0.f; | |
| 1102 node->data.combined_starting_animation_scale = 0.f; | |
| 1103 | |
| 1104 // This ensures that descendants know we've failed to compute a maximum | |
| 1105 // animated scale. | |
| 1106 node->data.to_screen_has_scale_animation = true; | |
| 1107 return; | |
| 1108 } | |
| 1109 | |
| 1110 if (!node->data.to_screen_has_scale_animation) { | |
| 1111 node->data.combined_maximum_animation_target_scale = 0.f; | |
| 1112 node->data.combined_starting_animation_scale = 0.f; | |
| 1113 return; | |
| 1114 } | |
| 1115 | |
| 1116 // At this point, we know exactly one of this node or an ancestor is animating | |
| 1117 // scale. | |
| 1118 if (node->data.has_only_translation_animations) { | |
| 1119 // An ancestor is animating scale. | |
| 1120 gfx::Vector2dF local_scales = | |
| 1121 MathUtil::ComputeTransform2dScaleComponents(node->data.local, 0.f); | |
| 1122 float max_local_scale = std::max(local_scales.x(), local_scales.y()); | |
| 1123 node->data.combined_maximum_animation_target_scale = | |
| 1124 max_local_scale * ancestor_maximum_target_scale; | |
| 1125 node->data.combined_starting_animation_scale = | |
| 1126 max_local_scale * ancestor_starting_animation_scale; | |
| 1127 return; | |
| 1128 } | |
| 1129 | |
| 1130 if (node->data.local_starting_animation_scale == 0.f || | |
| 1131 node->data.local_maximum_animation_target_scale == 0.f) { | |
| 1132 node->data.combined_maximum_animation_target_scale = 0.f; | |
| 1133 node->data.combined_starting_animation_scale = 0.f; | |
| 1134 return; | |
| 1135 } | |
| 1136 | |
| 1137 gfx::Vector2dF ancestor_scales = | |
| 1138 parent_node ? MathUtil::ComputeTransform2dScaleComponents( | |
| 1139 ToTarget(parent_node->id), 0.f) | |
| 1140 : gfx::Vector2dF(1.f, 1.f); | |
| 1141 float max_ancestor_scale = std::max(ancestor_scales.x(), ancestor_scales.y()); | |
| 1142 node->data.combined_maximum_animation_target_scale = | |
| 1143 max_ancestor_scale * node->data.local_maximum_animation_target_scale; | |
| 1144 node->data.combined_starting_animation_scale = | |
| 1145 max_ancestor_scale * node->data.local_starting_animation_scale; | |
| 1146 } | 1054 } |
| 1147 | 1055 |
| 1148 void TransformTree::UndoSnapping(TransformNode* node) { | 1056 void TransformTree::UndoSnapping(TransformNode* node) { |
| 1149 // to_parent transform has the scroll snap from previous frame baked in. | 1057 // to_parent transform has the scroll snap from previous frame baked in. |
| 1150 // We need to undo it and use the un-snapped transform to compute current | 1058 // We need to undo it and use the un-snapped transform to compute current |
| 1151 // target and screen space transforms. | 1059 // target and screen space transforms. |
| 1152 node->data.to_parent.Translate(-node->data.scroll_snap.x(), | 1060 node->data.to_parent.Translate(-node->data.scroll_snap.x(), |
| 1153 -node->data.scroll_snap.y()); | 1061 -node->data.scroll_snap.y()); |
| 1154 } | 1062 } |
| 1155 | 1063 |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2142 } | 2050 } |
| 2143 | 2051 |
| 2144 gfx::ScrollOffset ScrollTree::ClampScrollOffsetToLimits( | 2052 gfx::ScrollOffset ScrollTree::ClampScrollOffsetToLimits( |
| 2145 gfx::ScrollOffset offset, | 2053 gfx::ScrollOffset offset, |
| 2146 ScrollNode* scroll_node) const { | 2054 ScrollNode* scroll_node) const { |
| 2147 offset.SetToMin(MaxScrollOffset(scroll_node->id)); | 2055 offset.SetToMin(MaxScrollOffset(scroll_node->id)); |
| 2148 offset.SetToMax(gfx::ScrollOffset()); | 2056 offset.SetToMax(gfx::ScrollOffset()); |
| 2149 return offset; | 2057 return offset; |
| 2150 } | 2058 } |
| 2151 | 2059 |
| 2060 PropertyTreesCachedData::PropertyTreesCachedData() | |
| 2061 : property_tree_update_number(0) { | |
| 2062 animation_scales.clear(); | |
| 2063 } | |
| 2064 | |
| 2065 PropertyTreesCachedData::~PropertyTreesCachedData() {} | |
| 2066 | |
| 2152 PropertyTrees::PropertyTrees() | 2067 PropertyTrees::PropertyTrees() |
| 2153 : needs_rebuild(true), | 2068 : needs_rebuild(true), |
| 2154 non_root_surfaces_enabled(true), | 2069 non_root_surfaces_enabled(true), |
| 2155 changed(false), | 2070 changed(false), |
| 2156 full_tree_damaged(false), | 2071 full_tree_damaged(false), |
| 2157 sequence_number(0), | 2072 sequence_number(0), |
| 2158 is_main_thread(true), | 2073 is_main_thread(true), |
| 2159 is_active(false) { | 2074 is_active(false) { |
| 2160 transform_tree.SetPropertyTrees(this); | 2075 transform_tree.SetPropertyTrees(this); |
| 2161 effect_tree.SetPropertyTrees(this); | 2076 effect_tree.SetPropertyTrees(this); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2204 inner_viewport_container_bounds_delta_ = | 2119 inner_viewport_container_bounds_delta_ = |
| 2205 from.inner_viewport_container_bounds_delta(); | 2120 from.inner_viewport_container_bounds_delta(); |
| 2206 outer_viewport_container_bounds_delta_ = | 2121 outer_viewport_container_bounds_delta_ = |
| 2207 from.outer_viewport_container_bounds_delta(); | 2122 from.outer_viewport_container_bounds_delta(); |
| 2208 inner_viewport_scroll_bounds_delta_ = | 2123 inner_viewport_scroll_bounds_delta_ = |
| 2209 from.inner_viewport_scroll_bounds_delta(); | 2124 from.inner_viewport_scroll_bounds_delta(); |
| 2210 transform_tree.SetPropertyTrees(this); | 2125 transform_tree.SetPropertyTrees(this); |
| 2211 effect_tree.SetPropertyTrees(this); | 2126 effect_tree.SetPropertyTrees(this); |
| 2212 clip_tree.SetPropertyTrees(this); | 2127 clip_tree.SetPropertyTrees(this); |
| 2213 scroll_tree.SetPropertyTrees(this); | 2128 scroll_tree.SetPropertyTrees(this); |
| 2129 ResetCachedData(); | |
| 2214 return *this; | 2130 return *this; |
| 2215 } | 2131 } |
| 2216 | 2132 |
| 2217 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { | 2133 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { |
| 2218 // TODO(khushalsagar): Add support for sending diffs when serializaing | 2134 // TODO(khushalsagar): Add support for sending diffs when serializaing |
| 2219 // property trees. See crbug/555370. | 2135 // property trees. See crbug/555370. |
| 2220 transform_tree.ToProtobuf(proto->mutable_transform_tree()); | 2136 transform_tree.ToProtobuf(proto->mutable_transform_tree()); |
| 2221 effect_tree.ToProtobuf(proto->mutable_effect_tree()); | 2137 effect_tree.ToProtobuf(proto->mutable_effect_tree()); |
| 2222 clip_tree.ToProtobuf(proto->mutable_clip_tree()); | 2138 clip_tree.ToProtobuf(proto->mutable_clip_tree()); |
| 2223 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); | 2139 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2386 clip_tree.AsValueInto(value.get()); | 2302 clip_tree.AsValueInto(value.get()); |
| 2387 value->EndDictionary(); | 2303 value->EndDictionary(); |
| 2388 | 2304 |
| 2389 value->BeginDictionary("scroll_tree"); | 2305 value->BeginDictionary("scroll_tree"); |
| 2390 scroll_tree.AsValueInto(value.get()); | 2306 scroll_tree.AsValueInto(value.get()); |
| 2391 value->EndDictionary(); | 2307 value->EndDictionary(); |
| 2392 | 2308 |
| 2393 return value; | 2309 return value; |
| 2394 } | 2310 } |
| 2395 | 2311 |
| 2312 CombinedAnimationScale PropertyTrees::GetAnimationScales( | |
| 2313 int transform_node_id, | |
| 2314 LayerTreeImpl* layer_tree_impl) { | |
| 2315 if (cached_data_.animation_scales[transform_node_id].update_number != | |
| 2316 cached_data_.property_tree_update_number) { | |
| 2317 TransformNode* node = transform_tree.Node(transform_node_id); | |
| 2318 TransformNode* parent_node = transform_tree.parent(node); | |
| 2319 bool ancestor_is_animating_scale = false; | |
| 2320 float ancestor_maximum_target_scale = 0.f; | |
| 2321 float ancestor_starting_animation_scale = 0.f; | |
| 2322 if (parent_node) { | |
| 2323 ancestor_is_animating_scale = | |
| 2324 parent_node->data.to_screen_has_scale_animation; | |
| 2325 CombinedAnimationScale combined_animation_scale = GetAnimationScales( | |
| 2326 transform_tree.Node(transform_node_id)->parent_id, layer_tree_impl); | |
| 2327 ancestor_maximum_target_scale = | |
| 2328 combined_animation_scale.maximum_animation_scale; | |
| 2329 ancestor_starting_animation_scale = | |
| 2330 combined_animation_scale.starting_animation_scale; | |
| 2331 } | |
| 2332 | |
| 2333 bool failed_at_ancestor = | |
| 2334 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; | |
| 2335 bool failed_for_non_scale_or_translation = | |
| 2336 !transform_tree.ToTarget(transform_node_id).IsScaleOrTranslation(); | |
| 2337 bool failed_for_multiple_scale_animations = | |
| 2338 ancestor_is_animating_scale && | |
| 2339 !node->data.has_only_translation_animations; | |
| 2340 | |
| 2341 if (failed_at_ancestor || failed_for_non_scale_or_translation || | |
| 2342 failed_for_multiple_scale_animations) { | |
| 2343 node->data.to_screen_has_scale_animation = true; | |
|
ajuma
2016/06/29 15:04:37
If to_screen_has_scale_animation is only used for
sunxd
2016/06/30 15:29:44
Done.
| |
| 2344 cached_data_.animation_scales[transform_node_id] | |
| 2345 .combined_maximum_animation_target_scale = 0.f; | |
| 2346 cached_data_.animation_scales[transform_node_id] | |
| 2347 .combined_starting_animation_scale = 0.f; | |
| 2348 } else if (!node->data.to_screen_has_scale_animation) { | |
| 2349 cached_data_.animation_scales[transform_node_id] | |
| 2350 .combined_maximum_animation_target_scale = 0.f; | |
| 2351 cached_data_.animation_scales[transform_node_id] | |
| 2352 .combined_starting_animation_scale = 0.f; | |
| 2353 } else if (node->data.has_only_translation_animations) { | |
| 2354 gfx::Vector2dF local_scales = | |
| 2355 MathUtil::ComputeTransform2dScaleComponents(node->data.local, 0.f); | |
| 2356 float max_local_scale = std::max(local_scales.x(), local_scales.y()); | |
| 2357 cached_data_.animation_scales[transform_node_id] | |
| 2358 .combined_maximum_animation_target_scale = | |
| 2359 max_local_scale * ancestor_maximum_target_scale; | |
| 2360 cached_data_.animation_scales[transform_node_id] | |
| 2361 .combined_starting_animation_scale = | |
| 2362 max_local_scale * ancestor_starting_animation_scale; | |
| 2363 } else { | |
| 2364 LayerImpl* layer_impl = layer_tree_impl->LayerById(node->owner_id); | |
| 2365 layer_tree_impl->MaximumTargetScale( | |
|
ajuma
2016/06/29 15:04:37
Please leave a TODO to make these calls take an id
sunxd
2016/06/30 15:29:44
Done.
| |
| 2366 layer_impl, &cached_data_.animation_scales[transform_node_id] | |
| 2367 .local_maximum_animation_target_scale); | |
| 2368 layer_tree_impl->AnimationStartScale( | |
| 2369 layer_impl, &cached_data_.animation_scales[transform_node_id] | |
| 2370 .local_starting_animation_scale); | |
| 2371 gfx::Vector2dF local_scales = | |
| 2372 MathUtil::ComputeTransform2dScaleComponents(node->data.local, 0.f); | |
| 2373 float max_local_scale = std::max(local_scales.x(), local_scales.y()); | |
| 2374 | |
| 2375 if (cached_data_.animation_scales[transform_node_id] | |
| 2376 .local_starting_animation_scale == 0.f || | |
| 2377 cached_data_.animation_scales[transform_node_id] | |
| 2378 .local_maximum_animation_target_scale == 0.f) { | |
| 2379 cached_data_.animation_scales[transform_node_id] | |
| 2380 .combined_maximum_animation_target_scale = | |
| 2381 max_local_scale * ancestor_maximum_target_scale; | |
| 2382 cached_data_.animation_scales[transform_node_id] | |
| 2383 .combined_starting_animation_scale = | |
| 2384 max_local_scale * ancestor_starting_animation_scale; | |
| 2385 } else { | |
| 2386 gfx::Vector2dF ancestor_scales = | |
| 2387 parent_node ? MathUtil::ComputeTransform2dScaleComponents( | |
| 2388 transform_tree.ToTarget(parent_node->id), 0.f) | |
| 2389 : gfx::Vector2dF(1.f, 1.f); | |
| 2390 float max_ancestor_scale = | |
| 2391 std::max(ancestor_scales.x(), ancestor_scales.y()); | |
| 2392 cached_data_.animation_scales[transform_node_id] | |
| 2393 .combined_maximum_animation_target_scale = | |
| 2394 max_ancestor_scale * | |
| 2395 cached_data_.animation_scales[transform_node_id] | |
| 2396 .local_maximum_animation_target_scale; | |
| 2397 cached_data_.animation_scales[transform_node_id] | |
| 2398 .combined_starting_animation_scale = | |
| 2399 max_ancestor_scale * | |
| 2400 cached_data_.animation_scales[transform_node_id] | |
| 2401 .local_starting_animation_scale; | |
| 2402 } | |
| 2403 } | |
| 2404 cached_data_.animation_scales[transform_node_id].update_number = | |
| 2405 cached_data_.property_tree_update_number; | |
| 2406 } | |
| 2407 return CombinedAnimationScale(cached_data_.animation_scales[transform_node_id] | |
| 2408 .combined_maximum_animation_target_scale, | |
| 2409 cached_data_.animation_scales[transform_node_id] | |
| 2410 .combined_starting_animation_scale); | |
| 2411 } | |
| 2412 | |
| 2413 void PropertyTrees::SetAnimationScalesForTesting( | |
| 2414 int transform_id, | |
| 2415 float maximum_animation_scale, | |
| 2416 float starting_animation_scale) { | |
| 2417 cached_data_.animation_scales[transform_id] | |
| 2418 .combined_maximum_animation_target_scale = maximum_animation_scale; | |
| 2419 cached_data_.animation_scales[transform_id] | |
| 2420 .combined_starting_animation_scale = starting_animation_scale; | |
| 2421 cached_data_.animation_scales[transform_id].update_number = | |
| 2422 cached_data_.property_tree_update_number; | |
| 2423 } | |
| 2424 | |
| 2425 void PropertyTrees::ResetCachedData() { | |
| 2426 cached_data_.property_tree_update_number = 0; | |
| 2427 cached_data_.animation_scales = std::vector<AnimationScaleData>( | |
| 2428 transform_tree.nodes().size(), AnimationScaleData()); | |
| 2429 } | |
| 2430 | |
| 2431 void PropertyTrees::UpdateCachedNumber() { | |
| 2432 cached_data_.property_tree_update_number++; | |
| 2433 } | |
| 2434 | |
| 2396 } // namespace cc | 2435 } // namespace cc |
| OLD | NEW |