Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC (flutter/engine#51633)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/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 https://github.com/flutter/flutter/issues/137801. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -78,12 +78,32 @@ source_set("flutter_framework_source_arc") {
|
||||
"framework/Source/FlutterTextInputPlugin.mm",
|
||||
"framework/Source/FlutterTextureRegistryRelay.h",
|
||||
"framework/Source/FlutterTextureRegistryRelay.mm",
|
||||
"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",
|
||||
"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_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",
|
||||
]
|
||||
|
||||
frameworks = [
|
||||
@@ -92,11 +112,16 @@ 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",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -132,8 +157,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",
|
||||
@@ -147,22 +170,6 @@ 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",
|
||||
"ios_external_view_embedder.mm",
|
||||
"ios_surface.h",
|
||||
@@ -177,8 +184,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,17 +196,14 @@ 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",
|
||||
"//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",
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
// 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/ios/framework/Source/FlutterUIPressProxy.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h"
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
@interface FlutterUIPressProxy ()
|
||||
@property(nonatomic, readonly) UIPress* press;
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -25,8 +25,6 @@ class IOSContextMetalImpeller final : public IOSContext {
|
||||
|
||||
~IOSContextMetalImpeller();
|
||||
|
||||
fml::scoped_nsobject<FlutterDarwinContextMetalSkia> GetDarwinContext() const;
|
||||
|
||||
IOSRenderingBackend GetBackend() const override;
|
||||
|
||||
// |IOSContext|
|
||||
|
||||
@@ -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(
|
||||
@@ -16,11 +18,6 @@ IOSContextMetalImpeller::IOSContextMetalImpeller(
|
||||
|
||||
IOSContextMetalImpeller::~IOSContextMetalImpeller() = default;
|
||||
|
||||
fml::scoped_nsobject<FlutterDarwinContextMetalSkia> IOSContextMetalImpeller::GetDarwinContext()
|
||||
const {
|
||||
return fml::scoped_nsobject<FlutterDarwinContextMetalSkia>{};
|
||||
}
|
||||
|
||||
IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const {
|
||||
return IOSRenderingBackend::kImpeller;
|
||||
}
|
||||
@@ -54,9 +51,9 @@ std::unique_ptr<Texture> IOSContextMetalImpeller::CreateExternalTexture(
|
||||
int64_t texture_id,
|
||||
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
|
||||
return std::make_unique<IOSExternalTextureMetal>(
|
||||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{
|
||||
[[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id
|
||||
texture:texture] retain]});
|
||||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{[darwin_context_metal_impeller_
|
||||
createExternalTextureWithIdentifier:texture_id
|
||||
texture:texture]});
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -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 @@ std::unique_ptr<Texture> IOSContextMetalSkia::CreateExternalTexture(
|
||||
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) {
|
||||
return std::make_unique<IOSExternalTextureMetal>(
|
||||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{
|
||||
[[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id
|
||||
texture:texture] retain]});
|
||||
[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]});
|
||||
}
|
||||
|
||||
} // namespace flutter
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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<MTLDevice> device = MTLCreateSystemDefaultDevice();
|
||||
ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3];
|
||||
[device release];
|
||||
}
|
||||
return ios_version_supports_metal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user