A client that wraps a CADisplayLink to deliver synchronized vsync signals.
More...
#include <FlutterVSyncClient.h>
Instance Methods | |
| (instancetype) | - initWithTaskRunner:isVariableRefreshRateEnabled:maxRefreshRate:callback: |
| Initializes the vsync client. | |
| (void) | - await |
| Requests a vsync signal. | |
| (void) | - pause |
| Pauses the vsync client. | |
| (void) | - invalidate |
| Call invalidate before releasing this object to remove from runloops. | |
| (void) | - setMaxRefreshRate: |
| Dynamically configures the display link's frame rate ranges. | |
| (void) | - onDisplayLink: |
Properties | |
| double | refreshRate |
| The current display refresh rate in Hertz, rounded to the nearest integer value. | |
| 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. | |
| CADisplayLink * | displayLink |
A client that wraps a CADisplayLink to deliver synchronized vsync signals.
Schedules on-demand vsync signals using a request-and-pause cycle to maintain CPU
and battery efficiency. Adds additional logic around the wrapped CADisplayLink to
ensure consistent frame timings both on display link startup and at steady state.
Definition at line 64 of file FlutterVSyncClient.h.
| - (void) await |
Requests a vsync signal.
Unpauses the underlying `CADisplayLink` to schedule the next vsync callback.
Once the vsync callback executes, the client automatically pauses the display
link if `allowPauseAfterVsync` is `YES`.
Definition at line 21 of file FlutterVSyncClient.mm.
| - (instancetype) initWithTaskRunner: | (FlutterFMLTaskRunner*) | taskRunner | |
| isVariableRefreshRateEnabled: | (BOOL) | isVariableRefreshRateEnabled | |
| maxRefreshRate: | (double) | maxRefreshRate | |
| callback: | (void(^)(CFTimeInterval startTime, CFTimeInterval targetTime)) | callback | |
Initializes the vsync client.
| taskRunner | The task runner to use for posting tasks. |
| isVariableRefreshRateEnabled | Whether variable refresh rate should be enabled. |
| maxRefreshRate | The maximum refresh rate to configure the display link with. |
| callback | The callback to invoke when a vsync signal is received. |
Definition at line 21 of file FlutterVSyncClient.mm.
| - (void) invalidate |
Call invalidate before releasing this object to remove from runloops.
Definition at line 21 of file FlutterVSyncClient.mm.
| - (void) onDisplayLink: | (CADisplayLink *) | link |
Manually triggers the display link callback for testing without waiting for actual vsyncs.
Provided by category FlutterVSyncClient(Testing).
| - (void) pause |
Pauses the vsync client.
Pauses the underlying `CADisplayLink` to stop receiving vsync signals immediately.
Definition at line 21 of file FlutterVSyncClient.mm.
| - (void) setMaxRefreshRate: | (double) | refreshRate |
Dynamically configures the display link's frame rate ranges.
Adjusts the target and minimum FPS limits of the display link to support variable
refresh rates (e.g. on ProMotion displays) when dynamic rate changes are enabled.
| refreshRate | The target maximum refresh rate in Hz. |
Definition at line 21 of file FlutterVSyncClient.mm.
|
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.
| allowPauseAfterVsync | Allow vsync client to pause after receiving a vsync signal. |
Definition at line 85 of file FlutterVSyncClient.h.
|
readnonatomicassign |
The underlying CADisplayLink instance.
Provided by category FlutterVSyncClient(Testing).
Definition at line 20 of file FlutterVSyncClient+Testing.h.
|
readnonatomicassign |
The current display refresh rate in Hertz, rounded to the nearest integer value.
This value is calculated during each vsync callback as the inverse of the
frame duration (the time between the current frame and the target next frame). The
resulting frequency is rounded to the nearest whole number to smooth out minor
hardware timestamp variations.
Definition at line 74 of file FlutterVSyncClient.h.
Referenced by flutter::VsyncWaiterIOS::GetRefreshRate().