FlutterView: Use default backing layer (flutter/engine#25523)
This commit is contained in:
@@ -25,14 +25,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CALayer*)makeBackingLayer {
|
||||
return [CAMetalLayer layer];
|
||||
}
|
||||
|
||||
+ (Class)layerClass {
|
||||
return [CAMetalLayer class];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace flutter::testing {
|
||||
@@ -41,10 +33,10 @@ static FlutterMetalSurfaceManager* CreateSurfaceManager() {
|
||||
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||
id<MTLCommandQueue> commandQueue = [device newCommandQueue];
|
||||
TestMetalView* metalView = [[TestMetalView alloc] init];
|
||||
CAMetalLayer* layer = reinterpret_cast<CAMetalLayer*>(metalView.layer);
|
||||
CALayer* layer = reinterpret_cast<CALayer*>(metalView.layer);
|
||||
return [[FlutterMetalSurfaceManager alloc] initWithDevice:device
|
||||
commandQueue:commandQueue
|
||||
metalLayer:layer];
|
||||
layer:layer];
|
||||
}
|
||||
|
||||
TEST(FlutterMetalSurfaceManager, EnsureSizeUpdatesSize) {
|
||||
|
||||
@@ -16,15 +16,4 @@
|
||||
*/
|
||||
+ (BOOL)renderUsingMetal;
|
||||
|
||||
/**
|
||||
* CALayer class depending on the rendering backend.
|
||||
*/
|
||||
+ (nonnull Class)layerClass;
|
||||
|
||||
/**
|
||||
* On both Metal and OpenGL rendering backends, `wantsLayer` is set on the `FlutterView`. This
|
||||
* methos is used by `FlutterView` to provide the said `CALayer`.
|
||||
*/
|
||||
+ (nonnull CALayer*)createBackingLayer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -19,29 +19,4 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
+ (Class)layerClass {
|
||||
BOOL enableMetal = [FlutterRenderingBackend renderUsingMetal];
|
||||
if (enableMetal) {
|
||||
return [CAMetalLayer class];
|
||||
} else {
|
||||
return [CAOpenGLLayer class];
|
||||
}
|
||||
}
|
||||
|
||||
+ (CALayer*)createBackingLayer {
|
||||
BOOL enableMetal = [FlutterRenderingBackend renderUsingMetal];
|
||||
if (enableMetal) {
|
||||
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;
|
||||
} else {
|
||||
return [CAOpenGLLayer layer];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -53,6 +53,6 @@
|
||||
*/
|
||||
- (nonnull instancetype)initWithDevice:(nonnull id<MTLDevice>)device
|
||||
commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
|
||||
metalLayer:(nonnull CAMetalLayer*)layer;
|
||||
layer:(nonnull CALayer*)layer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -57,14 +57,14 @@
|
||||
|
||||
- (instancetype)initWithDevice:(id<MTLDevice>)device
|
||||
commandQueue:(id<MTLCommandQueue>)commandQueue
|
||||
metalLayer:(CAMetalLayer*)layer {
|
||||
layer:(CALayer*)layer {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_device = device;
|
||||
_commandQueue = commandQueue;
|
||||
_surfaceManager = [[FlutterMetalSurfaceManager alloc] initWithDevice:device
|
||||
commandQueue:commandQueue
|
||||
metalLayer:layer];
|
||||
layer:layer];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,6 @@
|
||||
*/
|
||||
- (nullable instancetype)initWithDevice:(nonnull id<MTLDevice>)device
|
||||
commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
|
||||
metalLayer:(nonnull CAMetalLayer*)layer;
|
||||
layer:(nonnull CALayer*)containingLayer;
|
||||
|
||||
@end
|
||||
|
||||
@@ -121,8 +121,8 @@ enum {
|
||||
|
||||
- (nullable instancetype)initWithDevice:(nonnull id<MTLDevice>)device
|
||||
commandQueue:(nonnull id<MTLCommandQueue>)commandQueue
|
||||
metalLayer:(nonnull CAMetalLayer*)layer {
|
||||
self = [super initWithLayer:layer contentTransform:CATransform3DIdentity];
|
||||
layer:(nonnull CALayer*)containingLayer {
|
||||
self = [super initWithLayer:containingLayer contentTransform:CATransform3DIdentity];
|
||||
if (self) {
|
||||
super.delegate = self;
|
||||
_device = device;
|
||||
|
||||
@@ -30,24 +30,16 @@
|
||||
[self setWantsLayer:YES];
|
||||
[self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize];
|
||||
_reshapeListener = reshapeListener;
|
||||
_resizableBackingStoreProvider = [[FlutterMetalResizableBackingStoreProvider alloc]
|
||||
initWithDevice:device
|
||||
commandQueue:commandQueue
|
||||
metalLayer:reinterpret_cast<CAMetalLayer*>(self.layer)];
|
||||
_resizableBackingStoreProvider =
|
||||
[[FlutterMetalResizableBackingStoreProvider alloc] initWithDevice:device
|
||||
commandQueue:commandQueue
|
||||
layer:self.layer];
|
||||
_resizeSynchronizer =
|
||||
[[FlutterResizeSynchronizer alloc] initWithDelegate:_resizableBackingStoreProvider];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (Class)layerClass {
|
||||
return [FlutterRenderingBackend layerClass];
|
||||
}
|
||||
|
||||
- (CALayer*)makeBackingLayer {
|
||||
return [FlutterRenderingBackend createBackingLayer];
|
||||
}
|
||||
|
||||
- (instancetype)initWithMainContext:(NSOpenGLContext*)mainContext
|
||||
reshapeListener:(id<FlutterViewReshapeListener>)reshapeListener {
|
||||
return [self initWithFrame:NSZeroRect mainContext:mainContext reshapeListener:reshapeListener];
|
||||
|
||||
Reference in New Issue
Block a user