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 { |
523 // We compute invertibility of a draw transforms lazily. | |
524 // Invertible is true if we have not computed the inverse of either to_target | |
525 // or from_target, or to_target / from_target is invertible. | |
520 bool invertible; | 526 bool invertible; |
ajuma
2016/10/12 20:08:47
Having this be true when we don't know if the tran
sunxd
2016/10/12 21:08:19
Done.
| |
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 : 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 | |
ajuma
2016/10/12 20:08:47
Nit: this line shouldn't be deleted
sunxd
2016/10/12 21:08:19
Done.
| |
552 class CC_EXPORT PropertyTrees final { | 569 class CC_EXPORT PropertyTrees final { |
553 public: | 570 public: |
554 PropertyTrees(); | 571 PropertyTrees(); |
555 PropertyTrees(const PropertyTrees& other) = delete; | 572 PropertyTrees(const PropertyTrees& other) = delete; |
556 ~PropertyTrees(); | 573 ~PropertyTrees(); |
557 | 574 |
558 bool operator==(const PropertyTrees& other) const; | 575 bool operator==(const PropertyTrees& other) const; |
559 PropertyTrees& operator=(const PropertyTrees& from); | 576 PropertyTrees& operator=(const PropertyTrees& from); |
560 | 577 |
561 void ToProtobuf(proto::PropertyTrees* proto) const; | 578 void ToProtobuf(proto::PropertyTrees* proto) const; |
(...skipping 19 matching lines...) Expand all Loading... | |
581 bool changed; | 598 bool changed; |
582 // We cache a global bool for full tree damages to avoid walking the entire | 599 // We cache a global bool for full tree damages to avoid walking the entire |
583 // tree. | 600 // tree. |
584 // TODO(jaydasika): Changes to transform and effects that damage the entire | 601 // 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 | 602 // tree should be tracked by this bool. Currently, they are tracked by the |
586 // individual nodes. | 603 // individual nodes. |
587 bool full_tree_damaged; | 604 bool full_tree_damaged; |
588 int sequence_number; | 605 int sequence_number; |
589 bool is_main_thread; | 606 bool is_main_thread; |
590 bool is_active; | 607 bool is_active; |
591 bool verify_transform_tree_calculations; | |
592 | 608 |
593 void clear(); | 609 void clear(); |
594 | 610 |
595 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 611 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
596 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 612 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
597 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); | 613 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); |
598 void PushOpacityIfNeeded(PropertyTrees* target_tree); | 614 void PushOpacityIfNeeded(PropertyTrees* target_tree); |
599 void RemoveIdFromIdToIndexMaps(int id); | 615 void RemoveIdFromIdToIndexMaps(int id); |
600 bool IsInIdToIndexMap(TreeType tree_type, int id); | 616 bool IsInIdToIndexMap(TreeType tree_type, int id); |
601 void UpdateChangeTracking(); | 617 void UpdateChangeTracking(); |
(...skipping 13 matching lines...) Expand all Loading... | |
615 } | 631 } |
616 | 632 |
617 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; | 633 std::unique_ptr<base::trace_event::TracedValue> AsTracedValue() const; |
618 | 634 |
619 CombinedAnimationScale GetAnimationScales(int transform_node_id, | 635 CombinedAnimationScale GetAnimationScales(int transform_node_id, |
620 LayerTreeImpl* layer_tree_impl); | 636 LayerTreeImpl* layer_tree_impl); |
621 void SetAnimationScalesForTesting(int transform_id, | 637 void SetAnimationScalesForTesting(int transform_id, |
622 float maximum_animation_scale, | 638 float maximum_animation_scale, |
623 float starting_animation_scale); | 639 float starting_animation_scale); |
624 | 640 |
641 bool GetToTarget(int transform_id, | |
642 int effect_id, | |
643 gfx::Transform* to_target) const; | |
644 bool GetFromTarget(int transform_id, | |
645 int effect_id, | |
646 gfx::Transform* from_target) const; | |
647 | |
625 // GetDrawTransforms may change the value of cached_data_. | 648 // GetDrawTransforms may change the value of cached_data_. |
626 const DrawTransforms& GetDrawTransforms(int transform_id, | 649 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; |
627 int effect_id) const; | 650 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, |
ajuma
2016/10/12 20:08:47
Can this be private?
sunxd
2016/10/12 21:08:19
Done.
| |
651 int effect_id) const; | |
628 | 652 |
629 void ResetCachedData(); | 653 void ResetCachedData(); |
630 void UpdateCachedNumber(); | 654 void UpdateCachedNumber(); |
631 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( | 655 gfx::Transform ToScreenSpaceTransformWithoutSurfaceContentsScale( |
632 int transform_id, | 656 int transform_id, |
633 int effect_id) const; | 657 int effect_id) const; |
634 bool ComputeTransformToTarget(int transform_id, | 658 bool ComputeTransformToTarget(int transform_id, |
635 int effect_id, | 659 int effect_id, |
636 gfx::Transform* transform) const; | 660 gfx::Transform* transform) const; |
637 | 661 |
638 bool ComputeTransformFromTarget(int transform_id, | 662 bool ComputeTransformFromTarget(int transform_id, |
639 int effect_id, | 663 int effect_id, |
640 gfx::Transform* transform) const; | 664 gfx::Transform* transform) const; |
641 | 665 |
642 private: | 666 private: |
643 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 667 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
644 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 668 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
645 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 669 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
646 | 670 |
647 PropertyTreesCachedData cached_data_; | 671 PropertyTreesCachedData cached_data_; |
648 }; | 672 }; |
649 | 673 |
650 } // namespace cc | 674 } // namespace cc |
651 | 675 |
652 #endif // CC_TREES_PROPERTY_TREE_H_ | 676 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |