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

Side by Side Diff: services/gfx/compositor/graph/universe.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/snapshot.cc ('k') | services/gfx/compositor/graph/universe.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 2016 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_UNIVERSE_H_
6 #define SERVICES_GFX_COMPOSITOR_GRAPH_UNIVERSE_H_
7
8 #include <deque>
9 #include <iosfwd>
10
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "services/gfx/compositor/graph/scene_label.h"
14 #include "services/gfx/compositor/graph/snapshot.h"
15
16 namespace compositor {
17
18 class SceneContent;
19 class Snapshot;
20
21 // Manages all active or pending versions of all scenes in the entire universe.
22 //
23 // Currently there is only one instance of the universe (this could change
24 // someday). Its job is to efficiently build snapshots for rendering
25 // subject to the following invariants.
26 //
27 // 1. Scene state evolution always progresses forwards in time. At no time
28 // will an older version of a scene be included in a snapshot once a
29 // newer version becomes unblocked. This is true even when the scene is
30 // being rendered in multiple places.
31 //
32 // 2. A scene dependency which does not specify an explicit version (by
33 // passing |kSceneVersionNone|) will never be blocked as long as the
34 // dependent scene still exists and has published at least one unblocked
35 // version. (Clients should watch for |OnResourceUnavailable| to handle
36 // the case where a dependent scene spontaneously becomes unavailable.)
37 //
38 // 3. A scene dependency which specifies an explicit version may become
39 // blocked or unblocked as the dependent scene publishes newer unblocked
40 // scene versions.
41 //
42 // 4. Scene dependency cycles are resolved by considering all scenes within
43 // the cycle to be blocked. This guarantees consistent behavior regardless
44 // of how the cycle is entered.
45 //
46 // TODO(jeffbrown): In principle this object could keep track of scene
47 // invalidations and incremental updates.
48 class Universe {
49 public:
50 Universe();
51 ~Universe();
52
53 void AddScene(const SceneLabel& scene_label);
54 void PresentScene(const scoped_refptr<const SceneContent>& content);
55 void RemoveScene(const mojo::gfx::composition::SceneToken& scene_token);
56
57 scoped_refptr<const Snapshot> SnapshotScene(
58 const mojo::gfx::composition::SceneToken& scene_token,
59 uint32_t version,
60 std::ostream* block_log);
61
62 private:
63 struct SceneInfo {
64 SceneInfo(const SceneLabel& label);
65 ~SceneInfo();
66
67 SceneLabel label;
68
69 // Set to the current generation when the queue was last updated.
70 // TODO(jeffbrown): We should perform more fine-grained invalidation of
71 // scenes based on their dependencies.
72 uint64_t update_generation = 0u;
73 Snapshot::Disposition disposition = Snapshot::Disposition::kBlocked;
74 std::deque<scoped_refptr<const SceneContent>> content_queue;
75 };
76
77 class Snapshotter : public SnapshotBuilder {
78 public:
79 Snapshotter(Universe* universe, std::ostream* block_log);
80 ~Snapshotter() override;
81
82 protected:
83 Snapshot::Disposition ResolveAndSnapshotScene(
84 const mojo::gfx::composition::SceneToken& scene_token,
85 uint32_t version,
86 scoped_refptr<const SceneContent>* out_content) override;
87
88 private:
89 Universe* universe_;
90 SceneInfo* cycle_ = nullptr;
91
92 DISALLOW_COPY_AND_ASSIGN(Snapshotter);
93 };
94
95 std::unordered_map<uint32_t, std::unique_ptr<SceneInfo>> scenes_;
96 uint64_t generation_ = 0u;
97
98 DISALLOW_COPY_AND_ASSIGN(Universe);
99 };
100
101 } // namespace compositor
102
103 #endif // SERVICES_GFX_COMPOSITOR_GRAPH_UNIVERSE_H_
OLDNEW
« no previous file with comments | « services/gfx/compositor/graph/snapshot.cc ('k') | services/gfx/compositor/graph/universe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698