Flutter Engine
The Flutter Engine
Instance Methods | Protected Attributes | List of all members
_FlutterDisplayLink Class Reference
Inheritance diagram for _FlutterDisplayLink:
FlutterDisplayLink

Instance Methods

(void) - didFireWithTimestamp:targetTimestamp:
 
(instancetype) - initWithView: [implementation]
 
(void) - invalidate [implementation]
 Invalidates the display link. Must be called on the main thread. More...
 
(void) - updateScreen [implementation]
 
(void) - viewDidChangeWindow: [implementation]
 
(void) - windowDidChangeScreen: [implementation]
 
(BOOL- paused [implementation]
 
(void) - setPaused: [implementation]
 
(CFTimeInterval) - nominalOutputRefreshPeriod [implementation]
 
(void) - invalidate
 Invalidates the display link. Must be called on the main thread. More...
 

Protected Attributes

_FlutterDisplayLinkView_view
 
std::optional< CGDirectDisplayID > _display_id
 
BOOL _paused
 

Additional Inherited Members

Detailed Description

Definition at line 29 of file FlutterDisplayLink.mm.

Method Documentation

◆ didFireWithTimestamp:targetTimestamp:

- (void) didFireWithTimestamp: (CFTimeInterval)  timestamp
targetTimestamp: (CFTimeInterval)  targetTimestamp 

Definition at line 69 of file FlutterDisplayLink.mm.

309 :(CFTimeInterval)timestamp
310 targetTimestamp:(CFTimeInterval)targetTimestamp {
311 @synchronized(self) {
312 if (!_paused) {
313 id<FlutterDisplayLinkDelegate> delegate = _delegate;
314 [delegate onDisplayLink:timestamp targetTimestamp:targetTimestamp];
315 }
316 }
317}

◆ initWithView:

- (instancetype) initWithView: (NSView*)  view
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

243 :(NSView*)view {
244 FML_DCHECK([NSThread isMainThread]);
245 if (self = [super init]) {
246 self->_view = [[_FlutterDisplayLinkView alloc] initWithFrame:CGRectZero];
247 [view addSubview:self->_view];
248 _paused = YES;
249 [[NSNotificationCenter defaultCenter] addObserver:self
250 selector:@selector(viewDidChangeWindow:)
251 name:kFlutterDisplayLinkViewDidMoveToWindow
252 object:self->_view];
253 [[NSNotificationCenter defaultCenter] addObserver:self
254 selector:@selector(windowDidChangeScreen:)
255 name:NSWindowDidChangeScreenNotification
256 object:nil];
257 [self updateScreen];
258 }
259 return self;
260}
#define FML_DCHECK(condition)
Definition: logging.h:103
static bool init()

◆ invalidate

- (void) invalidate
implementation

Invalidates the display link. Must be called on the main thread.

Reimplemented from FlutterDisplayLink.

Definition at line 69 of file FlutterDisplayLink.mm.

262 {
263 @synchronized(self) {
264 FML_DCHECK([NSThread isMainThread]);
265 // Unregister observer before removing the view to ensure
266 // that the viewDidChangeWindow notification is not received
267 // while in @synchronized block.
268 [[NSNotificationCenter defaultCenter] removeObserver:self];
269 [_view removeFromSuperview];
270 _view = nil;
271 _delegate = nil;
272 }
273 DisplayLinkManager::Instance().UnregisterDisplayLink(self);
274}

◆ nominalOutputRefreshPeriod

- (CFTimeInterval) nominalOutputRefreshPeriod
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

335 {
336 CGDirectDisplayID display_id;
337 @synchronized(self) {
338 if (_display_id.has_value()) {
339 display_id = *_display_id;
340 } else {
341 return 0;
342 }
343 }
344 return DisplayLinkManager::Instance().GetNominalOutputPeriod(display_id);
345}

◆ paused

- (BOOL) paused
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

319 {
320 @synchronized(self) {
321 return _paused;
322 }
323}

◆ setPaused:

- (void) setPaused: (BOOL paused
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

325 :(BOOL)paused {
326 @synchronized(self) {
327 if (_paused == paused) {
328 return;
329 }
330 _paused = paused;
331 }
332 DisplayLinkManager::Instance().PausedDidChange(self);
333}
int BOOL
Definition: windows_types.h:37

◆ updateScreen

- (void) updateScreen
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

276 {
277 DisplayLinkManager::Instance().UnregisterDisplayLink(self);
278 std::optional<CGDirectDisplayID> displayId;
279 @synchronized(self) {
280 NSScreen* screen = _view.window.screen;
281 if (screen != nil) {
282 // https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc
283 _display_id = (CGDirectDisplayID)[
284 [[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
285 } else {
286 _display_id = std::nullopt;
287 }
288 displayId = _display_id;
289 }
290 if (displayId.has_value()) {
291 DisplayLinkManager::Instance().RegisterDisplayLink(self, *displayId);
292 }
293}

◆ viewDidChangeWindow:

- (void) viewDidChangeWindow: (NSNotification*)  notification
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

295 :(NSNotification*)notification {
296 NSView* view = notification.object;
297 if (_view == view) {
298 [self updateScreen];
299 }
300}

◆ windowDidChangeScreen:

- (void) windowDidChangeScreen: (NSNotification*)  notification
implementation

Definition at line 69 of file FlutterDisplayLink.mm.

302 :(NSNotification*)notification {
303 NSWindow* window = notification.object;
304 if (_view.window == window) {
305 [self updateScreen];
306 }
307}
GLFWwindow * window
Definition: main.cc:45

Member Data Documentation

◆ _display_id

- (optional<CGDirectDisplayID>) _FlutterDisplayLink:
protected

Definition at line 31 of file FlutterDisplayLink.mm.

◆ _paused

- (BOOL) _paused
protected

Definition at line 32 of file FlutterDisplayLink.mm.

◆ _view

- (_FlutterDisplayLinkView*) _view
protected

Definition at line 30 of file FlutterDisplayLink.mm.


The documentation for this class was generated from the following file: