From d8d6ef63ab4f330c7e73fffb6547d6fd71f8f346 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Fri, 22 Mar 2024 14:22:12 -0700 Subject: [PATCH 1/5] Migrate a few "leaf import" MRC iOS files to ARC --- shell/platform/darwin/ios/BUILD.gn | 29 ++++++++++--------- .../framework/Source/connection_collection.mm | 4 +++ .../platform_message_response_darwin.mm | 4 +++ .../framework/Source/profiler_metrics_ios.mm | 3 ++ shell/platform/darwin/ios/ios_context.mm | 2 ++ .../darwin/ios/ios_context_software.mm | 2 ++ .../darwin/ios/rendering_api_selection.mm | 6 ++-- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 5f97a319f1620..bb9e3eb6c489a 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -82,8 +82,20 @@ source_set("flutter_framework_source_arc") { "framework/Source/KeyCodeMap_Internal.h", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm", + "framework/Source/connection_collection.h", + "framework/Source/connection_collection.mm", + "framework/Source/platform_message_response_darwin.h", + "framework/Source/platform_message_response_darwin.mm", + "framework/Source/profiler_metrics_ios.h", + "framework/Source/profiler_metrics_ios.mm", "framework/Source/vsync_waiter_ios.h", "framework/Source/vsync_waiter_ios.mm", + "ios_context.h", + "ios_context.mm", + "ios_context_software.h", + "ios_context_software.mm", + "rendering_api_selection.h", + "rendering_api_selection.mm", ] frameworks = [ @@ -93,10 +105,13 @@ source_set("flutter_framework_source_arc") { deps += [ "//flutter/common:common", + "//flutter/common/graphics", "//flutter/lib/ui", "//flutter/runtime", "//flutter/shell/common", + "//flutter/shell/platform/darwin/common", "//flutter/shell/platform/embedder:embedder_as_internal_library", + "//flutter/shell/profiling:profiling", ] } @@ -147,20 +162,10 @@ source_set("flutter_framework_source") { "framework/Source/accessibility_bridge.mm", "framework/Source/accessibility_text_entry.h", "framework/Source/accessibility_text_entry.mm", - "framework/Source/connection_collection.h", - "framework/Source/connection_collection.mm", - "framework/Source/platform_message_response_darwin.h", - "framework/Source/platform_message_response_darwin.mm", - "framework/Source/profiler_metrics_ios.h", - "framework/Source/profiler_metrics_ios.mm", - "ios_context.h", - "ios_context.mm", "ios_context_metal_impeller.h", "ios_context_metal_impeller.mm", "ios_context_metal_skia.h", "ios_context_metal_skia.mm", - "ios_context_software.h", - "ios_context_software.mm", "ios_external_texture_metal.h", "ios_external_texture_metal.mm", "ios_external_view_embedder.h", @@ -177,8 +182,6 @@ source_set("flutter_framework_source") { "platform_message_handler_ios.mm", "platform_view_ios.h", "platform_view_ios.mm", - "rendering_api_selection.h", - "rendering_api_selection.mm", ] sources += _flutter_framework_headers @@ -191,10 +194,8 @@ source_set("flutter_framework_source") { deps += [ ":ios_gpu_configuration", "//flutter/common", - "//flutter/common/graphics", "//flutter/flow", "//flutter/fml", - "//flutter/lib/ui", "//flutter/runtime", "//flutter/runtime:libdart", "//flutter/shell/common", diff --git a/shell/platform/darwin/ios/framework/Source/connection_collection.mm b/shell/platform/darwin/ios/framework/Source/connection_collection.mm index fc9e734109ea6..b52eb17f23dbb 100644 --- a/shell/platform/darwin/ios/framework/Source/connection_collection.mm +++ b/shell/platform/darwin/ios/framework/Source/connection_collection.mm @@ -4,6 +4,10 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/connection_collection.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" + +FLUTTER_ASSERT_ARC + namespace flutter { ConnectionCollection::Connection ConnectionCollection::AquireConnection(const std::string& name) { Connection nextConnection = ++counter_; diff --git a/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm b/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm index c823cf3f39bc2..00c155af049ca 100644 --- a/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm +++ b/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm @@ -4,6 +4,10 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" + +FLUTTER_ASSERT_ARC + namespace flutter { PlatformMessageResponseDarwin::PlatformMessageResponseDarwin( diff --git a/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm b/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm index ac04c1183a804..01bb213d12275 100644 --- a/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm +++ b/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm @@ -6,8 +6,11 @@ #import +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/ios/framework/Source/IOKit.h" +FLUTTER_ASSERT_ARC + namespace { // RAII holder for `thread_array_t` this is so any early returns in diff --git a/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 2a5fd7bc5de15..07d55a2cb9fc3 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -10,6 +10,8 @@ #include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h" #include "flutter/shell/platform/darwin/ios/ios_context_software.h" +FLUTTER_ASSERT_ARC + namespace flutter { IOSContext::IOSContext(MsaaSampleCount msaa_samples) : msaa_samples_(msaa_samples) {} diff --git a/shell/platform/darwin/ios/ios_context_software.mm b/shell/platform/darwin/ios/ios_context_software.mm index c58ad6dc93ed8..2c24ce6e158fc 100644 --- a/shell/platform/darwin/ios/ios_context_software.mm +++ b/shell/platform/darwin/ios/ios_context_software.mm @@ -5,6 +5,8 @@ #import "flutter/shell/platform/darwin/ios/ios_context_software.h" #include "ios_context.h" +FLUTTER_ASSERT_ARC + namespace flutter { IOSContextSoftware::IOSContextSoftware() : IOSContext(MsaaSampleCount::kNone) {} diff --git a/shell/platform/darwin/ios/rendering_api_selection.mm b/shell/platform/darwin/ios/rendering_api_selection.mm index b9659796bb9b5..81099d7df1f3f 100644 --- a/shell/platform/darwin/ios/rendering_api_selection.mm +++ b/shell/platform/darwin/ios/rendering_api_selection.mm @@ -12,16 +12,18 @@ #include "flutter/fml/logging.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.h" +FLUTTER_ASSERT_ARC + namespace flutter { bool ShouldUseMetalRenderer() { bool ios_version_supports_metal = false; if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) { - auto device = MTLCreateSystemDefaultDevice(); + id device = MTLCreateSystemDefaultDevice(); ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; - [device release]; } return ios_version_supports_metal; } From 86cb270b40ea72e9398eaf51e37ab21ed29597b9 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 8 Apr 2024 18:16:29 -0700 Subject: [PATCH 2/5] FlutterUIPressProxy --- shell/platform/darwin/ios/BUILD.gn | 4 ++-- .../darwin/ios/framework/Source/FlutterUIPressProxy.mm | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index bb9e3eb6c489a..d0ed93b25db72 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -80,6 +80,8 @@ source_set("flutter_framework_source_arc") { "framework/Source/FlutterTextureRegistryRelay.mm", "framework/Source/KeyCodeMap.g.mm", "framework/Source/KeyCodeMap_Internal.h", + "framework/Source/FlutterUIPressProxy.h", + "framework/Source/FlutterUIPressProxy.mm", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm", "framework/Source/connection_collection.h", @@ -147,8 +149,6 @@ source_set("flutter_framework_source") { "framework/Source/FlutterSemanticsScrollView.mm", "framework/Source/FlutterSpellCheckPlugin.h", "framework/Source/FlutterSpellCheckPlugin.mm", - "framework/Source/FlutterUIPressProxy.h", - "framework/Source/FlutterUIPressProxy.mm", "framework/Source/FlutterUndoManagerDelegate.h", "framework/Source/FlutterUndoManagerPlugin.h", "framework/Source/FlutterUndoManagerPlugin.mm", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm index 8c2ad30a452bf..e324fe500ce8b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm @@ -4,8 +4,11 @@ #import +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" +FLUTTER_ASSERT_ARC + @interface FlutterUIPressProxy () @property(nonatomic, readonly) UIPress* press; @property(nonatomic, readonly) UIEvent* event; From cedec0c531017a5b1c6fec330a643cd0d4df8539 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 8 Apr 2024 18:42:24 -0700 Subject: [PATCH 3/5] context --- shell/platform/darwin/ios/BUILD.gn | 19 ++++++++++--------- .../framework/Source/FlutterUIPressProxy.mm | 5 +++-- .../darwin/ios/ios_context_metal_impeller.mm | 8 +++++--- .../darwin/ios/ios_context_metal_skia.mm | 5 +++-- .../darwin/ios/ios_external_texture_metal.mm | 2 ++ 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index d0ed93b25db72..83e5ed10fedaa 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -78,10 +78,10 @@ source_set("flutter_framework_source_arc") { "framework/Source/FlutterTextInputPlugin.mm", "framework/Source/FlutterTextureRegistryRelay.h", "framework/Source/FlutterTextureRegistryRelay.mm", - "framework/Source/KeyCodeMap.g.mm", - "framework/Source/KeyCodeMap_Internal.h", "framework/Source/FlutterUIPressProxy.h", "framework/Source/FlutterUIPressProxy.mm", + "framework/Source/KeyCodeMap.g.mm", + "framework/Source/KeyCodeMap_Internal.h", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h", "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm", "framework/Source/connection_collection.h", @@ -94,8 +94,14 @@ source_set("flutter_framework_source_arc") { "framework/Source/vsync_waiter_ios.mm", "ios_context.h", "ios_context.mm", + "ios_context_metal_impeller.h", + "ios_context_metal_impeller.mm", + "ios_context_metal_skia.h", + "ios_context_metal_skia.mm", "ios_context_software.h", "ios_context_software.mm", + "ios_external_texture_metal.h", + "ios_external_texture_metal.mm", "rendering_api_selection.h", "rendering_api_selection.mm", ] @@ -106,12 +112,14 @@ source_set("flutter_framework_source_arc") { ] deps += [ + ":ios_gpu_configuration", "//flutter/common:common", "//flutter/common/graphics", "//flutter/lib/ui", "//flutter/runtime", "//flutter/shell/common", "//flutter/shell/platform/darwin/common", + "//flutter/shell/platform/darwin/graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/profiling:profiling", ] @@ -162,12 +170,6 @@ source_set("flutter_framework_source") { "framework/Source/accessibility_bridge.mm", "framework/Source/accessibility_text_entry.h", "framework/Source/accessibility_text_entry.mm", - "ios_context_metal_impeller.h", - "ios_context_metal_impeller.mm", - "ios_context_metal_skia.h", - "ios_context_metal_skia.mm", - "ios_external_texture_metal.h", - "ios_external_texture_metal.mm", "ios_external_view_embedder.h", "ios_external_view_embedder.mm", "ios_surface.h", @@ -202,7 +204,6 @@ source_set("flutter_framework_source") { "//flutter/shell/platform/common:common_cpp_input", "//flutter/shell/platform/darwin/common", "//flutter/shell/platform/darwin/common:framework_common", - "//flutter/shell/platform/darwin/graphics", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/profiling:profiling", "//flutter/skia", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm index e324fe500ce8b..7995280891dec 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm @@ -2,10 +2,11 @@ // 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/ios/framework/Source/FlutterUIPressProxy.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" + +#import FLUTTER_ASSERT_ARC diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index 6d4cfdddb76e4..acb8dac4c3a31 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -6,6 +6,8 @@ #include "flutter/impeller/entity/mtl/entity_shaders.h" #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" +FLUTTER_ASSERT_ARC + namespace flutter { IOSContextMetalImpeller::IOSContextMetalImpeller( @@ -54,9 +56,9 @@ int64_t texture_id, fml::scoped_nsobject> texture) { return std::make_unique( - fml::scoped_nsobject{ - [[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id - texture:texture] retain]}); + fml::scoped_nsobject{[darwin_context_metal_impeller_ + createExternalTextureWithIdentifier:texture_id + texture:texture]}); } } // namespace flutter diff --git a/shell/platform/darwin/ios/ios_context_metal_skia.mm b/shell/platform/darwin/ios/ios_context_metal_skia.mm index 1a4d8c8ed358e..f58ea7c8db0d9 100644 --- a/shell/platform/darwin/ios/ios_context_metal_skia.mm +++ b/shell/platform/darwin/ios/ios_context_metal_skia.mm @@ -10,6 +10,8 @@ #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" #include "third_party/skia/include/gpu/GrContextOptions.h" +FLUTTER_ASSERT_ARC + namespace flutter { IOSContextMetalSkia::IOSContextMetalSkia(MsaaSampleCount msaa_samples) : IOSContext(msaa_samples) { @@ -52,8 +54,7 @@ fml::scoped_nsobject> texture) { return std::make_unique( fml::scoped_nsobject{ - [[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id - texture:texture] retain]}); + [darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]}); } } // namespace flutter diff --git a/shell/platform/darwin/ios/ios_external_texture_metal.mm b/shell/platform/darwin/ios/ios_external_texture_metal.mm index 65171b9186907..4e77bd35b2e66 100644 --- a/shell/platform/darwin/ios/ios_external_texture_metal.mm +++ b/shell/platform/darwin/ios/ios_external_texture_metal.mm @@ -5,6 +5,8 @@ #import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" #include "flow/layers/layer.h" +FLUTTER_ASSERT_ARC + namespace flutter { IOSExternalTextureMetal::IOSExternalTextureMetal( From 03f9b7159578b5db50af57a2b33fce7ffb833b8f Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 10 Apr 2024 20:52:33 -0700 Subject: [PATCH 4/5] import order --- .../darwin/ios/framework/Source/FlutterUIPressProxy.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm index 7995280891dec..540b6ae0beb99 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.mm @@ -4,10 +4,10 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" -#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" - #import +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" + FLUTTER_ASSERT_ARC @interface FlutterUIPressProxy () From d4899bb480c059f255dccbdcd3cf13830d798f93 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 15 Apr 2024 15:02:22 -0700 Subject: [PATCH 5/5] Remove GetDarwinContext --- shell/platform/darwin/ios/ios_context_metal_impeller.h | 2 -- shell/platform/darwin/ios/ios_context_metal_impeller.mm | 5 ----- 2 files changed, 7 deletions(-) diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.h b/shell/platform/darwin/ios/ios_context_metal_impeller.h index 10d9ca0c0ae28..5e2ed7a32dee9 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -25,8 +25,6 @@ class IOSContextMetalImpeller final : public IOSContext { ~IOSContextMetalImpeller(); - fml::scoped_nsobject GetDarwinContext() const; - IOSRenderingBackend GetBackend() const override; // |IOSContext| diff --git a/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/shell/platform/darwin/ios/ios_context_metal_impeller.mm index acb8dac4c3a31..146980c341746 100644 --- a/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -18,11 +18,6 @@ IOSContextMetalImpeller::~IOSContextMetalImpeller() = default; -fml::scoped_nsobject IOSContextMetalImpeller::GetDarwinContext() - const { - return fml::scoped_nsobject{}; -} - IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const { return IOSRenderingBackend::kImpeller; }