Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
flutter::VsyncWaiterIOS Class Referencefinal

#include <vsync_waiter_ios.h>

Inheritance diagram for flutter::VsyncWaiterIOS:
flutter::VsyncWaiter flutter::VariableRefreshRateReporter

Public Member Functions

 VsyncWaiterIOS (const flutter::TaskRunners &task_runners)
 
 ~VsyncWaiterIOS () override
 
double GetRefreshRate () const override
 
- Public Member Functions inherited from flutter::VsyncWaiter
virtual ~VsyncWaiter ()
 
void AsyncWaitForVsync (const Callback &callback)
 
void ScheduleSecondaryCallback (uintptr_t id, const fml::closure &callback)
 
- Public Member Functions inherited from flutter::VariableRefreshRateReporter
 VariableRefreshRateReporter ()=default
 
 FML_DISALLOW_COPY_AND_ASSIGN (VariableRefreshRateReporter)
 

Static Public Member Functions

static CFTimeInterval SnapDuration (CFTimeInterval duration, double max_refresh_rate)
 

Additional Inherited Members

- Public Types inherited from flutter::VsyncWaiter
using Callback = std::function< void(std::unique_ptr< FrameTimingsRecorder >)>
 
- Protected Member Functions inherited from flutter::VsyncWaiter
 VsyncWaiter (const TaskRunners &task_runners)
 
virtual void AwaitVSyncForSecondaryCallback ()
 
void FireCallback (fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
 
- Protected Attributes inherited from flutter::VsyncWaiter
const TaskRunners task_runners_
 

Detailed Description

Definition at line 15 of file vsync_waiter_ios.h.

Constructor & Destructor Documentation

◆ VsyncWaiterIOS()

flutter::VsyncWaiterIOS::VsyncWaiterIOS ( const flutter::TaskRunners task_runners)
explicit

Definition at line 18 of file vsync_waiter_ios.mm.

19 : VsyncWaiter(task_runners) {
20 auto vsyncCallback = ^(CFTimeInterval startTime, CFTimeInterval targetTime) {
21 // Compute delay using the same CACurrentMediaTime() clock.
22 CFTimeInterval delay = CACurrentMediaTime() - startTime;
23 if (delay < 0.0) {
24 delay = 0.0;
25 }
26
27 // Align the start time to the C++ steady_clock used by fml::TimePoint.
29
30 // Snap to the nearest whole Hz value to avoid floating point errors.
31 CFTimeInterval duration =
32 VsyncWaiterIOS::SnapDuration(targetTime - startTime, max_refresh_rate_);
33
34 // Align target time to the C++ steady_clock used by fml::TimePoint.
35 fml::TimePoint target_time = start_time + fml::TimeDelta::FromSecondsF(duration);
36 FireCallback(start_time, target_time, true);
37 };
38 FlutterFMLTaskRunner* uiTaskRunner =
39 [[FlutterFMLTaskRunner alloc] initWithTaskRunner:task_runners_.GetUITaskRunner()];
40 client_ = [[FlutterVSyncClient alloc]
41 initWithTaskRunner:uiTaskRunner
44 callback:vsyncCallback];
46}
fml::RefPtr< fml::TaskRunner > GetUITaskRunner() const
VsyncWaiter(const TaskRunners &task_runners)
void FireCallback(fml::TimePoint frame_start_time, fml::TimePoint frame_target_time, bool pause_secondary_tasks=true)
const TaskRunners task_runners_
static CFTimeInterval SnapDuration(CFTimeInterval duration, double max_refresh_rate)
static constexpr TimeDelta FromSecondsF(double seconds)
Definition time_delta.h:53
static TimePoint Now()
Definition time_point.cc:49
FlutterDesktopBinaryReply callback
A client that wraps a CADisplayLink to deliver synchronized vsync signals.

References callback, FlutterDisplayLinkManager::displayRefreshRate, flutter::VsyncWaiter::FireCallback(), fml::TimeDelta::FromSecondsF(), flutter::TaskRunners::GetUITaskRunner(), FlutterDisplayLinkManager::maxRefreshRateEnabledOnIPhone, fml::TimePoint::Now(), SnapDuration(), and flutter::VsyncWaiter::task_runners_.

◆ ~VsyncWaiterIOS()

flutter::VsyncWaiterIOS::~VsyncWaiterIOS ( )
override

Definition at line 48 of file vsync_waiter_ios.mm.

48 {
49 // This way, we will get no more callbacks from the display link that holds a weak (non-nilling)
50 // reference to this C++ object.
51 [client_ invalidate];
52}

Member Function Documentation

◆ GetRefreshRate()

double flutter::VsyncWaiterIOS::GetRefreshRate ( ) const
overridevirtual

Implements flutter::VariableRefreshRateReporter.

Definition at line 64 of file vsync_waiter_ios.mm.

64 {
65 return client_.refreshRate;
66}
double refreshRate
The current display refresh rate in Hertz, rounded to the nearest integer value.

References FlutterVSyncClient::refreshRate.

◆ SnapDuration()

CFTimeInterval flutter::VsyncWaiterIOS::SnapDuration ( CFTimeInterval  duration,
double  max_refresh_rate 
)
static

Definition at line 68 of file vsync_waiter_ios.mm.

68 {
69 if (duration > 0.0) {
70 double roundedRefreshRate = round(1.0 / duration);
71 return 1.0 / roundedRefreshRate;
72 }
73 double fallbackRefreshRate = max_refresh_rate > 0.0 ? max_refresh_rate : 60.0;
74 return 1.0 / fallbackRefreshRate;
75}

Referenced by VsyncWaiterIOS().


The documentation for this class was generated from the following files: