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

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

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: fix android build Created 4 years, 10 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_def.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
6 #define SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
7
8 #include <iosfwd>
9 #include <memory>
10 #include <unordered_set>
11
12 #include "base/macros.h"
13 #include "mojo/services/geometry/interfaces/geometry.mojom.h"
14 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
15
16 namespace compositor {
17
18 class SceneDef;
19 class RenderFrame;
20
21 // Describes a single frame snapshot of the scene graph, sufficient for
22 // rendering and hit testing. When the snapshot is made, all predicated and
23 // blocked scene nodes are evaluated to produce a final description of
24 // the frame along with its dependencies.
25 //
26 // The snapshot holds a list of dependencies for the scenes whose state was
27 // originally used to produce it. The snapshot must be invalidated whenever
28 // any of these scenes change. Note that the snapshot will contain a list
29 // of dependencies even in the case where a frame could not be produced,
30 // in which case the dependencies express the set of scenes which, if updated,
31 // might allow composition to be unblocked and make progress on a subsequent
32 // frame.
33 //
34 // Snapshot objects are not thread-safe since they have direct references to
35 // the scene graph definition. However, the snapshot's frame is thread-safe
36 // and is intended to be shared by other components.
37 class Snapshot {
38 public:
39 ~Snapshot();
40
41 // Returns true if the snapshot is valid.
42 bool valid() const { return valid_; }
43
44 // Gets the frame produced from this snapshot, or null if none.
45 //
46 // This is always null if |valid()| is false but it may be null even
47 // when |valid()| is true if composition was blocked and unable to produce
48 // a frame during the snapshot operation.
49 const std::shared_ptr<RenderFrame>& frame() const { return frame_; }
50
51 // Unconditionally marks the snapshot as invalid.
52 //
53 // Returns true if the snapshot became invalid as a result of this operation,
54 // or false if it was already invalid.
55 bool Invalidate();
56
57 // Invalidates the snapshot if it has a dependency on the specified scene.
58 // When this occurs, the entire list of dependencies is flushed (we no longer
59 // need them) in case the scene in question or its contents are about to
60 // be destroyed.
61 //
62 // Returns true if the snapshot became invalid as a result of this operation,
63 // or false if it was already invalid.
64 bool InvalidateScene(SceneDef* scene_def);
65
66 private:
67 friend class SnapshotBuilder;
68
69 Snapshot();
70
71 std::unordered_set<SceneDef*> dependencies_;
72 std::shared_ptr<RenderFrame> frame_;
73 bool valid_ = true;
74
75 DISALLOW_COPY_AND_ASSIGN(Snapshot);
76 };
77
78 // Builder for snapshots.
79 class SnapshotBuilder {
80 public:
81 // Creates a snapshot builder.
82 //
83 // |block_log|, if not null, the snapshotter will append information to
84 // this stream describing the parts of the scene graph for which
85 // composition was blocked.
86 explicit SnapshotBuilder(std::ostream* block_log);
87 ~SnapshotBuilder();
88
89 // If not null, the snapshotter will append information to this stream
90 // describing the parts of the scene graph for which composition was blocked.
91 std::ostream* block_log() { return block_log_; }
92
93 // Adds a scene dependency to the snapshot.
94 void AddSceneDependency(SceneDef* scene);
95
96 // Builds a snapshot rooted at the specified scene.
97 std::unique_ptr<Snapshot> Build(
98 SceneDef* root_scene,
99 const mojo::Rect& viewport,
100 const mojo::gfx::composition::FrameInfo& frame_info);
101
102 private:
103 std::ostream* const block_log_;
104 std::unique_ptr<Snapshot> snapshot_;
105
106 DISALLOW_COPY_AND_ASSIGN(SnapshotBuilder);
107 };
108
109 } // namespace compositor
110
111 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_SNAPSHOT_H_
OLDNEW
« no previous file with comments | « services/gfx/compositor/graph/scene_def.cc ('k') | services/gfx/compositor/graph/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698