| 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 107 of file vsync_waiter_ios.mm.

107 {
108 display_link_.get().paused = NO;
109 }

References display_link_.

## ◆ getRefreshRate

- (double) getRefreshRate |  |  |

Definition at line 148 of file vsync_waiter_ios.mm.

148 {
149 return current_refresh_rate_;
150 }

References current_refresh_rate_.

## ◆ initWithTaskRunner:callback:

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

Definition at line 68 of file vsync_waiter_ios.mm.

68 :(fml::RefPtr<fml::TaskRunner>)task_runner
69 callback:(flutter::VsyncWaiter::Callback)callback {
70 self = [super init];
71
72 if (self) {
73 current_refresh_rate_ = [DisplayLinkManager displayRefreshRate];
74 _allowPauseAfterVsync = YES;
75 callback_ = std::move(callback);
76 display_link_ = fml::scoped_nsobject<CADisplayLink> {
77 [[CADisplayLink displayLinkWithTarget:self selector:@selector(onDisplayLink:)] retain]
78 };
79 display_link_.get().paused = YES;
80
81 [self setMaxRefreshRate:[DisplayLinkManager displayRefreshRate]];
82
83 task_runner->PostTask([client = [self retain]]() {
84 [client->display_link_.get() addToRunLoop:[NSRunLoop currentRunLoop]
85 forMode:NSRunLoopCommonModes];
86 [client release];
87 });
88 }
89
90 return self;
91 }

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

## ◆ invalidate

- (void) invalidate |  |  |

Definition at line 138 of file vsync_waiter_ios.mm.

138 {
139 [display_link_.get() invalidate];
140 }

## ◆ pause

- (void) pause |  |  |

Definition at line 111 of file vsync_waiter_ios.mm.

111 {
112 display_link_.get().paused = YES;
113 }

References display_link_.

## ◆ setMaxRefreshRate:

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

Definition at line 93 of file vsync_waiter_ios.mm.

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

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: FlutterMetalLayer.mm:13
DisplayLinkManager
Definition: FlutterMetalLayer.mm:12
display_link_
fml::scoped_nsobject< CADisplayLink > display_link_
Definition: vsync_waiter_ios.mm:62
current_refresh_rate_
double current_refresh_rate_
Definition: vsync_waiter_ios.mm:65
+[DisplayLinkManager displayRefreshRate]
double displayRefreshRate()
Definition: vsync_waiter_ios.mm:160