Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: cc/trees/property_tree.h

Issue 1736073002: cc: Move SyncedScrollOffset to scroll tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and add comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 UpdateScrollOffsetMap(ScrollOffsetMap* new_scroll_offset_map,
581 LayerTreeImpl* layer_tree_impl);
582 ScrollOffsetMap& scroll_offset_map();
583 const ScrollOffsetMap& scroll_offset_map() const;
584 void ApplySentScrollDeltasFromAbortedCommit();
585 bool SetScrollOffset(int layer_id, const gfx::ScrollOffset& scroll_offset);
586
564 private: 587 private:
565 int currently_scrolling_node_id_; 588 int currently_scrolling_node_id_;
589 ScrollOffsetMap layer_id_to_scroll_offset_map_;
590
591 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset);
592 void UpdateScrollOffsetMapEntry(int key,
593 ScrollOffsetMap* new_scroll_offset_map,
594 LayerTreeImpl* layer_tree_impl);
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
(...skipping 11 matching lines...) Expand all
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 // We cache a global bool for full tree damages to avoid walking the entire 619 // We cache a global bool for full tree damages to avoid walking the entire
591 // tree. 620 // tree.
592 // TODO(jaydasika): Changes to transform and effects that damage the entire 621 // TODO(jaydasika): Changes to transform and effects that damage the entire
593 // tree should be tracked by this bool. Currently, they are tracked by the 622 // tree should be tracked by this bool. Currently, they are tracked by the
594 // individual nodes. 623 // individual nodes.
595 bool full_tree_damaged; 624 bool full_tree_damaged;
596 int sequence_number; 625 int sequence_number;
626 bool is_main_thread;
627 bool is_active;
597 enum ResetFlags { EFFECT_TREE, TRANSFORM_TREE, ALL_TREES }; 628 enum ResetFlags { EFFECT_TREE, TRANSFORM_TREE, ALL_TREES };
598 629
599 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 630 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
600 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 631 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
601 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); 632 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta);
602 void PushChangeTrackingTo(PropertyTrees* tree); 633 void PushChangeTrackingTo(PropertyTrees* tree);
603 void ResetAllChangeTracking(ResetFlags flag); 634 void ResetAllChangeTracking(ResetFlags flag);
604 635
605 gfx::Vector2dF inner_viewport_container_bounds_delta() const { 636 gfx::Vector2dF inner_viewport_container_bounds_delta() const {
606 return inner_viewport_container_bounds_delta_; 637 return inner_viewport_container_bounds_delta_;
607 } 638 }
608 639
609 gfx::Vector2dF outer_viewport_container_bounds_delta() const { 640 gfx::Vector2dF outer_viewport_container_bounds_delta() const {
610 return outer_viewport_container_bounds_delta_; 641 return outer_viewport_container_bounds_delta_;
611 } 642 }
612 643
613 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { 644 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const {
614 return inner_viewport_scroll_bounds_delta_; 645 return inner_viewport_scroll_bounds_delta_;
615 } 646 }
616 647
617 private: 648 private:
618 gfx::Vector2dF inner_viewport_container_bounds_delta_; 649 gfx::Vector2dF inner_viewport_container_bounds_delta_;
619 gfx::Vector2dF outer_viewport_container_bounds_delta_; 650 gfx::Vector2dF outer_viewport_container_bounds_delta_;
620 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 651 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
621 }; 652 };
622 653
623 } // namespace cc 654 } // namespace cc
624 655
625 #endif // CC_TREES_PROPERTY_TREE_H_ 656 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698