From c32f0cd65aceb54d688363b92e38ff548b256b97 Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Thu, 1 Oct 2020 20:39:34 +0200 Subject: [PATCH] Change [FlutterView start] to synchronousResizing property --- .../darwin/macos/framework/Source/FlutterEngine.mm | 6 +++--- .../darwin/macos/framework/Source/FlutterView.h | 2 +- .../darwin/macos/framework/Source/FlutterView.mm | 10 +++------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 3d98704fa24ed..62caccd0f1793 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -289,7 +289,7 @@ - (BOOL)runWithEntrypoint:(NSString*)entrypoint { [self sendUserLocales]; [self updateDisplayConfig]; - [self.viewController.flutterView start]; + self.viewController.flutterView.synchronousResizing = YES; return YES; } @@ -301,7 +301,7 @@ - (void)setViewController:(FlutterViewController*)controller { _resourceContext = nil; } if (_engine) { - [self.viewController.flutterView start]; + self.viewController.flutterView.synchronousResizing = YES; } } @@ -353,7 +353,7 @@ - (void)updateDisplayConfig { CVDisplayLinkRelease(displayLinkRef); } -// Must be driven by FlutterView (i.e. [FlutterView start]) +// Called by [FlutterViewController viewDidReshape] - (void)updateWindowMetrics { if (!_engine) { return; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.h b/shell/platform/darwin/macos/framework/Source/FlutterView.h index 4123d1a5fde30..1e4358e11ce98 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.h @@ -21,6 +21,7 @@ @interface FlutterView : NSView @property(readwrite, nonatomic, nonnull) NSOpenGLContext* openGLContext; +@property(readwrite, nonatomic) BOOL synchronousResizing; - (nullable instancetype)initWithFrame:(NSRect)frame shareContext:(nonnull NSOpenGLContext*)shareContext @@ -37,7 +38,6 @@ - (nullable instancetype)initWithCoder:(nonnull NSCoder*)coder NS_UNAVAILABLE; - (nonnull instancetype)init NS_UNAVAILABLE; -- (void)start; - (void)present; - (int)getFrameBufferIdForSize:(CGSize)size; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index 2eeee2569db04..a5c0403b9bb33 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -13,7 +13,6 @@ @interface FlutterView () { __weak id _reshapeListener; FlutterResizeSynchronizer* resizeSynchronizer; FlutterSurfaceManager* surfaceManager; - BOOL active; CALayer* contentLayer; } @@ -80,18 +79,15 @@ - (void)present { [resizeSynchronizer requestCommit]; } -- (void)start { - active = YES; - [self reshaped]; -} - - (void)reshaped { - if (active) { + if (self.synchronousResizing) { CGSize scaledSize = [self convertSizeToBacking:self.bounds.size]; [resizeSynchronizer beginResize:scaledSize notify:^{ [_reshapeListener viewDidReshape:self]; }]; + } else { + [_reshapeListener viewDidReshape:self]; } }