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

Unified Diff: cc/trees/property_tree.h

Issue 1417963011: Added serialization to protobufs for property trees. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and address comments. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/proto/property_tree.proto ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree.h
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h
index 6f26ef68768c594a9ce8a86c524b0ea374a50799..4fbcc4312ca687609158779dcdda38acd9e972d1 100644
--- a/cc/trees/property_tree.h
+++ b/cc/trees/property_tree.h
@@ -15,6 +15,23 @@
namespace cc {
+namespace proto {
+class ClipNodeData;
+class EffectNodeData;
+class PropertyTree;
+class PropertyTrees;
+class TranformNodeData;
+class TransformTreeData;
+class TreeNode;
+}
+
+// ------------------------------*IMPORTANT*---------------------------------
+// Each class declared here has a corresponding proto defined in
+// 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 +39,11 @@ struct CC_EXPORT TreeNode {
int parent_id;
int owner_id;
T data;
+
+ bool operator==(const TreeNode<T>& other) const;
+
+ void ToProtobuf(proto::TreeNode* proto) const;
+ void FromProtobuf(const proto::TreeNode& proto);
};
struct CC_EXPORT TransformNodeData {
@@ -141,6 +163,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 +174,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 +225,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 +243,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 +258,8 @@ class CC_EXPORT PropertyTree {
PropertyTree();
virtual ~PropertyTree();
+ bool operator==(const PropertyTree<T>& other) const;
+
int Insert(const T& tree_node, int parent_id);
T* Node(int i) {
@@ -248,8 +287,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 +306,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 +377,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 +397,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 +459,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;
« no previous file with comments | « cc/proto/property_tree.proto ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698