| Flutter iOS Embedder |

Instance Methods | Properties | List of all members
VSyncClient Class Reference

`#import <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. More...
(void) | - setMaxRefreshRate:

## 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. More...

## Detailed Description

Definition at line 36 of file vsync_waiter_ios.h.

## Method Documentation

## ◆ await

- (void) await |  |  |

Definition at line 106 of file vsync_waiter_ios.mm.

106 {
107 _displayLink.paused = NO;
108 }

References _displayLink.

Referenced by flutter::VsyncWaiterIOS::AwaitVSync.

## ◆ initWithTaskRunner:callback:

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

Definition at line 69 of file vsync_waiter_ios.mm.

69 :(fml::RefPtr<fml::TaskRunner>)task_runner
70 callback:(flutter::VsyncWaiter::Callback)callback {
71 self = [super init];
72
73 if (self) {
74 _refreshRate = DisplayLinkManager.displayRefreshRate;
75 _allowPauseAfterVsync = YES;
76 _callback = std::move(callback);
77 _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onDisplayLink:)];
78 _displayLink.paused = YES;
79
80 [self setMaxRefreshRate:DisplayLinkManager.displayRefreshRate];
81
82 // Strongly retain the the captured link until it is added to the runloop.
83 CADisplayLink* localDisplayLink = _displayLink;
84 task_runner->PostTask([localDisplayLink]() {
85 [localDisplayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSRunLoopCommonModes];
86 });
87 }
88
89 return self;
90 }

References _displayLink, DisplayLinkManager::displayRefreshRate, and setMaxRefreshRate:.

## ◆ invalidate

- (void) invalidate |  |  |

Call invalidate before releasing this object to remove from runloops.

Definition at line 137 of file vsync_waiter_ios.mm.

137 {
138 [_displayLink invalidate];
139 _displayLink = nil; // Break retain cycle.
140 }

References _displayLink.

Referenced by flutter::VsyncWaiterIOS::~VsyncWaiterIOS.

## ◆ pause

- (void) pause |  |  |

Definition at line 110 of file vsync_waiter_ios.mm.

110 {
111 _displayLink.paused = YES;
112 }

References _displayLink.

## ◆ setMaxRefreshRate:

- (void) setMaxRefreshRate: |  | (double) | refreshRate |

Definition at line 92 of file vsync_waiter_ios.mm.

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

References _displayLink, and DisplayLinkManager::maxRefreshRateEnabledOnIPhone.

Referenced by flutter::VsyncWaiterIOS::AwaitVSync, and initWithTaskRunner:callback:.

## Property Documentation

## ◆ allowPauseAfterVsync

- (BOOL) allowPauseAfterVsync
| read write nonatomic assign

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

  allowPauseAfterVsync | Allow vsync client to pause after receiving a vsync signal.

Definition at line 46 of file vsync_waiter_ios.h.

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

- shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h
- shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm

DisplayLinkManager::maxRefreshRateEnabledOnIPhone
BOOL maxRefreshRateEnabledOnIPhone
Definition: FlutterMetalLayer.mm:17
DisplayLinkManager
Definition: FlutterMetalLayer.mm:16
DisplayLinkManager::displayRefreshRate
double displayRefreshRate
The display refresh rate used for reporting purposes. The engine does not care about this for frame s...
Definition: vsync_waiter_ios.h:32
_displayLink
CADisplayLink * _displayLink
Definition: vsync_waiter_ios.mm:64