Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 8ecb1c9

Browse files
authored
[macOS] Remove OpenGL rendering backend (#37448)
In flutter/buildroot#648 (rolled to the engine in #37380) the minimum macOS SDK was bumped from 10.13 to 10.14. As of macOS 10.14, Metal is available for all users. This eliminates the macOS OpenGL rendering support code. Note that this only removes the GL-specific code in the embedder. A followup patch will land refactorings to clean up the remaining code, for example, cases where a parent interface exists only because we had both a GL and a Metal implementation. This is being does in two patches in order to keep review clear and simple and to simplify rebases of any outstanding patches that also touches this code. Issue: flutter/flutter#114445
1 parent 214b841 commit 8ecb1c9

33 files changed

+18
-1255
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,8 +2589,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/Accessibilit
25892589
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterAppDelegate.mm
25902590
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h
25912591
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm
2592-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h
2593-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm
25942592
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.h
25952593
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponder.mm
25962594
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterChannelKeyResponderUnittests.mm
@@ -2607,16 +2605,8 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngin
26072605
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.h
26082606
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngineTestUtils.mm
26092607
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterEngine_Internal.h
2610-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h
2611-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm
26122608
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.h
26132609
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureMetal.mm
2614-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.h
2615-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProvider.mm
2616-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterFrameBufferProviderUnittests.mm
2617-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h
2618-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm
2619-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm
26202610
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.h
26212611
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterIOSurfaceHolder.mm
26222612
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterKeyPrimaryResponder.h
@@ -2638,18 +2628,13 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMetal
26382628
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalSurfaceManagerTest.mm
26392629
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.h
26402630
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.mm
2641-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h
2642-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.mm
2643-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRendererTest.mm
26442631
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.h
26452632
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMac.mm
26462633
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformNodeDelegateMacTest.mm
26472634
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.h
26482635
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.mm
26492636
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewControllerTest.mm
26502637
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderer.h
2651-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h
2652-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.mm
26532638
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.h
26542639
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizableBackingStoreProvider.mm
26552640
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterResizeSynchronizer.h
@@ -2677,8 +2662,6 @@ FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewE
26772662
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/FlutterViewProvider.h
26782663
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap.g.mm
26792664
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/KeyCodeMap_Internal.h
2680-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.h
2681-
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/MacOSGLContextSwitch.mm
26822665
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.h
26832666
FILE: ../../../flutter/shell/platform/darwin/macos/framework/Source/TestFlutterPlatformView.mm
26842667
FILE: ../../../flutter/shell/platform/darwin/macos/framework/module.modulemap

shell/platform/darwin/macos/BUILD.gn

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ source_set("flutter_framework_source") {
5959
"framework/Source/FlutterAppDelegate.mm",
6060
"framework/Source/FlutterBackingStore.h",
6161
"framework/Source/FlutterBackingStore.mm",
62-
"framework/Source/FlutterBackingStoreData.h",
63-
"framework/Source/FlutterBackingStoreData.mm",
6462
"framework/Source/FlutterChannelKeyResponder.h",
6563
"framework/Source/FlutterChannelKeyResponder.mm",
6664
"framework/Source/FlutterCompositor.h",
@@ -71,14 +69,8 @@ source_set("flutter_framework_source") {
7169
"framework/Source/FlutterEmbedderKeyResponder.mm",
7270
"framework/Source/FlutterEngine.mm",
7371
"framework/Source/FlutterEngine_Internal.h",
74-
"framework/Source/FlutterExternalTextureGL.h",
75-
"framework/Source/FlutterExternalTextureGL.mm",
7672
"framework/Source/FlutterExternalTextureMetal.h",
7773
"framework/Source/FlutterExternalTextureMetal.mm",
78-
"framework/Source/FlutterFrameBufferProvider.h",
79-
"framework/Source/FlutterFrameBufferProvider.mm",
80-
"framework/Source/FlutterGLCompositor.h",
81-
"framework/Source/FlutterGLCompositor.mm",
8274
"framework/Source/FlutterIOSurfaceHolder.h",
8375
"framework/Source/FlutterIOSurfaceHolder.mm",
8476
"framework/Source/FlutterKeyPrimaryResponder.h",
@@ -96,15 +88,11 @@ source_set("flutter_framework_source") {
9688
"framework/Source/FlutterMetalRenderer.mm",
9789
"framework/Source/FlutterMouseCursorPlugin.h",
9890
"framework/Source/FlutterMouseCursorPlugin.mm",
99-
"framework/Source/FlutterOpenGLRenderer.h",
100-
"framework/Source/FlutterOpenGLRenderer.mm",
10191
"framework/Source/FlutterPlatformNodeDelegateMac.h",
10292
"framework/Source/FlutterPlatformNodeDelegateMac.mm",
10393
"framework/Source/FlutterPlatformViewController.h",
10494
"framework/Source/FlutterPlatformViewController.mm",
10595
"framework/Source/FlutterRenderer.h",
106-
"framework/Source/FlutterRenderingBackend.h",
107-
"framework/Source/FlutterRenderingBackend.mm",
10896
"framework/Source/FlutterResizableBackingStoreProvider.h",
10997
"framework/Source/FlutterResizableBackingStoreProvider.mm",
11098
"framework/Source/FlutterResizeSynchronizer.h",
@@ -125,8 +113,6 @@ source_set("flutter_framework_source") {
125113
"framework/Source/FlutterViewEngineProvider.mm",
126114
"framework/Source/FlutterViewProvider.h",
127115
"framework/Source/KeyCodeMap.g.mm",
128-
"framework/Source/MacOSGLContextSwitch.h",
129-
"framework/Source/MacOSGLContextSwitch.mm",
130116
]
131117

132118
sources += _flutter_framework_headers
@@ -190,14 +176,11 @@ executable("flutter_desktop_darwin_unittests") {
190176
"framework/Source/FlutterEngineTest.mm",
191177
"framework/Source/FlutterEngineTestUtils.h",
192178
"framework/Source/FlutterEngineTestUtils.mm",
193-
"framework/Source/FlutterFrameBufferProviderUnittests.mm",
194-
"framework/Source/FlutterGLCompositorUnittests.mm",
195179
"framework/Source/FlutterKeyboardManagerUnittests.mm",
196180
"framework/Source/FlutterMenuPluginTest.mm",
197181
"framework/Source/FlutterMetalCompositorUnittests.mm",
198182
"framework/Source/FlutterMetalRendererTest.mm",
199183
"framework/Source/FlutterMetalSurfaceManagerTest.mm",
200-
"framework/Source/FlutterOpenGLRendererTest.mm",
201184
"framework/Source/FlutterPlatformNodeDelegateMacTest.mm",
202185
"framework/Source/FlutterPlatformViewControllerTest.mm",
203186
"framework/Source/FlutterTextInputPluginTest.mm",

shell/platform/darwin/macos/framework/Source/FlutterBackingStore.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,6 @@
1313

1414
@end
1515

16-
/**
17-
* Wraps an OpenGL frame buffer.
18-
*/
19-
@interface FlutterOpenGLRenderBackingStore : FlutterRenderBackingStore
20-
21-
/**
22-
* Frame buffer ID referenced by this backing store instance.
23-
*/
24-
@property(nonatomic, readonly) uint32_t frameBufferID;
25-
26-
/**
27-
* Initializes a backing store with the specified frame buffer id.
28-
*/
29-
- (nonnull instancetype)initWithFrameBufferID:(uint32_t)fboID;
30-
31-
@end
32-
3316
/**
3417
* Wraps a Metal texture.
3518
*/

shell/platform/darwin/macos/framework/Source/FlutterBackingStore.mm

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
@implementation FlutterRenderBackingStore
88
@end
99

10-
@implementation FlutterOpenGLRenderBackingStore
11-
12-
- (instancetype)initWithFrameBufferID:(uint32_t)fboID {
13-
self = [super init];
14-
if (self) {
15-
_frameBufferID = fboID;
16-
}
17-
return self;
18-
}
19-
20-
@end
21-
2210
@implementation FlutterMetalRenderBackingStore
2311

2412
- (instancetype)initWithTexture:(id<MTLTexture>)texture {

shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.h

Lines changed: 0 additions & 30 deletions
This file was deleted.

shell/platform/darwin/macos/framework/Source/FlutterBackingStoreData.mm

Lines changed: 0 additions & 23 deletions
This file was deleted.

shell/platform/darwin/macos/framework/Source/FlutterEngine.mm

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010
#include <vector>
1111

1212
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h"
13-
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h"
14-
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h"
1513
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMenuPlugin.h"
1614
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h"
1715
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalRenderer.h"
1816
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMouseCursorPlugin.h"
19-
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterOpenGLRenderer.h"
2017
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterPlatformViewController.h"
21-
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterRenderingBackend.h"
2218
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h"
2319
#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewEngineProvider.h"
2420
#include "flutter/shell/platform/embedder/embedder.h"
@@ -251,11 +247,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix
251247
_embedderAPI.struct_size = sizeof(FlutterEngineProcTable);
252248
FlutterEngineGetProcAddresses(&_embedderAPI);
253249

254-
if ([FlutterRenderingBackend renderUsingMetal]) {
255-
_renderer = [[FlutterMetalRenderer alloc] initWithFlutterEngine:self];
256-
} else {
257-
_renderer = [[FlutterOpenGLRenderer alloc] initWithFlutterEngine:self];
258-
}
250+
_renderer = [[FlutterMetalRenderer alloc] initWithFlutterEngine:self];
259251

260252
NSNotificationCenter* notificationCenter = [NSNotificationCenter defaultCenter];
261253
[notificationCenter addObserver:self
@@ -436,16 +428,9 @@ - (FlutterCompositor*)createFlutterCompositor {
436428

437429
__weak FlutterEngine* weakSelf = self;
438430

439-
if ([FlutterRenderingBackend renderUsingMetal]) {
440-
FlutterMetalRenderer* metalRenderer = reinterpret_cast<FlutterMetalRenderer*>(_renderer);
441-
_macOSCompositor = std::make_unique<flutter::FlutterMetalCompositor>(
442-
_viewProvider, _platformViewController, metalRenderer.device);
443-
} else {
444-
FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast<FlutterOpenGLRenderer*>(_renderer);
445-
[openGLRenderer.openGLContext makeCurrentContext];
446-
_macOSCompositor =
447-
std::make_unique<flutter::FlutterGLCompositor>(_viewProvider, openGLRenderer.openGLContext);
448-
}
431+
FlutterMetalRenderer* metalRenderer = reinterpret_cast<FlutterMetalRenderer*>(_renderer);
432+
_macOSCompositor = std::make_unique<flutter::FlutterMetalCompositor>(
433+
_viewProvider, _platformViewController, metalRenderer.device);
449434
_macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) {
450435
if (has_flutter_content) {
451436
return [weakSelf.renderer present] == YES;

shell/platform/darwin/macos/framework/Source/FlutterEngineTest.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323

2424
@interface FlutterEngine (Test)
2525
/**
26-
* The FlutterCompositor object currently in use by the FlutterEngine. This is
27-
* either a FlutterOpenGLCompositor or a FlutterMetalCompositor.
26+
* The FlutterCompositor object currently in use by the FlutterEngine.
2827
*
2928
* May be nil if the compositor has not been initialized yet.
3029
*/

shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

shell/platform/darwin/macos/framework/Source/FlutterExternalTextureGL.mm

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)