Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,19 @@ - (FlutterRenderBackingStore*)backingStore {
}

- (void)resizeSynchronizerFlush:(nonnull FlutterResizeSynchronizer*)synchronizer {
// TODO (kaushikiska): Support smooth resizing on Metal.
// no-op when using Metal rendering backend.
}

- (void)resizeSynchronizerCommit:(nonnull FlutterResizeSynchronizer*)synchronizer {
[CATransaction begin];
[CATransaction setDisableActions:YES];

id<MTLCommandBuffer> commandBuffer = [_commandQueue commandBuffer];
[commandBuffer commit];
[commandBuffer waitUntilScheduled];
[_surfaceManager swapBuffers];

[CATransaction commit];
}

@end
10 changes: 9 additions & 1 deletion shell/platform/darwin/macos/framework/Source/FlutterView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ - (instancetype)initWithMTLDevice:(id<MTLDevice>)device
self = [super initWithFrame:NSZeroRect];
if (self) {
[self setWantsLayer:YES];
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize];
_reshapeListener = reshapeListener;
_resizableBackingStoreProvider = [[FlutterMetalResizableBackingStoreProvider alloc]
initWithDevice:device
Expand All @@ -44,7 +45,14 @@ + (Class)layerClass {
}

- (CALayer*)makeBackingLayer {
return [CAMetalLayer layer];
CAMetalLayer* metalLayer = [CAMetalLayer layer];
// This is set to true to synchronize the presentation of the layer and its contents with Core
// Animation. When presenting the texture see `[FlutterMetalResizableBackingStoreProvider
// resizeSynchronizerCommit:]` we start a CATransaction and wait for the command buffer to be
// scheduled. This ensures that the resizing process is smooth.
metalLayer.presentsWithTransaction = YES;
metalLayer.autoresizingMask = kCALayerHeightSizable | kCALayerWidthSizable;
return metalLayer;
}
#endif

Expand Down