| 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/proto/gfx_conversions.h" |
| 11 #include "cc/proto/property_tree.pb.h" |
| 12 #include "cc/proto/scroll_offset.pb.h" |
| 13 #include "cc/proto/transform.pb.h" |
| 14 #include "cc/proto/vector2df.pb.h" |
| 10 #include "cc/trees/property_tree.h" | 15 #include "cc/trees/property_tree.h" |
| 11 | 16 |
| 12 namespace cc { | 17 namespace cc { |
| 13 | 18 |
| 14 template <typename T> | 19 template <typename T> |
| 20 bool TreeNode<T>::operator==(const TreeNode<T>& other) const { |
| 21 return id == other.id && parent_id == other.parent_id && |
| 22 owner_id == other.owner_id && data == other.data; |
| 23 } |
| 24 |
| 25 template <typename T> |
| 26 void TreeNode<T>::ToProtobuf(proto::TreeNode* proto) const { |
| 27 proto->set_id(id); |
| 28 proto->set_parent_id(parent_id); |
| 29 proto->set_owner_id(owner_id); |
| 30 data.ToProtobuf(proto); |
| 31 } |
| 32 |
| 33 template <typename T> |
| 34 void TreeNode<T>::FromProtobuf(const proto::TreeNode& proto) { |
| 35 id = proto.id(); |
| 36 parent_id = proto.parent_id(); |
| 37 owner_id = proto.owner_id(); |
| 38 data.FromProtobuf(proto); |
| 39 } |
| 40 |
| 41 template struct TreeNode<TransformNodeData>; |
| 42 template struct TreeNode<ClipNodeData>; |
| 43 template struct TreeNode<EffectNodeData>; |
| 44 |
| 45 template <typename T> |
| 15 PropertyTree<T>::PropertyTree() | 46 PropertyTree<T>::PropertyTree() |
| 16 : needs_update_(false) { | 47 : needs_update_(false) { |
| 17 nodes_.push_back(T()); | 48 nodes_.push_back(T()); |
| 18 back()->id = 0; | 49 back()->id = 0; |
| 19 back()->parent_id = -1; | 50 back()->parent_id = -1; |
| 20 } | 51 } |
| 21 | 52 |
| 22 template <typename T> | 53 template <typename T> |
| 23 PropertyTree<T>::~PropertyTree() { | 54 PropertyTree<T>::~PropertyTree() { |
| 24 } | 55 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 43 } | 74 } |
| 44 | 75 |
| 45 template <typename T> | 76 template <typename T> |
| 46 void PropertyTree<T>::clear() { | 77 void PropertyTree<T>::clear() { |
| 47 nodes_.clear(); | 78 nodes_.clear(); |
| 48 nodes_.push_back(T()); | 79 nodes_.push_back(T()); |
| 49 back()->id = 0; | 80 back()->id = 0; |
| 50 back()->parent_id = -1; | 81 back()->parent_id = -1; |
| 51 } | 82 } |
| 52 | 83 |
| 84 template <typename T> |
| 85 bool PropertyTree<T>::operator==(const PropertyTree<T>& other) const { |
| 86 return nodes_ == other.nodes() && needs_update_ == other.needs_update(); |
| 87 } |
| 88 |
| 89 template <typename T> |
| 90 void PropertyTree<T>::ToProtobuf(proto::PropertyTree* proto) const { |
| 91 DCHECK_EQ(0, proto->nodes_size()); |
| 92 for (const auto& node : nodes_) |
| 93 node.ToProtobuf(proto->add_nodes()); |
| 94 proto->set_needs_update(needs_update_); |
| 95 } |
| 96 |
| 97 template <typename T> |
| 98 void PropertyTree<T>::FromProtobuf(const proto::PropertyTree& proto) { |
| 99 // Verify that the property tree is empty. |
| 100 DCHECK_EQ(static_cast<int>(nodes_.size()), 1); |
| 101 DCHECK_EQ(back()->id, 0); |
| 102 DCHECK_EQ(back()->parent_id, -1); |
| 103 |
| 104 // Add the first node. |
| 105 DCHECK_GT(proto.nodes_size(), 0); |
| 106 nodes_.back().FromProtobuf(proto.nodes(0)); |
| 107 |
| 108 for (int i = 1; i < proto.nodes_size(); ++i) { |
| 109 nodes_.push_back(T()); |
| 110 nodes_.back().FromProtobuf(proto.nodes(i)); |
| 111 } |
| 112 |
| 113 needs_update_ = proto.needs_update(); |
| 114 } |
| 115 |
| 53 template class PropertyTree<TransformNode>; | 116 template class PropertyTree<TransformNode>; |
| 54 template class PropertyTree<ClipNode>; | 117 template class PropertyTree<ClipNode>; |
| 55 template class PropertyTree<EffectNode>; | 118 template class PropertyTree<EffectNode>; |
| 56 | 119 |
| 57 TransformNodeData::TransformNodeData() | 120 TransformNodeData::TransformNodeData() |
| 58 : target_id(-1), | 121 : target_id(-1), |
| 59 content_target_id(-1), | 122 content_target_id(-1), |
| 60 source_node_id(-1), | 123 source_node_id(-1), |
| 61 needs_local_transform_update(true), | 124 needs_local_transform_update(true), |
| 62 is_invertible(true), | 125 is_invertible(true), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 in_subtree_of_page_scale_layer(false), | 140 in_subtree_of_page_scale_layer(false), |
| 78 post_local_scale_factor(1.0f), | 141 post_local_scale_factor(1.0f), |
| 79 local_maximum_animation_target_scale(0.f), | 142 local_maximum_animation_target_scale(0.f), |
| 80 local_starting_animation_scale(0.f), | 143 local_starting_animation_scale(0.f), |
| 81 combined_maximum_animation_target_scale(0.f), | 144 combined_maximum_animation_target_scale(0.f), |
| 82 combined_starting_animation_scale(0.f) {} | 145 combined_starting_animation_scale(0.f) {} |
| 83 | 146 |
| 84 TransformNodeData::~TransformNodeData() { | 147 TransformNodeData::~TransformNodeData() { |
| 85 } | 148 } |
| 86 | 149 |
| 150 bool TransformNodeData::operator==(const TransformNodeData& other) const { |
| 151 return pre_local == other.pre_local && local == other.local && |
| 152 post_local == other.post_local && to_parent == other.to_parent && |
| 153 to_target == other.to_target && from_target == other.from_target && |
| 154 to_screen == other.to_screen && from_screen == other.from_screen && |
| 155 target_id == other.target_id && |
| 156 content_target_id == other.content_target_id && |
| 157 source_node_id == other.source_node_id && |
| 158 needs_local_transform_update == other.needs_local_transform_update && |
| 159 is_invertible == other.is_invertible && |
| 160 ancestors_are_invertible == other.ancestors_are_invertible && |
| 161 is_animated == other.is_animated && |
| 162 to_screen_is_animated == other.to_screen_is_animated && |
| 163 has_only_translation_animations == |
| 164 other.has_only_translation_animations && |
| 165 to_screen_has_scale_animation == other.to_screen_has_scale_animation && |
| 166 flattens_inherited_transform == other.flattens_inherited_transform && |
| 167 node_and_ancestors_are_flat == other.node_and_ancestors_are_flat && |
| 168 node_and_ancestors_have_only_integer_translation == |
| 169 other.node_and_ancestors_have_only_integer_translation && |
| 170 scrolls == other.scrolls && |
| 171 needs_sublayer_scale == other.needs_sublayer_scale && |
| 172 affected_by_inner_viewport_bounds_delta_x == |
| 173 other.affected_by_inner_viewport_bounds_delta_x && |
| 174 affected_by_inner_viewport_bounds_delta_y == |
| 175 other.affected_by_inner_viewport_bounds_delta_y && |
| 176 affected_by_outer_viewport_bounds_delta_x == |
| 177 other.affected_by_outer_viewport_bounds_delta_x && |
| 178 affected_by_outer_viewport_bounds_delta_y == |
| 179 other.affected_by_outer_viewport_bounds_delta_y && |
| 180 in_subtree_of_page_scale_layer == |
| 181 other.in_subtree_of_page_scale_layer && |
| 182 post_local_scale_factor == other.post_local_scale_factor && |
| 183 local_maximum_animation_target_scale == |
| 184 other.local_maximum_animation_target_scale && |
| 185 local_starting_animation_scale == |
| 186 other.local_starting_animation_scale && |
| 187 combined_maximum_animation_target_scale == |
| 188 other.combined_maximum_animation_target_scale && |
| 189 combined_starting_animation_scale == |
| 190 other.combined_starting_animation_scale && |
| 191 sublayer_scale == other.sublayer_scale && |
| 192 scroll_offset == other.scroll_offset && |
| 193 scroll_snap == other.scroll_snap && |
| 194 source_offset == other.source_offset && |
| 195 source_to_parent == other.source_to_parent; |
| 196 } |
| 197 |
| 87 void TransformNodeData::update_pre_local_transform( | 198 void TransformNodeData::update_pre_local_transform( |
| 88 const gfx::Point3F& transform_origin) { | 199 const gfx::Point3F& transform_origin) { |
| 89 pre_local.MakeIdentity(); | 200 pre_local.MakeIdentity(); |
| 90 pre_local.Translate3d(-transform_origin.x(), -transform_origin.y(), | 201 pre_local.Translate3d(-transform_origin.x(), -transform_origin.y(), |
| 91 -transform_origin.z()); | 202 -transform_origin.z()); |
| 92 } | 203 } |
| 93 | 204 |
| 94 void TransformNodeData::update_post_local_transform( | 205 void TransformNodeData::update_post_local_transform( |
| 95 const gfx::PointF& position, | 206 const gfx::PointF& position, |
| 96 const gfx::Point3F& transform_origin) { | 207 const gfx::Point3F& transform_origin) { |
| 97 post_local.MakeIdentity(); | 208 post_local.MakeIdentity(); |
| 98 post_local.Scale(post_local_scale_factor, post_local_scale_factor); | 209 post_local.Scale(post_local_scale_factor, post_local_scale_factor); |
| 99 post_local.Translate3d( | 210 post_local.Translate3d( |
| 100 position.x() + source_offset.x() + transform_origin.x(), | 211 position.x() + source_offset.x() + transform_origin.x(), |
| 101 position.y() + source_offset.y() + transform_origin.y(), | 212 position.y() + source_offset.y() + transform_origin.y(), |
| 102 transform_origin.z()); | 213 transform_origin.z()); |
| 103 } | 214 } |
| 104 | 215 |
| 216 void TransformNodeData::ToProtobuf(proto::TreeNode* proto) const { |
| 217 DCHECK(!proto->has_transform_node_data()); |
| 218 proto::TranformNodeData* data = proto->mutable_transform_node_data(); |
| 219 |
| 220 TransformToProto(pre_local, data->mutable_pre_local()); |
| 221 TransformToProto(local, data->mutable_local()); |
| 222 TransformToProto(post_local, data->mutable_post_local()); |
| 223 |
| 224 TransformToProto(to_parent, data->mutable_to_parent()); |
| 225 |
| 226 TransformToProto(to_target, data->mutable_to_target()); |
| 227 TransformToProto(from_target, data->mutable_from_target()); |
| 228 |
| 229 TransformToProto(to_screen, data->mutable_to_screen()); |
| 230 TransformToProto(from_screen, data->mutable_from_screen()); |
| 231 |
| 232 data->set_target_id(target_id); |
| 233 data->set_content_target_id(content_target_id); |
| 234 data->set_source_node_id(source_node_id); |
| 235 |
| 236 data->set_needs_local_transform_update(needs_local_transform_update); |
| 237 |
| 238 data->set_is_invertible(is_invertible); |
| 239 data->set_ancestors_are_invertible(ancestors_are_invertible); |
| 240 |
| 241 data->set_is_animated(is_animated); |
| 242 data->set_to_screen_is_animated(to_screen_is_animated); |
| 243 data->set_has_only_translation_animations(has_only_translation_animations); |
| 244 data->set_to_screen_has_scale_animation(to_screen_has_scale_animation); |
| 245 |
| 246 data->set_flattens_inherited_transform(flattens_inherited_transform); |
| 247 data->set_node_and_ancestors_are_flat(node_and_ancestors_are_flat); |
| 248 |
| 249 data->set_node_and_ancestors_have_only_integer_translation( |
| 250 node_and_ancestors_have_only_integer_translation); |
| 251 data->set_scrolls(scrolls); |
| 252 data->set_needs_sublayer_scale(needs_sublayer_scale); |
| 253 |
| 254 data->set_affected_by_inner_viewport_bounds_delta_x( |
| 255 affected_by_inner_viewport_bounds_delta_x); |
| 256 data->set_affected_by_inner_viewport_bounds_delta_y( |
| 257 affected_by_inner_viewport_bounds_delta_y); |
| 258 data->set_affected_by_outer_viewport_bounds_delta_x( |
| 259 affected_by_outer_viewport_bounds_delta_x); |
| 260 data->set_affected_by_outer_viewport_bounds_delta_y( |
| 261 affected_by_outer_viewport_bounds_delta_y); |
| 262 |
| 263 data->set_in_subtree_of_page_scale_layer(in_subtree_of_page_scale_layer); |
| 264 data->set_post_local_scale_factor(post_local_scale_factor); |
| 265 data->set_local_maximum_animation_target_scale( |
| 266 local_maximum_animation_target_scale); |
| 267 data->set_local_starting_animation_scale(local_starting_animation_scale); |
| 268 data->set_combined_maximum_animation_target_scale( |
| 269 combined_maximum_animation_target_scale); |
| 270 data->set_combined_starting_animation_scale( |
| 271 combined_starting_animation_scale); |
| 272 |
| 273 Vector2dFToProto(sublayer_scale, data->mutable_sublayer_scale()); |
| 274 ScrollOffsetToProto(scroll_offset, data->mutable_scroll_offset()); |
| 275 Vector2dFToProto(scroll_snap, data->mutable_scroll_snap()); |
| 276 Vector2dFToProto(source_offset, data->mutable_source_offset()); |
| 277 Vector2dFToProto(source_to_parent, data->mutable_source_to_parent()); |
| 278 } |
| 279 |
| 280 void TransformNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 281 DCHECK(proto.has_transform_node_data()); |
| 282 const proto::TranformNodeData& data = proto.transform_node_data(); |
| 283 |
| 284 pre_local = ProtoToTransform(data.pre_local()); |
| 285 local = ProtoToTransform(data.local()); |
| 286 post_local = ProtoToTransform(data.post_local()); |
| 287 |
| 288 to_parent = ProtoToTransform(data.to_parent()); |
| 289 |
| 290 to_target = ProtoToTransform(data.to_target()); |
| 291 from_target = ProtoToTransform(data.from_target()); |
| 292 |
| 293 to_screen = ProtoToTransform(data.to_screen()); |
| 294 from_screen = ProtoToTransform(data.from_screen()); |
| 295 |
| 296 target_id = data.target_id(); |
| 297 content_target_id = data.content_target_id(); |
| 298 source_node_id = data.source_node_id(); |
| 299 |
| 300 needs_local_transform_update = data.needs_local_transform_update(); |
| 301 |
| 302 is_invertible = data.is_invertible(); |
| 303 ancestors_are_invertible = data.ancestors_are_invertible(); |
| 304 |
| 305 is_animated = data.is_animated(); |
| 306 to_screen_is_animated = data.to_screen_is_animated(); |
| 307 has_only_translation_animations = data.has_only_translation_animations(); |
| 308 to_screen_has_scale_animation = data.to_screen_has_scale_animation(); |
| 309 |
| 310 flattens_inherited_transform = data.flattens_inherited_transform(); |
| 311 node_and_ancestors_are_flat = data.node_and_ancestors_are_flat(); |
| 312 |
| 313 node_and_ancestors_have_only_integer_translation = |
| 314 data.node_and_ancestors_have_only_integer_translation(); |
| 315 scrolls = data.scrolls(); |
| 316 needs_sublayer_scale = data.needs_sublayer_scale(); |
| 317 |
| 318 affected_by_inner_viewport_bounds_delta_x = |
| 319 data.affected_by_inner_viewport_bounds_delta_x(); |
| 320 affected_by_inner_viewport_bounds_delta_y = |
| 321 data.affected_by_inner_viewport_bounds_delta_y(); |
| 322 affected_by_outer_viewport_bounds_delta_x = |
| 323 data.affected_by_outer_viewport_bounds_delta_x(); |
| 324 affected_by_outer_viewport_bounds_delta_y = |
| 325 data.affected_by_outer_viewport_bounds_delta_y(); |
| 326 |
| 327 in_subtree_of_page_scale_layer = data.in_subtree_of_page_scale_layer(); |
| 328 post_local_scale_factor = data.post_local_scale_factor(); |
| 329 local_maximum_animation_target_scale = |
| 330 data.local_maximum_animation_target_scale(); |
| 331 local_starting_animation_scale = data.local_starting_animation_scale(); |
| 332 combined_maximum_animation_target_scale = |
| 333 data.combined_maximum_animation_target_scale(); |
| 334 combined_starting_animation_scale = data.combined_starting_animation_scale(); |
| 335 |
| 336 sublayer_scale = ProtoToVector2dF(data.sublayer_scale()); |
| 337 scroll_offset = ProtoToScrollOffset(data.scroll_offset()); |
| 338 scroll_snap = ProtoToVector2dF(data.scroll_snap()); |
| 339 source_offset = ProtoToVector2dF(data.source_offset()); |
| 340 source_to_parent = ProtoToVector2dF(data.source_to_parent()); |
| 341 } |
| 342 |
| 105 ClipNodeData::ClipNodeData() | 343 ClipNodeData::ClipNodeData() |
| 106 : transform_id(-1), | 344 : transform_id(-1), |
| 107 target_id(-1), | 345 target_id(-1), |
| 108 applies_local_clip(true), | 346 applies_local_clip(true), |
| 109 layer_clipping_uses_only_local_clip(false), | 347 layer_clipping_uses_only_local_clip(false), |
| 110 target_is_clipped(false), | 348 target_is_clipped(false), |
| 111 layers_are_clipped(false), | 349 layers_are_clipped(false), |
| 112 layers_are_clipped_when_surfaces_disabled(false), | 350 layers_are_clipped_when_surfaces_disabled(false), |
| 113 resets_clip(false) {} | 351 resets_clip(false) {} |
| 114 | 352 |
| 353 bool ClipNodeData::operator==(const ClipNodeData& other) const { |
| 354 return clip == other.clip && |
| 355 combined_clip_in_target_space == other.combined_clip_in_target_space && |
| 356 clip_in_target_space == other.clip_in_target_space && |
| 357 transform_id == other.transform_id && target_id == other.target_id && |
| 358 applies_local_clip == other.applies_local_clip && |
| 359 layer_clipping_uses_only_local_clip == |
| 360 other.layer_clipping_uses_only_local_clip && |
| 361 target_is_clipped == other.target_is_clipped && |
| 362 layers_are_clipped == other.layers_are_clipped && |
| 363 layers_are_clipped_when_surfaces_disabled == |
| 364 other.layers_are_clipped_when_surfaces_disabled && |
| 365 resets_clip == other.resets_clip; |
| 366 } |
| 367 |
| 368 void ClipNodeData::ToProtobuf(proto::TreeNode* proto) const { |
| 369 DCHECK(!proto->has_clip_node_data()); |
| 370 proto::ClipNodeData* data = proto->mutable_clip_node_data(); |
| 371 |
| 372 RectFToProto(clip, data->mutable_clip()); |
| 373 RectFToProto(combined_clip_in_target_space, |
| 374 data->mutable_combined_clip_in_target_space()); |
| 375 RectFToProto(clip_in_target_space, data->mutable_clip_in_target_space()); |
| 376 |
| 377 data->set_transform_id(transform_id); |
| 378 data->set_target_id(target_id); |
| 379 data->set_applies_local_clip(applies_local_clip); |
| 380 data->set_layer_clipping_uses_only_local_clip( |
| 381 layer_clipping_uses_only_local_clip); |
| 382 data->set_target_is_clipped(target_is_clipped); |
| 383 data->set_layers_are_clipped(layers_are_clipped); |
| 384 data->set_layers_are_clipped_when_surfaces_disabled( |
| 385 layers_are_clipped_when_surfaces_disabled); |
| 386 data->set_resets_clip(resets_clip); |
| 387 } |
| 388 |
| 389 void ClipNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 390 DCHECK(proto.has_clip_node_data()); |
| 391 const proto::ClipNodeData& data = proto.clip_node_data(); |
| 392 |
| 393 clip = ProtoToRectF(data.clip()); |
| 394 combined_clip_in_target_space = |
| 395 ProtoToRectF(data.combined_clip_in_target_space()); |
| 396 clip_in_target_space = ProtoToRectF(data.clip_in_target_space()); |
| 397 |
| 398 transform_id = data.transform_id(); |
| 399 target_id = data.target_id(); |
| 400 applies_local_clip = data.applies_local_clip(); |
| 401 layer_clipping_uses_only_local_clip = |
| 402 data.layer_clipping_uses_only_local_clip(); |
| 403 target_is_clipped = data.target_is_clipped(); |
| 404 layers_are_clipped = data.layers_are_clipped(); |
| 405 layers_are_clipped_when_surfaces_disabled = |
| 406 data.layers_are_clipped_when_surfaces_disabled(); |
| 407 resets_clip = data.resets_clip(); |
| 408 } |
| 409 |
| 115 EffectNodeData::EffectNodeData() | 410 EffectNodeData::EffectNodeData() |
| 116 : opacity(1.f), | 411 : opacity(1.f), |
| 117 screen_space_opacity(1.f), | 412 screen_space_opacity(1.f), |
| 118 has_render_surface(false), | 413 has_render_surface(false), |
| 119 transform_id(0), | 414 transform_id(0), |
| 120 clip_id(0) {} | 415 clip_id(0) {} |
| 121 | 416 |
| 417 bool EffectNodeData::operator==(const EffectNodeData& other) const { |
| 418 return opacity == other.opacity && |
| 419 screen_space_opacity == other.screen_space_opacity && |
| 420 has_render_surface == other.has_render_surface && |
| 421 transform_id == other.transform_id && clip_id == other.clip_id; |
| 422 } |
| 423 |
| 424 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { |
| 425 DCHECK(!proto->has_effect_node_data()); |
| 426 proto::EffectNodeData* data = proto->mutable_effect_node_data(); |
| 427 data->set_opacity(opacity); |
| 428 data->set_screen_space_opacity(screen_space_opacity); |
| 429 data->set_has_render_surface(has_render_surface); |
| 430 data->set_transform_id(transform_id); |
| 431 data->set_clip_id(clip_id); |
| 432 } |
| 433 |
| 434 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 435 DCHECK(proto.has_effect_node_data()); |
| 436 const proto::EffectNodeData& data = proto.effect_node_data(); |
| 437 |
| 438 opacity = data.opacity(); |
| 439 screen_space_opacity = data.screen_space_opacity(); |
| 440 has_render_surface = data.has_render_surface(); |
| 441 transform_id = data.transform_id(); |
| 442 clip_id = data.clip_id(); |
| 443 } |
| 444 |
| 122 void TransformTree::clear() { | 445 void TransformTree::clear() { |
| 123 PropertyTree<TransformNode>::clear(); | 446 PropertyTree<TransformNode>::clear(); |
| 124 | 447 |
| 125 nodes_affected_by_inner_viewport_bounds_delta_.clear(); | 448 nodes_affected_by_inner_viewport_bounds_delta_.clear(); |
| 126 nodes_affected_by_outer_viewport_bounds_delta_.clear(); | 449 nodes_affected_by_outer_viewport_bounds_delta_.clear(); |
| 127 } | 450 } |
| 128 | 451 |
| 129 bool TransformTree::ComputeTransform(int source_id, | 452 bool TransformTree::ComputeTransform(int source_id, |
| 130 int dest_id, | 453 int dest_id, |
| 131 gfx::Transform* transform) const { | 454 gfx::Transform* transform) const { |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 } | 940 } |
| 618 | 941 |
| 619 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { | 942 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { |
| 620 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); | 943 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); |
| 621 } | 944 } |
| 622 | 945 |
| 623 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { | 946 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { |
| 624 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); | 947 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); |
| 625 } | 948 } |
| 626 | 949 |
| 950 bool TransformTree::operator==(const TransformTree& other) const { |
| 951 return PropertyTree::operator==(other) && |
| 952 source_to_parent_updates_allowed_ == |
| 953 other.source_to_parent_updates_allowed() && |
| 954 page_scale_factor_ == other.page_scale_factor() && |
| 955 device_scale_factor_ == other.device_scale_factor() && |
| 956 device_transform_scale_factor_ == |
| 957 other.device_transform_scale_factor() && |
| 958 inner_viewport_bounds_delta_ == other.inner_viewport_bounds_delta() && |
| 959 outer_viewport_bounds_delta_ == other.outer_viewport_bounds_delta() && |
| 960 nodes_affected_by_inner_viewport_bounds_delta_ == |
| 961 other.nodes_affected_by_inner_viewport_bounds_delta() && |
| 962 nodes_affected_by_outer_viewport_bounds_delta_ == |
| 963 other.nodes_affected_by_outer_viewport_bounds_delta(); |
| 964 } |
| 965 |
| 966 void TransformTree::ToProtobuf(proto::PropertyTree* proto) const { |
| 967 DCHECK(!proto->has_property_type()); |
| 968 proto->set_property_type(proto::PropertyTree::Transform); |
| 969 |
| 970 PropertyTree::ToProtobuf(proto); |
| 971 proto::TransformTreeData* data = proto->mutable_transform_tree_data(); |
| 972 |
| 973 data->set_source_to_parent_updates_allowed(source_to_parent_updates_allowed_); |
| 974 data->set_page_scale_factor(page_scale_factor_); |
| 975 data->set_device_scale_factor(device_scale_factor_); |
| 976 data->set_device_transform_scale_factor(device_transform_scale_factor_); |
| 977 |
| 978 Vector2dFToProto(inner_viewport_bounds_delta_, |
| 979 data->mutable_inner_viewport_bounds_delta()); |
| 980 Vector2dFToProto(outer_viewport_bounds_delta_, |
| 981 data->mutable_outer_viewport_bounds_delta()); |
| 982 |
| 983 for (auto i : nodes_affected_by_inner_viewport_bounds_delta_) |
| 984 data->add_nodes_affected_by_inner_viewport_bounds_delta(i); |
| 985 |
| 986 for (auto i : nodes_affected_by_outer_viewport_bounds_delta_) |
| 987 data->add_nodes_affected_by_outer_viewport_bounds_delta(i); |
| 988 } |
| 989 |
| 990 void TransformTree::FromProtobuf(const proto::PropertyTree& proto) { |
| 991 DCHECK(proto.has_property_type()); |
| 992 DCHECK_EQ(proto.property_type(), proto::PropertyTree::Transform); |
| 993 |
| 994 PropertyTree::FromProtobuf(proto); |
| 995 const proto::TransformTreeData& data = proto.transform_tree_data(); |
| 996 |
| 997 source_to_parent_updates_allowed_ = data.source_to_parent_updates_allowed(); |
| 998 page_scale_factor_ = data.page_scale_factor(); |
| 999 device_scale_factor_ = data.device_scale_factor(); |
| 1000 device_transform_scale_factor_ = data.device_transform_scale_factor(); |
| 1001 |
| 1002 inner_viewport_bounds_delta_ = |
| 1003 ProtoToVector2dF(data.inner_viewport_bounds_delta()); |
| 1004 outer_viewport_bounds_delta_ = |
| 1005 ProtoToVector2dF(data.outer_viewport_bounds_delta()); |
| 1006 |
| 1007 DCHECK(nodes_affected_by_inner_viewport_bounds_delta_.empty()); |
| 1008 for (int i = 0; i < data.nodes_affected_by_inner_viewport_bounds_delta_size(); |
| 1009 ++i) { |
| 1010 nodes_affected_by_inner_viewport_bounds_delta_.push_back( |
| 1011 data.nodes_affected_by_inner_viewport_bounds_delta(i)); |
| 1012 } |
| 1013 |
| 1014 DCHECK(nodes_affected_by_outer_viewport_bounds_delta_.empty()); |
| 1015 for (int i = 0; i < data.nodes_affected_by_outer_viewport_bounds_delta_size(); |
| 1016 ++i) { |
| 1017 nodes_affected_by_outer_viewport_bounds_delta_.push_back( |
| 1018 data.nodes_affected_by_outer_viewport_bounds_delta(i)); |
| 1019 } |
| 1020 } |
| 1021 |
| 627 void EffectTree::UpdateOpacities(int id) { | 1022 void EffectTree::UpdateOpacities(int id) { |
| 628 EffectNode* node = Node(id); | 1023 EffectNode* node = Node(id); |
| 629 node->data.screen_space_opacity = node->data.opacity; | 1024 node->data.screen_space_opacity = node->data.opacity; |
| 630 | 1025 |
| 631 EffectNode* parent_node = parent(node); | 1026 EffectNode* parent_node = parent(node); |
| 632 if (parent_node) | 1027 if (parent_node) |
| 633 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; | 1028 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; |
| 634 } | 1029 } |
| 635 | 1030 |
| 636 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( | 1031 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 653 node->data.clip = viewport_rect; | 1048 node->data.clip = viewport_rect; |
| 654 set_needs_update(true); | 1049 set_needs_update(true); |
| 655 } | 1050 } |
| 656 | 1051 |
| 657 gfx::RectF ClipTree::ViewportClip() { | 1052 gfx::RectF ClipTree::ViewportClip() { |
| 658 const unsigned long min_size = 1; | 1053 const unsigned long min_size = 1; |
| 659 DCHECK_GT(size(), min_size); | 1054 DCHECK_GT(size(), min_size); |
| 660 return Node(1)->data.clip; | 1055 return Node(1)->data.clip; |
| 661 } | 1056 } |
| 662 | 1057 |
| 1058 bool ClipTree::operator==(const ClipTree& other) const { |
| 1059 return PropertyTree::operator==(other); |
| 1060 } |
| 1061 |
| 1062 void ClipTree::ToProtobuf(proto::PropertyTree* proto) const { |
| 1063 DCHECK(!proto->has_property_type()); |
| 1064 proto->set_property_type(proto::PropertyTree::Clip); |
| 1065 |
| 1066 PropertyTree::ToProtobuf(proto); |
| 1067 } |
| 1068 |
| 1069 void ClipTree::FromProtobuf(const proto::PropertyTree& proto) { |
| 1070 DCHECK(proto.has_property_type()); |
| 1071 DCHECK_EQ(proto.property_type(), proto::PropertyTree::Clip); |
| 1072 |
| 1073 PropertyTree::FromProtobuf(proto); |
| 1074 } |
| 1075 |
| 1076 bool EffectTree::operator==(const EffectTree& other) const { |
| 1077 return PropertyTree::operator==(other); |
| 1078 } |
| 1079 |
| 1080 void EffectTree::ToProtobuf(proto::PropertyTree* proto) const { |
| 1081 DCHECK(!proto->has_property_type()); |
| 1082 proto->set_property_type(proto::PropertyTree::Effect); |
| 1083 |
| 1084 PropertyTree::ToProtobuf(proto); |
| 1085 } |
| 1086 |
| 1087 void EffectTree::FromProtobuf(const proto::PropertyTree& proto) { |
| 1088 DCHECK(proto.has_property_type()); |
| 1089 DCHECK_EQ(proto.property_type(), proto::PropertyTree::Effect); |
| 1090 |
| 1091 PropertyTree::FromProtobuf(proto); |
| 1092 } |
| 1093 |
| 663 PropertyTrees::PropertyTrees() | 1094 PropertyTrees::PropertyTrees() |
| 664 : needs_rebuild(true), | 1095 : needs_rebuild(true), |
| 665 non_root_surfaces_enabled(true), | 1096 non_root_surfaces_enabled(true), |
| 666 sequence_number(0) {} | 1097 sequence_number(0) {} |
| 667 | 1098 |
| 1099 bool PropertyTrees::operator==(const PropertyTrees& other) const { |
| 1100 return transform_tree == other.transform_tree && |
| 1101 effect_tree == other.effect_tree && clip_tree == other.clip_tree && |
| 1102 needs_rebuild == other.needs_rebuild && |
| 1103 non_root_surfaces_enabled == other.non_root_surfaces_enabled && |
| 1104 sequence_number == other.sequence_number; |
| 1105 } |
| 1106 |
| 1107 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { |
| 1108 // TODO(khushalsagar): Add support for sending diffs when serializaing |
| 1109 // property trees. See crbug/555370. |
| 1110 transform_tree.ToProtobuf(proto->mutable_transform_tree()); |
| 1111 effect_tree.ToProtobuf(proto->mutable_effect_tree()); |
| 1112 clip_tree.ToProtobuf(proto->mutable_clip_tree()); |
| 1113 proto->set_needs_rebuild(needs_rebuild); |
| 1114 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); |
| 1115 |
| 1116 // TODO(khushalsagar): Consider using the sequence number to decide if |
| 1117 // property trees need to be serialized again for a commit. See crbug/555370. |
| 1118 proto->set_sequence_number(sequence_number); |
| 1119 } |
| 1120 |
| 1121 // static |
| 1122 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { |
| 1123 transform_tree.FromProtobuf(proto.transform_tree()); |
| 1124 effect_tree.FromProtobuf(proto.effect_tree()); |
| 1125 clip_tree.FromProtobuf(proto.clip_tree()); |
| 1126 |
| 1127 needs_rebuild = proto.needs_rebuild(); |
| 1128 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
| 1129 sequence_number = proto.sequence_number(); |
| 1130 } |
| 1131 |
| 668 } // namespace cc | 1132 } // namespace cc |
| OLD | NEW |