Flutter Engine
vsync_recorder.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_RECORDER_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_RECORDER_H_
7 
8 #include <optional>
9 
10 #include "flutter/fml/time/time_delta.h"
11 #include "flutter/fml/time/time_point.h"
12 #include "lib/ui/scenic/cpp/session.h"
13 
14 namespace flutter_runner {
15 
16 struct VsyncInfo {
19 };
20 
22  public:
23  static VsyncRecorder& GetInstance();
24 
25  // Retrieve the most recent |PresentationInfo| provided to us by scenic.
26  // This function is safe to call from any thread.
27  VsyncInfo GetCurrentVsyncInfo() const;
28 
29  // Update the next Vsync info to |next_presentation_info_|. This is expected
30  // to be called in |scenic::Session::Present2| immedaite callbacks with the
31  // presentation info provided by Scenic. Only the next vsync
32  // information will be saved (in order to handle edge cases involving
33  // multiple Scenic sessions in the same process). This function is safe to
34  // call from any thread.
35  void UpdateNextPresentationInfo(
36  fuchsia::scenic::scheduling::FuturePresentationTimes info);
37 
38  void UpdateFramePresentedInfo(zx::time presentation_time);
39 
40  fml::TimePoint GetLastPresentationTime() const;
41 
42  private:
43  VsyncRecorder() { next_presentation_info_.set_presentation_time(0); }
44 
45  fuchsia::scenic::scheduling::PresentationInfo next_presentation_info_;
46  fml::TimePoint last_presentation_time_ = fml::TimePoint::Now();
47 
48  // Disallow copy and assignment.
49  VsyncRecorder(const VsyncRecorder&) = delete;
50  VsyncRecorder& operator=(const VsyncRecorder&) = delete;
51 };
52 
53 } // namespace flutter_runner
54 
55 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_VSYNC_RECORDER_H_
fml::TimeDelta presentation_interval
fml::TimePoint presentation_time
static TimePoint Now()
Definition: time_point.cc:26