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

Unified 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 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
new file mode 100644
index 0000000000000000000000000000000000000000..cc502a8ba1ceab0bd409771c98cd527cce23de0c
--- /dev/null
+++ b/cc/trees/property_tree.h
@@ -0,0 +1,107 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CC_TREES_PROPERTY_TREE_H_
+#define CC_TREES_PROPERTY_TREE_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "cc/base/cc_export.h"
+#include "ui/gfx/rect.h"
+#include "ui/gfx/transform.h"
+
+namespace cc {
+
+template <typename T>
+struct CC_EXPORT TreeNode {
+ TreeNode() : id(-1), parent_id(-1), data() {}
+ int id;
+ int parent_id;
+ T data;
+};
+
+struct CC_EXPORT TransformNodeData {
+ TransformNodeData();
+ ~TransformNodeData();
+
+ gfx::Transform to_parent;
+ gfx::Transform from_parent;
+
+ gfx::Transform to_screen;
+ gfx::Transform from_screen;
+
+ int target_id;
+
+ bool is_invertible;
+ bool ancestors_are_invertible;
+ bool flattens;
+
+ void set_to_parent(const gfx::Transform& transform) {
+ to_parent = transform;
+ is_invertible = to_parent.GetInverse(&from_parent);
+ }
+};
+
+typedef TreeNode<TransformNodeData> TransformNode;
+
+struct CC_EXPORT ClipNodeData {
+ ClipNodeData();
+
+ gfx::RectF clip;
+ gfx::RectF combined_clip;
+ int transform_id;
+ int target_id;
+};
+
+typedef TreeNode<ClipNodeData> ClipNode;
+
+template <typename T>
+class CC_EXPORT PropertyTree {
+ public:
+ PropertyTree();
+ // 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.
+ ~PropertyTree();
+
+ int Insert(const T& tree_node, int parent_id);
+
+ T* Node(int i) { return i > -1 ? &nodes_[i] : nullptr; }
+ const T* Node(int i) const { return i > -1 ? &nodes_[i] : nullptr; }
+
+ T* parent(const T* t) {
+ return t->parent_id > -1 ? Node(t->parent_id) : nullptr;
+ }
+ const T* parent(const T* t) const {
+ return t->parent_id > -1 ? Node(t->parent_id) : nullptr;
+ }
+
+ T* back() { return size() ? &nodes_[nodes_.size() - 1] : nullptr; }
+ const T* back() const {
+ return size() ? &nodes_[nodes_.size() - 1] : nullptr;
+ }
+
+ void clear() { nodes_.clear(); }
+ size_t size() const { return nodes_.size(); }
+
+ private:
+ // Copy and assign are permitted. This is how we'll do tree sync.
+ std::vector<T> nodes_;
+};
+
+typedef PropertyTree<TransformNode> TransformTree;
+typedef PropertyTree<ClipNode> ClipTree;
+
+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.
+ int source_id,
+ int dest_id,
+ gfx::Transform* transform);
+
+bool CC_EXPORT
+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.
+
+void CC_EXPORT UpdateScreenSpaceTransform(TransformTree* tree, int id);
+
+} // namespace cc
+
+#endif // CC_TREES_PROPERTY_TREE_H_

Powered by Google App Engine
This is Rietveld 408576698