diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 5cb3aed373664..4aa0dd2ac9800 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -2588,8 +2588,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/Accessibilit FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterAppDelegate.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponderUnittests.mm @@ -2606,16 +2604,8 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngin FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyPrimaryResponder.h @@ -2637,9 +2627,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMetal FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalSurfaceManagerTest.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm @@ -2647,8 +2634,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatf FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewControllerTest.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h @@ -2676,8 +2661,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewE FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h -FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.mm FILE: ../../../flutter/shell/platform/darwin/macos/framework/module.modulemap diff --git a/shell/platform/darwin/macos/BUILD.gn b/shell/platform/darwin/macos/BUILD.gn index 72ba77e0aed1b..1802069cd207a 100644 --- a/shell/platform/darwin/macos/BUILD.gn +++ b/shell/platform/darwin/macos/BUILD.gn @@ -59,8 +59,6 @@ source_set("flutter_framework_source") { "framework/Source/FlutterAppDelegate.mm", "framework/Source/FlutterBackingStore.h", "framework/Source/FlutterBackingStore.mm", - "framework/Source/FlutterBackingStoreData.h", - "framework/Source/FlutterBackingStoreData.mm", "framework/Source/FlutterChannelKeyResponder.h", "framework/Source/FlutterChannelKeyResponder.mm", "framework/Source/FlutterCompositor.h", @@ -71,14 +69,8 @@ source_set("flutter_framework_source") { "framework/Source/FlutterEmbedderKeyResponder.mm", "framework/Source/FlutterEngine.mm", "framework/Source/FlutterEngine_Internal.h", - "framework/Source/FlutterExternalTextureGL.h", - "framework/Source/FlutterExternalTextureGL.mm", "framework/Source/FlutterExternalTextureMetal.h", "framework/Source/FlutterExternalTextureMetal.mm", - "framework/Source/FlutterFrameBufferProvider.h", - "framework/Source/FlutterFrameBufferProvider.mm", - "framework/Source/FlutterGLCompositor.h", - "framework/Source/FlutterGLCompositor.mm", "framework/Source/FlutterIOSurfaceHolder.h", "framework/Source/FlutterIOSurfaceHolder.mm", "framework/Source/FlutterKeyPrimaryResponder.h", @@ -96,15 +88,11 @@ source_set("flutter_framework_source") { "framework/Source/FlutterMetalRenderer.mm", "framework/Source/FlutterMouseCursorPlugin.h", "framework/Source/FlutterMouseCursorPlugin.mm", - "framework/Source/FlutterOpenGLRenderer.h", - "framework/Source/FlutterOpenGLRenderer.mm", "framework/Source/FlutterPlatformNodeDelegateMac.h", "framework/Source/FlutterPlatformNodeDelegateMac.mm", "framework/Source/FlutterPlatformViewController.h", "framework/Source/FlutterPlatformViewController.mm", "framework/Source/FlutterRenderer.h", - "framework/Source/FlutterRenderingBackend.h", - "framework/Source/FlutterRenderingBackend.mm", "framework/Source/FlutterResizableBackingStoreProvider.h", "framework/Source/FlutterResizableBackingStoreProvider.mm", "framework/Source/FlutterResizeSynchronizer.h", @@ -125,8 +113,6 @@ source_set("flutter_framework_source") { "framework/Source/FlutterViewEngineProvider.mm", "framework/Source/FlutterViewProvider.h", "framework/Source/KeyCodeMap.g.mm", - "framework/Source/MacOSGLContextSwitch.h", - "framework/Source/MacOSGLContextSwitch.mm", ] sources += _flutter_framework_headers @@ -190,14 +176,11 @@ executable("flutter_desktop_darwin_unittests") { "framework/Source/FlutterEngineTest.mm", "framework/Source/FlutterEngineTestUtils.h", "framework/Source/FlutterEngineTestUtils.mm", - "framework/Source/FlutterFrameBufferProviderUnittests.mm", - "framework/Source/FlutterGLCompositorUnittests.mm", "framework/Source/FlutterKeyboardManagerUnittests.mm", "framework/Source/FlutterMenuPluginTest.mm", "framework/Source/FlutterMetalCompositorUnittests.mm", "framework/Source/FlutterMetalRendererTest.mm", "framework/Source/FlutterMetalSurfaceManagerTest.mm", - "framework/Source/FlutterOpenGLRendererTest.mm", "framework/Source/FlutterPlatformNodeDelegateMacTest.mm", "framework/Source/FlutterPlatformViewControllerTest.mm", "framework/Source/FlutterTextInputPluginTest.mm", diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h index 017fabfe881d2..354d21a6fe59f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h @@ -13,23 +13,6 @@ @end -/** - * Wraps an OpenGL frame buffer. - */ -@interface FlutterOpenGLRenderBackingStore : FlutterRenderBackingStore - -/** - * Frame buffer ID referenced by this backing store instance. - */ -@property(nonatomic, readonly) uint32_t frameBufferID; - -/** - * Initializes a backing store with the specified frame buffer id. - */ -- (nonnull instancetype)initWithFrameBufferID:(uint32_t)fboID; - -@end - /** * Wraps a Metal texture. */ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm index ad1ced7cfb135..8a0119203a975 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm @@ -7,18 +7,6 @@ @implementation FlutterRenderBackingStore @end -@implementation FlutterOpenGLRenderBackingStore - -- (instancetype)initWithFrameBufferID:(uint32_t)fboID { - self = [super init]; - if (self) { - _frameBufferID = fboID; - } - return self; -} - -@end - @implementation FlutterMetalRenderBackingStore - (instancetype)initWithTexture:(id)texture { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h b/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h deleted file mode 100644 index 43e1ea20e2171..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h +++ /dev/null @@ -1,30 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h" - -#import -#import - -/** - * FlutterBackingStoreData holds data to be stored in the - * BackingStore's user_data. - */ -@interface FlutterBackingStoreData : NSObject - -- (nullable instancetype)initWithFbProvider:(nonnull FlutterFrameBufferProvider*)fbProvider - ioSurfaceHolder:(nonnull FlutterIOSurfaceHolder*)ioSurfaceHolder; - -/** - * Provides the fbo for rendering the layer. - */ -@property(nonnull, nonatomic, readonly) FlutterFrameBufferProvider* frameBufferProvider; - -/** - * Contains the IOSurfaceRef with the layer contents. - */ -@property(nonnull, nonatomic, readonly) FlutterIOSurfaceHolder* ioSurfaceHolder; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm b/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm deleted file mode 100644 index 7150ba30baa41..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm +++ /dev/null @@ -1,23 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h" - -#import - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h" - -@implementation FlutterBackingStoreData - -- (nullable instancetype)initWithFbProvider:(nonnull FlutterFrameBufferProvider*)fbProvider - ioSurfaceHolder:(nonnull FlutterIOSurfaceHolder*)ioSurfaceHolder { - if (self = [super init]) { - _frameBufferProvider = fbProvider; - _ioSurfaceHolder = ioSurfaceHolder; - } - return self; -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index d8bf40e3b2cf9..c077930e6f18f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -10,15 +10,11 @@ #include #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalRenderer.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h" #include "flutter/shell/platform/embedder/embedder.h" @@ -251,11 +247,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix _embedderAPI.struct_size = sizeof(FlutterEngineProcTable); FlutterEngineGetProcAddresses(&_embedderAPI); - if ([FlutterRenderingBackend renderUsingMetal]) { - _renderer = [[FlutterMetalRenderer alloc] initWithFlutterEngine:self]; - } else { - _renderer = [[FlutterOpenGLRenderer alloc] initWithFlutterEngine:self]; - } + _renderer = [[FlutterMetalRenderer alloc] initWithFlutterEngine:self]; NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter]; [notificationCenter addObserver:self @@ -436,16 +428,9 @@ - (FlutterCompositor*)createFlutterCompositor { __weak FlutterEngine* weakSelf = self; - if ([FlutterRenderingBackend renderUsingMetal]) { - FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); - _macOSCompositor = std::make_unique( - _viewProvider, _platformViewController, metalRenderer.device); - } else { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(_renderer); - [openGLRenderer.openGLContext makeCurrentContext]; - _macOSCompositor = - std::make_unique(_viewProvider, openGLRenderer.openGLContext); - } + FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); + _macOSCompositor = std::make_unique( + _viewProvider, _platformViewController, metalRenderer.device); _macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) { if (has_flutter_content) { return [weakSelf.renderer present] == YES; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm index f6ac4a37a181a..bcedd7cbd2116 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm @@ -23,8 +23,7 @@ @interface FlutterEngine (Test) /** - * The FlutterCompositor object currently in use by the FlutterEngine. This is - * either a FlutterOpenGLCompositor or a FlutterMetalCompositor. + * The FlutterCompositor object currently in use by the FlutterEngine. * * May be nil if the compositor has not been initialized yet. */ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h b/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h deleted file mode 100644 index 706a8f9873c08..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h +++ /dev/null @@ -1,28 +0,0 @@ -// 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 - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMacOSExternalTexture.h" - -/** - * Used to bridge FlutterTexture object and handle the texture copy request the - * Flutter engine. - */ -@interface FlutterExternalTextureGL : NSObject - -/** - * Initializes a texture adapter with |texture|. - */ -- (nonnull instancetype)initWithFlutterTexture:(nonnull id)texture; - -/** - * Accepts texture buffer copy request from the Flutter engine. - * When the user side marks the textureID as available, the Flutter engine will - * callback to this method and ask for populate the |openGLTexture| object, - * such as the texture type and the format of the pixel buffer and the texture object. - */ -- (BOOL)populateTexture:(nonnull FlutterOpenGLTexture*)openGLTexture; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm b/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm deleted file mode 100644 index 6a2a82031c181..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm +++ /dev/null @@ -1,85 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h" - -#import -#import -#import - -static void OnCVOpenGLTextureRelease(CVOpenGLTextureRef cvOpenGLTexture) { - CVOpenGLTextureRelease(cvOpenGLTexture); -} - -@implementation FlutterExternalTextureGL { - /** - * OpenGL texture cache. - */ - CVOpenGLTextureCacheRef _openGLTextureCache; - /** - * User side texture object, used to copy pixel buffer. - */ - id _texture; -} - -- (instancetype)initWithFlutterTexture:(id)texture { - self = [super init]; - if (self) { - _texture = texture; - } - return self; -} - -- (int64_t)textureID { - return reinterpret_cast(_texture); -} - -- (BOOL)populateTexture:(FlutterOpenGLTexture*)openGLTexture { - // Copy the pixel buffer from the FlutterTexture instance implemented on the user side. - CVPixelBufferRef pixelBuffer = [_texture copyPixelBuffer]; - - if (!pixelBuffer) { - return NO; - } - - // Create the opengl texture cache if necessary. - if (!_openGLTextureCache) { - CGLContextObj context = [NSOpenGLContext currentContext].CGLContextObj; - CGLPixelFormatObj format = CGLGetPixelFormat(context); - if (CVOpenGLTextureCacheCreate(kCFAllocatorDefault, NULL, context, format, NULL, - &_openGLTextureCache) != kCVReturnSuccess) { - NSLog(@"Could not create texture cache."); - CVPixelBufferRelease(pixelBuffer); - return NO; - } - } - - // Try to clear the cache of OpenGL textures to save memory. - CVOpenGLTextureCacheFlush(_openGLTextureCache, 0); - - CVOpenGLTextureRef cvOpenGLTexture = NULL; - if (CVOpenGLTextureCacheCreateTextureFromImage(kCFAllocatorDefault, _openGLTextureCache, - pixelBuffer, NULL, - &cvOpenGLTexture) != kCVReturnSuccess) { - CVPixelBufferRelease(pixelBuffer); - return NO; - } - - openGLTexture->target = static_cast(CVOpenGLTextureGetTarget(cvOpenGLTexture)); - openGLTexture->name = static_cast(CVOpenGLTextureGetName(cvOpenGLTexture)); - openGLTexture->format = static_cast(GL_RGBA8); - openGLTexture->destruction_callback = (VoidCallback)OnCVOpenGLTextureRelease; - openGLTexture->user_data = cvOpenGLTexture; - openGLTexture->width = CVPixelBufferGetWidth(pixelBuffer); - openGLTexture->height = CVPixelBufferGetHeight(pixelBuffer); - - CVPixelBufferRelease(pixelBuffer); - return YES; -} - -- (void)dealloc { - CVOpenGLTextureCacheRelease(_openGLTextureCache); -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h b/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h deleted file mode 100644 index 1a1808440f260..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 - -/** - * Creates framebuffers and their backing textures. - */ -@interface FlutterFrameBufferProvider : NSObject - -- (nullable instancetype)initWithOpenGLContext:(nonnull const NSOpenGLContext*)openGLContext; - -/** - * Returns the id of the framebuffer. - */ -- (uint32_t)glFrameBufferId; - -/** - * Returns the id of the backing texture.. - */ -- (uint32_t)glTextureId; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm b/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm deleted file mode 100644 index c28d904587ec0..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm +++ /dev/null @@ -1,57 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" - -#import - -#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" - -@interface FlutterFrameBufferProvider () { - const NSOpenGLContext* _openGLContext; - uint32_t _frameBufferId; - uint32_t _backingTexture; -} -@end - -@implementation FlutterFrameBufferProvider -- (instancetype)initWithOpenGLContext:(const NSOpenGLContext*)openGLContext { - if (self = [super init]) { - _openGLContext = openGLContext; - MacOSGLContextSwitch context_switch(_openGLContext); - - glGenFramebuffers(1, &_frameBufferId); - glGenTextures(1, &_backingTexture); - - [self createFramebuffer]; - } - return self; -} - -- (void)createFramebuffer { - glBindFramebuffer(GL_FRAMEBUFFER, _frameBufferId); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, _backingTexture); - glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); -} - -- (uint32_t)glFrameBufferId { - return _frameBufferId; -} - -- (uint32_t)glTextureId { - return _backingTexture; -} - -- (void)dealloc { - MacOSGLContextSwitch context_switch(_openGLContext); - - glDeleteFramebuffers(1, &_frameBufferId); - glDeleteTextures(1, &_backingTexture); -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm deleted file mode 100644 index 38437c3a29cbb..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm +++ /dev/null @@ -1,41 +0,0 @@ -// 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 - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" -#import "flutter/testing/testing.h" - -#import - -namespace flutter::testing { - -TEST(FlutterFrameBufferProviderTest, TestCreate) { - NSOpenGLPixelFormatAttribute attributes[] = { - NSOpenGLPFAColorSize, 24, NSOpenGLPFAAlphaSize, 8, 0, - }; - NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; - NSOpenGLContext* context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; - - [context makeCurrentContext]; - FlutterFrameBufferProvider* framebufferProvider = - [[FlutterFrameBufferProvider alloc] initWithOpenGLContext:context]; - - GLuint fbo = [framebufferProvider glFrameBufferId]; - GLuint texture = [framebufferProvider glTextureId]; - - // Normally we'd back this using an IOSurface but for this test let's just create a TexImage2D - // with no backing data. - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); - glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, texture, - 0); - - GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); - - EXPECT_TRUE(status == GL_FRAMEBUFFER_COMPLETE); -} - -} // namespace flutter::testing diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h deleted file mode 100644 index ef704134429d9..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h +++ /dev/null @@ -1,57 +0,0 @@ -// 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. - -#ifndef FLUTTER_GL_COMPOSITOR_H_ -#define FLUTTER_GL_COMPOSITOR_H_ - -#include "flutter/fml/macros.h" -#include "flutter/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h" -#include "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" -#include "flutter/shell/platform/embedder/embedder.h" -#include "third_party/skia/include/gpu/GrDirectContext.h" - -namespace flutter { - -// FlutterGLCompositor creates and manages the backing stores used for -// rendering Flutter content and presents Flutter content and Platform views. -// Platform views are not yet supported. -// FlutterGLCompositor is created and destroyed by FlutterEngine. -class FlutterGLCompositor : public FlutterCompositor { - public: - FlutterGLCompositor(id view_provider, - NSOpenGLContext* opengl_context); - - virtual ~FlutterGLCompositor() = default; - - // Creates a BackingStore and saves updates the backing_store_out - // data with the new BackingStore data. - // If the backing store is being requested for the first time - // for a given frame, this compositor does not create a new backing - // store but rather returns the backing store associated with the - // FlutterView's FlutterSurfaceManager. - // - // Any additional state allocated for the backing store and - // saved as user_data in the backing store must be collected - // in the backing_store's destruction_callback field which will - // be called when the embedder collects the backing store. - bool CreateBackingStore(const FlutterBackingStoreConfig* config, - FlutterBackingStore* backing_store_out) override; - - // Releases the memory for any state used by the backing store. - bool CollectBackingStore(const FlutterBackingStore* backing_store) override; - - // Presents the FlutterLayers by updating FlutterView(s) using the - // layer content. - // Present sets frame_started_ to false. - bool Present(const FlutterLayer** layers, size_t layers_count) override; - - private: - const NSOpenGLContext* open_gl_context_; - - FML_DISALLOW_COPY_AND_ASSIGN(FlutterGLCompositor); -}; - -} // namespace flutter - -#endif // FLUTTER_GL_COMPOSITOR_H_ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm deleted file mode 100644 index 8ab6a993f8c86..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ /dev/null @@ -1,122 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h" - -#import - -#include "flutter/fml/logging.h" -#include "flutter/fml/platform/darwin/cf_utils.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h" -#include "third_party/skia/include/core/SkCanvas.h" -#include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/gpu/gl/GrGLAssembleInterface.h" -#include "third_party/skia/include/utils/mac/SkCGUtils.h" - -namespace flutter { - -FlutterGLCompositor::FlutterGLCompositor(id view_provider, - NSOpenGLContext* opengl_context) - : FlutterCompositor(view_provider), open_gl_context_(opengl_context) {} - -bool FlutterGLCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, - FlutterBackingStore* backing_store_out) { - // TODO(dkwingsmt): This class only supports single-view for now. As more - // classes are gradually converted to multi-view, it should get the view ID - // from somewhere. - FlutterView* view = GetView(kFlutterDefaultViewId); - if (!view) { - return false; - } - - CGSize size = CGSizeMake(config->size.width, config->size.height); - - if (GetFrameStatus() != FrameStatus::kStarted) { - StartFrame(); - // If the backing store is for the first layer, return the fbo for the - // FlutterView. - FlutterOpenGLRenderBackingStore* backingStore = - reinterpret_cast([view backingStoreForSize:size]); - backing_store_out->open_gl.framebuffer.name = backingStore.frameBufferID; - } else { - FlutterFrameBufferProvider* fb_provider = - [[FlutterFrameBufferProvider alloc] initWithOpenGLContext:open_gl_context_]; - FlutterIOSurfaceHolder* io_surface_holder = [FlutterIOSurfaceHolder alloc]; - - GLuint fbo = [fb_provider glFrameBufferId]; - GLuint texture = [fb_provider glTextureId]; - - [io_surface_holder bindSurfaceToTexture:texture fbo:fbo size:size]; - - FlutterBackingStoreData* data = - [[FlutterBackingStoreData alloc] initWithFbProvider:fb_provider - ioSurfaceHolder:io_surface_holder]; - - backing_store_out->open_gl.framebuffer.name = fbo; - backing_store_out->open_gl.framebuffer.user_data = (__bridge_retained void*)data; - } - - backing_store_out->type = kFlutterBackingStoreTypeOpenGL; - backing_store_out->open_gl.type = kFlutterOpenGLTargetTypeFramebuffer; - backing_store_out->open_gl.framebuffer.target = GL_RGBA8; - backing_store_out->open_gl.framebuffer.destruction_callback = [](void* user_data) { - if (user_data != nullptr) { - // This deletes the OpenGL framebuffer object and texture backing it. - CFRelease(user_data); - } - }; - - return true; -} - -bool FlutterGLCompositor::CollectBackingStore(const FlutterBackingStore* backing_store) { - return true; -} - -bool FlutterGLCompositor::Present(const FlutterLayer** layers, size_t layers_count) { - // TODO(dkwingsmt): This class only supports single-view for now. As more - // classes are gradually converted to multi-view, it should get the view ID - // from somewhere. - FlutterView* view = GetView(kFlutterDefaultViewId); - if (!view) { - return false; - } - - SetFrameStatus(FrameStatus::kPresenting); - - bool has_flutter_content = false; - - for (size_t i = 0; i < layers_count; ++i) { - const auto* layer = layers[i]; - FlutterBackingStore* backing_store = const_cast(layer->backing_store); - switch (layer->type) { - case kFlutterLayerContentTypeBackingStore: { - if (backing_store->open_gl.framebuffer.user_data) { - FlutterBackingStoreData* backing_store_data = - (__bridge FlutterBackingStoreData*)backing_store->open_gl.framebuffer.user_data; - - FlutterIOSurfaceHolder* io_surface_holder = [backing_store_data ioSurfaceHolder]; - IOSurfaceRef io_surface = [io_surface_holder ioSurface]; - - // The surface is an OpenGL texture, which means it has origin in bottom left corner - // and needs to be flipped vertically - InsertCALayerForIOSurface(view, io_surface, CATransform3DMakeScale(1, -1, 1)); - } - has_flutter_content = true; - break; - } - case kFlutterLayerContentTypePlatformView: - // Add functionality in follow up PR. - FML_LOG(WARNING) << "Presenting PlatformViews not yet supported"; - break; - }; - } - - return EndFrame(has_flutter_content); -} - -} // namespace flutter diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm deleted file mode 100644 index 82b9a629652db..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm +++ /dev/null @@ -1,63 +0,0 @@ -// 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 -#import - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTestUtils.h" -#import "flutter/testing/testing.h" - -@interface FlutterViewMockProviderGL : NSObject { - FlutterView* _defaultView; -} -/** - * Create a FlutterViewMockProviderGL with the provided view as the default view. - */ -- (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view; -@end - -@implementation FlutterViewMockProviderGL - -- (nonnull instancetype)initWithDefaultView:(nonnull FlutterView*)view { - self = [super init]; - if (self != nil) { - _defaultView = view; - } - return self; -} - -- (nullable FlutterView*)getView:(uint64_t)viewId { - if (viewId == kFlutterDefaultViewId) { - return _defaultView; - } - return nil; -} - -@end - -namespace flutter::testing { -namespace { - -id MockViewProvider() { - id viewMock = OCMClassMock([FlutterView class]); - return [[FlutterViewMockProviderGL alloc] initWithDefaultView:viewMock]; -} -} // namespace - -TEST(FlutterGLCompositorTest, TestPresent) { - std::unique_ptr macos_compositor = - std::make_unique(MockViewProvider(), nullptr); - - bool flag = false; - macos_compositor->SetPresentCallback([f = &flag](bool has_flutter_content) { - *f = true; - return true; - }); - - ASSERT_TRUE(macos_compositor->Present(nil, 0)); - ASSERT_TRUE(flag); -} - -} // namespace flutter::testing diff --git a/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h b/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h index 39b4e4b515dd6..e3a1f8a7113dd 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h @@ -10,11 +10,6 @@ */ @interface FlutterIOSurfaceHolder : NSObject -/** - * Bind the IOSurface to the provided texture and fbo. - */ -- (void)bindSurfaceToTexture:(GLuint)texture fbo:(GLuint)fbo size:(CGSize)size; - /** * Releases the current IOSurface if one exists * and creates a new IOSurface with the specified size. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm b/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm index dc249698ee4f8..d8553507442f9 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm @@ -4,8 +4,6 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h" -#import - @interface FlutterIOSurfaceHolder () { IOSurfaceRef _ioSurface; } @@ -13,24 +11,6 @@ @interface FlutterIOSurfaceHolder () { @implementation FlutterIOSurfaceHolder -- (void)bindSurfaceToTexture:(GLuint)texture fbo:(GLuint)fbo size:(CGSize)size { - [self recreateIOSurfaceWithSize:size]; - - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture); - - CGLTexImageIOSurface2D(CGLGetCurrentContext(), GL_TEXTURE_RECTANGLE_ARB, GL_RGBA, int(size.width), - int(size.height), GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, _ioSurface, - 0 /* plane */); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, 0); - - glBindFramebuffer(GL_FRAMEBUFFER, fbo); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, texture, - 0); - - NSAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, - @"Framebuffer status check failed"); -} - - (void)recreateIOSurfaceWithSize:(CGSize)size { if (_ioSurface) { CFRelease(_ioSurface); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h b/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h deleted file mode 100644 index 2d8bf08d90c08..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h +++ /dev/null @@ -1,53 +0,0 @@ -// 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 - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h" - -/** - * Provides the renderer config needed to initialize the embedder engine and also handles external - * texture management. This is initialized during FlutterEngine creation and then attached to the - * FlutterView once the FlutterViewController is initializer. - */ -@interface FlutterOpenGLRenderer : FlutterTextureRegistrar - -/** - * The resource context used by the engine for texture uploads. FlutterViews associated with this - * engine should be created to share with this context. - */ -@property(nonatomic, readonly, nullable) NSOpenGLContext* resourceContext; - -/** - * The main OpenGL which will be used for rendering contents to the FlutterView. - */ -@property(readwrite, nonatomic, nonnull) NSOpenGLContext* openGLContext; - -/** - * Called by the engine to make the context the engine should draw into current. - */ -- (BOOL)makeCurrent; - -/** - * Called by the engine to clear the context the engine should draw into. - */ -- (BOOL)clearCurrent; - -/** - * Called by the engine when framebuffer object ID is requested. - */ -- (uint32_t)fboForFrameInfo:(nonnull const FlutterFrameInfo*)info; - -/** - * Makes the resource context the current context. - */ -- (BOOL)makeResourceCurrent; - -/** - * Populates the texture registry with the provided openGLTexture. - */ -- (BOOL)populateTextureWithIdentifier:(int64_t)textureID - openGLTexture:(nonnull FlutterOpenGLTexture*)openGLTexture; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm b/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm deleted file mode 100644 index 9c694480d8421..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm +++ /dev/null @@ -1,161 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h" - -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h" - -#pragma mark - Static methods for openGL callbacks that require the engine. - -static bool OnMakeCurrent(FlutterEngine* engine) { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - return [openGLRenderer makeCurrent]; -} - -static bool OnClearCurrent(FlutterEngine* engine) { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - return [openGLRenderer clearCurrent]; -} - -static bool OnPresent(FlutterEngine* engine) { - return [engine.renderer present]; -} - -static uint32_t OnFBO(FlutterEngine* engine, const FlutterFrameInfo* info) { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - return [openGLRenderer fboForFrameInfo:info]; -} - -static bool OnMakeResourceCurrent(FlutterEngine* engine) { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - return [openGLRenderer makeResourceCurrent]; -} - -static bool OnAcquireExternalTexture(FlutterEngine* engine, - int64_t textureIdentifier, - size_t width, - size_t height, - FlutterOpenGLTexture* openGlTexture) { - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - return [openGLRenderer populateTextureWithIdentifier:textureIdentifier - openGLTexture:openGlTexture]; -} - -#pragma mark - FlutterOpenGLRenderer implementation. - -@implementation FlutterOpenGLRenderer { - FlutterView* _flutterView; - - // The context provided to the Flutter engine for rendering to the FlutterView. This is lazily - // created during initialization of the FlutterView. This is used to render content into the - // FlutterView. - NSOpenGLContext* _openGLContext; - - // The context provided to the Flutter engine for resource loading. - NSOpenGLContext* _resourceContext; -} - -- (instancetype)initWithFlutterEngine:(FlutterEngine*)flutterEngine { - self = [super initWithDelegate:self engine:flutterEngine]; - return self; -} - -- (void)setFlutterView:(FlutterView*)view { - _flutterView = view; - if (!view) { - _resourceContext = nil; - } -} - -- (BOOL)makeCurrent { - if (!_openGLContext) { - return false; - } - [_openGLContext makeCurrentContext]; - return true; -} - -- (BOOL)clearCurrent { - [NSOpenGLContext clearCurrentContext]; - return true; -} - -- (BOOL)present { - if (!_openGLContext || !_flutterView) { - return NO; - } - [_flutterView present]; - return YES; -} - -- (void)presentWithoutContent { - if (!_flutterView) { - return; - } - [_flutterView presentWithoutContent]; -} - -- (uint32_t)fboForFrameInfo:(const FlutterFrameInfo*)info { - CGSize size = CGSizeMake(info->size.width, info->size.height); - FlutterOpenGLRenderBackingStore* backingStore = - reinterpret_cast([_flutterView backingStoreForSize:size]); - return backingStore.frameBufferID; -} - -- (NSOpenGLContext*)resourceContext { - if (!_resourceContext) { - NSOpenGLPixelFormatAttribute attributes[] = { - NSOpenGLPFAColorSize, 24, NSOpenGLPFAAlphaSize, 8, 0, - }; - NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; - _resourceContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil]; - } - return _resourceContext; -} - -- (NSOpenGLContext*)openGLContext { - if (!_openGLContext) { - NSOpenGLContext* shareContext = [self resourceContext]; - _openGLContext = [[NSOpenGLContext alloc] initWithFormat:shareContext.pixelFormat - shareContext:shareContext]; - } - return _openGLContext; -} - -- (BOOL)makeResourceCurrent { - [self.resourceContext makeCurrentContext]; - return YES; -} - -#pragma mark - FlutterTextureRegistrar - -- (BOOL)populateTextureWithIdentifier:(int64_t)textureID - openGLTexture:(FlutterOpenGLTexture*)openGLTexture { - id texture = [self getTextureWithID:textureID]; - FlutterExternalTextureGL* glTexture = reinterpret_cast(texture); - return [glTexture populateTexture:openGLTexture]; -} - -- (id)onRegisterTexture:(id)texture { - return [[FlutterExternalTextureGL alloc] initWithFlutterTexture:texture]; -} - -- (FlutterRendererConfig)createRendererConfig { - const FlutterRendererConfig rendererConfig = { - .type = kOpenGL, - .open_gl.struct_size = sizeof(FlutterOpenGLRendererConfig), - .open_gl.make_current = reinterpret_cast(OnMakeCurrent), - .open_gl.clear_current = reinterpret_cast(OnClearCurrent), - .open_gl.present = reinterpret_cast(OnPresent), - .open_gl.fbo_with_frame_info_callback = reinterpret_cast(OnFBO), - .open_gl.fbo_reset_after_present = true, - .open_gl.make_resource_current = reinterpret_cast(OnMakeResourceCurrent), - .open_gl.gl_external_texture_frame_callback = - reinterpret_cast(OnAcquireExternalTexture), - }; - return rendererConfig; -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm b/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm deleted file mode 100644 index 808e32686dd6c..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm +++ /dev/null @@ -1,141 +0,0 @@ -// 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 - -#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterEngine.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" -#include "flutter/shell/platform/embedder/embedder.h" -#include "flutter/shell/platform/embedder/test_utils/proc_table_replacement.h" -#include "flutter/testing/testing.h" - -// MOCK_ENGINE_PROC is leaky by design -// NOLINTBEGIN(clang-analyzer-core.StackAddressEscape) - -@interface TestOpenGLEngine : FlutterEngine - -@property(nonatomic, readwrite) id renderer; - -- (nullable instancetype)initWithGLRenderer; - -@end - -@implementation TestOpenGLEngine - -@synthesize renderer; - -- (nullable instancetype)initWithGLRenderer { - NSString* fixtures = @(flutter::testing::GetFixturesPath()); - FlutterDartProject* project = [[FlutterDartProject alloc] - initWithAssetsPath:fixtures - ICUDataPath:[fixtures stringByAppendingString:@"/icudtl.dat"]]; - self = [self initWithName:@"test" project:project allowHeadlessExecution:true]; - if (self) { - renderer = [[FlutterOpenGLRenderer alloc] initWithFlutterEngine:self]; - } - return self; -} - -@end - -namespace flutter::testing { - -TEST(FlutterOpenGLRenderer, RegisterExternalTexture) { - FlutterEngine* engine = [[TestOpenGLEngine alloc] initWithGLRenderer]; - EXPECT_TRUE([engine runWithEntrypoint:@"main"]); - - id flutterTexture = OCMProtocolMock(@protocol(FlutterTexture)); - bool called = false; - - engine.embedderAPI.RegisterExternalTexture = - MOCK_ENGINE_PROC(RegisterExternalTexture, [&](auto engine, int64_t textureIdentifier) { - called = true; - EXPECT_EQ(textureIdentifier, reinterpret_cast(flutterTexture)); - return kSuccess; - }); - - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - [openGLRenderer registerTexture:flutterTexture]; - EXPECT_TRUE(called); - - [engine shutDownEngine]; -} - -TEST(FlutterOpenGLRenderer, UnregisterExternalTexture) { - FlutterEngine* engine = [[TestOpenGLEngine alloc] initWithGLRenderer]; - EXPECT_TRUE([engine runWithEntrypoint:@"main"]); - - id flutterTexture = OCMProtocolMock(@protocol(FlutterTexture)); - bool called = false; - - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - int64_t registeredTextureId = [openGLRenderer registerTexture:flutterTexture]; - engine.embedderAPI.UnregisterExternalTexture = - MOCK_ENGINE_PROC(UnregisterExternalTexture, [&](auto engine, int64_t textureIdentifier) { - called = true; - EXPECT_EQ(textureIdentifier, registeredTextureId); - return kSuccess; - }); - - [openGLRenderer unregisterTexture:registeredTextureId]; - EXPECT_TRUE(called); - - [engine shutDownEngine]; -} - -TEST(FlutterOpenGLRenderer, MarkExternalTextureFrameAvailable) { - FlutterEngine* engine = [[TestOpenGLEngine alloc] initWithGLRenderer]; - EXPECT_TRUE([engine runWithEntrypoint:@"main"]); - - id flutterTexture = OCMProtocolMock(@protocol(FlutterTexture)); - bool called = false; - - FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(engine.renderer); - int64_t registeredTextureId = [openGLRenderer registerTexture:flutterTexture]; - engine.embedderAPI.MarkExternalTextureFrameAvailable = MOCK_ENGINE_PROC( - MarkExternalTextureFrameAvailable, [&](auto engine, int64_t textureIdentifier) { - called = true; - EXPECT_EQ(textureIdentifier, registeredTextureId); - return kSuccess; - }); - - [openGLRenderer textureFrameAvailable:registeredTextureId]; - EXPECT_TRUE(called); - - [engine shutDownEngine]; -} - -TEST(FlutterOpenGLRenderer, PresetDelegatesToFlutterView) { - FlutterEngine* engine = [[TestOpenGLEngine alloc] initWithGLRenderer]; - FlutterOpenGLRenderer* renderer = [[FlutterOpenGLRenderer alloc] initWithFlutterEngine:engine]; - id mockFlutterView = OCMClassMock([FlutterView class]); - [(FlutterView*)[mockFlutterView expect] present]; - [renderer setFlutterView:mockFlutterView]; - [renderer openGLContext]; - [renderer present]; -} - -TEST(FlutterOpenGLRenderer, FBOReturnedByFlutterView) { - FlutterEngine* engine = [[TestOpenGLEngine alloc] initWithGLRenderer]; - FlutterOpenGLRenderer* renderer = [[FlutterOpenGLRenderer alloc] initWithFlutterEngine:engine]; - id mockFlutterView = OCMClassMock([FlutterView class]); - FlutterFrameInfo frameInfo; - frameInfo.struct_size = sizeof(FlutterFrameInfo); - FlutterUIntSize dimensions; - dimensions.width = 100; - dimensions.height = 200; - frameInfo.size = dimensions; - CGSize size = CGSizeMake(dimensions.width, dimensions.height); - [[mockFlutterView expect] backingStoreForSize:size]; - [renderer setFlutterView:mockFlutterView]; - [renderer openGLContext]; - [renderer fboForFrameInfo:&frameInfo]; -} - -} // namespace flutter::testing - -// NOLINTEND(clang-analyzer-core.StackAddressEscape) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h b/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h deleted file mode 100644 index 7ee9499cf3217..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h +++ /dev/null @@ -1,19 +0,0 @@ -// 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 - -/** - * Flutter on macOS currently supports both OpenGL and Metal rendering backends. This class provides - * utilities for determining the rendering backend and the corresponging layer properties. - */ -@interface FlutterRenderingBackend : NSObject - -/** - * Returns YES if the engine is supposed to use Metal as the rendering backend. On macOS versions - * >= 10.4 this is YES. - */ -+ (BOOL)renderUsingMetal; - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm b/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm deleted file mode 100644 index b9525187f1ffc..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm +++ /dev/null @@ -1,22 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h" - -#import -#import - -@implementation FlutterRenderingBackend - -+ (BOOL)renderUsingMetal { -#ifdef SHELL_ENABLE_METAL - if (@available(macOS 10.14, *)) { - BOOL systemSupportsMetal = MTLCreateSystemDefaultDevice() != nil; - return systemSupportsMetal; - } -#endif - return NO; -} - -@end diff --git a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h index e4510284f42f4..eb8ae31d5963a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h @@ -26,21 +26,6 @@ @end -/** - * OpenGL-backed FlutterResizableBackingStoreProvider. Backing store in this context implies a frame - * buffer. - */ -@interface FlutterOpenGLResizableBackingStoreProvider - : NSObject - -/** - * Creates a resizable backing store provider for the given CALayer. - */ -- (nonnull instancetype)initWithMainContext:(nonnull NSOpenGLContext*)mainContext - layer:(nonnull CALayer*)layer; - -@end - /** * Metal-backed FlutterResizableBackingStoreProvider. Backing store in this context implies a * MTLTexture. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm index 1d4c2921e837e..620c8dbf8cddb 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm @@ -4,50 +4,9 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h" -#import #import #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" - -@implementation FlutterOpenGLResizableBackingStoreProvider { - NSOpenGLContext* _mainContext; - id _surfaceManager; -} - -- (instancetype)initWithMainContext:(NSOpenGLContext*)mainContext layer:(CALayer*)layer { - self = [super init]; - if (self) { - _mainContext = mainContext; - _surfaceManager = [[FlutterGLSurfaceManager alloc] initWithLayer:layer - openGLContext:_mainContext]; - } - return self; -} - -- (void)onBackingStoreResized:(CGSize)size { - [_surfaceManager ensureSurfaceSize:size]; -} - -- (FlutterRenderBackingStore*)backingStore { - return [_surfaceManager renderBuffer]; -} - -- (void)resizeSynchronizerFlush:(nonnull FlutterResizeSynchronizer*)synchronizer { - MacOSGLContextSwitch context_switch(_mainContext); - glFlush(); -} - -- (void)resizeSynchronizerCommit:(nonnull FlutterResizeSynchronizer*)synchronizer { - [CATransaction begin]; - [CATransaction setDisableActions:YES]; - - [_surfaceManager swapBuffers]; - - [CATransaction commit]; -} - -@end @implementation FlutterMetalResizableBackingStoreProvider { id _device; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h b/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h index 03c837d98464b..556856ed3684d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h @@ -12,7 +12,7 @@ @protocol FlutterResizeSynchronizerDelegate /** - * Invoked on raster thread; Delegate should flush the OpenGL context. + * Invoked on raster thread; Delegate should flush the graphics context. */ - (void)resizeSynchronizerFlush:(nonnull FlutterResizeSynchronizer*)synchronizer; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h index 666f8d544e574..cc5ab327823f4 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h @@ -60,9 +60,8 @@ /** * Manages IOSurfaces for the FlutterEngine to render to. * - * The backing store when rendering with OpenGL is a frame buffer backed by a texture, on Metal its - * a Metal texture. There are two IOSurfaces created during initialization, FlutterSurfaceManager - * manages the lifecycle of these. + * The backing store when rendering with on Metal its a Metal texture. There are two IOSurfaces + * created during initialization, FlutterSurfaceManager manages the lifecycle of these. */ @interface FlutterIOSurfaceManager : NSObject @@ -82,20 +81,6 @@ @end -/** - * FlutterSurfaceManager implementation where the IOSurfaces managed are backed by a frame buffers - * which are bound to offscreen textures. - */ -@interface FlutterGLSurfaceManager : FlutterIOSurfaceManager - -/** - * Creates two IOSurfaces backed by frame buffers and their backing textures. - */ -- (nullable instancetype)initWithLayer:(nonnull CALayer*)containingLayer - openGLContext:(nonnull NSOpenGLContext*)openGLContext; - -@end - /** * FlutterSurfaceManager implementation where the IOSurfaces managed are backed by a Metal textures. */ diff --git a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm index b11cd679d7121..938c9cf08ac00 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.mm @@ -5,13 +5,10 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" #import -#import #include -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" enum { kFlutterSurfaceManagerFrontBuffer = 0, @@ -128,53 +125,6 @@ - (nonnull FlutterRenderBackingStore*)renderBuffer { @end -@implementation FlutterGLSurfaceManager { - NSOpenGLContext* _openGLContext; - - FlutterFrameBufferProvider* _frameBuffers[kFlutterSurfaceManagerBufferCount]; -} - -- (instancetype)initWithLayer:(CALayer*)containingLayer - openGLContext:(NSOpenGLContext*)openGLContext { - self = [super initWithLayer:containingLayer contentTransform:CATransform3DMakeScale(1, -1, 1)]; - - if (self) { - super.delegate = self; - _openGLContext = openGLContext; - } - return self; -} - -- (FlutterRenderBackingStore*)renderBuffer { - [self ensureBackBuffer]; - uint32_t fboID = [_frameBuffers[kFlutterSurfaceManagerBackBuffer] glFrameBufferId]; - return [[FlutterOpenGLRenderBackingStore alloc] initWithFrameBufferID:fboID]; -} - -- (void)onSwapBuffers { - std::swap(_frameBuffers[kFlutterSurfaceManagerBackBuffer], - _frameBuffers[kFlutterSurfaceManagerFrontBuffer]); -} - -- (void)onUpdateSurface:(FlutterIOSurfaceHolder*)surface - bufferIndex:(size_t)index - size:(CGSize)size { - if (_frameBuffers[index] == nil) { - _frameBuffers[index] = - [[FlutterFrameBufferProvider alloc] initWithOpenGLContext:_openGLContext]; - } - MacOSGLContextSwitch context_switch(_openGLContext); - GLuint fbo = [_frameBuffers[index] glFrameBufferId]; - GLuint texture = [_frameBuffers[index] glTextureId]; - [surface bindSurfaceToTexture:texture fbo:fbo size:size]; -} - -- (void)onSurfaceReleased:(size_t)index { - _frameBuffers[index] = nil; -} - -@end - @implementation FlutterMetalSurfaceManager { id _device; id _commandQueue; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.h b/shell/platform/darwin/macos/framework/Source/FlutterView.h index f45f94655445b..2da2f48f34963 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.h @@ -42,15 +42,6 @@ constexpr uint64_t kFlutterDefaultViewId = 0; reshapeListener:(nonnull id)reshapeListener NS_DESIGNATED_INITIALIZER; -- (nullable instancetype)initWithFrame:(NSRect)frame - mainContext:(nonnull NSOpenGLContext*)mainContext - reshapeListener:(nonnull id)reshapeListener - NS_DESIGNATED_INITIALIZER; - -- (nullable instancetype)initWithMainContext:(nonnull NSOpenGLContext*)mainContext - reshapeListener: - (nonnull id)reshapeListener; - - (nullable instancetype)initWithFrame:(NSRect)frameRect pixelFormat:(nullable NSOpenGLPixelFormat*)format NS_UNAVAILABLE; - (nonnull instancetype)initWithFrame:(NSRect)frameRect NS_UNAVAILABLE; @@ -58,7 +49,7 @@ constexpr uint64_t kFlutterDefaultViewId = 0; - (nonnull instancetype)init NS_UNAVAILABLE; /** - * Flushes the OpenGL context and flips the surfaces. Expected to be called on raster thread. + * Flushes the graphics context and flips the surfaces. Expected to be called on raster thread. */ - (void)present; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterView.mm b/shell/platform/darwin/macos/framework/Source/FlutterView.mm index b2c85efba3cd4..60f3b0c3f70d6 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterView.mm @@ -4,12 +4,9 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterSurfaceManager.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" -#import #import @interface FlutterView () { @@ -41,28 +38,6 @@ - (instancetype)initWithMTLDevice:(id)device return self; } -- (instancetype)initWithMainContext:(NSOpenGLContext*)mainContext - reshapeListener:(id)reshapeListener { - return [self initWithFrame:NSZeroRect mainContext:mainContext reshapeListener:reshapeListener]; -} - -- (instancetype)initWithFrame:(NSRect)frame - mainContext:(NSOpenGLContext*)mainContext - reshapeListener:(id)reshapeListener { - self = [super initWithFrame:frame]; - if (self) { - [self setWantsLayer:YES]; - [self setBackgroundColor:[NSColor blackColor]]; - _reshapeListener = reshapeListener; - _resizableBackingStoreProvider = - [[FlutterOpenGLResizableBackingStoreProvider alloc] initWithMainContext:mainContext - layer:self.layer]; - _resizeSynchronizer = - [[FlutterResizeSynchronizer alloc] initWithDelegate:_resizableBackingStoreProvider]; - } - return self; -} - - (FlutterRenderBackingStore*)backingStoreForSize:(CGSize)size { if ([_resizeSynchronizer shouldEnsureSurfaceForSize:size]) { [_resizableBackingStoreProvider onBackingStoreResized:size]; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm index d78c3941aa275..7c40c8bb0f2fa 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterViewController.mm @@ -15,8 +15,6 @@ #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyPrimaryResponder.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyboardManager.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalRenderer.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterTextInputSemanticsObject.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" #import "flutter/shell/platform/embedder/embedder.h" @@ -361,27 +359,16 @@ - (BOOL)isDispatchingKeyEvent:(NSEvent*)event { - (void)loadView { FlutterView* flutterView; - if ([FlutterRenderingBackend renderUsingMetal]) { - FlutterMetalRenderer* metalRenderer = reinterpret_cast(_engine.renderer); - id device = metalRenderer.device; - id commandQueue = metalRenderer.commandQueue; - if (!device || !commandQueue) { - NSLog(@"Unable to create FlutterView; no MTLDevice or MTLCommandQueue available."); - return; - } - flutterView = [[FlutterView alloc] initWithMTLDevice:device - commandQueue:commandQueue - reshapeListener:self]; - } else { - FlutterOpenGLRenderer* openGLRenderer = - reinterpret_cast(_engine.renderer); - NSOpenGLContext* mainContext = openGLRenderer.openGLContext; - if (!mainContext) { - NSLog(@"Unable to create FlutterView; no GL context available."); - return; - } - flutterView = [[FlutterView alloc] initWithMainContext:mainContext reshapeListener:self]; + FlutterMetalRenderer* metalRenderer = reinterpret_cast(_engine.renderer); + id device = metalRenderer.device; + id commandQueue = metalRenderer.commandQueue; + if (!device || !commandQueue) { + NSLog(@"Unable to create FlutterView; no MTLDevice or MTLCommandQueue available."); + return; } + flutterView = [[FlutterView alloc] initWithMTLDevice:device + commandQueue:commandQueue + reshapeListener:self]; if (_backgroundColor != nil) { [flutterView setBackgroundColor:_backgroundColor]; } diff --git a/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h b/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h deleted file mode 100644 index 079000dcea91a..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h +++ /dev/null @@ -1,21 +0,0 @@ -// 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 - -/** - * RAII wrapper that sets provided NSOpenGLContext as current and restores - * original context on scope exit. - */ -class MacOSGLContextSwitch { - public: - explicit MacOSGLContextSwitch(const NSOpenGLContext* context); - ~MacOSGLContextSwitch(); - - MacOSGLContextSwitch(const MacOSGLContextSwitch&) = delete; - MacOSGLContextSwitch(MacOSGLContextSwitch&&) = delete; - - private: - NSOpenGLContext* previous_; -}; diff --git a/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.mm b/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.mm deleted file mode 100644 index 73d0bfef51f41..0000000000000 --- a/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.mm +++ /dev/null @@ -1,18 +0,0 @@ -// 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 "flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h" - -MacOSGLContextSwitch::MacOSGLContextSwitch(const NSOpenGLContext* context) { - previous_ = [NSOpenGLContext currentContext]; - [context makeCurrentContext]; -} - -MacOSGLContextSwitch::~MacOSGLContextSwitch() { - if (previous_) { - [previous_ makeCurrentContext]; - } else { - [NSOpenGLContext clearCurrentContext]; - } -}