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

Side by Side Diff: services/gfx/compositor/graph/snapshot.h

Issue 1873573003: Mozart: Ensure time always runs forward. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-3
Patch Set: fix build error on Android Created 4 years, 8 months 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
« no previous file with comments | « services/gfx/compositor/graph/scene_label.cc ('k') | services/gfx/compositor/graph/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_ 5 #ifndef SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
6 #define SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_ 6 #define SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <unordered_map> 9 #include <unordered_map>
10 #include <unordered_set> 10 #include <unordered_set>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "mojo/services/geometry/interfaces/geometry.mojom.h" 14 #include "mojo/services/geometry/interfaces/geometry.mojom.h"
15 #include "mojo/services/gfx/composition/interfaces/hit_tests.mojom.h" 15 #include "mojo/services/gfx/composition/interfaces/hit_tests.mojom.h"
16 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h" 16 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
17 17
18 namespace compositor { 18 namespace compositor {
19 19
20 class Node; 20 class Node;
21 class SceneDef;
22 class SceneContent; 21 class SceneContent;
23 class SceneNode; 22 class SceneNode;
24 class RenderFrame; 23 class RenderFrame;
25 24
26 // Describes a single frame snapshot of the scene graph, sufficient for 25 // Describes a single frame snapshot of the scene graph, sufficient for
27 // rendering and hit testing. When the snapshot is made, all predicated and 26 // rendering and hit testing. When the snapshot is made, all predicated and
28 // blocked scene nodes are evaluated to produce a final description of 27 // blocked scene nodes are evaluated to produce a final description of
29 // the content of the frame along with its dependencies. 28 // the content of the frame along with its dependencies.
30 // 29 //
31 // The snapshot holds a list of dependencies for the scenes whose state was 30 // The snapshot holds a list of dependencies for the scenes whose state was
(...skipping 22 matching lines...) Expand all
54 // Returns true if the snapshot is blocked from rendering. 53 // Returns true if the snapshot is blocked from rendering.
55 bool is_blocked() const { return disposition_ == Disposition::kBlocked; } 54 bool is_blocked() const { return disposition_ == Disposition::kBlocked; }
56 55
57 // Gets the root scene content for the snapshot, or null if blocked. 56 // Gets the root scene content for the snapshot, or null if blocked.
58 const SceneContent* root_scene_content() const { 57 const SceneContent* root_scene_content() const {
59 return root_scene_content_.get(); 58 return root_scene_content_.get();
60 } 59 }
61 60
62 // Returns true if the snapshot has a dependency on content from the 61 // Returns true if the snapshot has a dependency on content from the
63 // specified scene. 62 // specified scene.
64 bool HasDependency(const SceneDef* scene) const; 63 bool HasDependency(
64 const mojo::gfx::composition::SceneToken& scene_token) const;
65 65
66 // Creates a frame for rendering. 66 // Creates a frame for rendering.
67 // Only valid if |!is_blocked()|. 67 // Only valid if |!is_blocked()|.
68 scoped_refptr<RenderFrame> CreateFrame( 68 scoped_refptr<RenderFrame> CreateFrame(
69 const mojo::Rect& viewport, 69 const mojo::Rect& viewport,
70 const mojo::gfx::composition::FrameInfo& frame_info) const; 70 const mojo::gfx::composition::FrameInfo& frame_info) const;
71 71
72 // Performs a hit test at the specified point, populating the result. 72 // Performs a hit test at the specified point, populating the result.
73 // Only valid if |!is_blocked()|. 73 // Only valid if |!is_blocked()|.
74 void HitTest(const mojo::PointF& point, 74 void HitTest(const mojo::PointF& point,
(...skipping 18 matching lines...) Expand all
93 // Disposition of the snapshot as a whole. 93 // Disposition of the snapshot as a whole.
94 Disposition disposition_; 94 Disposition disposition_;
95 95
96 // Just the set of dependent scene tokens. Used for invalidation. 96 // Just the set of dependent scene tokens. Used for invalidation.
97 std::unordered_set<uint32_t> dependencies_; 97 std::unordered_set<uint32_t> dependencies_;
98 98
99 // The root scene in the graph. 99 // The root scene in the graph.
100 // This reference together with |resolved_scenes| retains all of the 100 // This reference together with |resolved_scenes| retains all of the
101 // nodes used by the snapshot so that we can use bare pointers for nodes 101 // nodes used by the snapshot so that we can use bare pointers for nodes
102 // and avoid excess reference counting overhead in other data structures. 102 // and avoid excess reference counting overhead in other data structures.
103 // Empty when the snapshot is blocked.
103 scoped_refptr<const SceneContent> root_scene_content_; 104 scoped_refptr<const SceneContent> root_scene_content_;
104 105
105 // Map of scenes which were resolved from scene nodes. 106 // Map of scenes which were resolved from scene nodes.
107 // Empty when the snapshot is blocked.
106 std::unordered_map<const SceneNode*, scoped_refptr<const SceneContent>> 108 std::unordered_map<const SceneNode*, scoped_refptr<const SceneContent>>
107 resolved_scene_contents_; 109 resolved_scene_contents_;
108 110
109 // Node states, true if snapshotted successfully, false if blocked. 111 // Node dispositions. We only ever observe |kSuccess| or |kBlocked| here.
112 // Empty when the snapshot is blocked.
110 std::unordered_map<const Node*, Disposition> node_dispositions_; 113 std::unordered_map<const Node*, Disposition> node_dispositions_;
111 114
112 DISALLOW_COPY_AND_ASSIGN(Snapshot); 115 DISALLOW_COPY_AND_ASSIGN(Snapshot);
113 }; 116 };
114 117
115 // Builds a table of all of the state which will be required for rendering 118 // Builds a table of all of the state which will be required for rendering
116 // a scene graph. 119 // a scene graph.
117 class SnapshotBuilder { 120 class SnapshotBuilder {
118 public: 121 public:
119 explicit SnapshotBuilder(std::ostream* block_log); 122 explicit SnapshotBuilder(std::ostream* block_log);
120 ~SnapshotBuilder(); 123 virtual ~SnapshotBuilder();
121 124
122 // If not null, the snapshotter will append information to this stream 125 // If not null, the snapshotter will append information to this stream
123 // describing the parts of the scene graph for which composition was blocked. 126 // describing the parts of the scene graph for which composition was blocked.
124 std::ostream* block_log() { return block_log_; } 127 std::ostream* block_log() { return block_log_; }
125 128
126 // Snapshots the requested node. 129 // Snapshots the requested node.
127 Snapshot::Disposition SnapshotNode(const Node* node, 130 Snapshot::Disposition SnapshotNode(const Node* node,
128 const SceneContent* content); 131 const SceneContent* content);
129 132
130 // Snapshots the requested scene. 133 // Snapshots the referenced scene.
131 Snapshot::Disposition SnapshotScene(const SceneDef* scene, 134 Snapshot::Disposition SnapshotReferencedScene(
132 uint32_t version, 135 const SceneNode* referrer_node,
133 const SceneNode* referrer_node, 136 const SceneContent* referrer_content);
134 const SceneContent* referrer_content);
135 137
136 // Builds a snapshot rooted at the specified scene. 138 // Builds a snapshot rooted at the specified scene.
137 scoped_refptr<const Snapshot> Build(const SceneDef* root_scene); 139 scoped_refptr<const Snapshot> Build(
140 const mojo::gfx::composition::SceneToken& scene_token,
141 uint32_t version);
142
143 protected:
144 // Resolves and snapshots a particular version of a scene.
145 virtual Snapshot::Disposition ResolveAndSnapshotScene(
146 const mojo::gfx::composition::SceneToken& scene_token,
147 uint32_t version,
148 scoped_refptr<const SceneContent>* out_content) = 0;
149
150 // Snapshots a scene.
151 Snapshot::Disposition SnapshotSceneContent(const SceneContent* content);
138 152
139 private: 153 private:
140 // Snapshots the root scene of a renderer. 154 Snapshot::Disposition AddDependencyResolveAndSnapshotScene(
141 // This is just like |SnapshotScene| but the errors are reported a little 155 const mojo::gfx::composition::SceneToken& scene_token,
142 // differently since there is no referrer node. 156 uint32_t version,
143 Snapshot::Disposition SnapshotRenderer(const SceneDef* scene); 157 scoped_refptr<const SceneContent>* out_content);
144 158
145 // Snapshots the root node of a scene and detects cycles. 159 scoped_refptr<Snapshot> snapshot_;
146 // This is just like |SnapshotNode| but performs cycle detection which
147 // isn't otherwise needed.
148 Snapshot::Disposition SnapshotRootAndDetectCycles(
149 const Node* node,
150 const SceneContent* content);
151
152 std::ostream* const block_log_; 160 std::ostream* const block_log_;
153 scoped_refptr<Snapshot> snapshot_;
154 const SceneContent* cycle_ = nullptr; // point where a cycle was detected
155 161
156 DISALLOW_COPY_AND_ASSIGN(SnapshotBuilder); 162 DISALLOW_COPY_AND_ASSIGN(SnapshotBuilder);
157 }; 163 };
158 164
159 } // namespace compositor 165 } // namespace compositor
160 166
161 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_ 167 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « services/gfx/compositor/graph/scene_label.cc ('k') | services/gfx/compositor/graph/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698