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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
13 #include "ui/gfx/transform.h" | 13 #include "ui/gfx/transform.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 template <typename T> | 17 template <typename T> |
18 struct CC_EXPORT TreeNode { | 18 struct CC_EXPORT TreeNode { |
19 TreeNode() : id(-1), parent_id(-1), data() {} | 19 TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} |
20 int id; | 20 int id; |
21 int parent_id; | 21 int parent_id; |
| 22 int owner_id; |
22 T data; | 23 T data; |
23 }; | 24 }; |
24 | 25 |
25 struct CC_EXPORT TransformNodeData { | 26 struct CC_EXPORT TransformNodeData { |
26 TransformNodeData(); | 27 TransformNodeData(); |
27 ~TransformNodeData(); | 28 ~TransformNodeData(); |
28 | 29 |
29 // The local transform information is combined to form to_parent (ignoring | 30 // The local transform information is combined to form to_parent (ignoring |
30 // snapping) as follows: | 31 // snapping) as follows: |
31 // | 32 // |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // This is true if the to_parent transform at every node on the path to the | 76 // This is true if the to_parent transform at every node on the path to the |
76 // root is flat. | 77 // root is flat. |
77 bool node_and_ancestors_are_flat; | 78 bool node_and_ancestors_are_flat; |
78 | 79 |
79 bool scrolls; | 80 bool scrolls; |
80 | 81 |
81 bool needs_sublayer_scale; | 82 bool needs_sublayer_scale; |
82 // This is used as a fallback when we either cannot adjust raster scale or if | 83 // This is used as a fallback when we either cannot adjust raster scale or if |
83 // the raster scale cannot be extracted from the screen space transform. | 84 // the raster scale cannot be extracted from the screen space transform. |
84 float layer_scale_factor; | 85 float layer_scale_factor; |
| 86 |
| 87 // TODO(vollick): will be moved when accelerated effects are implemented. |
| 88 float post_local_scale_factor; |
| 89 |
85 gfx::Vector2dF sublayer_scale; | 90 gfx::Vector2dF sublayer_scale; |
86 | 91 |
87 // TODO(vollick): will be moved when accelerated effects are implemented. | 92 // TODO(vollick): will be moved when accelerated effects are implemented. |
88 gfx::Vector2dF scroll_offset; | 93 gfx::Vector2dF scroll_offset; |
89 | 94 |
90 // We scroll snap where possible, but this has an effect on scroll | 95 // We scroll snap where possible, but this has an effect on scroll |
91 // compensation: the snap is yet more scrolling that must be compensated for. | 96 // compensation: the snap is yet more scrolling that must be compensated for. |
92 // This value stores the snapped amount for this purpose. | 97 // This value stores the snapped amount for this purpose. |
93 gfx::Vector2dF scroll_snap; | 98 gfx::Vector2dF scroll_snap; |
94 | 99 |
| 100 // TODO(vollick): will be moved when accelerated effects are implemented. |
| 101 gfx::Vector2dF parent_offset; |
| 102 |
95 void set_to_parent(const gfx::Transform& transform) { | 103 void set_to_parent(const gfx::Transform& transform) { |
96 to_parent = transform; | 104 to_parent = transform; |
97 is_invertible = to_parent.IsInvertible(); | 105 is_invertible = to_parent.IsInvertible(); |
98 } | 106 } |
| 107 |
| 108 void update_post_local_transform(const gfx::PointF& position, |
| 109 const gfx::Point3F& transform_origin); |
99 }; | 110 }; |
100 | 111 |
101 typedef TreeNode<TransformNodeData> TransformNode; | 112 typedef TreeNode<TransformNodeData> TransformNode; |
102 | 113 |
103 struct CC_EXPORT ClipNodeData { | 114 struct CC_EXPORT ClipNodeData { |
104 ClipNodeData(); | 115 ClipNodeData(); |
105 | 116 |
106 gfx::RectF clip; | 117 gfx::RectF clip; |
107 gfx::RectF combined_clip; | 118 gfx::RectF combined_clip; |
108 int transform_id; | 119 int transform_id; |
109 int target_id; | 120 int target_id; |
110 }; | 121 }; |
111 | 122 |
112 typedef TreeNode<ClipNodeData> ClipNode; | 123 typedef TreeNode<ClipNodeData> ClipNode; |
113 | 124 |
114 typedef TreeNode<float> OpacityNode; | 125 typedef TreeNode<float> OpacityNode; |
115 | 126 |
116 template <typename T> | 127 template <typename T> |
117 class CC_EXPORT PropertyTree { | 128 class CC_EXPORT PropertyTree { |
118 public: | 129 public: |
119 PropertyTree(); | 130 PropertyTree(); |
120 virtual ~PropertyTree(); | 131 virtual ~PropertyTree(); |
121 | 132 |
122 int Insert(const T& tree_node, int parent_id); | 133 int Insert(const T& tree_node, int parent_id); |
123 | 134 |
124 T* Node(int i) { return i > -1 ? &nodes_[i] : nullptr; } | 135 T* Node(int i) { return i > -1 ? &nodes_[i] : nullptr; } |
125 const T* Node(int i) const { return i > -1 ? &nodes_[i] : nullptr; } | 136 const T* Node(int i) const { return i > -1 ? &nodes_[i] : nullptr; } |
126 | 137 |
127 T* parent(const T* t) { | 138 T* parent(const T* t) { return Node(t->parent_id); } |
128 return t->parent_id > -1 ? Node(t->parent_id) : nullptr; | 139 const T* parent(const T* t) const { return Node(t->parent_id); } |
129 } | |
130 const T* parent(const T* t) const { | |
131 return t->parent_id > -1 ? Node(t->parent_id) : nullptr; | |
132 } | |
133 | 140 |
134 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } | 141 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } |
135 const T* back() const { | 142 const T* back() const { |
136 return size() ? &nodes_[nodes_.size() - 1] : nullptr; | 143 return size() ? &nodes_[nodes_.size() - 1] : nullptr; |
137 } | 144 } |
138 | 145 |
139 void clear() { nodes_.clear(); } | 146 void clear(); |
140 size_t size() const { return nodes_.size(); } | 147 size_t size() const { return nodes_.size(); } |
141 | 148 |
142 private: | 149 private: |
143 // Copy and assign are permitted. This is how we do tree sync. | 150 // Copy and assign are permitted. This is how we do tree sync. |
144 std::vector<T> nodes_; | 151 std::vector<T> nodes_; |
145 }; | 152 }; |
146 | 153 |
147 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { | 154 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
148 public: | 155 public: |
149 // Computes the change of basis transform from node |source_id| to |dest_id|. | 156 // Computes the change of basis transform from node |source_id| to |dest_id|. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node); | 213 void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node); |
207 void UpdateSnapping(TransformNode* node); | 214 void UpdateSnapping(TransformNode* node); |
208 }; | 215 }; |
209 | 216 |
210 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; | 217 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; |
211 | 218 |
212 class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {}; | 219 class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {}; |
213 | 220 |
214 class CC_EXPORT PropertyTrees final { | 221 class CC_EXPORT PropertyTrees final { |
215 public: | 222 public: |
| 223 PropertyTrees(); |
| 224 |
216 TransformTree transform_tree; | 225 TransformTree transform_tree; |
217 OpacityTree opacity_tree; | 226 OpacityTree opacity_tree; |
218 ClipTree clip_tree; | 227 ClipTree clip_tree; |
| 228 bool needs_rebuild; |
219 }; | 229 }; |
220 | 230 |
221 } // namespace cc | 231 } // namespace cc |
222 | 232 |
223 #endif // CC_TREES_PROPERTY_TREE_H_ | 233 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |