OLD | NEW |
(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 // Provides support for scheduling drawing and composition operations |
| 9 // for a particular scene. |
| 10 // |
| 11 // Instances of this interface must be obtained from a |Scene|. This interface |
| 12 // is modeled separately so as to allow applications to use different threads |
| 13 // for scheduling work as opposed to publishing scene updates. |
| 14 interface SceneScheduler { |
| 15 // Asks the compositor to invoke the callback when it is a good time to |
| 16 // draw the next frame. |
| 17 // |
| 18 // The rate at which the callback is invoked may depend on how the scene |
| 19 // has been embedded. The scene will only receive frame callbacks while |
| 20 // it is attached to a scene graph which the compositor has been asked |
| 21 // to renderer since timing information ultimately derives from the |
| 22 // renderer. If the same scene is being rendered to multiple destinations |
| 23 // with different timing requirements, the compositor will perform rate |
| 24 // adaptation as required behind the scenes. |
| 25 // |
| 26 // The returned |frame_info| provides information about the frame to |
| 27 // be drawn. |
| 28 // |
| 29 // TODO(jeffbrown): Consider whether we should have the callback be invoked |
| 30 // immediately rather than on schedule, letting the client set its own |
| 31 // timers. Advantage may be a reduction in latency due to the elimination |
| 32 // of an IPC on a timing critical path. Disadvantage may be an increase |
| 33 // in the number of context switches and some extra client side bookkeeping. |
| 34 // Note that although clients could predict future frame times based on the |
| 35 // reported information, it's still better for them to schedule each frame |
| 36 // individually so they stay in sync with one another and quickly catch |
| 37 // up to any changes in timing. This also gives the compositor more |
| 38 // opportunity to plan for the upcoming frame, perhaps even boost clocks |
| 39 // in anticipation. |
| 40 ScheduleFrame() => (FrameInfo frame_info); |
| 41 }; |
| 42 |
| 43 // Provides timestamp information about a frame which has been scheduled |
| 44 // to be drawn. |
| 45 struct FrameInfo { |
| 46 // A timestamp indicating when the work of updating the frame was scheduled |
| 47 // to begin which may be used to coordinate animations that require a |
| 48 // monotonic timing reference for synchronization, even across scenes. |
| 49 // |
| 50 // This value monotonically increases with each frame, never repeats, and |
| 51 // is guaranteed to represent a time in the past. It will always be less |
| 52 // than or equal to the value returned by |MojoGetTimeTicksNow()| when the |
| 53 // frame info is received as part of a |ScheduleFrame()| callback. |
| 54 // |
| 55 // Expressed in microseconds in the |MojoTimeTicks| timebase. |
| 56 // TODO(jeffbrown): Time ticks may need finer resolution guarantees. |
| 57 int64 frame_time; |
| 58 |
| 59 // The anticipated time interval between the currently scheduled frame |
| 60 // and the next one. |
| 61 // |
| 62 // The interval is approximate and may change at any time. There is no |
| 63 // guarantee that the next frame will occur precisely on the specified |
| 64 // interval. |
| 65 // |
| 66 // Expressed in microseconds. |
| 67 uint64 frame_interval; |
| 68 |
| 69 // A timestamp indicating when scene updates must be published and ready |
| 70 // to be composited in order for the changes to be reflected in this frame. |
| 71 // |
| 72 // This value is guaranteed to be no less than |frame_time| but it is |
| 73 // not necessarily monotonic; it may briefly go backwards if the frame |
| 74 // interval or pipeline depth changes between frames. |
| 75 // |
| 76 // Expressed in microseconds in the |MojoTimeTicks| timebase. |
| 77 int64 frame_deadline; |
| 78 |
| 79 // A timestamp indicating approximately when the contents of the frame |
| 80 // will be shown on the display output assuming everything is fully rendered |
| 81 // and submitted by the indicated |frame_deadline|. |
| 82 // |
| 83 // This value is guaranteed to be no less than |frame_deadline| but it is |
| 84 // not necessarily monotonic; it may briefly go backwards if the frame |
| 85 // interval or pipeline depth changes between frames. |
| 86 // |
| 87 // Expressed in microseconds in the |MojoTimeTicks| timebase. |
| 88 int64 presentation_time; |
| 89 }; |
OLD | NEW |