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

Unified Diff: mojo/services/gfx/composition/cpp/frame_tracker.h

Issue 1943153002: Mozart: Move frame lag compensation to new class. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 8 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 | « mojo/services/gfx/composition/cpp/BUILD.gn ('k') | mojo/services/gfx/composition/cpp/frame_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/gfx/composition/cpp/frame_tracker.h
diff --git a/mojo/services/gfx/composition/cpp/frame_tracker.h b/mojo/services/gfx/composition/cpp/frame_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..109346286d021e92b6b32353eed820939009a753
--- /dev/null
+++ b/mojo/services/gfx/composition/cpp/frame_tracker.h
@@ -0,0 +1,57 @@
+// Copyright 2016 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 MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_
+#define MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_
+
+#include "mojo/services/gfx/composition/interfaces/scheduling.mojom.h"
+
+namespace mojo {
+namespace gfx {
+namespace composition {
+
+// Tracks frame scheduling information.
+class FrameTracker {
+ public:
+ FrameTracker();
+ ~FrameTracker();
+
+ // Returns the number of frames that have been tracked.
+ uint64_t frame_count() const { return frame_count_; }
+
+ // Returns the current frame info.
+ // This value is not meaningful when |frame_count()| is zero.
+ const mojo::gfx::composition::FrameInfo& frame_info() const {
+ return frame_info_;
+ }
+
+ // Clears the frame tracker's state such that the next update will be
+ // treated as if it were the first.
+ void Clear();
+
+ // Updates |frame_info()| with new frame scheduling information
+ // from |raw_frame_info| and applies compensation for lag.
+ //
+ // |now| should come from a recent call to |mojo::GetTimeTicksNow()|.
+ //
+ // Whenever an application receives new frame scheduling information from the
+ // system, it should call this function before using it.
+ //
+ // Returns the time delta between the previous frame and the current frame
+ // in microseconds, or 0 if this is the first frame.
+ uint64_t Update(const mojo::gfx::composition::FrameInfo& raw_frame_info,
+ MojoTimeTicks now);
+
+ private:
+ uint64_t frame_count_ = 0u;
+ mojo::gfx::composition::FrameInfo frame_info_;
+
+ MOJO_DISALLOW_COPY_AND_ASSIGN(FrameTracker);
+};
+
+} // namespace composition
+} // namespace gfx
+} // namespace mojo
+
+#endif // MOJO_SERVICES_GFX_COMPOSITION_CPP_SCHEDULING_H_
« no previous file with comments | « mojo/services/gfx/composition/cpp/BUILD.gn ('k') | mojo/services/gfx/composition/cpp/frame_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698