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), data() {} |
20 int id; | 20 int id; |
21 int parent_id; | 21 int parent_id; |
22 T data; | 22 T data; |
23 }; | 23 }; |
24 | 24 |
25 struct CC_EXPORT TransformNodeData { | 25 struct CC_EXPORT TransformNodeData { |
26 TransformNodeData(); | 26 TransformNodeData(); |
27 ~TransformNodeData(); | 27 ~TransformNodeData(); |
28 | 28 |
| 29 // The local transform information is combined to form to_parent (ignoring |
| 30 // snapping) as follows: |
| 31 // |
| 32 // to_parent = M_post_local * T_scroll * M_local * M_pre_local. |
| 33 // |
| 34 // The pre/post may seem odd when read LTR, but we multiply our points from |
| 35 // the right, so the pre_local matrix affects the result "first". This lines |
| 36 // up with the notions of pre/post used in skia and gfx::Transform. |
| 37 // |
| 38 // TODO(vollick): The values labeled with "will be moved..." take up a lot of |
| 39 // space, but are only necessary for animated or scrolled nodes (otherwise |
| 40 // we'll just use the baked to_parent). These values will be ultimately stored |
| 41 // directly on the transform/scroll display list items when that's possible, |
| 42 // or potentially in a scroll tree. |
| 43 // |
| 44 // TODO(vollick): will be moved when accelerated effects are implemented. |
| 45 gfx::Transform pre_local; |
| 46 gfx::Transform local; |
| 47 gfx::Transform post_local; |
| 48 |
29 gfx::Transform to_parent; | 49 gfx::Transform to_parent; |
30 gfx::Transform from_parent; | 50 gfx::Transform from_parent; |
31 | 51 |
| 52 gfx::Transform to_target; |
| 53 gfx::Transform from_target; |
| 54 |
32 gfx::Transform to_screen; | 55 gfx::Transform to_screen; |
33 gfx::Transform from_screen; | 56 gfx::Transform from_screen; |
34 | 57 |
35 int target_id; | 58 int target_id; |
| 59 // This id is used for all content that draws into a render surface associated |
| 60 // with this transform node. |
| 61 int content_target_id; |
| 62 |
| 63 // TODO(vollick): will be moved when accelerated effects are implemented. |
| 64 bool needs_local_transform_update; |
36 | 65 |
37 bool is_invertible; | 66 bool is_invertible; |
38 bool ancestors_are_invertible; | 67 bool ancestors_are_invertible; |
39 | 68 |
40 bool is_animated; | 69 bool is_animated; |
41 bool to_screen_is_animated; | 70 bool to_screen_is_animated; |
42 | 71 |
43 bool flattens; | 72 bool flattens; |
| 73 bool scrolls; |
| 74 |
| 75 bool needs_sublayer_scale; |
| 76 // This is used as a fallback when we either cannot adjust raster scale or if |
| 77 // the raster scale cannot be extracted from the screen space transform. |
| 78 float layer_scale_factor; |
| 79 gfx::Vector2dF sublayer_scale; |
| 80 |
| 81 // TODO(vollick): will be moved when accelerated effects are implemented. |
| 82 gfx::Vector2dF scroll_offset; |
44 | 83 |
45 void set_to_parent(const gfx::Transform& transform) { | 84 void set_to_parent(const gfx::Transform& transform) { |
46 to_parent = transform; | 85 to_parent = transform; |
47 is_invertible = to_parent.GetInverse(&from_parent); | 86 is_invertible = to_parent.GetInverse(&from_parent); |
48 } | 87 } |
49 }; | 88 }; |
50 | 89 |
51 typedef TreeNode<TransformNodeData> TransformNode; | 90 typedef TreeNode<TransformNodeData> TransformNode; |
52 | 91 |
53 struct CC_EXPORT ClipNodeData { | 92 struct CC_EXPORT ClipNodeData { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // The function returns false iff the inverse of a singular transform was | 137 // The function returns false iff the inverse of a singular transform was |
99 // used (and the result should, therefore, not be trusted). | 138 // used (and the result should, therefore, not be trusted). |
100 bool ComputeTransform(int source_id, | 139 bool ComputeTransform(int source_id, |
101 int dest_id, | 140 int dest_id, |
102 gfx::Transform* transform) const; | 141 gfx::Transform* transform) const; |
103 | 142 |
104 // Returns true iff the nodes indexed by |source_id| and |dest_id| are 2D axis | 143 // Returns true iff the nodes indexed by |source_id| and |dest_id| are 2D axis |
105 // aligned with respect to one another. | 144 // aligned with respect to one another. |
106 bool Are2DAxisAligned(int source_id, int dest_id) const; | 145 bool Are2DAxisAligned(int source_id, int dest_id) const; |
107 | 146 |
108 // This recomputes the screen space transform (and its inverse) for the node | 147 // Updates the parent, target, and screen space transforms and snapping. |
109 // at |id|. | 148 void UpdateTransforms(int id); |
110 void UpdateScreenSpaceTransform(int id); | |
111 | 149 |
112 private: | 150 private: |
113 // Returns true iff the node at |desc_id| is a descendant of the node at | 151 // Returns true iff the node at |desc_id| is a descendant of the node at |
114 // |anc_id|. | 152 // |anc_id|. |
115 bool IsDescendant(int desc_id, int anc_id) const; | 153 bool IsDescendant(int desc_id, int anc_id) const; |
116 | 154 |
117 // Returns the index of the lowest common ancestor of the nodes |a| and |b|. | 155 // Returns the index of the lowest common ancestor of the nodes |a| and |b|. |
118 int LowestCommonAncestor(int a, int b) const; | 156 int LowestCommonAncestor(int a, int b) const; |
119 | 157 |
120 // Computes the combined transform between |source_id| and |dest_id| and | 158 // Computes the combined transform between |source_id| and |dest_id| and |
121 // returns false if the inverse of a singular transform was used. These two | 159 // returns false if the inverse of a singular transform was used. These two |
122 // nodes must be on the same ancestor chain. | 160 // nodes must be on the same ancestor chain. |
123 bool CombineTransformsBetween(int source_id, | 161 bool CombineTransformsBetween(int source_id, |
124 int dest_id, | 162 int dest_id, |
125 gfx::Transform* transform) const; | 163 gfx::Transform* transform) const; |
126 | 164 |
127 // Computes the combined inverse transform between |source_id| and |dest_id| | 165 // Computes the combined inverse transform between |source_id| and |dest_id| |
128 // and returns false if the inverse of a singular transform was used. These | 166 // and returns false if the inverse of a singular transform was used. These |
129 // two nodes must be on the same ancestor chain. | 167 // two nodes must be on the same ancestor chain. |
130 bool CombineInversesBetween(int source_id, | 168 bool CombineInversesBetween(int source_id, |
131 int dest_id, | 169 int dest_id, |
132 gfx::Transform* transform) const; | 170 gfx::Transform* transform) const; |
| 171 |
| 172 void UpdateLocalTransform(TransformNode* node); |
| 173 void UpdateScreenSpaceTransform(TransformNode* node, |
| 174 TransformNode* parent_node, |
| 175 TransformNode* target_node); |
| 176 void UpdateSublayerScale(TransformNode* node); |
| 177 void UpdateTargetSpaceTransform(TransformNode* node, |
| 178 TransformNode* target_node); |
| 179 void UpdateIsAnimated(TransformNode* node, TransformNode* parent_node); |
| 180 void UpdateSnapping(TransformNode* node); |
133 }; | 181 }; |
134 | 182 |
135 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; | 183 class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {}; |
136 | 184 |
137 } // namespace cc | 185 } // namespace cc |
138 | 186 |
139 #endif // CC_TREES_PROPERTY_TREE_H_ | 187 #endif // CC_TREES_PROPERTY_TREE_H_ |
OLD | NEW |