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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 private: | 121 private: |
122 std::vector<T> nodes_; | 122 std::vector<T> nodes_; |
123 | 123 |
124 // These maps map from layer id to the property tree node index. | 124 // These maps map from layer id to the property tree node index. |
125 std::unordered_map<int, int> owning_layer_id_to_node_index; | 125 std::unordered_map<int, int> owning_layer_id_to_node_index; |
126 | 126 |
127 bool needs_update_; | 127 bool needs_update_; |
128 PropertyTrees* property_trees_; | 128 PropertyTrees* property_trees_; |
129 }; | 129 }; |
130 | 130 |
131 struct StickyPositionNodeData { | 131 struct StickyPositionNodeData; |
132 int scroll_ancestor; | |
133 LayerStickyPositionConstraint constraints; | |
134 | |
135 // This is the offset that blink has already applied to counteract the main | |
136 // thread scroll offset of the scroll ancestor. We need to account for this | |
137 // by computing the additional offset necessary to keep the element stuck. | |
138 gfx::Vector2dF main_thread_offset; | |
139 | |
140 StickyPositionNodeData() : scroll_ancestor(-1) {} | |
141 }; | |
142 | 132 |
143 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 133 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
144 public: | 134 public: |
145 TransformTree(); | 135 TransformTree(); |
146 | 136 |
147 // These C++ special member functions cannot be implicit inline because | 137 // These C++ special member functions cannot be implicit inline because |
148 // they are exported by CC_EXPORT. They will be instantiated in every | 138 // they are exported by CC_EXPORT. They will be instantiated in every |
149 // compilation units that included this header, and compilation can fail | 139 // compilation units that included this header, and compilation can fail |
150 // because TransformCachedNodeData may be incomplete. | 140 // because TransformCachedNodeData may be incomplete. |
151 TransformTree(const TransformTree&) = delete; | 141 TransformTree(const TransformTree&) = delete; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // scale factor of device transform. So we need to store them explicitly. | 284 // scale factor of device transform. So we need to store them explicitly. |
295 float page_scale_factor_; | 285 float page_scale_factor_; |
296 float device_scale_factor_; | 286 float device_scale_factor_; |
297 float device_transform_scale_factor_; | 287 float device_transform_scale_factor_; |
298 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; | 288 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; |
299 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; | 289 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; |
300 std::vector<TransformCachedNodeData> cached_data_; | 290 std::vector<TransformCachedNodeData> cached_data_; |
301 std::vector<StickyPositionNodeData> sticky_position_data_; | 291 std::vector<StickyPositionNodeData> sticky_position_data_; |
302 }; | 292 }; |
303 | 293 |
| 294 struct StickyPositionNodeData { |
| 295 int scroll_ancestor; |
| 296 LayerStickyPositionConstraint constraints; |
| 297 |
| 298 // This is the offset that blink has already applied to counteract the main |
| 299 // thread scroll offset of the scroll ancestor. We need to account for this |
| 300 // by computing the additional offset necessary to keep the element stuck. |
| 301 gfx::Vector2dF main_thread_offset; |
| 302 |
| 303 // In order to properly compute the sticky offset, we need to know if we have |
| 304 // any sticky ancestors both between ourselves and our containing block and |
| 305 // between our containing block and the viewport. These ancestors are then |
| 306 // used to correct the constraining rect locations. |
| 307 int nearest_node_shifting_sticky_box; |
| 308 int nearest_node_shifting_containing_block; |
| 309 |
| 310 // For performance we cache our accumulated sticky offset to allow descendant |
| 311 // sticky elements to offset their constraint rects. Because we can either |
| 312 // affect the sticky box constraint rect or the containing block constraint |
| 313 // rect, we need to accumulate both. |
| 314 gfx::Vector2dF total_sticky_box_sticky_offset; |
| 315 gfx::Vector2dF total_containing_block_sticky_offset; |
| 316 |
| 317 StickyPositionNodeData() |
| 318 : scroll_ancestor(TransformTree::kInvalidNodeId), |
| 319 nearest_node_shifting_sticky_box(TransformTree::kInvalidNodeId), |
| 320 nearest_node_shifting_containing_block(TransformTree::kInvalidNodeId) {} |
| 321 }; |
| 322 |
304 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { | 323 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
305 public: | 324 public: |
306 bool operator==(const ClipTree& other) const; | 325 bool operator==(const ClipTree& other) const; |
307 | 326 |
308 static const int kViewportNodeId = 1; | 327 static const int kViewportNodeId = 1; |
309 | 328 |
310 void SetViewportClip(gfx::RectF viewport_rect); | 329 void SetViewportClip(gfx::RectF viewport_rect); |
311 gfx::RectF ViewportClip() const; | 330 gfx::RectF ViewportClip() const; |
312 }; | 331 }; |
313 | 332 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; | 696 DrawTransforms& GetDrawTransforms(int transform_id, int effect_id) const; |
678 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, | 697 DrawTransformData& FetchDrawTransformsDataFromCache(int transform_id, |
679 int effect_id) const; | 698 int effect_id) const; |
680 | 699 |
681 PropertyTreesCachedData cached_data_; | 700 PropertyTreesCachedData cached_data_; |
682 }; | 701 }; |
683 | 702 |
684 } // namespace cc | 703 } // namespace cc |
685 | 704 |
686 #endif // CC_TREES_PROPERTY_TREE_H_ | 705 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |