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

Side by Side Diff: cc/trees/property_tree.h

Issue 1088773003: Reuse property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no more first tick nonsense. Created 5 years, 8 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 <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
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) {
125 const T* Node(int i) const { return i > -1 ? &nodes_[i] : nullptr; } 136 return i > -1 && i < static_cast<int>(size()) ? &nodes_[i] : nullptr;
ajuma 2015/04/16 14:52:14 Do we need this check because we're winding up wit
Ian Vollick 2015/04/17 14:56:22 This was due to a bad bug! What was happening was
137 }
138 const T* Node(int i) const {
139 return i > -1 && i < static_cast<int>(size()) ? &nodes_[i] : nullptr;
140 }
126 141
127 T* parent(const T* t) { 142 T* parent(const T* t) { return Node(t->parent_id); }
128 return t->parent_id > -1 ? Node(t->parent_id) : nullptr; 143 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 144
134 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } 145 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; }
135 const T* back() const { 146 const T* back() const {
136 return size() ? &nodes_[nodes_.size() - 1] : nullptr; 147 return size() ? &nodes_[nodes_.size() - 1] : nullptr;
137 } 148 }
138 149
139 void clear() { nodes_.clear(); } 150 void clear();
140 size_t size() const { return nodes_.size(); } 151 size_t size() const { return nodes_.size(); }
141 152
142 private: 153 private:
143 // Copy and assign are permitted. This is how we do tree sync. 154 // Copy and assign are permitted. This is how we do tree sync.
144 std::vector<T> nodes_; 155 std::vector<T> nodes_;
145 }; 156 };
146 157
147 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { 158 class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
148 public: 159 public:
149 // Computes the change of basis transform from node |source_id| to |dest_id|. 160 // 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
206 void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node); 217 void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node);
207 void UpdateSnapping(TransformNode* node); 218 void UpdateSnapping(TransformNode* node);
208 }; 219 };
209 220
210 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; 221 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {};
211 222
212 class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {}; 223 class CC_EXPORT OpacityTree final : public PropertyTree<OpacityNode> {};
213 224
214 class CC_EXPORT PropertyTrees final { 225 class CC_EXPORT PropertyTrees final {
215 public: 226 public:
227 PropertyTrees();
228
216 TransformTree transform_tree; 229 TransformTree transform_tree;
217 OpacityTree opacity_tree; 230 OpacityTree opacity_tree;
218 ClipTree clip_tree; 231 ClipTree clip_tree;
232 bool needs_rebuild;
219 }; 233 };
220 234
221 } // namespace cc 235 } // namespace cc
222 236
223 #endif // CC_TREES_PROPERTY_TREE_H_ 237 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698