Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
VSyncClient Class Reference

#include <vsync_waiter_ios.h>

Inheritance diagram for VSyncClient:

Instance Methods

(instancetype) - initWithTaskRunner:callback:
 
(void) - await
 
(void) - pause
 
(void) - invalidate
 Call invalidate before releasing this object to remove from runloops.
 
(void) - setMaxRefreshRate:
 
(void) - onDisplayLink: [implementation]
 
(CADisplayLink *) - getDisplayLink [implementation]
 

Properties

BOOL allowPauseAfterVsync
 Default value is YES. Vsync client will pause vsync callback after receiving a vsync signal. Setting this property to NO can avoid this and vsync client will trigger vsync callback continuously.
 
double refreshRate [implementation]
 

Detailed Description

Definition at line 36 of file vsync_waiter_ios.h.

Method Documentation

◆ await

- (void) await

Definition at line 63 of file vsync_waiter_ios.mm.

103 {
104 _displayLink.paused = NO;
105}
CADisplayLink * _displayLink

◆ getDisplayLink

- (CADisplayLink *) getDisplayLink
implementation

Provided by category VSyncClient(Testing).

Definition at line 63 of file vsync_waiter_ios.mm.

139 {
140 return _displayLink;
141}

◆ initWithTaskRunner:callback:

- (instancetype) initWithTaskRunner: (fml::RefPtr<fml::TaskRunner>)  task_runner
callback: (flutter::VsyncWaiter::Callback callback 

Definition at line 63 of file vsync_waiter_ios.mm.

67 callback:(flutter::VsyncWaiter::Callback)callback {
68 self = [super init];
69
70 if (self) {
72 _allowPauseAfterVsync = YES;
73 _callback = std::move(callback);
74 _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onDisplayLink:)];
75 _displayLink.paused = YES;
76
77 [self setMaxRefreshRate:DisplayLinkManager.displayRefreshRate];
78
79 // Strongly retain the the captured link until it is added to the runloop.
80 CADisplayLink* localDisplayLink = _displayLink;
81 task_runner->PostTask([localDisplayLink]() {
82 [localDisplayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSRunLoopCommonModes];
83 });
84 }
85
86 return self;
87}
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
double displayRefreshRate
The display refresh rate used for reporting purposes. The engine does not care about this for frame s...
std::function< void(MTLRenderPipelineDescriptor *)> Callback
init(device_serial, adb_binary)
Definition _adb_path.py:12

◆ invalidate

- (void) invalidate

Call invalidate before releasing this object to remove from runloops.

Definition at line 63 of file vsync_waiter_ios.mm.

134 {
135 [_displayLink invalidate];
136 _displayLink = nil; // Break retain cycle.
137}

◆ onDisplayLink:

- (void) onDisplayLink: (CADisplayLink*)  link
implementation

Provided by category VSyncClient(Testing).

Definition at line 63 of file vsync_waiter_ios.mm.

111 :(CADisplayLink*)link {
112 CFTimeInterval delay = CACurrentMediaTime() - link.timestamp;
113 fml::TimePoint frame_start_time = fml::TimePoint::Now() - fml::TimeDelta::FromSecondsF(delay);
114
115 CFTimeInterval duration = link.targetTimestamp - link.timestamp;
116 fml::TimePoint frame_target_time = frame_start_time + fml::TimeDelta::FromSecondsF(duration);
117
118 TRACE_EVENT2_INT("flutter", "PlatformVsync", "frame_start_time",
119 frame_start_time.ToEpochDelta().ToMicroseconds(), "frame_target_time",
120 frame_target_time.ToEpochDelta().ToMicroseconds());
121
122 std::unique_ptr<flutter::FrameTimingsRecorder> recorder =
123 std::make_unique<flutter::FrameTimingsRecorder>();
124
125 _refreshRate = round(1 / (frame_target_time - frame_start_time).ToSecondsF());
126
127 recorder->RecordVsync(frame_start_time, frame_target_time);
128 if (_allowPauseAfterVsync) {
129 link.paused = YES;
130 }
131 _callback(std::move(recorder));
132}
static void round(SkPoint *p)
constexpr int64_t ToMicroseconds() const
Definition time_delta.h:62
TimeDelta ToEpochDelta() const
Definition time_point.h:52
static TimePoint Now()
Definition time_point.cc:49
double duration
Definition examples.cpp:30
link(from_root, to_root)
Definition dart_pkg.py:44
#define TRACE_EVENT2_INT(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)

◆ pause

- (void) pause

Definition at line 63 of file vsync_waiter_ios.mm.

107 {
108 _displayLink.paused = YES;
109}

◆ setMaxRefreshRate:

- (void) setMaxRefreshRate: (double)  refreshRate

Definition at line 63 of file vsync_waiter_ios.mm.

89 :(double)refreshRate {
91 return;
92 }
93 double maxFrameRate = fmax(refreshRate, 60);
94 double minFrameRate = fmax(maxFrameRate / 2, 60);
95 if (@available(iOS 15.0, *)) {
96 _displayLink.preferredFrameRateRange =
97 CAFrameRateRangeMake(minFrameRate, maxFrameRate, maxFrameRate);
98 } else {
99 _displayLink.preferredFramesPerSecond = maxFrameRate;
100 }
101}

Property Documentation

◆ allowPauseAfterVsync

- (BOOL) allowPauseAfterVsync
readwritenonatomicassign

Default value is YES. Vsync client will pause vsync callback after receiving a vsync signal. Setting this property to NO can avoid this and vsync client will trigger vsync callback continuously.

Parameters
allowPauseAfterVsyncAllow vsync client to pause after receiving a vsync signal.

Definition at line 46 of file vsync_waiter_ios.h.

◆ refreshRate

- (double) refreshRate
readnonatomicassignimplementation

Provided by category VSyncClient().

Definition at line 19 of file vsync_waiter_ios.mm.


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