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

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

Issue 687873004: Introduce Property Trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wip-awoloszyn2
Patch Set: . Created 6 years, 1 month 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"
(...skipping 10 matching lines...) Expand all
21 : id(-1), 21 : id(-1),
22 parent_id(-1), 22 parent_id(-1),
23 value(value), 23 value(value),
24 layer(layer) {} 24 layer(layer) {}
25 int id; 25 int id;
26 int parent_id; 26 int parent_id;
27 T value; 27 T value;
28 Layer* layer; 28 Layer* layer;
29 }; 29 };
30 30
31 typedef TreeNode<double> OpacityTreeNode; 31 typedef TreeNode<double> OpacityNode;
32 32
33 struct TransformTreeNode : public TreeNode<gfx::Transform> { 33 struct TransformNode : public TreeNode<gfx::Transform> {
34 TransformTreeNode(Layer* layer, const gfx::Transform& transform); 34 TransformNode(Layer* layer, const gfx::Transform& transform);
35 ~TransformTreeNode(); 35 ~TransformNode();
36 // TODO(awoloszyn): can we rework the algorithm so that we don't need this 36 // TODO(awoloszyn): can we rework the algorithm so that we don't need this
37 // rect? 37 // rect?
38 gfx::Transform clip_transform_from_transform_parent; 38 gfx::Transform clip_transform_from_transform_parent;
39 gfx::RectF clip_rect; 39 gfx::RectF clip_rect;
40 }; 40 };
41 41
42 struct ClipTreeNode : public TreeNode<gfx::RectF> { 42 struct ClipNode : public TreeNode<gfx::RectF> {
43 ClipTreeNode(Layer* layer, const gfx::RectF& rect); 43 ClipNode(Layer* layer, const gfx::RectF& rect);
44 ClipTreeNode(Layer* layer, const gfx::RectF& rect, bool clips); 44 ClipNode(Layer* layer, const gfx::RectF& rect, bool clips);
45 gfx::RectF GetClipForLayer(Layer* layer) const { 45 gfx::RectF GetClipForLayer(Layer* layer) const {
46 if(clips) 46 if(clips)
47 return value; 47 return value;
48 return gfx::RectF(layer->content_bounds()); 48 return gfx::RectF(layer->content_bounds());
49 } 49 }
50 ~ClipTreeNode(); 50 ~ClipNode();
51 51
52 // ClipTreeNodes that don't clip are used to reset clipping state. 52 // ClipNodes that don't clip are used to reset clipping state.
53 bool clips; 53 bool clips;
54 }; 54 };
55 55
56 template <typename T> 56 template <typename T>
57 class PropertyTree { 57 class PropertyTree {
58 public: 58 public:
59 PropertyTree(); 59 explicit PropertyTree(Layer* root);
60 // Not virtual. Should not derive from this class. 60 // Not virtual. Should not derive from this class.
61 ~PropertyTree(); 61 ~PropertyTree();
62 62
63 // Returns id of inserted layer. 63 // TODO(vollick): we can probably do without the return value.
64 int InsertRootNode(const T& tree_node); 64 int InsertWithParent(const T& tree_node, int parent_id);
65 65
66 // Returns id of inserted layer.
67 int InsertWithParent(const T& tree_node, int parent_id);
68 int GetLastNodeID() const; 66 int GetLastNodeID() const;
69 67
70 T* Node(int id); 68 T* Node(int id);
71 const T* Node(int id) const; 69 const T* Node(int id) const;
72 70
73 T* root() { return Node(0); } 71 T* root() { return Node(0); }
74 const T* root() const { return Node(0); } 72 const T* root() const { return Node(0); }
75 73
76 void clear() { nodes_.clear(); } 74 void clear() { nodes_.clear(); }
77 typedef T NodeType; 75 typedef T NodeType;
78 76
79 private: 77 private:
78 int InsertRootNode(const T& tree_node);
80 std::vector<T> nodes_; 79 std::vector<T> nodes_;
81 }; 80 };
82 81
83 typedef PropertyTree<TransformTreeNode> TransformTree; 82 typedef PropertyTree<TransformNode> TransformTree;
84 typedef PropertyTree<OpacityTreeNode> OpacityTree; 83 typedef PropertyTree<OpacityNode> OpacityTree;
85 typedef PropertyTree<ClipTreeNode> ClipTree; 84 typedef PropertyTree<ClipNode> ClipTree;
86 85
87 } // namespace cc 86 } // namespace cc
88 87
89 #endif // CC_TREES_PROPERTY_TREE_H_ 88 #endif // CC_TREES_PROPERTY_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698