Chromium Code Reviews| Index: cc/trees/property_tree.h |
| diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h |
| index 6f26ef68768c594a9ce8a86c524b0ea374a50799..4c6fec3aa463221974c93d43a3ddecc44cc035e5 100644 |
| --- a/cc/trees/property_tree.h |
| +++ b/cc/trees/property_tree.h |
| @@ -15,6 +15,22 @@ |
| namespace cc { |
| +namespace proto { |
| +class ClipNodeData; |
| +class EffectNodeData; |
| +class PropertyTree; |
| +class PropertyTrees; |
| +class TranformNodeData; |
| +class TransformTreeData; |
| +class TreeNode; |
| +} |
| + |
| +// Each class declared here has a corresponding proto defined in |
|
vmpstr
2015/11/19 23:24:51
Can you add
// IMPORTANT!
Khushal
2015/11/20 01:42:09
Done. :D
|
| +// cc/proto/property_tree.proto. When making any changes to a class structure |
| +// including addition/deletion/updation of a field, please also make the |
| +// change to its proto and the ToProtobuf and FromProtobuf methods for that |
| +// class. |
| + |
| template <typename T> |
| struct CC_EXPORT TreeNode { |
| TreeNode() : id(-1), parent_id(-1), owner_id(-1), data() {} |
| @@ -22,6 +38,11 @@ struct CC_EXPORT TreeNode { |
| int parent_id; |
| int owner_id; |
| T data; |
| + |
| + bool operator==(const TreeNode& other) const; |
|
vmpstr
2015/11/19 23:24:51
I'd prefer const TreeNode<T>& other (ie explicit <
Khushal
2015/11/20 01:42:09
Done.
|
| + |
| + void ToProtobuf(proto::TreeNode* proto) const; |
| + void FromProtobuf(const proto::TreeNode& proto); |
| }; |
| struct CC_EXPORT TransformNodeData { |
| @@ -141,6 +162,8 @@ struct CC_EXPORT TransformNodeData { |
| gfx::Vector2dF source_offset; |
| gfx::Vector2dF source_to_parent; |
| + bool operator==(const TransformNodeData& other) const; |
| + |
| void set_to_parent(const gfx::Transform& transform) { |
| to_parent = transform; |
| is_invertible = to_parent.IsInvertible(); |
| @@ -150,6 +173,9 @@ struct CC_EXPORT TransformNodeData { |
| void update_post_local_transform(const gfx::PointF& position, |
| const gfx::Point3F& transform_origin); |
| + |
| + void ToProtobuf(proto::TreeNode* proto) const; |
| + void FromProtobuf(const proto::TreeNode& proto); |
| }; |
| typedef TreeNode<TransformNodeData> TransformNode; |
| @@ -198,6 +224,11 @@ struct CC_EXPORT ClipNodeData { |
| // Nodes that correspond to unclipped surfaces disregard ancestor clips. |
| bool resets_clip : 1; |
| + |
| + bool operator==(const ClipNodeData& other) const; |
| + |
| + void ToProtobuf(proto::TreeNode* proto) const; |
| + void FromProtobuf(const proto::TreeNode& proto); |
| }; |
| typedef TreeNode<ClipNodeData> ClipNode; |
| @@ -211,6 +242,11 @@ struct CC_EXPORT EffectNodeData { |
| bool has_render_surface; |
| int transform_id; |
| int clip_id; |
| + |
| + bool operator==(const EffectNodeData& other) const; |
| + |
| + void ToProtobuf(proto::TreeNode* proto) const; |
| + void FromProtobuf(const proto::TreeNode& proto); |
| }; |
| typedef TreeNode<EffectNodeData> EffectNode; |
| @@ -221,6 +257,8 @@ class CC_EXPORT PropertyTree { |
| PropertyTree(); |
| virtual ~PropertyTree(); |
| + bool operator==(const PropertyTree& other) const; |
| + |
| int Insert(const T& tree_node, int parent_id); |
| T* Node(int i) { |
| @@ -248,8 +286,13 @@ class CC_EXPORT PropertyTree { |
| void set_needs_update(bool needs_update) { needs_update_ = needs_update; } |
| bool needs_update() const { return needs_update_; } |
| + const std::vector<T>& nodes() const { return nodes_; } |
| + |
| int next_available_id() const { return static_cast<int>(size()); } |
| + void ToProtobuf(proto::PropertyTree* proto) const; |
| + void FromProtobuf(const proto::PropertyTree& proto); |
| + |
| private: |
| // Copy and assign are permitted. This is how we do tree sync. |
| std::vector<T> nodes_; |
| @@ -262,6 +305,8 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| TransformTree(); |
| ~TransformTree() override; |
| + bool operator==(const TransformTree& other) const; |
| + |
| void clear() override; |
| // Computes the change of basis transform from node |source_id| to |dest_id|. |
| @@ -331,6 +376,9 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| void SetDeviceTransform(const gfx::Transform& transform, |
| gfx::PointF root_position); |
| void SetDeviceTransformScaleFactor(const gfx::Transform& transform); |
| + float device_transform_scale_factor() const { |
| + return device_transform_scale_factor_; |
| + } |
| void SetInnerViewportBoundsDelta(gfx::Vector2dF bounds_delta); |
| gfx::Vector2dF inner_viewport_bounds_delta() const { |
| @@ -348,6 +396,18 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| bool HasNodesAffectedByInnerViewportBoundsDelta() const; |
| bool HasNodesAffectedByOuterViewportBoundsDelta() const; |
| + const std::vector<int>& nodes_affected_by_inner_viewport_bounds_delta() |
| + const { |
| + return nodes_affected_by_inner_viewport_bounds_delta_; |
| + } |
| + const std::vector<int>& nodes_affected_by_outer_viewport_bounds_delta() |
| + const { |
| + return nodes_affected_by_outer_viewport_bounds_delta_; |
| + } |
| + |
| + void ToProtobuf(proto::PropertyTree* proto) const; |
| + void FromProtobuf(const proto::PropertyTree& proto); |
| + |
| private: |
| // Returns true iff the node at |desc_id| is a descendant of the node at |
| // |anc_id|. |
| @@ -398,19 +458,34 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> { |
| class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> { |
| public: |
| + bool operator==(const ClipTree& other) const; |
| + |
| void SetViewportClip(gfx::RectF viewport_rect); |
| gfx::RectF ViewportClip(); |
| + |
| + void ToProtobuf(proto::PropertyTree* proto) const; |
| + void FromProtobuf(const proto::PropertyTree& proto); |
| }; |
| class CC_EXPORT EffectTree final : public PropertyTree<EffectNode> { |
| public: |
| + bool operator==(const EffectTree& other) const; |
| + |
| void UpdateOpacities(int id); |
| + |
| + void ToProtobuf(proto::PropertyTree* proto) const; |
| + void FromProtobuf(const proto::PropertyTree& proto); |
| }; |
| class CC_EXPORT PropertyTrees final { |
| public: |
| PropertyTrees(); |
| + bool operator==(const PropertyTrees& other) const; |
| + |
| + void ToProtobuf(proto::PropertyTrees* proto) const; |
| + void FromProtobuf(const proto::PropertyTrees& proto); |
| + |
| TransformTree transform_tree; |
| EffectTree effect_tree; |
| ClipTree clip_tree; |