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

Unified 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: fix android build 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/gfx/compositor/backend/output.h ('k') | services/gfx/compositor/backend/scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/gfx/compositor/backend/scheduler.h
diff --git a/services/gfx/compositor/backend/scheduler.h b/services/gfx/compositor/backend/scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce8d3d997e89ed79928374fad036e9fb0588e05e
--- /dev/null
+++ b/services/gfx/compositor/backend/scheduler.h
@@ -0,0 +1,89 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
+#define SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
+
+#include <limits>
+#include <mutex>
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
+
+namespace compositor {
+
+// A frame scheduler is responsible for deciding when to perform each
+// phase of composition.
+//
+// During the "update" phase, the compositor signals each application that
+// that it should start producing the next frame of content.
+//
+// During the "snapshot" phase, the compositor gathers all pending scene
+// graph updates and produces a new frame for rendering. Rendering begins
+// immediately after the snapshot is taken.
+//
+// An instance of the |Scheduler| interface is exposed by each |Output|
+// so as to express the timing requirements of the output.
+class Scheduler {
+ public:
+ // Determines the behavior of |ScheduleFrame()|.
+ enum class SchedulingMode {
+ // Schedules a snapshot, at minimum.
+ kSnapshot,
+
+ // Schedules an update followed by a snapshot, at minimum.
+ kUpdateAndSnapshot,
+ };
+
+ Scheduler() = default;
+ virtual ~Scheduler() = default;
+
+ // Schedules work for a frame.
+ //
+ // This function ensures that every update is followed by a snapshot
+ // unless scheduling is suspended in the meantime.
+ //
+ // When |scheduling_mode| is |kSnapshot|, if there is time between now
+ // and the snapshot during which an update can be performed, then an
+ // update will also be scheduled before the requested snapshot.
+ //
+ // When |scheduling_mode| is |kUpdateAndSnapshot|, if there is time
+ // between now and the update during which a snapshot can be performed,
+ // then a snapshot will also be scheduled before the requested update
+ // and the next snapshot.
+ //
+ // This design is intended to minimize latency by anticipating that
+ // snapshots will be needed after updates and by scheduling updates in
+ // advance if it is known that a snapshot will be needed on the next frame.
+ virtual void ScheduleFrame(SchedulingMode scheduling_mode) = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(Scheduler);
+};
+
+// Scheduling callbacks.
+//
+// These callbacks are provided to the |Output| in order to receive the
+// events produced by the output's associated |Scheduler|.
+struct SchedulerCallbacks {
+ using FrameCallback =
+ base::Callback<void(const mojo::gfx::composition::FrameInfo&)>;
+
+ SchedulerCallbacks(const FrameCallback& update_callback,
+ const FrameCallback& snapshot_callback);
+ ~SchedulerCallbacks();
+
+ // Called when it's time for applications to/ update the contents of
+ // their scenes.
+ const FrameCallback update_callback;
+
+ // Called when it's time for the compositor to snapshot and submit
+ // the next frame.
+ const FrameCallback snapshot_callback;
+};
+
+} // namespace compositor
+
+#endif // SERVICES_GFX_COMPOSITOR_BACKEND_SCHEDULER_H_
« no previous file with comments | « services/gfx/compositor/backend/output.h ('k') | services/gfx/compositor/backend/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698