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> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "cc/animation/element_id.h" | 14 #include "cc/animation/element_id.h" |
15 #include "cc/base/cc_export.h" | 15 #include "cc/base/cc_export.h" |
16 #include "cc/base/synced_property.h" | 16 #include "cc/base/synced_property.h" |
| 17 #include "cc/layers/layer_sticky_position_constraint.h" |
17 #include "cc/output/filter_operations.h" | 18 #include "cc/output/filter_operations.h" |
18 #include "ui/gfx/geometry/rect_f.h" | 19 #include "ui/gfx/geometry/rect_f.h" |
19 #include "ui/gfx/geometry/scroll_offset.h" | 20 #include "ui/gfx/geometry/scroll_offset.h" |
20 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
21 | 22 |
22 namespace base { | 23 namespace base { |
23 namespace trace_event { | 24 namespace trace_event { |
24 class TracedValue; | 25 class TracedValue; |
25 } | 26 } |
26 } | 27 } |
27 | 28 |
28 namespace cc { | 29 namespace cc { |
29 | 30 |
30 namespace proto { | 31 namespace proto { |
31 class PropertyTree; | 32 class PropertyTree; |
32 class PropertyTrees; | 33 class PropertyTrees; |
33 class ScrollNodeData; | 34 class ScrollNodeData; |
| 35 class StickyPositionNodeData; |
34 class TreeNode; | 36 class TreeNode; |
35 } // namespace proto | 37 } // namespace proto |
36 | 38 |
37 class CopyOutputRequest; | 39 class CopyOutputRequest; |
38 class LayerTreeImpl; | 40 class LayerTreeImpl; |
39 class ScrollState; | 41 class ScrollState; |
40 struct ClipNode; | 42 struct ClipNode; |
41 struct EffectNode; | 43 struct EffectNode; |
42 struct ScrollAndScaleSet; | 44 struct ScrollAndScaleSet; |
43 struct ScrollNode; | 45 struct ScrollNode; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 117 |
116 void AsValueInto(base::trace_event::TracedValue* value) const; | 118 void AsValueInto(base::trace_event::TracedValue* value) const; |
117 | 119 |
118 private: | 120 private: |
119 std::vector<T> nodes_; | 121 std::vector<T> nodes_; |
120 | 122 |
121 bool needs_update_; | 123 bool needs_update_; |
122 PropertyTrees* property_trees_; | 124 PropertyTrees* property_trees_; |
123 }; | 125 }; |
124 | 126 |
| 127 struct StickyPositionNodeData { |
| 128 int scroll_ancestor; |
| 129 LayerStickyPositionConstraint constraints; |
| 130 |
| 131 // This is the offset that blink has already applied to counteract the main |
| 132 // thread scroll offset of the scroll ancestor. We need to account for this |
| 133 // by computing the additional offset necessary to keep the element stuck. |
| 134 gfx::Vector2dF main_thread_offset; |
| 135 |
| 136 StickyPositionNodeData() : scroll_ancestor(-1) {} |
| 137 void ToProtobuf(proto::StickyPositionNodeData* proto) const; |
| 138 void FromProtobuf(const proto::StickyPositionNodeData& proto); |
| 139 }; |
| 140 |
125 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 141 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
126 public: | 142 public: |
127 TransformTree(); | 143 TransformTree(); |
128 | 144 |
129 // These C++ special member functions cannot be implicit inline because | 145 // These C++ special member functions cannot be implicit inline because |
130 // they are exported by CC_EXPORT. They will be instantiated in every | 146 // they are exported by CC_EXPORT. They will be instantiated in every |
131 // compilation units that included this header, and compilation can fail | 147 // compilation units that included this header, and compilation can fail |
132 // because TransformCachedNodeData may be incomplete. | 148 // because TransformCachedNodeData may be incomplete. |
133 TransformTree(const TransformTree&) = delete; | 149 TransformTree(const TransformTree&) = delete; |
134 ~TransformTree(); | 150 ~TransformTree(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 int TargetId(int node_id) const; | 264 int TargetId(int node_id) const; |
249 void SetTargetId(int node_id, int target_id); | 265 void SetTargetId(int node_id, int target_id); |
250 | 266 |
251 int ContentTargetId(int node_id) const; | 267 int ContentTargetId(int node_id) const; |
252 void SetContentTargetId(int node_id, int content_target_id); | 268 void SetContentTargetId(int node_id, int content_target_id); |
253 | 269 |
254 const std::vector<TransformCachedNodeData>& cached_data() const { | 270 const std::vector<TransformCachedNodeData>& cached_data() const { |
255 return cached_data_; | 271 return cached_data_; |
256 } | 272 } |
257 | 273 |
| 274 StickyPositionNodeData* StickyPositionData(int node_id); |
| 275 |
258 void ToProtobuf(proto::PropertyTree* proto) const; | 276 void ToProtobuf(proto::PropertyTree* proto) const; |
259 void FromProtobuf(const proto::PropertyTree& proto, | 277 void FromProtobuf(const proto::PropertyTree& proto, |
260 std::unordered_map<int, int>* node_id_to_index_map); | 278 std::unordered_map<int, int>* node_id_to_index_map); |
261 | 279 |
262 // Computes the combined transform between |source_id| and |dest_id|. These | 280 // Computes the combined transform between |source_id| and |dest_id|. These |
263 // two nodes must be on the same ancestor chain. | 281 // two nodes must be on the same ancestor chain. |
264 void CombineTransformsBetween(int source_id, | 282 void CombineTransformsBetween(int source_id, |
265 int dest_id, | 283 int dest_id, |
266 gfx::Transform* transform) const; | 284 gfx::Transform* transform) const; |
267 | 285 |
(...skipping 28 matching lines...) Expand all Loading... |
296 bool source_to_parent_updates_allowed_; | 314 bool source_to_parent_updates_allowed_; |
297 // When to_screen transform has perspective, the transform node's sublayer | 315 // When to_screen transform has perspective, the transform node's sublayer |
298 // scale is calculated using page scale factor, device scale factor and the | 316 // scale is calculated using page scale factor, device scale factor and the |
299 // scale factor of device transform. So we need to store them explicitly. | 317 // scale factor of device transform. So we need to store them explicitly. |
300 float page_scale_factor_; | 318 float page_scale_factor_; |
301 float device_scale_factor_; | 319 float device_scale_factor_; |
302 float device_transform_scale_factor_; | 320 float device_transform_scale_factor_; |
303 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; | 321 std::vector<int> nodes_affected_by_inner_viewport_bounds_delta_; |
304 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; | 322 std::vector<int> nodes_affected_by_outer_viewport_bounds_delta_; |
305 std::vector<TransformCachedNodeData> cached_data_; | 323 std::vector<TransformCachedNodeData> cached_data_; |
| 324 std::vector<StickyPositionNodeData> sticky_position_data_; |
306 }; | 325 }; |
307 | 326 |
308 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { | 327 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
309 public: | 328 public: |
310 bool operator==(const ClipTree& other) const; | 329 bool operator==(const ClipTree& other) const; |
311 | 330 |
312 static const int kViewportNodeId = 1; | 331 static const int kViewportNodeId = 1; |
313 | 332 |
314 void SetViewportClip(gfx::RectF viewport_rect); | 333 void SetViewportClip(gfx::RectF viewport_rect); |
315 gfx::RectF ViewportClip() const; | 334 gfx::RectF ViewportClip() const; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 gfx::Vector2dF inner_viewport_container_bounds_delta_; | 646 gfx::Vector2dF inner_viewport_container_bounds_delta_; |
628 gfx::Vector2dF outer_viewport_container_bounds_delta_; | 647 gfx::Vector2dF outer_viewport_container_bounds_delta_; |
629 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; | 648 gfx::Vector2dF inner_viewport_scroll_bounds_delta_; |
630 | 649 |
631 PropertyTreesCachedData cached_data_; | 650 PropertyTreesCachedData cached_data_; |
632 }; | 651 }; |
633 | 652 |
634 } // namespace cc | 653 } // namespace cc |
635 | 654 |
636 #endif // CC_TREES_PROPERTY_TREE_H_ | 655 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |