-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix code style issues in MacOS embedder (#22270)
- Loading branch information
Showing
13 changed files
with
262 additions
and
194 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 60 additions & 41 deletions
101
shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,78 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@class FlutterResizeSynchronizer; | ||
|
||
/** | ||
* Implemented by FlutterView. | ||
*/ | ||
@protocol FlutterResizeSynchronizerDelegate | ||
|
||
// Invoked on raster thread; Delegate should flush the OpenGL context | ||
- (void)resizeSynchronizerFlush:(FlutterResizeSynchronizer*)synchronizer; | ||
/** | ||
* Invoked on raster thread; Delegate should flush the OpenGL context. | ||
*/ | ||
- (void)resizeSynchronizerFlush:(nonnull FlutterResizeSynchronizer*)synchronizer; | ||
|
||
// Invoked on platform thread; Delegate should flip the surfaces | ||
- (void)resizeSynchronizerCommit:(FlutterResizeSynchronizer*)synchronizer; | ||
/** | ||
* Invoked on platform thread; Delegate should flip the surfaces. | ||
*/ | ||
- (void)resizeSynchronizerCommit:(nonnull FlutterResizeSynchronizer*)synchronizer; | ||
|
||
@end | ||
|
||
// Encapsulates the logic for blocking platform thread during window resize as | ||
// well as synchronizing the raster and platform thread during commit (presenting frame) | ||
// | ||
// Flow during window resize | ||
// | ||
// 1. Platform thread calls [synchronizer beginResize:notify:] | ||
// This will hold the platform thread until we're ready to display contents. | ||
// 2. Raster thread calls [synchronizer shouldEnsureSurfaceForSize:] with target size | ||
// This will return false for any size other than target size | ||
// 3. Raster thread calls [synchronizer requestCommit] | ||
// Any commit calls before shouldEnsureSurfaceForSize: is called with the right | ||
// size are simply ignored; There's no point rasterizing and displaying frames | ||
// with wrong size. | ||
// Both delegate methods (flush/commit) will be invoked before beginResize returns | ||
// | ||
// Flow during regular operation (no resizing) | ||
// | ||
// 1. Raster thread calls [synchronizer requestCommit] | ||
// This will invoke [delegate flush:] on raster thread and | ||
// [delegate commit:] on platform thread. The requestCommit call will be blocked | ||
// until this is done. This is necessary to ensure that rasterizer won't start | ||
// rasterizing next frame before we flipped the surface, which must be performed | ||
// on platform thread | ||
/** | ||
* Encapsulates the logic for blocking platform thread during window resize as | ||
* well as synchronizing the raster and platform thread during commit (presenting frame). | ||
* | ||
* Flow during window resize | ||
* | ||
* 1. Platform thread calls [synchronizer beginResize:notify:] | ||
* This will hold the platform thread until we're ready to display contents. | ||
* 2. Raster thread calls [synchronizer shouldEnsureSurfaceForSize:] with target size | ||
* This will return false for any size other than target size | ||
* 3. Raster thread calls [synchronizer requestCommit] | ||
* Any commit calls before shouldEnsureSurfaceForSize: is called with the right | ||
* size are simply ignored; There's no point rasterizing and displaying frames | ||
* with wrong size. | ||
* Both delegate methods (flush/commit) will be invoked before beginResize returns | ||
* | ||
* Flow during regular operation (no resizing) | ||
* | ||
* 1. Raster thread calls [synchronizer requestCommit] | ||
* This will invoke [delegate flush:] on raster thread and | ||
* [delegate commit:] on platform thread. The requestCommit call will be blocked | ||
* until this is done. This is necessary to ensure that rasterizer won't start | ||
* rasterizing next frame before we flipped the surface, which must be performed | ||
* on platform thread | ||
*/ | ||
@interface FlutterResizeSynchronizer : NSObject | ||
|
||
- (instancetype)initWithDelegate:(id<FlutterResizeSynchronizerDelegate>)delegate; | ||
- (nullable instancetype)initWithDelegate:(nonnull id<FlutterResizeSynchronizerDelegate>)delegate; | ||
|
||
// Blocks the platform thread until | ||
// - shouldEnsureSurfaceForSize is called with proper size and | ||
// - requestCommit is called | ||
// All requestCommit calls before `shouldEnsureSurfaceForSize` is called with | ||
// expected size are ignored; | ||
// The notify block is invoked immediately after synchronizer mutex is acquired | ||
- (void)beginResize:(CGSize)size notify:(dispatch_block_t)notify; | ||
/** | ||
* Blocks the platform thread until | ||
* - shouldEnsureSurfaceForSize is called with proper size and | ||
* - requestCommit is called | ||
* All requestCommit calls before `shouldEnsureSurfaceForSize` is called with | ||
* expected size are ignored; | ||
* The notify block is invoked immediately after synchronizer mutex is acquired. | ||
*/ | ||
- (void)beginResize:(CGSize)size notify:(nonnull dispatch_block_t)notify; | ||
|
||
// Returns whether the view should ensure surfaces with given size; | ||
// This will be false during resizing for any size other than size specified | ||
// during beginResize | ||
- (bool)shouldEnsureSurfaceForSize:(CGSize)size; | ||
/** | ||
* Returns whether the view should ensure surfaces with given size; | ||
* This will be false during resizing for any size other than size specified | ||
* during beginResize. | ||
*/ | ||
- (BOOL)shouldEnsureSurfaceForSize:(CGSize)size; | ||
|
||
// Called from rasterizer thread, will block until delegate resizeSynchronizerCommit: | ||
// method is called (on platform thread) | ||
/** | ||
* Called from rasterizer thread, will block until delegate resizeSynchronizerCommit: | ||
* method is called (on platform thread). | ||
*/ | ||
- (void)requestCommit; | ||
|
||
@end |
114 changes: 64 additions & 50 deletions
114
shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.