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

Unified Diff: mc/scheduler/scheduler.h

Issue 731893002: Add a simple scheduler for animation frames (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix math Created 6 years, 1 month 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 | « mc/scheduler/DEPS ('k') | mc/scheduler/scheduler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mc/scheduler/scheduler.h
diff --git a/mc/scheduler/scheduler.h b/mc/scheduler/scheduler.h
new file mode 100644
index 0000000000000000000000000000000000000000..6afc5407cd533e1040cea308db8cdc5632238df9
--- /dev/null
+++ b/mc/scheduler/scheduler.h
@@ -0,0 +1,45 @@
+// Copyright 2014 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 MC_SCHEDULER_SCHEDULER_H_
+#define MC_SCHEDULER_SCHEDULER_H_
+
+#include "base/single_thread_task_runner.h"
+#include "base/time/time.h"
+#include "mc/scheduler/timer.h"
+
+namespace mc {
+
+class Scheduler : public Timer::Client {
+ public:
+ class Client {
+ public:
+ virtual void BeginFrame(base::TimeTicks frame_time,
+ base::TimeTicks deadline) = 0;
+
+ protected:
+ virtual ~Client();
+ };
+
+ Scheduler(Client* client,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner);
+ ~Scheduler();
+
+ void UpdateFrameDuration(base::TimeDelta estimate);
+ void UpdateVSync(const TimeInterval& vsync);
+
+ void SetNeedsFrame();
+
+ private:
+ void UpdateTimerInterval();
+ void OnTimerTick(base::TimeTicks now) override;
+
+ Client* client_;
+ Timer timer_;
+ TimeInterval vsync_;
+ base::TimeDelta frame_duration_;
+};
+}
+
+#endif // MC_SCHEDULER_SCHEDULER_H_
« no previous file with comments | « mc/scheduler/DEPS ('k') | mc/scheduler/scheduler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698