Flutter macOS Embedder
FlutterDisplayLink.h
Go to the documentation of this file.
1 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDISPLAYLINK_H_
2 #define FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDISPLAYLINK_H_
3 
4 #import <AppKit/AppKit.h>
5 
6 @protocol FlutterDisplayLinkDelegate <NSObject>
7 /// This will be called on main thread.
8 - (void)onDisplayLink:(CFTimeInterval)timestamp targetTimestamp:(CFTimeInterval)targetTimestamp;
9 @end
10 
11 /// Provides notifications of display refresh.
12 ///
13 /// Internally FlutterDisplayLink will use at most one CVDisplayLink per
14 /// screen shared for all views belonging to that screen. This is necessary
15 /// because each CVDisplayLink comes with its own thread.
16 ///
17 /// All methods must be called on main thread.
18 @interface FlutterDisplayLink : NSObject
19 
20 /// Creates new instance tied to provided NSView. FlutterDisplayLink
21 /// will track view display changes transparently to synchronize
22 /// update with display refresh.
23 + (instancetype)displayLinkWithView:(NSView*)view;
24 
25 /// Delegate must be set on main thread.
26 /// Delegate method will be also called on main thread.
27 @property(nonatomic, weak) id<FlutterDisplayLinkDelegate> delegate;
28 
29 /// Pauses and resumes the display link.
30 @property(readwrite) BOOL paused;
31 
32 /// Returns the nominal refresh period of the display to which the view
33 /// currently belongs (in seconds). If view does not belong to any display,
34 /// returns 0.
35 @property(readonly) CFTimeInterval nominalOutputRefreshPeriod;
36 
37 /// Invalidates the display link.
38 - (void)invalidate;
39 
40 @end
41 
42 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_MACOS_FRAMEWORK_SOURCE_FLUTTERDISPLAYLINK_H_