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 #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 <unordered_map> | |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "cc/base/cc_export.h" | 13 #include "cc/base/cc_export.h" |
| 14 #include "cc/base/synced_property.h" | |
| 13 #include "ui/gfx/geometry/rect_f.h" | 15 #include "ui/gfx/geometry/rect_f.h" |
| 14 #include "ui/gfx/geometry/scroll_offset.h" | 16 #include "ui/gfx/geometry/scroll_offset.h" |
| 15 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
| 16 | 18 |
| 17 namespace cc { | 19 namespace cc { |
| 18 | 20 |
| 19 namespace proto { | 21 namespace proto { |
| 20 class ClipNodeData; | 22 class ClipNodeData; |
| 21 class EffectNodeData; | 23 class EffectNodeData; |
| 22 class PropertyTree; | 24 class PropertyTree; |
| 23 class PropertyTrees; | 25 class PropertyTrees; |
| 24 class ScrollNodeData; | 26 class ScrollNodeData; |
| 25 class TranformNodeData; | 27 class TranformNodeData; |
| 26 class TransformTreeData; | 28 class TransformTreeData; |
| 27 class TreeNode; | 29 class TreeNode; |
| 28 } | 30 } |
| 29 | 31 |
| 32 class LayerTreeImpl; | |
| 33 struct ScrollAndScaleSet; | |
| 34 | |
| 30 // ------------------------------*IMPORTANT*--------------------------------- | 35 // ------------------------------*IMPORTANT*--------------------------------- |
| 31 // Each class declared here has a corresponding proto defined in | 36 // Each class declared here has a corresponding proto defined in |
| 32 // cc/proto/property_tree.proto. When making any changes to a class structure | 37 // cc/proto/property_tree.proto. When making any changes to a class structure |
| 33 // including addition/deletion/updation of a field, please also make the | 38 // including addition/deletion/updation of a field, please also make the |
| 34 // change to its proto and the ToProtobuf and FromProtobuf methods for that | 39 // change to its proto and the ToProtobuf and FromProtobuf methods for that |
| 35 // class. | 40 // class. |
| 36 | 41 |
| 42 typedef SyncedProperty<AdditionGroup<gfx::ScrollOffset>> SyncedScrollOffset; | |
| 43 | |
| 37 template <typename T> | 44 template <typename T> |
| 38 struct CC_EXPORT TreeNode { | 45 struct CC_EXPORT TreeNode { |
| 39 TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} | 46 TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} |
| 40 int id; | 47 int id; |
| 41 int parent_id; | 48 int parent_id; |
| 42 int owner_id; | 49 int owner_id; |
| 43 T data; | 50 T data; |
| 44 | 51 |
| 45 bool operator==(const TreeNode<T>& other) const; | 52 bool operator==(const TreeNode<T>& other) const; |
| 46 | 53 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 private: | 549 private: |
| 543 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); | 550 void UpdateOpacities(EffectNode* node, EffectNode* parent_node); |
| 544 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); | 551 void UpdateIsDrawn(EffectNode* node, EffectNode* parent_node); |
| 545 }; | 552 }; |
| 546 | 553 |
| 547 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { | 554 class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { |
| 548 public: | 555 public: |
| 549 ScrollTree(); | 556 ScrollTree(); |
| 550 ~ScrollTree() override; | 557 ~ScrollTree() override; |
| 551 | 558 |
| 559 ScrollTree& operator=(const ScrollTree& from); | |
| 552 bool operator==(const ScrollTree& other) const; | 560 bool operator==(const ScrollTree& other) const; |
| 553 | 561 |
| 554 void ToProtobuf(proto::PropertyTree* proto) const; | 562 void ToProtobuf(proto::PropertyTree* proto) const; |
| 555 void FromProtobuf(const proto::PropertyTree& proto); | 563 void FromProtobuf(const proto::PropertyTree& proto); |
| 556 | 564 |
| 565 void clear() override; | |
| 566 | |
| 567 typedef std::unordered_map<int, scoped_refptr<SyncedScrollOffset>> | |
| 568 ScrollOffsetMap; | |
| 569 | |
| 557 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; | 570 gfx::ScrollOffset MaxScrollOffset(int scroll_node_id) const; |
| 558 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; | 571 gfx::Size scroll_clip_layer_bounds(int scroll_node_id) const; |
| 559 ScrollNode* CurrentlyScrollingNode(); | 572 ScrollNode* CurrentlyScrollingNode(); |
| 560 const ScrollNode* CurrentlyScrollingNode() const; | 573 const ScrollNode* CurrentlyScrollingNode() const; |
| 561 void set_currently_scrolling_node(int scroll_node_id); | 574 void set_currently_scrolling_node(int scroll_node_id); |
| 562 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; | 575 gfx::Transform ScreenSpaceTransform(int scroll_node_id) const; |
| 563 | 576 |
| 577 // synced_scroll_offset is supposed to be called by Layer/LayerImpl only | |
| 578 SyncedScrollOffset* synced_scroll_offset(int layer_id); | |
| 579 void CollectScrollDeltas(ScrollAndScaleSet* scroll_info); | |
| 580 void UpdateScrollOffsetMapEntry(int key, | |
|
ajuma
2016/03/02 18:43:10
Can this be private?
sunxd
2016/03/02 20:52:55
Done.
| |
| 581 ScrollOffsetMap* new_scroll_offset_map, | |
| 582 LayerTreeImpl* layer_tree_impl); | |
| 583 void UpdateScrollOffsetMap(ScrollOffsetMap* new_scroll_offset_map, | |
| 584 LayerTreeImpl* layer_tree_impl); | |
| 585 ScrollOffsetMap& scroll_offset_map(); | |
| 586 const ScrollOffsetMap& scroll_offset_map() const; | |
| 587 void ApplySentScrollDeltasFromAbortedCommit(); | |
| 588 bool SetScrollOffset(int layer_id, const gfx::ScrollOffset& scroll_offset); | |
| 589 | |
| 564 private: | 590 private: |
| 565 int currently_scrolling_node_id_; | 591 int currently_scrolling_node_id_; |
| 592 ScrollOffsetMap layer_id_to_scroll_offset_map_; | |
| 593 | |
| 594 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset); | |
| 566 }; | 595 }; |
| 567 | 596 |
| 568 class CC_EXPORT PropertyTrees final { | 597 class CC_EXPORT PropertyTrees final { |
| 569 public: | 598 public: |
| 570 PropertyTrees(); | 599 PropertyTrees(); |
| 571 ~PropertyTrees(); | 600 ~PropertyTrees(); |
| 572 | 601 |
| 573 bool operator==(const PropertyTrees& other) const; | 602 bool operator==(const PropertyTrees& other) const; |
| 574 PropertyTrees& operator=(const PropertyTrees& from); | 603 PropertyTrees& operator=(const PropertyTrees& from); |
| 575 | 604 |
| 576 void ToProtobuf(proto::PropertyTrees* proto) const; | 605 void ToProtobuf(proto::PropertyTrees* proto) const; |
| 577 void FromProtobuf(const proto::PropertyTrees& proto); | 606 void FromProtobuf(const proto::PropertyTrees& proto); |
| 578 | 607 |
| 579 TransformTree transform_tree; | 608 TransformTree transform_tree; |
| 580 EffectTree effect_tree; | 609 EffectTree effect_tree; |
| 581 ClipTree clip_tree; | 610 ClipTree clip_tree; |
| 582 ScrollTree scroll_tree; | 611 ScrollTree scroll_tree; |
| 583 bool needs_rebuild; | 612 bool needs_rebuild; |
| 584 bool non_root_surfaces_enabled; | 613 bool non_root_surfaces_enabled; |
| 585 // Change tracking done on property trees needs to be preserved across commits | 614 // Change tracking done on property trees needs to be preserved across commits |
| 586 // (when they are not rebuild). We cache a global bool which stores whether | 615 // (when they are not rebuild). We cache a global bool which stores whether |
| 587 // we did any change tracking so that we can skip copying the change status | 616 // we did any change tracking so that we can skip copying the change status |
| 588 // between property trees when this bool is false. | 617 // between property trees when this bool is false. |
| 589 bool changed; | 618 bool changed; |
| 590 int sequence_number; | 619 int sequence_number; |
| 620 bool is_main_thread; | |
| 621 bool is_active; | |
| 591 | 622 |
| 592 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 623 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 593 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); | 624 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); |
| 594 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); | 625 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); |
| 595 void PushChangeTrackingTo(PropertyTrees* tree); | 626 void PushChangeTrackingTo(PropertyTrees* tree); |
| 596 | 627 |
| 597 gfx::Vector2dF inner_viewport_container_bounds_delta() const { | 628 gfx::Vector2dF inner_viewport_container_bounds_delta() const { |
| 598 return inner_viewport_container_bounds_delta_; | 629 return inner_viewport_container_bounds_delta_; |
| 599 } | 630 } |
| 600 | 631 |
| 601 gfx::Vector2dF outer_viewport_container_bounds_delta() const { | 632 gfx::Vector2dF outer_viewport_container_bounds_delta() const { |
| 602 return outer_viewport_container_bounds_delta_; | 633 return outer_viewport_container_bounds_delta_; |
| 603 } | 634 } |
| 604 | 635 |
| 605 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { | 636 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { |
| 606 return inner_viewport_scroll_bounds_delta_; | 637 return inner_viewport_scroll_bounds_delta_; |
| 607 } | 638 } |
| 608 | 639 |
| 609 private: | 640 private: |
| 610 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 641 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
| 611 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 642 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
| 612 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 643 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
| 613 }; | 644 }; |
| 614 | 645 |
| 615 } // namespace cc | 646 } // namespace cc |
| 616 | 647 |
| 617 #endif // CC_TREES_PROPERTY_TREE_H_ | 648 #endif // CC_TREES_PROPERTY_TREE_H_ |
| OLD | NEW |