Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CC_TREES_PROPERTY_TREE_H_ | |
| 6 #define CC_TREES_PROPERTY_TREE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "cc/base/cc_export.h" | |
| 12 #include "ui/gfx/rect.h" | |
| 13 #include "ui/gfx/transform.h" | |
| 14 | |
| 15 namespace cc { | |
| 16 | |
| 17 template <typename T> | |
| 18 struct CC_EXPORT TreeNode { | |
| 19 TreeNode() : id(-1), parent_id(-1), data() {} | |
| 20 int id; | |
| 21 int parent_id; | |
| 22 T data; | |
| 23 }; | |
| 24 | |
| 25 struct CC_EXPORT TransformNodeData { | |
| 26 TransformNodeData(); | |
| 27 ~TransformNodeData(); | |
| 28 | |
| 29 gfx::Transform to_parent; | |
| 30 gfx::Transform from_parent; | |
| 31 | |
| 32 gfx::Transform to_screen; | |
| 33 gfx::Transform from_screen; | |
| 34 | |
| 35 int target_id; | |
| 36 | |
| 37 bool is_invertible; | |
| 38 bool ancestors_are_invertible; | |
| 39 bool flattens; | |
| 40 | |
| 41 void set_to_parent(const gfx::Transform& transform) { | |
| 42 to_parent = transform; | |
| 43 is_invertible = to_parent.GetInverse(&from_parent); | |
| 44 } | |
| 45 }; | |
| 46 | |
| 47 typedef TreeNode<TransformNodeData> TransformNode; | |
| 48 | |
| 49 struct CC_EXPORT ClipNodeData { | |
| 50 ClipNodeData(); | |
| 51 | |
| 52 gfx::RectF clip; | |
| 53 gfx::RectF combined_clip; | |
| 54 int transform_id; | |
| 55 int target_id; | |
| 56 }; | |
| 57 | |
| 58 typedef TreeNode<ClipNodeData> ClipNode; | |
| 59 | |
| 60 template <typename T> | |
| 61 class CC_EXPORT PropertyTree { | |
| 62 public: | |
| 63 PropertyTree(); | |
| 64 // Not virtual. Should not derive from this class. | |
|
enne (OOO)
2014/12/10 23:45:59
final?
Ian Vollick
2014/12/12 03:01:47
Done.
| |
| 65 ~PropertyTree(); | |
| 66 | |
| 67 int Insert(const T& tree_node, int parent_id); | |
| 68 | |
| 69 T* Node(int i) { return i > -1 ? &nodes_[i] : nullptr; } | |
| 70 const T* Node(int i) const { return i > -1 ? &nodes_[i] : nullptr; } | |
| 71 | |
| 72 T* parent(const T* t) { | |
| 73 return t->parent_id > -1 ? Node(t->parent_id) : nullptr; | |
| 74 } | |
| 75 const T* parent(const T* t) const { | |
| 76 return t->parent_id > -1 ? Node(t->parent_id) : nullptr; | |
| 77 } | |
| 78 | |
| 79 T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; } | |
| 80 const T* back() const { | |
| 81 return size() ? &nodes_[nodes_.size() - 1] : nullptr; | |
| 82 } | |
| 83 | |
| 84 void clear() { nodes_.clear(); } | |
| 85 size_t size() const { return nodes_.size(); } | |
| 86 | |
| 87 private: | |
| 88 // Copy and assign are permitted. This is how we'll do tree sync. | |
| 89 std::vector<T> nodes_; | |
| 90 }; | |
| 91 | |
| 92 typedef PropertyTree<TransformNode> TransformTree; | |
| 93 typedef PropertyTree<ClipNode> ClipTree; | |
| 94 | |
| 95 bool CC_EXPORT ComputeTransform(const TransformTree& tree, | |
|
enne (OOO)
2014/12/10 23:45:59
Make this a const function on TransformTree?
Ian Vollick
2014/12/12 03:01:47
Done.
| |
| 96 int source_id, | |
| 97 int dest_id, | |
| 98 gfx::Transform* transform); | |
| 99 | |
| 100 bool CC_EXPORT | |
| 101 Are2DAxisAligned(const TransformTree& tree, int source_id, int dest_id); | |
|
enne (OOO)
2014/12/10 23:45:59
Same here?
Ian Vollick
2014/12/12 03:01:47
Done.
| |
| 102 | |
| 103 void CC_EXPORT UpdateScreenSpaceTransform(TransformTree* tree, int id); | |
| 104 | |
| 105 } // namespace cc | |
| 106 | |
| 107 #endif // CC_TREES_PROPERTY_TREE_H_ | |
| OLD | NEW |