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

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: Fix after rebase 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
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 LayerListImpl;
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;
ajuma 2016/03/01 22:54:20 This typedef also exists in layer_impl.h. Can it g
sunxd 2016/03/02 17:45:34 Done.
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
ajuma 2016/03/01 22:54:20 Would things break if something else called this?
sunxd 2016/03/02 17:45:34 It would not. This is only a logical restriction.
ajuma 2016/03/02 18:43:09 Should this be a TODO then? (about removing this)
sunxd 2016/03/02 20:52:55 Done.
sunxd 2016/03/02 20:52:55 I think the prerequisite is that layer/layer_impl
578 SyncedScrollOffset* synced_scroll_offset(int layer_id);
579 void CollectScrollDeltas(ScrollAndScaleSet* scroll_info);
580 void UpdateScrollOffsetMapEntry(int key,
581 ScrollOffsetMap* new_scroll_offset_map,
582 LayerListImpl* layer_list_impl);
583 void UpdateScrollOffsetMap(ScrollOffsetMap* new_scroll_offset_map,
584 LayerListImpl* layer_list_impl);
585 ScrollOffsetMap& scroll_offset_map();
586 const ScrollOffsetMap& scroll_offset_map() const;
587 void ApplySentScrollDeltasFromAbortedCommit();
588
564 private: 589 private:
565 int currently_scrolling_node_id_; 590 int currently_scrolling_node_id_;
591 ScrollOffsetMap layer_id_to_scroll_offset_map_;
592
593 gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset);
566 }; 594 };
567 595
568 class CC_EXPORT PropertyTrees final { 596 class CC_EXPORT PropertyTrees final {
569 public: 597 public:
570 PropertyTrees(); 598 PropertyTrees();
571 ~PropertyTrees(); 599 ~PropertyTrees();
572 600
573 bool operator==(const PropertyTrees& other) const; 601 bool operator==(const PropertyTrees& other) const;
574 PropertyTrees& operator=(const PropertyTrees& from); 602 PropertyTrees& operator=(const PropertyTrees& from);
575 603
576 void ToProtobuf(proto::PropertyTrees* proto) const; 604 void ToProtobuf(proto::PropertyTrees* proto) const;
577 void FromProtobuf(const proto::PropertyTrees& proto); 605 void FromProtobuf(const proto::PropertyTrees& proto);
578 606
579 TransformTree transform_tree; 607 TransformTree transform_tree;
580 EffectTree effect_tree; 608 EffectTree effect_tree;
581 ClipTree clip_tree; 609 ClipTree clip_tree;
582 ScrollTree scroll_tree; 610 ScrollTree scroll_tree;
583 bool needs_rebuild; 611 bool needs_rebuild;
584 bool non_root_surfaces_enabled; 612 bool non_root_surfaces_enabled;
585 // Change tracking done on property trees needs to be preserved across commits 613 // 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 614 // (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 615 // we did any change tracking so that we can skip copying the change status
588 // between property trees when this bool is false. 616 // between property trees when this bool is false.
589 bool changed; 617 bool changed;
590 int sequence_number; 618 int sequence_number;
619 bool is_main_thread;
620 bool is_active;
591 621
592 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 622 void SetInnerViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
593 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta); 623 void SetOuterViewportContainerBoundsDelta(gfx::Vector2dF bounds_delta);
594 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta); 624 void SetInnerViewportScrollBoundsDelta(gfx::Vector2dF bounds_delta);
595 void PushChangeTrackingTo(PropertyTrees* tree); 625 void PushChangeTrackingTo(PropertyTrees* tree);
596 626
597 gfx::Vector2dF inner_viewport_container_bounds_delta() const { 627 gfx::Vector2dF inner_viewport_container_bounds_delta() const {
598 return inner_viewport_container_bounds_delta_; 628 return inner_viewport_container_bounds_delta_;
599 } 629 }
600 630
601 gfx::Vector2dF outer_viewport_container_bounds_delta() const { 631 gfx::Vector2dF outer_viewport_container_bounds_delta() const {
602 return outer_viewport_container_bounds_delta_; 632 return outer_viewport_container_bounds_delta_;
603 } 633 }
604 634
605 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const { 635 gfx::Vector2dF inner_viewport_scroll_bounds_delta() const {
606 return inner_viewport_scroll_bounds_delta_; 636 return inner_viewport_scroll_bounds_delta_;
607 } 637 }
608 638
609 private: 639 private:
610 gfx::Vector2dF inner_viewport_container_bounds_delta_; 640 gfx::Vector2dF inner_viewport_container_bounds_delta_;
611 gfx::Vector2dF outer_viewport_container_bounds_delta_; 641 gfx::Vector2dF outer_viewport_container_bounds_delta_;
612 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; 642 gfx::Vector2dF inner_viewport_scroll_bounds_delta_;
613 }; 643 };
614 644
615 } // namespace cc 645 } // namespace cc
616 646
617 #endif // CC_TREES_PROPERTY_TREE_H_ 647 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698