diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h index 354d21a6fe59f..809c174c37343 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h @@ -11,13 +11,6 @@ */ @interface FlutterRenderBackingStore : NSObject -@end - -/** - * Wraps a Metal texture. - */ -@interface FlutterMetalRenderBackingStore : FlutterRenderBackingStore - /** * MTLTexture referenced by this backing store instance. */ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm index 8a0119203a975..61404932c9c2d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm @@ -5,9 +5,6 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h" @implementation FlutterRenderBackingStore -@end - -@implementation FlutterMetalRenderBackingStore - (instancetype)initWithTexture:(id)texture { self = [super init]; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 1cb1a412af769..ccdfaec180c2a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -37,8 +37,7 @@ StartFrame(); // If the backing store is for the first layer, return the MTLTexture for the // FlutterView. - FlutterMetalRenderBackingStore* backingStore = - reinterpret_cast([view backingStoreForSize:size]); + FlutterRenderBackingStore* backingStore = [view backingStoreForSize:size]; backing_store_out->metal.texture.texture = (__bridge FlutterMetalTextureHandle)backingStore.texture; } else { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositorUnittests.mm index b9f9f10b7807c..f2a9a8de3b8e7 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositorUnittests.mm @@ -43,8 +43,7 @@ - (nullable FlutterView*)getView:(uint64_t)viewId { id MockViewProvider() { FlutterView* viewMock = OCMClassMock([FlutterView class]); - FlutterMetalRenderBackingStore* backingStoreMock = - OCMClassMock([FlutterMetalRenderBackingStore class]); + FlutterRenderBackingStore* backingStoreMock = OCMClassMock([FlutterRenderBackingStore class]); __block id textureMock = OCMProtocolMock(@protocol(MTLTexture)); OCMStub([backingStoreMock texture]).andReturn(textureMock); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm index d02de6c5c8eab..996e613dba926 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterRenderer.mm @@ -95,8 +95,7 @@ - (FlutterMetalTexture)createTextureForView:(uint64_t)viewId size:(CGSize)size { // FlutterMetalTexture has texture `null`, therefore is discarded. return FlutterMetalTexture{}; } - FlutterMetalRenderBackingStore* backingStore = - (FlutterMetalRenderBackingStore*)[view backingStoreForSize:size]; + FlutterRenderBackingStore* backingStore = [view backingStoreForSize:size]; id texture = backingStore.texture; FlutterMetalTexture embedderTexture; embedderTexture.struct_size = sizeof(FlutterMetalTexture); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h index eb8ae31d5963a..00a93ac213078 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h @@ -10,10 +10,16 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h" /** - * Represents a buffer that can be resized. + * Provides resizable buffers backed by a MTLTexture. */ -@protocol FlutterResizableBackingStoreProvider +@interface FlutterResizableBackingStoreProvider : NSObject +/** + * Creates a resizable backing store provider for the given CAMetalLayer. + */ +- (nonnull instancetype)initWithDevice:(nonnull id)device + commandQueue:(nonnull id)commandQueue + layer:(nonnull CALayer*)layer; /** * Notify of the required backing store size updates. Called during window resize. */ @@ -25,19 +31,3 @@ - (nonnull FlutterRenderBackingStore*)backingStore; @end - -/** - * Metal-backed FlutterResizableBackingStoreProvider. Backing store in this context implies a - * MTLTexture. - */ -@interface FlutterMetalResizableBackingStoreProvider - : NSObject - -/** - * Creates a resizable backing store provider for the given CAMetalLayer. - */ -- (nonnull instancetype)initWithDevice:(nonnull id)device - commandQueue:(nonnull id)commandQueue - layer:(nonnull CALayer*)layer; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm index fc07530c375a0..436d41af68f15 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm @@ -8,7 +8,7 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" -@implementation FlutterMetalResizableBackingStoreProvider { +@implementation FlutterResizableBackingStoreProvider { id _device; id _commandQueue; FlutterSurfaceManager* _surfaceManager; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm index 06d0e5f234877..d3d612fd294c8 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm @@ -143,7 +143,7 @@ - (void)cancelIdle { - (nonnull FlutterRenderBackingStore*)renderBuffer { [self ensureBackBuffer]; id texture = _textures[kFlutterSurfaceManagerBackBuffer]; - return [[FlutterMetalRenderBackingStore alloc] initWithTexture:texture]; + return [[FlutterRenderBackingStore alloc] initWithTexture:texture]; } - (id)createTextureForSurface:(FlutterIOSurfaceHolder*)surface size:(CGSize)size { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManagerTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManagerTest.mm index fdcd62f9d7e34..27b0e8748de7b 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManagerTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManagerTest.mm @@ -43,8 +43,7 @@ - (instancetype)init { FlutterSurfaceManager* surfaceManager = CreateSurfaceManager(); CGSize size = CGSizeMake(100, 50); [surfaceManager ensureSurfaceSize:size]; - id texture = - (reinterpret_cast([surfaceManager renderBuffer])).texture; + id texture = [surfaceManager renderBuffer].texture; CGSize textureSize = CGSizeMake(texture.width, texture.height); ASSERT_TRUE(CGSizeEqualToSize(size, textureSize)); } @@ -55,8 +54,7 @@ - (instancetype)init { [surfaceManager ensureSurfaceSize:size]; [surfaceManager renderBuffer]; // make sure we have back buffer [surfaceManager swapBuffers]; - id texture = - (reinterpret_cast([surfaceManager renderBuffer])).texture; + id texture = [surfaceManager renderBuffer].texture; CGSize textureSize = CGSizeMake(texture.width, texture.height); ASSERT_TRUE(CGSizeEqualToSize(size, textureSize)); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index 60f3b0c3f70d6..8a92b9f5fbb59 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -12,7 +12,7 @@ @interface FlutterView () { __weak id _reshapeListener; FlutterResizeSynchronizer* _resizeSynchronizer; - id _resizableBackingStoreProvider; + FlutterResizableBackingStoreProvider* _resizableBackingStoreProvider; } @end @@ -29,9 +29,9 @@ - (instancetype)initWithMTLDevice:(id)device [self setLayerContentsRedrawPolicy:NSViewLayerContentsRedrawDuringViewResize]; _reshapeListener = reshapeListener; _resizableBackingStoreProvider = - [[FlutterMetalResizableBackingStoreProvider alloc] initWithDevice:device - commandQueue:commandQueue - layer:self.layer]; + [[FlutterResizableBackingStoreProvider alloc] initWithDevice:device + commandQueue:commandQueue + layer:self.layer]; _resizeSynchronizer = [[FlutterResizeSynchronizer alloc] initWithDelegate:_resizableBackingStoreProvider]; }