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

Side by Side Diff: mojo/services/gfx/composition/interfaces/scenes.mojom

Issue 1552963002: Initial checkin of the new Mozart compositor. (Closed) Base URL: git@github.com:domokit/mojo.git@moz-11
Patch Set: Created 4 years, 11 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
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 [DartPackage="mojo_services"]
6 module mojo.gfx.composition;
7
8 import "mojo/services/gfx/composition/interfaces/nodes.mojom";
9 import "mojo/services/gfx/composition/interfaces/resources.mojom";
10 import "mojo/services/gfx/composition/interfaces/scene_token.mojom";
11 import "mojo/services/gfx/composition/interfaces/scheduling.mojom";
12
13 // The node id which represents the root of a scene.
14 //
15 // Every scene should have a root node which uses this id unless the scene
16 // has no content at all.
17 const uint32 kSceneRootNodeId = 0;
18
19 // The scene version used as a placeholder when the version doesn't matter.
20 //
21 // This version code can be used by a consumer of a scene to express that
22 // it would like to consume the latest version of the scene.
23 //
24 // This version code can also be used by a scene itself if it has not
25 // received any other specific indications as to the version it should
26 // report when publishing its content.
27 const uint32 kSceneVersionNone = 0;
28
29 // A scene component maintains a description of some graphical content which
30 // an application would like to render. This description consists of
31 // resources and nodes.
32 //
33 // Use |Compositor.RegisterScene()| to register a scene. The application
34 // uses the |Scene| interface to manage the scene's content and implements
35 // the |SceneListener| interface to handle events.
36 //
37 // CONTENT
38 //
39 // Resources are references to foreign objects which are being imported into
40 // the scene graph, such as images and other scenes. Each resource must be
41 // given a locally unique identifier when it is bound to the scene.
42 //
43 // Nodes express the geometry and content of the scene, such as images and
44 // references to embedded scenes. Nodes are arranged to form a directed
45 // acyclic graph of drawing commands.
46 //
47 // The root node of the scene has the special id of |kSceneRootNodeId|.
48 //
49 // ATOMICITY
50 //
51 // To ensure atomicity of updates, the evolution of a scene occurs in two
52 // phases: update and publish. Incremental changes to the scene made during
53 // the update phase are not observed until published.
54 //
55 // - Update phase: To construct the next state of a scene, the scene owner
56 // issues any number of scene update requests to add, update, or remove
57 // resources and nodes.
58 //
59 // - Publish phase: When the next state of a scene is fully constructed, the
60 // scene owner issues a request to publish its changes to the scene and
61 // assigns it a version identifier. The version identifer may be used
62 // in scene references to coordinate updates across multiple scenes which
63 // must be synchronized.
64 //
65 // Once the scene has been published, the scene owner may begin to construct
66 // the next state without disrupting the state just published.
67 //
68 // SYNCHRONIZATION
69 //
70 // To ensure synchronization of updates across scenes, some additional work
71 // is needed.
72 //
73 // For example, consider the case of a scene X which embeds two other scenes
74 // A and B. If X changes size, it may need to resize A and B as well to
75 // fit properly within its layout.
76 //
77 // To do so, X sends the owners of A and B each a message indicating the
78 // new size it desires along with new scene version identifiers V(A) and
79 // V(B) which the owners of A and B must use when they publish the new scene
80 // state which incorporates the requested size change.
81 //
82 // Meanwhile, X produces a new scene of its own taking into account its
83 // new size. As part of constructing this new scene, it binds to the V(A)
84 // and V(B) versions of A and B to express its dependence on A and B
85 // having been updated to the new size.
86 //
87 // Propagating version information top-down through the scene graph in
88 // this manner allows for state changes to be synchronized in a purely
89 // feed-forward manner.
90 //
91 // CONCURRENCY
92 //
93 // In the above synchronization example, version numbers were used to
94 // couple the state of one scene with others that it depends on.
95 // What should happen if these dependencies are not satisfied promptly?
96 //
97 // Suppose X and A quickly produce new scenes with the new size but
98 // B is taking longer than anticipated to do so. We have a few choices:
99 //
100 // - Stall: The compositor could continue to show the old state of X, A, and B
101 // until such time as all three have published their new versions.
102 //
103 // - Recover: The compositor could realize that X and A are already up to date
104 // but B is lagging and choose to apply a transformation to B's old content
105 // cover for the lag, such as by scaling, clipping, masking, or discarding
106 // B's old content.
107 //
108 // - Speculate: The compositor could allow X to provide alternate descriptions
109 // of the scene in the case where A or B are not keeping up so that it
110 // can more finely control the recovery policy.
111 //
112 // To maximize concurrency, we adopt the latter approach.
113 interface Scene {
114 // Sets the listener for receiving events from the scene.
115 //
116 // If |listener| is null, then the previously set listener is removed.
117 SetListener(SceneListener? listener);
118
119 // Applies a batch of incremental updates to the contents of the scene.
120 //
121 // Incremental changes can be split across any number of updates but it is
122 // more efficient to process them in batches. Updates have no visible
123 // effect until the scene owner calls |Publish()| to publish them.
124 //
125 // Updates are buffered and applied when |Publish()| is called. This means
126 // it is safe to issue an update which adds a node that refers to a resource
127 // which is not added until a subsequent update as long as the scene is
128 // not published in between those updates.
129 Update(SceneUpdate update);
130
131 // Publishes the scene and tags it with the specified version.
132 //
133 // All pending incremental updates are applied atomically when the scene
134 // is published and the new state is labeled with the version indicated
135 // in the associated metadata.
136 //
137 // The |metadata| describes how the published scene should be presented.
138 // If null, this method behaves as if a |SceneMetadata| object initialized
139 // with default values had been supplied.
140 //
141 // Publishing a scene graph applies all pending updates. It is an error
142 // to publish updates which cause the scene state to become inconsistent,
143 // such as by having nodes which refer to non-existent resources; the
144 // connection will be closed.
145 Publish(SceneMetadata? metadata);
146
147 // Gets a scheduler for scheduling upcoming scene operations.
148 GetScheduler(SceneScheduler& scheduler);
149 };
150
151 // An interface applications may implement to receive events from a scene.
152 interface SceneListener {
153 // Called when a resource has become unavailable.
154 //
155 // Any nodes which are using the resource will be considered blocked
156 // until the resource is replaced or the nodes using it are removed.
157 OnResourceUnavailable(uint32 resource_id) => ();
158 };
159
160 // A batch of incremental changes to be applied to a scene.
161 struct SceneUpdate {
162 // If true, clears all resources before processing the update.
163 bool clear_resources = false;
164
165 // If true, clears all nodes before processing the update.
166 bool clear_nodes = false;
167
168 // Resources to be added, updated, or removed, indexed by resource id.
169 // The value replaces the definition of the resource with the given id.
170 // If the value is null, then the resource is removed from the scene.
171 map<uint32, Resource?>? resources;
172
173 // Nodes to be added, updated, or removed, indexed by node id.
174 // The value replaces the definition of the node with the given id.
175 // If the value is null, then the node is removed from the scene.
176 //
177 // The root node must have an id of 0.
178 map<uint32, Node?>? nodes;
179 };
180
181 // Describes how a published scene should be presented.
182 struct SceneMetadata {
183 // The scene's new version number.
184 //
185 // Version numbers are usually associated with requests to change the
186 // state of the scene. For example, the embedder of this scene may send
187 // it a request to resize its content or change its color and provide a
188 // new version number that this scene should apply when it publishes the
189 // first update which addresses this request.
190 //
191 // In general, the version number will be provided to the owner of the
192 // scene by some other party which is in change of synchronizing updates
193 // across multiple scenes including this one. The other party will
194 // frequently be the owner of some other scene which embeds this one.
195 //
196 // In certain cases there might not be a version number provided for
197 // synchronization. When this happens, set |version| to |kSceneVersionNone|.
198 //
199 // Note that version numbers are unordered; there is no need to increment
200 // them monotonically. Values may also be reused at will.
201 uint32 version = 0; // kSceneVersionNone
202
203 // A timestamp indicating approximately when the published contents of the
204 // scene are to be shown on the display output assuming everything is
205 // fully rendered and submitted by the appropriate deadline.
206 //
207 // Expressed in microseconds in the |MojoTimeTicks| timebase.
208 //
209 // A value of 0 means "as soon as possible".
210 //
211 // See also: |FrameInfo.presentation_time|.
212 int64 presentation_time = 0;
213 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698