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

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: 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
Index: cc/trees/property_tree.h
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h
index 6f26ef68768c594a9ce8a86c524b0ea374a50799..94e87d0abec9d00436ce98fc35dcd3e8248e937c 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
+// 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,9 @@ struct CC_EXPORT TreeNode {
int parent_id;
int owner_id;
T data;
+
+ void ToProtobuf(proto::TreeNode* proto) const;
+ void FromProtobuf(const proto::TreeNode& proto);
};
struct CC_EXPORT TransformNodeData {
@@ -150,6 +169,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 +220,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 +238,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;
@@ -250,6 +282,9 @@ class CC_EXPORT PropertyTree {
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_;
@@ -348,6 +383,9 @@ class CC_EXPORT TransformTree final : public PropertyTree<TransformNode> {
bool HasNodesAffectedByInnerViewportBoundsDelta() const;
bool HasNodesAffectedByOuterViewportBoundsDelta() const;
+ 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|.
@@ -400,17 +438,26 @@ class CC_EXPORT ClipTree final : public PropertyTree<ClipNode> {
public:
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:
void UpdateOpacities(int id);
+
+ void ToProtobuf(proto::PropertyTree* proto) const;
+ void FromProtobuf(const proto::PropertyTree& proto);
};
class CC_EXPORT PropertyTrees final {
public:
PropertyTrees();
+ static PropertyTrees CreateFromProtobuf(const proto::PropertyTrees& proto);
David Trainor- moved to gerrit 2015/11/12 22:46:11 do we want to just return a PropertyTrees object h
Khushal 2015/11/13 10:33:13 Yeah, just returning property trees is bad. I adde
+ void ToProtobuf(proto::PropertyTrees* proto) const;
+
TransformTree transform_tree;
EffectTree effect_tree;
ClipTree clip_tree;

Powered by Google App Engine
This is Rietveld 408576698