Flutter macOS Embedder
FlutterResizeSynchronizer Class Reference

#import <FlutterResizeSynchronizer.h>

Inheritance diagram for FlutterResizeSynchronizer:

Instance Methods

(void) - beginResizeForSize:notify:
 
(void) - performCommitForSize:notify:delay:
 
(void) - shutDown
 

Detailed Description

Class responsible for coordinating window resize with content update.

Definition at line 16 of file FlutterResizeSynchronizer.h.

Method Documentation

◆ beginResizeForSize:notify:

- (void) beginResizeForSize: (CGSize)  size
notify: (nonnull dispatch_block_t)  notify 

Begins a resize operation for the given size. Block the thread until performCommitForSize: with the same size is called. While the thread is blocked Flutter messages are being pumped. See [FlutterRunLoop pollFlutterMessagesOnce].

Definition at line 14 of file FlutterResizeSynchronizer.mm.

17  :(CGSize)size notify:(nonnull dispatch_block_t)notify {
19  notify();
20  return;
21  }
22 
23  _inResize = true;
24  _contentSize = CGSizeMake(-1, -1);
25  notify();
26  CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
27  while (true) {
28  if (CGSizeEqualToSize(_contentSize, size) || _shuttingDown) {
29  break;
30  }
31  if (CFAbsoluteTimeGetCurrent() - start > 1.0) {
32  FML_LOG(ERROR) << "Resize timed out.";
33  break;
34  }
36  }
37  _inResize = false;
38 }
BOOL _shuttingDown
CGSize _contentSize
BOOL _didReceiveFrame
void pollFlutterMessagesOnce()

◆ performCommitForSize:notify:delay:

- (void) performCommitForSize: (CGSize)  size
notify: (nonnull dispatch_block_t)  notify
delay: (NSTimeInterval)  delay 

Called from raster thread. Schedules the given block on platform thread at given delay and unblocks the platform thread if waiting for the surface during resize.

Definition at line 14 of file FlutterResizeSynchronizer.mm.

40  :(CGSize)size
41  notify:(nonnull dispatch_block_t)notify
42  delay:(NSTimeInterval)delay {
43  if (_inResize) {
44  delay = 0;
45  }
46  [FlutterRunLoop.mainRunLoop
47  performBlock:^{
48  _didReceiveFrame = YES;
49  _contentSize = size;
50  notify();
51  }
52  afterDelay:delay];
53 }
void performBlock:afterDelay:(void(^ block)(void),[afterDelay] NSTimeInterval delay)

Referenced by flutter::testing::TEST_F().

◆ shutDown

- (void) shutDown

Called when the view is shut down. Unblocks platform thread if blocked during resize.

Definition at line 14 of file FlutterResizeSynchronizer.mm.

55  {
56  [FlutterRunLoop.mainRunLoop performBlock:^{
57  _shuttingDown = YES;
58  }];
59 }
void performBlock:(void(^ block)(void))

Referenced by flutter::testing::TEST_F().


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