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

Side by Side Diff: services/gfx/compositor/backend/scheduler.h

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 #ifndef SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
6 #define SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
7
8 #include <limits>
9 #include <mutex>
10
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
14
15 namespace compositor {
16
17 // Determines the behavior of |ScheduleFrame()|.
18 enum class SchedulingMode {
viettrungluu 2016/01/04 21:08:24 Maybe this should be declared inside Scheduler? (D
jeffbrown 2016/01/16 03:28:31 I went back and forth on this. I'll move it back
19 // Schedules a snapshot, at minimum.
20 kSnapshot,
viettrungluu 2016/01/04 21:08:24 FYI: Typically, we've followed Chromium style, whi
jeffbrown 2016/01/16 03:28:31 Apparently the preferred style is now "kFoo" like
21
22 // Schedules an update followed by a snapshot, at minimum.
23 kUpdateAndSnapshot,
24 };
25
26 // Interface implemented by schedulers.
viettrungluu 2016/01/04 21:08:24 This comment is almost useless. :) It may be helpf
jeffbrown 2016/01/16 03:28:31 Done.
27 class Scheduler {
28 public:
29 Scheduler() = default;
30 virtual ~Scheduler() = default;
31
32 // Schedules work for a frame.
33 //
34 // This function ensures that every update is followed by a snapshot
35 // unless scheduling is suspended in the meantime.
36 //
37 // When |scheduling_mode| is |kSnapshot|, if there is time between now
38 // and the snapshot during which an update can be performed, then an
39 // update will also be scheduled before the requested snapshot.
40 //
41 // When |scheduling_mode| is |kUpdateAndSnapshot|, if there is time
42 // between now and the update during which a snapshot can be performed,
43 // then a snapshot will also be scheduled before the requested update
44 // and the next snapshot.
45 //
46 // This design is intended to minimize latency by anticipating that
47 // snapshots will be needed after updates and by scheduling updates in
48 // advance if it is known that a snapshot will be needed on the next frame.
49 virtual void ScheduleFrame(SchedulingMode scheduling_mode) = 0;
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(Scheduler);
53 };
54
55 // Scheduling callbacks.
56 struct SchedulerCallbacks {
viettrungluu 2016/01/04 21:08:23 When/where is this used? (It's a bit odd that it's
jeffbrown 2016/01/16 03:28:31 Added docs to make this clearer.
57 using FrameCallback =
58 base::Callback<void(const mojo::gfx::composition::FrameInfo&)>;
59
60 SchedulerCallbacks(const FrameCallback& update_callback,
61 const FrameCallback& snapshot_callback);
62 ~SchedulerCallbacks();
63
64 // Called when it's time for applications to/ update the contents of
65 // their scenes.
66 const FrameCallback update_callback;
67
68 // Called when it's time for the compositor to snapshot and submit
69 // the next frame.
70 const FrameCallback snapshot_callback;
71 };
72
73 } // namespace compositor
74
75 #endif // SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698