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