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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 PropertyTree(); | 60 PropertyTree(); |
61 PropertyTree(const PropertyTree& other) = delete; | 61 PropertyTree(const PropertyTree& other) = delete; |
62 | 62 |
63 // These C++ special member functions cannot be implicit inline because | 63 // These C++ special member functions cannot be implicit inline because |
64 // they are exported by CC_EXPORT. They will be instantiated in every | 64 // they are exported by CC_EXPORT. They will be instantiated in every |
65 // compilation units that included this header, and compilation can fail | 65 // compilation units that included this header, and compilation can fail |
66 // because T may be incomplete. | 66 // because T may be incomplete. |
67 ~PropertyTree(); | 67 ~PropertyTree(); |
68 PropertyTree<T>& operator=(const PropertyTree<T>&); | 68 PropertyTree<T>& operator=(const PropertyTree<T>&); |
69 | 69 |
| 70 // Property tree node starts from index 0. |
| 71 static const int kInvalidNodeId = -1; |
| 72 static const int kRootNodeId = 0; |
| 73 |
70 bool operator==(const PropertyTree<T>& other) const; | 74 bool operator==(const PropertyTree<T>& other) const; |
71 | 75 |
72 int Insert(const T& tree_node, int parent_id); | 76 int Insert(const T& tree_node, int parent_id); |
73 | 77 |
74 T* Node(int i) { | 78 T* Node(int i) { |
75 // TODO(vollick): remove this. | 79 // TODO(vollick): remove this. |
76 CHECK(i < static_cast<int>(nodes_.size())); | 80 CHECK(i < static_cast<int>(nodes_.size())); |
77 return i > -1 ? &nodes_[i] : nullptr; | 81 return i > -1 ? &nodes_[i] : nullptr; |
78 } | 82 } |
79 const T* Node(int i) const { | 83 const T* Node(int i) const { |
80 // TODO(vollick): remove this. | 84 // TODO(vollick): remove this. |
81 CHECK(i < static_cast<int>(nodes_.size())); | 85 CHECK(i < static_cast<int>(nodes_.size())); |
82 return i > -1 ? &nodes_[i] : nullptr; | 86 return i > -1 ? &nodes_[i] : nullptr; |
83 } | 87 } |
84 | 88 |
85 T* parent(const T* t) { return Node(t->parent_id); } | 89 T* parent(const T* t) { |
86 const T* parent(const T* t) const { return Node(t->parent_id); } | 90 return t->parent_id >= 0 ? Node(t->parent_id) : nullptr; |
| 91 } |
| 92 const T* parent(const T* t) const { |
| 93 return t->parent_id >= 0 ? Node(t->parent_id) : nullptr; |
| 94 } |
87 | 95 |
88 T* back() { return size() ? &nodes_.back() : nullptr; } | 96 T* back() { return size() ? &nodes_.back() : nullptr; } |
89 const T* back() const { return size() ? &nodes_.back() : nullptr; } | 97 const T* back() const { return size() ? &nodes_.back() : nullptr; } |
90 | 98 |
91 void clear(); | 99 void clear(); |
92 size_t size() const { return nodes_.size(); } | 100 size_t size() const { return nodes_.size(); } |
93 | 101 |
94 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } | 102 void set_needs_update(bool needs_update) { needs_update_ = needs_update; } |
95 bool needs_update() const { return needs_update_; } | 103 bool needs_update() const { return needs_update_; } |
96 | 104 |
(...skipping 25 matching lines...) Expand all Loading... |
122 TransformTree(); | 130 TransformTree(); |
123 | 131 |
124 // These C++ special member functions cannot be implicit inline because | 132 // These C++ special member functions cannot be implicit inline because |
125 // they are exported by CC_EXPORT. They will be instantiated in every | 133 // they are exported by CC_EXPORT. They will be instantiated in every |
126 // compilation units that included this header, and compilation can fail | 134 // compilation units that included this header, and compilation can fail |
127 // because TransformCachedNodeData may be incomplete. | 135 // because TransformCachedNodeData may be incomplete. |
128 TransformTree(const TransformTree&) = delete; | 136 TransformTree(const TransformTree&) = delete; |
129 ~TransformTree(); | 137 ~TransformTree(); |
130 TransformTree& operator=(const TransformTree&); | 138 TransformTree& operator=(const TransformTree&); |
131 | 139 |
| 140 // Transform tree requires a dummy node 0 representing device space. The root |
| 141 // node of transform tree with real information is node 1, unlike all other |
| 142 // property trees. When transform tree is created, it is created with dummy |
| 143 // node 0. |
| 144 static const int kDeviceNodeId = 0; |
| 145 static const int kRootNodeId = 1; |
| 146 |
132 bool operator==(const TransformTree& other) const; | 147 bool operator==(const TransformTree& other) const; |
133 | 148 |
134 int Insert(const TransformNode& tree_node, int parent_id); | 149 int Insert(const TransformNode& tree_node, int parent_id); |
135 | 150 |
136 void clear(); | 151 void clear(); |
137 | 152 |
138 // Computes the change of basis transform from node |source_id| to |dest_id|. | 153 // Computes the change of basis transform from node |source_id| to |dest_id|. |
139 // The function returns false iff the inverse of a singular transform was | 154 // The function returns false iff the inverse of a singular transform was |
140 // used (and the result should, therefore, not be trusted). Transforms may | 155 // used (and the result should, therefore, not be trusted). Transforms may |
141 // be computed between any pair of nodes that have an ancestor/descendant | 156 // be computed between any pair of nodes that have an ancestor/descendant |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 float page_scale_factor_; | 317 float page_scale_factor_; |
303 float device_scale_factor_; | 318 float device_scale_factor_; |
304 float device_transform_scale_factor_; | 319 float device_transform_scale_factor_; |
305 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; | 320 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; |
306 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; | 321 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; |
307 std::vector<TransformCachedNodeData> cached_data_; | 322 std::vector<TransformCachedNodeData> cached_data_; |
308 }; | 323 }; |
309 | 324 |
310 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { | 325 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
311 public: | 326 public: |
| 327 static const int kViewportNodeId = 0; |
| 328 |
312 bool operator==(const ClipTree& other) const; | 329 bool operator==(const ClipTree& other) const; |
313 | 330 |
314 void SetViewportClip(gfx::RectF viewport_rect); | 331 void SetViewportClip(gfx::RectF viewport_rect); |
315 gfx::RectF ViewportClip(); | 332 gfx::RectF ViewportClip(); |
316 | 333 |
317 void ToProtobuf(proto::PropertyTree* proto) const; | 334 void ToProtobuf(proto::PropertyTree* proto) const; |
318 void FromProtobuf(const proto::PropertyTree& proto, | 335 void FromProtobuf(const proto::PropertyTree& proto, |
319 std::unordered_map<int, int>* node_id_to_index_map); | 336 std::unordered_map<int, int>* node_id_to_index_map); |
320 }; | 337 }; |
321 | 338 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 585 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
569 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 586 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
570 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 587 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
571 | 588 |
572 PropertyTreesCachedData cached_data_; | 589 PropertyTreesCachedData cached_data_; |
573 }; | 590 }; |
574 | 591 |
575 } // namespace cc | 592 } // namespace cc |
576 | 593 |
577 #endif // CC_TREES_PROPERTY_TREE_H_ | 594 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |