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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 void SetPropertyTrees(PropertyTrees* property_trees) { | 113 void SetPropertyTrees(PropertyTrees* property_trees) { |
114 property_trees_ = property_trees; | 114 property_trees_ = property_trees; |
115 } | 115 } |
116 PropertyTrees* property_trees() const { return property_trees_; } | 116 PropertyTrees* property_trees() const { return property_trees_; } |
117 | 117 |
118 void AsValueInto(base::trace_event::TracedValue* value) const; | 118 void AsValueInto(base::trace_event::TracedValue* value) const; |
119 | 119 |
120 private: | 120 private: |
121 std::vector<T> nodes_; | 121 std::vector<T> nodes_; |
122 | 122 |
| 123 friend class TransformTree; |
123 bool needs_update_; | 124 bool needs_update_; |
124 PropertyTrees* property_trees_; | 125 PropertyTrees* property_trees_; |
125 }; | 126 }; |
126 | 127 |
127 struct StickyPositionNodeData { | 128 struct StickyPositionNodeData { |
128 int scroll_ancestor; | 129 int scroll_ancestor; |
129 LayerStickyPositionConstraint constraints; | 130 LayerStickyPositionConstraint constraints; |
130 | 131 |
131 // This is the offset that blink has already applied to counteract the main | 132 // This is the offset that blink has already applied to counteract the main |
132 // thread scroll offset of the scroll ancestor. We need to account for this | 133 // thread scroll offset of the scroll ancestor. We need to account for this |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 void ResetChangeTracking(); | 188 void ResetChangeTracking(); |
188 // Updates the parent, target, and screen space transforms and snapping. | 189 // Updates the parent, target, and screen space transforms and snapping. |
189 void UpdateTransforms(int id); | 190 void UpdateTransforms(int id); |
190 void UpdateTransformChanged(TransformNode* node, | 191 void UpdateTransformChanged(TransformNode* node, |
191 TransformNode* parent_node, | 192 TransformNode* parent_node, |
192 TransformNode* source_node); | 193 TransformNode* source_node); |
193 void UpdateNodeAndAncestorsAreAnimatedOrInvertible( | 194 void UpdateNodeAndAncestorsAreAnimatedOrInvertible( |
194 TransformNode* node, | 195 TransformNode* node, |
195 TransformNode* parent_node); | 196 TransformNode* parent_node); |
196 | 197 |
| 198 void set_needs_update(bool needs_update); |
| 199 |
197 // A TransformNode's source_to_parent value is used to account for the fact | 200 // A TransformNode's source_to_parent value is used to account for the fact |
198 // that fixed-position layers are positioned by Blink wrt to their layer tree | 201 // that fixed-position layers are positioned by Blink wrt to their layer tree |
199 // parent (their "source"), but are parented in the transform tree by their | 202 // parent (their "source"), but are parented in the transform tree by their |
200 // fixed-position container. This value needs to be updated on main-thread | 203 // fixed-position container. This value needs to be updated on main-thread |
201 // property trees (for position changes initiated by Blink), but not on the | 204 // property trees (for position changes initiated by Blink), but not on the |
202 // compositor thread (since the offset from a node corresponding to a | 205 // compositor thread (since the offset from a node corresponding to a |
203 // fixed-position layer to its fixed-position container is unaffected by | 206 // fixed-position layer to its fixed-position container is unaffected by |
204 // compositor-driven effects). | 207 // compositor-driven effects). |
205 void set_source_to_parent_updates_allowed(bool allowed) { | 208 void set_source_to_parent_updates_allowed(bool allowed) { |
206 source_to_parent_updates_allowed_ = allowed; | 209 source_to_parent_updates_allowed_ = allowed; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 243 |
241 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() | 244 const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() |
242 const { | 245 const { |
243 return nodes_affected_by_inner_viewport_bounds_delta_; | 246 return nodes_affected_by_inner_viewport_bounds_delta_; |
244 } | 247 } |
245 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() | 248 const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() |
246 const { | 249 const { |
247 return nodes_affected_by_outer_viewport_bounds_delta_; | 250 return nodes_affected_by_outer_viewport_bounds_delta_; |
248 } | 251 } |
249 | 252 |
250 const gfx::Transform& FromTarget(int node_id, int effect) const; | 253 gfx::Transform FromTarget(int node_id, int effect) const; |
251 void SetFromTarget(int node_id, const gfx::Transform& transform); | 254 void SetFromTarget(int node_id, const gfx::Transform& transform); |
252 | 255 |
253 // TODO(sunxd): Remove target space transforms in cached data when we | 256 // TODO(sunxd): Remove target space transforms in cached data when we |
254 // completely implement computing draw transforms on demand. | 257 // completely implement computing draw transforms on demand. |
255 const gfx::Transform& ToTarget(int node_id, int effect_id) const; | 258 gfx::Transform ToTarget(int node_id, int effect_id) const; |
256 void SetToTarget(int node_id, const gfx::Transform& transform); | 259 void SetToTarget(int node_id, const gfx::Transform& transform); |
257 | 260 |
258 const gfx::Transform& FromScreen(int node_id) const; | 261 const gfx::Transform& FromScreen(int node_id) const; |
259 void SetFromScreen(int node_id, const gfx::Transform& transform); | 262 void SetFromScreen(int node_id, const gfx::Transform& transform); |
260 | 263 |
261 const gfx::Transform& ToScreen(int node_id) const; | 264 const gfx::Transform& ToScreen(int node_id) const; |
262 void SetToScreen(int node_id, const gfx::Transform& transform); | 265 void SetToScreen(int node_id, const gfx::Transform& transform); |
263 | 266 |
264 int TargetId(int node_id) const; | 267 int TargetId(int node_id) const; |
265 void SetTargetId(int node_id, int target_id); | 268 void SetTargetId(int node_id, int target_id); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 513 |
511 CombinedAnimationScale(float maximum, float starting) | 514 CombinedAnimationScale(float maximum, float starting) |
512 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} | 515 : maximum_animation_scale(maximum), starting_animation_scale(starting) {} |
513 bool operator==(const CombinedAnimationScale& other) const { | 516 bool operator==(const CombinedAnimationScale& other) const { |
514 return maximum_animation_scale == other.maximum_animation_scale && | 517 return maximum_animation_scale == other.maximum_animation_scale && |
515 starting_animation_scale == other.starting_animation_scale; | 518 starting_animation_scale == other.starting_animation_scale; |
516 } | 519 } |
517 }; | 520 }; |
518 | 521 |
519 struct DrawTransforms { | 522 struct DrawTransforms { |
520 bool invertible; | 523 // We compute invertibility of a draw transforms lazily. |
| 524 // Might_be_invertible is true if we have not computed the inverse of either |
| 525 // to_target or from_target, or to_target / from_target is invertible. |
| 526 bool might_be_invertible; |
| 527 // From_valid is true if the from_target is already computed directly or |
| 528 // computed by inverting an invertible to_target. |
| 529 bool from_valid; |
| 530 // To_valid is true if to_target stores a valid result, similar to from_valid. |
| 531 bool to_valid; |
521 gfx::Transform from_target; | 532 gfx::Transform from_target; |
522 gfx::Transform to_target; | 533 gfx::Transform to_target; |
523 | 534 |
524 DrawTransforms(gfx::Transform from, gfx::Transform to) | 535 DrawTransforms(gfx::Transform from, gfx::Transform to) |
525 : invertible(true), from_target(from), to_target(to) {} | 536 : might_be_invertible(true), |
| 537 from_valid(false), |
| 538 to_valid(false), |
| 539 from_target(from), |
| 540 to_target(to) {} |
526 bool operator==(const DrawTransforms& other) const { | 541 bool operator==(const DrawTransforms& other) const { |
527 return invertible == other.invertible && from_target == other.from_target && | 542 return from_valid == other.from_valid && to_valid == other.to_valid && |
528 to_target == other.to_target; | 543 from_target == other.from_target && to_target == other.to_target; |
529 } | 544 } |
530 }; | 545 }; |
531 | 546 |
532 struct DrawTransformData { | 547 struct DrawTransformData { |
533 int update_number; | 548 int update_number; |
| 549 int target_id; |
| 550 |
534 DrawTransforms transforms; | 551 DrawTransforms transforms; |
535 | 552 |
536 // TODO(sunxd): Move screen space transforms here if it can improve | 553 // TODO(sunxd): Move screen space transforms here if it can improve |
537 // performance. | 554 // performance. |
538 DrawTransformData() | 555 DrawTransformData() |
539 : update_number(-1), transforms(gfx::Transform(), gfx::Transform()) {} | 556 : update_number(-1), |
| 557 target_id(-1), |
| 558 transforms(gfx::Transform(), gfx::Transform()) {} |
540 }; | 559 }; |
541 | 560 |
542 struct PropertyTreesCachedData { | 561 struct PropertyTreesCachedData { |
543 int property_tree_update_number; | 562 int property_tree_update_number; |
544 std::vector<AnimationScaleData> animation_scales; | 563 std::vector<AnimationScaleData> animation_scales; |
545 mutable std::vector<std::unordered_map<int, DrawTransformData>> | 564 mutable std::vector<std::vector<DrawTransformData>> draw_transforms; |
546 draw_transforms; | |
547 | 565 |
548 PropertyTreesCachedData(); | 566 PropertyTreesCachedData(); |
549 ~PropertyTreesCachedData(); | 567 ~PropertyTreesCachedData(); |
550 }; | 568 }; |
551 | 569 |
552 class CC_EXPORT PropertyTrees final { | 570 class CC_EXPORT PropertyTrees final { |
553 public: | 571 public: |
554 PropertyTrees(); | 572 PropertyTrees(); |
555 PropertyTrees(const PropertyTrees& other) = delete; | 573 PropertyTrees(const PropertyTrees& other) = delete; |
556 ~PropertyTrees(); | 574 ~PropertyTrees(); |
(...skipping 24 matching lines...) Expand all Loading... |
581 bool changed; | 599 bool changed; |
582 // We cache a global bool for full tree damages to avoid walking the entire | 600 // We cache a global bool for full tree damages to avoid walking the entire |
583 // tree. | 601 // tree. |
584 // TODO(jaydasika): Changes to transform and effects that damage the entire | 602 // TODO(jaydasika): Changes to transform and effects that damage the entire |
585 // tree should be tracked by this bool. Currently, they are tracked by the | 603 // tree should be tracked by this bool. Currently, they are tracked by the |
586 // individual nodes. | 604 // individual nodes. |
587 bool full_tree_damaged; | 605 bool full_tree_damaged; |
588 int sequence_number; | 606 int sequence_number; |
589 bool is_main_thread; | 607 bool is_main_thread; |
590 bool is_active; | 608 bool is_active; |
591 bool verify_transform_tree_calculations; | |
592 | 609 |
593 void clear(); | 610 void clear(); |
594 | 611 |
595 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 612 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
596 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 613 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
597 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); | 614 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); |
598 void PushOpacityIfNeeded(PropertyTrees* target_tree); | 615 void PushOpacityIfNeeded(PropertyTrees* target_tree); |
599 void RemoveIdFromIdToIndexMaps(int id); | 616 void RemoveIdFromIdToIndexMaps(int id); |
600 bool IsInIdToIndexMap(TreeType tree_type, int id); | 617 bool IsInIdToIndexMap(TreeType tree_type, int id); |
601 void UpdateChangeTracking(); | 618 void UpdateChangeTracking(); |
(...skipping 13 matching lines...) Expand all Loading... |
615 } | 632 } |
616 | 633 |
617 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; | 634 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; |
618 | 635 |
619 CombinedAnimationScale GetAnimationScales(int transform_node_id, | 636 CombinedAnimationScale GetAnimationScales(int transform_node_id, |
620 LayerTreeImpl* layer_tree_impl); | 637 LayerTreeImpl* layer_tree_impl); |
621 void SetAnimationScalesForTesting(int transform_id, | 638 void SetAnimationScalesForTesting(int transform_id, |
622 float maximum_animation_scale, | 639 float maximum_animation_scale, |
623 float starting_animation_scale); | 640 float starting_animation_scale); |
624 | 641 |
625 // GetDrawTransforms may change the value of cached_data_. | 642 bool GetToTarget(int transform_id, |
626 const DrawTransforms& GetDrawTransforms(int transform_id, | 643 int effect_id, |
627 int effect_id) const; | 644 gfx::Transform* to_target) const; |
| 645 bool GetFromTarget(int transform_id, |
| 646 int effect_id, |
| 647 gfx::Transform* from_target) const; |
628 | 648 |
629 void ResetCachedData(); | 649 void ResetCachedData(); |
630 void UpdateCachedNumber(); | 650 void UpdateCachedNumber(); |
631 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( | 651 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( |
632 int transform_id, | 652 int transform_id, |
633 int effect_id) const; | 653 int effect_id) const; |
634 bool ComputeTransformToTarget(int transform_id, | 654 bool ComputeTransformToTarget(int transform_id, |
635 int effect_id, | 655 int effect_id, |
636 gfx::Transform* transform) const; | 656 gfx::Transform* transform) const; |
637 | 657 |
638 bool ComputeTransformFromTarget(int transform_id, | 658 bool ComputeTransformFromTarget(int transform_id, |
639 int effect_id, | 659 int effect_id, |
640 gfx::Transform* transform) const; | 660 gfx::Transform* transform) const; |
641 | 661 |
642 private: | 662 private: |
643 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 663 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
644 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 664 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
645 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 665 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
646 | 666 |
| 667 // GetDrawTransforms may change the value of cached_data_. |
| 668 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; |
| 669 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, |
| 670 int effect_id) const; |
| 671 |
647 PropertyTreesCachedData cached_data_; | 672 PropertyTreesCachedData cached_data_; |
648 }; | 673 }; |
649 | 674 |
650 } // namespace cc | 675 } // namespace cc |
651 | 676 |
652 #endif // CC_TREES_PROPERTY_TREE_H_ | 677 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |