| 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
(double) | - getRefreshRate
(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 38 of file vsync_waiter_ios.h.

## Method Documentation

## ◆ await

- (void) await |  |  |

Definition at line 121 of file vsync_waiter_ios.mm.

121 {
122 display_link_.get().paused = NO;
123 }

References display_link_.

## ◆ getRefreshRate

- (double) getRefreshRate |  |  |

Definition at line 162 of file vsync_waiter_ios.mm.

162 {
163 return current_refresh_rate_;
164 }

References current_refresh_rate_.

## ◆ initWithTaskRunner:callback:

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

Definition at line 82 of file vsync_waiter_ios.mm.

82 :(fml::RefPtr<fml::TaskRunner>)task_runner
83 callback:(flutter::VsyncWaiter::Callback)callback {
84 self = [super init];
85
86 if (self) {
87 current_refresh_rate_ = [DisplayLinkManager displayRefreshRate];
88 _allowPauseAfterVsync = YES;
89 callback_ = std::move(callback);
90 display_link_ = fml::scoped_nsobject<CADisplayLink> {
91 [[CADisplayLink displayLinkWithTarget:self selector:@selector(onDisplayLink:)] retain]
92 };
93 display_link_.get().paused = YES;
94
95 [self setMaxRefreshRate:[DisplayLinkManager displayRefreshRate]];
96
97 task_runner->PostTask([client = [self retain]]() {
98 [client->display_link_.get() addToRunLoop:[NSRunLoop currentRunLoop]
99 forMode:NSRunLoopCommonModes];
100 [client release];
101 });
102 }
103
104 return self;
105 }

References current_refresh_rate_, display_link_, DisplayLinkManager::displayRefreshRate, and setMaxRefreshRate:.

## ◆ invalidate

- (void) invalidate |  |  |

Definition at line 152 of file vsync_waiter_ios.mm.

152 {
153 [display_link_.get() invalidate];
154 }

## ◆ pause

- (void) pause |  |  |

Definition at line 125 of file vsync_waiter_ios.mm.

125 {
126 display_link_.get().paused = YES;
127 }

References display_link_.

## ◆ setMaxRefreshRate:

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

Definition at line 107 of file vsync_waiter_ios.mm.

107 :(double)refreshRate {
108 if (!DisplayLinkManager.maxRefreshRateEnabledOnIPhone) {
109 return;
110 }
111 double maxFrameRate = fmax(refreshRate, 60);
112 double minFrameRate = fmax(maxFrameRate / 2, 60);
113 if (@available(iOS 15.0, *)) {
114 display_link_.get().preferredFrameRateRange =
115 CAFrameRateRangeMake(minFrameRate, maxFrameRate, maxFrameRate);
116 } else {
117 display_link_.get().preferredFramesPerSecond = maxFrameRate;
118 }
119 }

References display_link_, and DisplayLinkManager::maxRefreshRateEnabledOnIPhone.

Referenced by 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 48 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: vsync_waiter_ios.h:23
DisplayLinkManager
Definition: vsync_waiter_ios.h:16
display_link_
fml::scoped_nsobject< CADisplayLink > display_link_
Definition: vsync_waiter_ios.mm:76
current_refresh_rate_
double current_refresh_rate_
Definition: vsync_waiter_ios.mm:79
+[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.mm:174