| 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 #ifndef CC_TREES_PROPERTY_TREE_H_ | 5 #ifndef CC_TREES_PROPERTY_TREE_H_ |
| 6 #define CC_TREES_PROPERTY_TREE_H_ | 6 #define CC_TREES_PROPERTY_TREE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 PropertyTree(); | 60 PropertyTree(); |
| 61 PropertyTree(const PropertyTree& other) = delete; | 61 PropertyTree(const PropertyTree& other) = delete; |
| 62 | 62 |
| 63 // These C++ special member functions cannot be implicit inline because | 63 // These C++ special member functions cannot be implicit inline because |
| 64 // they are exported by CC_EXPORT. They will be instantiated in every | 64 // they are exported by CC_EXPORT. They will be instantiated in every |
| 65 // compilation units that included this header, and compilation can fail | 65 // compilation units that included this header, and compilation can fail |
| 66 // because T may be incomplete. | 66 // because T may be incomplete. |
| 67 ~PropertyTree(); | 67 ~PropertyTree(); |
| 68 PropertyTree<T>& operator=(const PropertyTree<T>&); | 68 PropertyTree<T>& operator=(const PropertyTree<T>&); |
| 69 | 69 |
| 70 // Property tree node starts from index 0. |
| 71 static const int kInvalidNodeId = -1; |
| 72 static const int kRootNodeId = 0; |
| 73 |
| 70 bool operator==(const PropertyTree<T>& other) const; | 74 bool operator==(const PropertyTree<T>& other) const; |
| 71 | 75 |
| 72 int Insert(const T& tree_node, int parent_id); | 76 int Insert(const T& tree_node, int parent_id); |
| 73 | 77 |
| 74 T* Node(int i) { | 78 T* Node(int i) { |
| 75 // TODO(vollick): remove this. | 79 // TODO(vollick): remove this. |
| 76 CHECK(i < static_cast<int>(nodes_.size())); | 80 CHECK(i < static_cast<int>(nodes_.size())); |
| 77 return i > -1 ? &nodes_[i] : nullptr; | 81 return i > -1 ? &nodes_[i] : nullptr; |
| 78 } | 82 } |
| 79 const T* Node(int i) const { | 83 const T* Node(int i) const { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 208 |
| 205 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() | 209 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() |
| 206 const { | 210 const { |
| 207 return nodes_affected_by_inner_viewport_bounds_delta_; | 211 return nodes_affected_by_inner_viewport_bounds_delta_; |
| 208 } | 212 } |
| 209 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() | 213 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() |
| 210 const { | 214 const { |
| 211 return nodes_affected_by_outer_viewport_bounds_delta_; | 215 return nodes_affected_by_outer_viewport_bounds_delta_; |
| 212 } | 216 } |
| 213 | 217 |
| 214 const gfx::Transform& FromTarget(int node_id) const; | 218 const gfx::Transform& FromTarget(int node_id, int effect) const; |
| 215 void SetFromTarget(int node_id, const gfx::Transform& transform); | 219 void SetFromTarget(int node_id, const gfx::Transform& transform); |
| 216 | 220 |
| 217 const gfx::Transform& ToTarget(int node_id) const; | 221 // TODO(sunxd): remove target space transforms in cached data when we |
| 222 // completely implement computing draw transforms on demand |
| 223 const gfx::Transform& ToTarget(int node_id, int effect_id) const; |
| 218 void SetToTarget(int node_id, const gfx::Transform& transform); | 224 void SetToTarget(int node_id, const gfx::Transform& transform); |
| 219 | 225 |
| 220 const gfx::Transform& FromScreen(int node_id) const; | 226 const gfx::Transform& FromScreen(int node_id) const; |
| 221 void SetFromScreen(int node_id, const gfx::Transform& transform); | 227 void SetFromScreen(int node_id, const gfx::Transform& transform); |
| 222 | 228 |
| 223 const gfx::Transform& ToScreen(int node_id) const; | 229 const gfx::Transform& ToScreen(int node_id) const; |
| 224 void SetToScreen(int node_id, const gfx::Transform& transform); | 230 void SetToScreen(int node_id, const gfx::Transform& transform); |
| 225 | 231 |
| 226 int TargetId(int node_id) const; | 232 int TargetId(int node_id) const; |
| 227 void SetTargetId(int node_id, int target_id); | 233 void SetTargetId(int node_id, int target_id); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 float starting_animation_scale; | 461 float starting_animation_scale; |
| 456 | 462 |
| 457 CombinedAnimationScale(float maximum, float starting) | 463 CombinedAnimationScale(float maximum, float starting) |
| 458 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} | 464 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} |
| 459 bool operator==(const CombinedAnimationScale& other) const { | 465 bool operator==(const CombinedAnimationScale& other) const { |
| 460 return maximum_animation_scale == other.maximum_animation_scale && | 466 return maximum_animation_scale == other.maximum_animation_scale && |
| 461 starting_animation_scale == other.starting_animation_scale; | 467 starting_animation_scale == other.starting_animation_scale; |
| 462 } | 468 } |
| 463 }; | 469 }; |
| 464 | 470 |
| 471 struct DrawTransforms { |
| 472 gfx::Transform from_target; |
| 473 gfx::Transform to_target; |
| 474 |
| 475 DrawTransforms(gfx::Transform from, gfx::Transform to) |
| 476 : from_target(from), to_target(to) {} |
| 477 bool operator==(const DrawTransforms& other) const { |
| 478 return from_target == other.from_target && to_target == other.to_target; |
| 479 } |
| 480 }; |
| 481 |
| 482 struct DrawTransformData { |
| 483 int update_number; |
| 484 DrawTransforms transforms; |
| 485 |
| 486 // TODO(sunxd): move screen space transforms here if it can improve |
| 487 // performance |
| 488 |
| 489 DrawTransformData() |
| 490 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {} |
| 491 }; |
| 492 |
| 465 struct PropertyTreesCachedData { | 493 struct PropertyTreesCachedData { |
| 466 int property_tree_update_number; | 494 int property_tree_update_number; |
| 467 std::vector<AnimationScaleData> animation_scales; | 495 std::vector<AnimationScaleData> animation_scales; |
| 496 mutable std::vector<std::unordered_map<int, DrawTransformData>> |
| 497 draw_transforms; |
| 468 | 498 |
| 469 PropertyTreesCachedData(); | 499 PropertyTreesCachedData(); |
| 470 ~PropertyTreesCachedData(); | 500 ~PropertyTreesCachedData(); |
| 471 }; | 501 }; |
| 472 | 502 |
| 473 class CC_EXPORT PropertyTrees final { | 503 class CC_EXPORT PropertyTrees final { |
| 474 public: | 504 public: |
| 475 PropertyTrees(); | 505 PropertyTrees(); |
| 476 PropertyTrees(const PropertyTrees& other) = delete; | 506 PropertyTrees(const PropertyTrees& other) = delete; |
| 477 ~PropertyTrees(); | 507 ~PropertyTrees(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 502 bool changed; | 532 bool changed; |
| 503 // We cache a global bool for full tree damages to avoid walking the entire | 533 // We cache a global bool for full tree damages to avoid walking the entire |
| 504 // tree. | 534 // tree. |
| 505 // TODO(jaydasika): Changes to transform and effects that damage the entire | 535 // TODO(jaydasika): Changes to transform and effects that damage the entire |
| 506 // tree should be tracked by this bool. Currently, they are tracked by the | 536 // tree should be tracked by this bool. Currently, they are tracked by the |
| 507 // individual nodes. | 537 // individual nodes. |
| 508 bool full_tree_damaged; | 538 bool full_tree_damaged; |
| 509 int sequence_number; | 539 int sequence_number; |
| 510 bool is_main_thread; | 540 bool is_main_thread; |
| 511 bool is_active; | 541 bool is_active; |
| 542 bool verify_transform_tree_calculations; |
| 512 | 543 |
| 513 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 544 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 514 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 545 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 515 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); | 546 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); |
| 516 void PushOpacityIfNeeded(PropertyTrees* target_tree); | 547 void PushOpacityIfNeeded(PropertyTrees* target_tree); |
| 517 void RemoveIdFromIdToIndexMaps(int id); | 548 void RemoveIdFromIdToIndexMaps(int id); |
| 518 bool IsInIdToIndexMap(TreeType tree_type, int id); | 549 bool IsInIdToIndexMap(TreeType tree_type, int id); |
| 519 void UpdateChangeTracking(); | 550 void UpdateChangeTracking(); |
| 520 void PushChangeTrackingTo(PropertyTrees* tree); | 551 void PushChangeTrackingTo(PropertyTrees* tree); |
| 521 void ResetAllChangeTracking(); | 552 void ResetAllChangeTracking(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 532 return inner_viewport_scroll_bounds_delta_; | 563 return inner_viewport_scroll_bounds_delta_; |
| 533 } | 564 } |
| 534 | 565 |
| 535 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; | 566 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; |
| 536 | 567 |
| 537 CombinedAnimationScale GetAnimationScales(int transform_node_id, | 568 CombinedAnimationScale GetAnimationScales(int transform_node_id, |
| 538 LayerTreeImpl* layer_tree_impl); | 569 LayerTreeImpl* layer_tree_impl); |
| 539 void SetAnimationScalesForTesting(int transform_id, | 570 void SetAnimationScalesForTesting(int transform_id, |
| 540 float maximum_animation_scale, | 571 float maximum_animation_scale, |
| 541 float starting_animation_scale); | 572 float starting_animation_scale); |
| 573 |
| 574 // GetDrawTransforms may change the value of cached_data_ |
| 575 const DrawTransforms& GetDrawTransforms(int transform_id, |
| 576 int effect_id) const; |
| 577 |
| 542 void ResetCachedData(); | 578 void ResetCachedData(); |
| 543 void UpdateCachedNumber(); | 579 void UpdateCachedNumber(); |
| 544 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( | 580 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( |
| 545 int transform_id, | 581 int transform_id, |
| 546 int effect_id) const; | 582 int effect_id) const; |
| 547 | 583 |
| 548 private: | 584 private: |
| 549 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 585 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
| 550 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 586 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
| 551 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 587 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
| 552 | 588 |
| 553 PropertyTreesCachedData cached_data_; | 589 PropertyTreesCachedData cached_data_; |
| 554 }; | 590 }; |
| 555 | 591 |
| 556 } // namespace cc | 592 } // namespace cc |
| 557 | 593 |
| 558 #endif // CC_TREES_PROPERTY_TREE_H_ | 594 #endif // CC_TREES_PROPERTY_TREE_H_ |
| OLD | NEW |