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

Commit 0e9ba75

Browse files
authored
Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC (#51633)
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162. Migrate some files from MRC to ARC. These files do not themselves import any MRC files, only ARC-ified files like `FlutterMetalLayer.h`, making them leaf nodes in the dependency graph of MRC files. Just doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues. Part of flutter/flutter#137801. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent c132aa5 commit 0e9ba75

12 files changed

+59
-38
lines changed

shell/platform/darwin/ios/BUILD.gn

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,32 @@ source_set("flutter_framework_source_arc") {
7878
"framework/Source/FlutterTextInputPlugin.mm",
7979
"framework/Source/FlutterTextureRegistryRelay.h",
8080
"framework/Source/FlutterTextureRegistryRelay.mm",
81+
"framework/Source/FlutterUIPressProxy.h",
82+
"framework/Source/FlutterUIPressProxy.mm",
8183
"framework/Source/KeyCodeMap.g.mm",
8284
"framework/Source/KeyCodeMap_Internal.h",
8385
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
8486
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
87+
"framework/Source/connection_collection.h",
88+
"framework/Source/connection_collection.mm",
89+
"framework/Source/platform_message_response_darwin.h",
90+
"framework/Source/platform_message_response_darwin.mm",
91+
"framework/Source/profiler_metrics_ios.h",
92+
"framework/Source/profiler_metrics_ios.mm",
8593
"framework/Source/vsync_waiter_ios.h",
8694
"framework/Source/vsync_waiter_ios.mm",
95+
"ios_context.h",
96+
"ios_context.mm",
97+
"ios_context_metal_impeller.h",
98+
"ios_context_metal_impeller.mm",
99+
"ios_context_metal_skia.h",
100+
"ios_context_metal_skia.mm",
101+
"ios_context_software.h",
102+
"ios_context_software.mm",
103+
"ios_external_texture_metal.h",
104+
"ios_external_texture_metal.mm",
105+
"rendering_api_selection.h",
106+
"rendering_api_selection.mm",
87107
]
88108

89109
frameworks = [
@@ -92,11 +112,16 @@ source_set("flutter_framework_source_arc") {
92112
]
93113

94114
deps += [
115+
":ios_gpu_configuration",
95116
"//flutter/common:common",
117+
"//flutter/common/graphics",
96118
"//flutter/lib/ui",
97119
"//flutter/runtime",
98120
"//flutter/shell/common",
121+
"//flutter/shell/platform/darwin/common",
122+
"//flutter/shell/platform/darwin/graphics",
99123
"//flutter/shell/platform/embedder:embedder_as_internal_library",
124+
"//flutter/shell/profiling:profiling",
100125
]
101126
}
102127

@@ -132,8 +157,6 @@ source_set("flutter_framework_source") {
132157
"framework/Source/FlutterSemanticsScrollView.mm",
133158
"framework/Source/FlutterSpellCheckPlugin.h",
134159
"framework/Source/FlutterSpellCheckPlugin.mm",
135-
"framework/Source/FlutterUIPressProxy.h",
136-
"framework/Source/FlutterUIPressProxy.mm",
137160
"framework/Source/FlutterUndoManagerDelegate.h",
138161
"framework/Source/FlutterUndoManagerPlugin.h",
139162
"framework/Source/FlutterUndoManagerPlugin.mm",
@@ -147,22 +170,6 @@ source_set("flutter_framework_source") {
147170
"framework/Source/accessibility_bridge.mm",
148171
"framework/Source/accessibility_text_entry.h",
149172
"framework/Source/accessibility_text_entry.mm",
150-
"framework/Source/connection_collection.h",
151-
"framework/Source/connection_collection.mm",
152-
"framework/Source/platform_message_response_darwin.h",
153-
"framework/Source/platform_message_response_darwin.mm",
154-
"framework/Source/profiler_metrics_ios.h",
155-
"framework/Source/profiler_metrics_ios.mm",
156-
"ios_context.h",
157-
"ios_context.mm",
158-
"ios_context_metal_impeller.h",
159-
"ios_context_metal_impeller.mm",
160-
"ios_context_metal_skia.h",
161-
"ios_context_metal_skia.mm",
162-
"ios_context_software.h",
163-
"ios_context_software.mm",
164-
"ios_external_texture_metal.h",
165-
"ios_external_texture_metal.mm",
166173
"ios_external_view_embedder.h",
167174
"ios_external_view_embedder.mm",
168175
"ios_surface.h",
@@ -177,8 +184,6 @@ source_set("flutter_framework_source") {
177184
"platform_message_handler_ios.mm",
178185
"platform_view_ios.h",
179186
"platform_view_ios.mm",
180-
"rendering_api_selection.h",
181-
"rendering_api_selection.mm",
182187
]
183188

184189
sources += _flutter_framework_headers
@@ -191,17 +196,14 @@ source_set("flutter_framework_source") {
191196
deps += [
192197
":ios_gpu_configuration",
193198
"//flutter/common",
194-
"//flutter/common/graphics",
195199
"//flutter/flow",
196200
"//flutter/fml",
197-
"//flutter/lib/ui",
198201
"//flutter/runtime",
199202
"//flutter/runtime:libdart",
200203
"//flutter/shell/common",
201204
"//flutter/shell/platform/common:common_cpp_input",
202205
"//flutter/shell/platform/darwin/common",
203206
"//flutter/shell/platform/darwin/common:framework_common",
204-
"//flutter/shell/platform/darwin/graphics",
205207
"//flutter/shell/platform/embedder:embedder_as_internal_library",
206208
"//flutter/shell/profiling:profiling",
207209
"//flutter/skia",

shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h"
6+
57
#import <UIKit/UIKit.h>
68

7-
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h"
9+
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
10+
11+
FLUTTER_ASSERT_ARC
812

913
@interface FlutterUIPressProxy ()
1014
@property(nonatomic, readonly) UIPress* press;

shell/platform/darwin/ios/framework/Source/connection_collection.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/connection_collection.h"
66

7+
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8+
9+
FLUTTER_ASSERT_ARC
10+
711
namespace flutter {
812
ConnectionCollection::Connection ConnectionCollection::AquireConnection(const std::string& name) {
913
Connection nextConnection = ++counter_;

shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#import "flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h"
66

7+
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8+
9+
FLUTTER_ASSERT_ARC
10+
711
namespace flutter {
812

913
PlatformMessageResponseDarwin::PlatformMessageResponseDarwin(

shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
#import <Foundation/Foundation.h>
88

9+
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
910
#import "flutter/shell/platform/darwin/ios/framework/Source/IOKit.h"
1011

12+
FLUTTER_ASSERT_ARC
13+
1114
namespace {
1215

1316
// RAII holder for `thread_array_t` this is so any early returns in

shell/platform/darwin/ios/ios_context.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h"
1111
#include "flutter/shell/platform/darwin/ios/ios_context_software.h"
1212

13+
FLUTTER_ASSERT_ARC
14+
1315
namespace flutter {
1416

1517
IOSContext::IOSContext(MsaaSampleCount msaa_samples) : msaa_samples_(msaa_samples) {}

shell/platform/darwin/ios/ios_context_metal_impeller.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class IOSContextMetalImpeller final : public IOSContext {
2525

2626
~IOSContextMetalImpeller();
2727

28-
fml::scoped_nsobject<FlutterDarwinContextMetalSkia> GetDarwinContext() const;
29-
3028
IOSRenderingBackend GetBackend() const override;
3129

3230
// |IOSContext|

shell/platform/darwin/ios/ios_context_metal_impeller.mm

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "flutter/impeller/entity/mtl/entity_shaders.h"
77
#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
88

9+
FLUTTER_ASSERT_ARC
10+
911
namespace flutter {
1012

1113
IOSContextMetalImpeller::IOSContextMetalImpeller(
@@ -16,11 +18,6 @@
1618

1719
IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
1820

19-
fml::scoped_nsobject<FlutterDarwinContextMetalSkia> IOSContextMetalImpeller::GetDarwinContext()
20-
const {
21-
return fml::scoped_nsobject<FlutterDarwinContextMetalSkia>{};
22-
}
23-
2421
IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
2522
return IOSRenderingBackend::kImpeller;
2623
}
@@ -54,9 +51,9 @@
5451
int64_t texture_id,
5552
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
5653
return std::make_unique<IOSExternalTextureMetal>(
57-
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{
58-
[[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id
59-
texture:texture] retain]});
54+
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{[darwin_context_metal_impeller_
55+
createExternalTextureWithIdentifier:texture_id
56+
texture:texture]});
6057
}
6158

6259
} // namespace flutter

shell/platform/darwin/ios/ios_context_metal_skia.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h"
1111
#include "third_party/skia/include/gpu/GrContextOptions.h"
1212

13+
FLUTTER_ASSERT_ARC
14+
1315
namespace flutter {
1416

1517
IOSContextMetalSkia::IOSContextMetalSkia(MsaaSampleCount msaa_samples) : IOSContext(msaa_samples) {
@@ -52,8 +54,7 @@
5254
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
5355
return std::make_unique<IOSExternalTextureMetal>(
5456
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{
55-
[[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id
56-
texture:texture] retain]});
57+
[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]});
5758
}
5859

5960
} // namespace flutter

shell/platform/darwin/ios/ios_context_software.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#import "flutter/shell/platform/darwin/ios/ios_context_software.h"
66
#include "ios_context.h"
77

8+
FLUTTER_ASSERT_ARC
9+
810
namespace flutter {
911

1012
IOSContextSoftware::IOSContextSoftware() : IOSContext(MsaaSampleCount::kNone) {}

0 commit comments

Comments
 (0)