From a4ddee9dfc16d473d5f62a6db5c0c4f21b4e067c Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 19 Oct 2020 10:52:25 -0700 Subject: [PATCH] Revert "[ios] Refactor IOSSurface factory and unify surface creation (#21877)" This reverts commit 6a3b5feb62cf29481545c1154c14eb2e3890a0cd. --- ci/licenses_golden/licenses_flutter | 2 - shell/platform/darwin/ios/BUILD.gn | 2 - .../ios/framework/Source/FlutterEngine.mm | 26 ++++-------- .../Source/FlutterEnginePlatformViewTest.mm | 1 - .../ios/framework/Source/FlutterOverlayView.h | 2 + .../framework/Source/FlutterOverlayView.mm | 8 ++++ .../framework/Source/FlutterPlatformViews.mm | 9 ++-- .../Source/FlutterPlatformViewsTest.mm | 42 ++++--------------- .../Source/FlutterPlatformViews_Internal.h | 9 +--- .../Source/FlutterPlatformViews_Internal.mm | 5 +-- .../darwin/ios/framework/Source/FlutterView.h | 1 + .../ios/framework/Source/FlutterView.mm | 9 ++++ .../Source/accessibility_bridge_test.mm | 17 +------- .../platform/darwin/ios/ios_surface_factory.h | 39 ----------------- .../darwin/ios/ios_surface_factory.mm | 30 ------------- shell/platform/darwin/ios/platform_view_ios.h | 3 -- .../platform/darwin/ios/platform_view_ios.mm | 8 +--- 17 files changed, 46 insertions(+), 167 deletions(-) delete mode 100644 shell/platform/darwin/ios/ios_surface_factory.h delete mode 100644 shell/platform/darwin/ios/ios_surface_factory.mm diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index a9d8d5cf71974..b1018822b05e9 100755 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1010,8 +1010,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_render_target_gl.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_render_target_gl.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface.mm -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_factory.h -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_factory.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_gl.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_gl.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal.h diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 05c39560e265b..793c97be93701 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -99,8 +99,6 @@ source_set("flutter_framework_source") { "ios_render_target_gl.mm", "ios_surface.h", "ios_surface.mm", - "ios_surface_factory.h", - "ios_surface_factory.mm", "ios_surface_gl.h", "ios_surface_gl.mm", "ios_surface_software.h", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 2c55925a2c4d5..5248f59a98b34 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -28,9 +28,7 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h" #import "flutter/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.h" #import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" -#import "flutter/shell/platform/darwin/ios/ios_context.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -#import "flutter/shell/platform/darwin/ios/ios_surface_factory.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" #include "flutter/shell/profiling/sampling_profiler.h" @@ -65,7 +63,6 @@ @implementation FlutterEngine { fml::WeakPtr _viewController; fml::scoped_nsobject _publisher; - std::shared_ptr _surfaceFactory; std::unique_ptr _platformViewsController; std::unique_ptr _profiler_metrics; std::unique_ptr _profiler; @@ -130,7 +127,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix _pluginPublications = [NSMutableDictionary new]; _registrars = [[NSMutableDictionary alloc] init]; - [self ensurePlatformViewController]; + _platformViewsController.reset(new flutter::FlutterPlatformViewsController()); _binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self]; _connections.reset(new flutter::ConnectionCollection()); @@ -164,16 +161,6 @@ - (instancetype)initWithName:(NSString*)labelPrefix return self; } -- (void)ensurePlatformViewController { - if (!_platformViewsController) { - auto renderingApi = flutter::GetRenderingAPIForProcess(FlutterView.forceSoftwareRendering); - _surfaceFactory = flutter::IOSSurfaceFactory::Create(renderingApi); - auto pvc = new flutter::FlutterPlatformViewsController(_surfaceFactory); - _surfaceFactory->SetPlatformViewsController(pvc); - _platformViewsController.reset(pvc); - } -} - - (void)dealloc { /// Notify plugins of dealloc. This should happen first in dealloc since the /// plugins may be talking to things like the binaryMessenger. @@ -523,13 +510,13 @@ - (BOOL)createShell:(NSString*)entrypoint threadHostType}; // Lambda captures by pointers to ObjC objects are fine here because the - // create call is synchronous. + // create call is + // synchronous. flutter::Shell::CreateCallback on_create_platform_view = - [self](flutter::Shell& shell) { - [self ensurePlatformViewController]; + [](flutter::Shell& shell) { return std::make_unique( shell, flutter::GetRenderingAPIForProcess(FlutterView.forceSoftwareRendering), - self->_surfaceFactory, shell.GetTaskRunners()); + shell.GetTaskRunners()); }; flutter::Shell::CreateCallback on_create_rasterizer = @@ -557,6 +544,9 @@ - (BOOL)createShell:(NSString*)entrypoint [self setupChannels]; [self onLocaleUpdated:nil]; [self initializeDisplays]; + if (!_platformViewsController) { + _platformViewsController.reset(new flutter::FlutterPlatformViewsController()); + } _publisher.reset([[FlutterObservatoryPublisher alloc] initWithEnableObservatoryPublication:settings.enable_observatory_publication]); [self maybeSetupPlatformViewChannels]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm index 3e002e2aa78ee..a202eba4d8d8d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm @@ -67,7 +67,6 @@ - (void)testCallsNotifyLowMemory { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id project = OCMClassMock([FlutterDartProject class]); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h index b77ac7181853f..cb56163c6c5c2 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h @@ -35,6 +35,8 @@ - (instancetype)init NS_DESIGNATED_INITIALIZER; - (instancetype)initWithContentsScale:(CGFloat)contentsScale; +- (std::unique_ptr)createSurface: + (std::shared_ptr)ios_context; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm index 345d3a36798cb..f6a0cd8239756 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.mm @@ -62,6 +62,14 @@ + (Class)layerClass { return [FlutterView layerClass]; } +- (std::unique_ptr)createSurface: + (std::shared_ptr)ios_context { + return flutter::IOSSurface::Create(std::move(ios_context), // context + fml::scoped_nsobject{[self.layer retain]}, // layer + nullptr // platform views controller + ); +} + // TODO(amirh): implement drawLayer to support snapshotting. @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 240134dc4d5b8..c0c185c6ee4b7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -16,7 +16,6 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterOverlayView.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -#import "flutter/shell/platform/darwin/ios/ios_surface_factory.h" #import "flutter/shell/platform/darwin/ios/ios_surface_gl.h" namespace flutter { @@ -33,8 +32,8 @@ overlay_view.reset([[FlutterOverlayView alloc] init]); overlay_view_wrapper.reset([[FlutterOverlayView alloc] init]); - auto ca_layer = fml::scoped_nsobject{[[overlay_view.get() layer] retain]}; - std::unique_ptr ios_surface = ios_surface_factory_->CreateSurface(ca_layer); + std::unique_ptr ios_surface = + [overlay_view.get() createSurface:std::move(ios_context)]; std::unique_ptr surface = ios_surface->CreateGPUSurface(); layer = std::make_shared( @@ -45,8 +44,8 @@ overlay_view.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]); overlay_view_wrapper.reset([[FlutterOverlayView alloc] initWithContentsScale:screenScale]); - auto ca_layer = fml::scoped_nsobject{[[overlay_view.get() layer] retain]}; - std::unique_ptr ios_surface = ios_surface_factory_->CreateSurface(ca_layer); + std::unique_ptr ios_surface = + [overlay_view.get() createSurface:std::move(ios_context)]; std::unique_ptr surface = ios_surface->CreateGPUSurface(gr_context); layer = std::make_shared( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 0a890b7e92882..283a86cf2ae46 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -121,16 +121,12 @@ - (void)testCanCreatePlatformViewWithoutFlutterView { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -179,16 +175,12 @@ - (void)testCompositePlatformView { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -238,16 +230,12 @@ - (void)testChildClippingViewShouldBeTheBoundingRectOfPlatformView { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -313,16 +301,12 @@ - (void)testClipRect { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -389,16 +373,12 @@ - (void)testClipRRect { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -465,16 +445,12 @@ - (void)testClipPath { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; @@ -542,16 +518,12 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - auto surface_factory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surface_factory, /*task_runners=*/runners); - auto flutterPlatformViewsController = - std::make_unique(surface_factory); - surface_factory->SetPlatformViewsController(flutterPlatformViewsController.get()); + auto flutterPlatformViewsController = std::make_unique(); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = [[FlutterPlatformViewsTestMockFlutterPlatformFactory new] autorelease]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index d9638d75b6b15..4fcaaf3874212 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -61,7 +61,6 @@ void ResetAnchor(CALayer* layer); class IOSContextGL; class IOSSurface; -class IOSSurfaceFactory; struct FlutterPlatformViewLayer { FlutterPlatformViewLayer(fml::scoped_nsobject overlay_view, @@ -88,9 +87,7 @@ struct FlutterPlatformViewLayer { // This class isn't thread safe. class FlutterPlatformViewLayerPool { public: - FlutterPlatformViewLayerPool(std::shared_ptr ios_surface_factory) - : ios_surface_factory_(ios_surface_factory) {} - + FlutterPlatformViewLayerPool() = default; ~FlutterPlatformViewLayerPool() = default; // Gets a layer from the pool if available, or allocates a new one. @@ -121,14 +118,12 @@ class FlutterPlatformViewLayerPool { size_t available_layer_index_ = 0; std::vector> layers_; - const std::shared_ptr ios_surface_factory_; - FML_DISALLOW_COPY_AND_ASSIGN(FlutterPlatformViewLayerPool); }; class FlutterPlatformViewsController { public: - FlutterPlatformViewsController(std::shared_ptr surface_factory); + FlutterPlatformViewsController(); ~FlutterPlatformViewsController(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index a46684ccb1064..a6d3d03653b17 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -23,9 +23,8 @@ FlutterPlatformViewLayer::~FlutterPlatformViewLayer() = default; -FlutterPlatformViewsController::FlutterPlatformViewsController( - std::shared_ptr surface_factory) - : layer_pool_(std::make_unique(surface_factory)), +FlutterPlatformViewsController::FlutterPlatformViewsController() + : layer_pool_(std::make_unique()), weak_factory_(std::make_unique>(this)){}; FlutterPlatformViewsController::~FlutterPlatformViewsController() = default; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.h b/shell/platform/darwin/ios/framework/Source/FlutterView.h index 13d7b6ec27cee..3a9c138de02aa 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.h @@ -32,6 +32,7 @@ - (instancetype)initWithDelegate:(id)delegate opaque:(BOOL)opaque NS_DESIGNATED_INITIALIZER; +- (std::unique_ptr)createSurface:(std::shared_ptr)context; // Set by FlutterEngine or FlutterViewController to override software rendering. @property(class, nonatomic) BOOL forceSoftwareRendering; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterView.mm b/shell/platform/darwin/ios/framework/Source/FlutterView.mm index 73a9b8b529088..3f6b19decdac3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterView.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterView.mm @@ -83,6 +83,15 @@ + (Class)layerClass { flutter::GetRenderingAPIForProcess(FlutterView.forceSoftwareRendering)); } +- (std::unique_ptr)createSurface: + (std::shared_ptr)ios_context { + return flutter::IOSSurface::Create( + std::move(ios_context), // context + fml::scoped_nsobject{[self.layer retain]}, // layer + [_delegate platformViewsController] // platform views controller + ); +} + - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context { TRACE_EVENT0("flutter", "SnapshotFlutterView"); diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index 754495cc527f4..41970e67c8f73 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -137,7 +137,6 @@ - (void)testCreate { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); auto bridge = std::make_unique(/*view=*/nil, @@ -157,7 +156,6 @@ - (void)testUpdateSemanticsEmpty { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -184,7 +182,6 @@ - (void)testUpdateSemanticsOneNode { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -227,12 +224,9 @@ - (void)testSemanticsDeallocated { /*raster=*/thread_task_runner, /*ui=*/thread_task_runner, /*io=*/thread_task_runner); - - auto surfaceFactory = flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware); auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - /*ios_surface_factory=*/surfaceFactory, /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -240,9 +234,8 @@ - (void)testSemanticsDeallocated { std::string label = "some label"; auto flutterPlatformViewsController = - std::make_unique(surfaceFactory); + std::make_unique(); flutterPlatformViewsController->SetFlutterView(mockFlutterView); - surfaceFactory->SetPlatformViewsController(flutterPlatformViewsController.get()); MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory new] autorelease]; flutterPlatformViewsController->RegisterViewFactory( @@ -286,7 +279,6 @@ - (void)testAnnouncesRouteChanges { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -352,7 +344,6 @@ - (void)testAnnouncesRouteChangesWhenNoNamesRoute { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -420,7 +411,6 @@ - (void)testAnnouncesLayoutChangeWithNilIfLastFocusIsRemoved { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); @@ -487,7 +477,6 @@ - (void)testAnnouncesLayoutChangeWithLastFocused { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); @@ -560,7 +549,6 @@ - (void)testAnnouncesLayoutChangeWhenFocusMovedOutside { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); @@ -635,7 +623,6 @@ - (void)testAnnouncesScrollChangeWithLastFocused { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); id mockFlutterView = OCMClassMock([FlutterView class]); @@ -706,7 +693,6 @@ - (void)testAnnouncesIgnoresRouteChangesWhenModal { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); id mockFlutterView = OCMClassMock([FlutterView class]); id mockFlutterViewController = OCMClassMock([FlutterViewController class]); @@ -774,7 +760,6 @@ - (void)testAccessibilityMessageAfterDeletion { auto platform_view = std::make_unique( /*delegate=*/mock_delegate, /*rendering_api=*/flutter::IOSRenderingAPI::kSoftware, - flutter::IOSSurfaceFactory::Create(flutter::IOSRenderingAPI::kSoftware), /*task_runners=*/runners); fml::AutoResetWaitableEvent latch; thread_task_runner->PostTask([&] { diff --git a/shell/platform/darwin/ios/ios_surface_factory.h b/shell/platform/darwin/ios/ios_surface_factory.h deleted file mode 100644 index a692c56754887..0000000000000 --- a/shell/platform/darwin/ios/ios_surface_factory.h +++ /dev/null @@ -1,39 +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_SHELL_PLATFORM_DARWIN_IOS_IOS__SURFACE_FACTORY_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS__SURFACE_FACTORY_H_ - -#include - -#import "flutter/shell/platform/darwin/ios/ios_surface.h" -#import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" - -namespace flutter { - -class IOSSurfaceFactory { - public: - static std::shared_ptr Create( - IOSRenderingAPI rendering_api); - - explicit IOSSurfaceFactory(std::shared_ptr ios_context); - - ~IOSSurfaceFactory(); - - void SetPlatformViewsController( - FlutterPlatformViewsController* platform_views_controller); - - std::unique_ptr CreateSurface( - fml::scoped_nsobject ca_layer); - - private: - FlutterPlatformViewsController* platform_views_controller_; - std::shared_ptr ios_context_; - - FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceFactory); -}; - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS__SURFACE_FACTORY_H_ diff --git a/shell/platform/darwin/ios/ios_surface_factory.mm b/shell/platform/darwin/ios/ios_surface_factory.mm deleted file mode 100644 index 4ed7d4c0b96a9..0000000000000 --- a/shell/platform/darwin/ios/ios_surface_factory.mm +++ /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/ios/ios_surface_factory.h" -#import "flutter/shell/platform/darwin/ios/ios_context.h" - -namespace flutter { - -IOSSurfaceFactory::IOSSurfaceFactory(std::shared_ptr ios_context) - : ios_context_(ios_context) {} - -std::shared_ptr IOSSurfaceFactory::Create(IOSRenderingAPI rendering_api) { - std::shared_ptr ios_context = IOSContext::Create(rendering_api); - return std::make_shared(ios_context); -} - -IOSSurfaceFactory::~IOSSurfaceFactory() = default; - -void IOSSurfaceFactory::SetPlatformViewsController( - FlutterPlatformViewsController* platform_views_controller) { - platform_views_controller_ = platform_views_controller; -} - -std::unique_ptr IOSSurfaceFactory::CreateSurface( - fml::scoped_nsobject ca_layer) { - return flutter::IOSSurface::Create(ios_context_, ca_layer, platform_views_controller_); -} - -} // namespace flutter diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index 661d5e57f5b85..8e63bbda2f132 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -19,7 +19,6 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/platform_message_router.h" #import "flutter/shell/platform/darwin/ios/ios_context.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -#import "flutter/shell/platform/darwin/ios/ios_surface_factory.h" #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" @class FlutterViewController; @@ -42,7 +41,6 @@ class PlatformViewIOS final : public PlatformView { public: explicit PlatformViewIOS(PlatformView::Delegate& delegate, IOSRenderingAPI rendering_api, - std::shared_ptr surface_factory, flutter::TaskRunners task_runners); ~PlatformViewIOS() override; @@ -126,7 +124,6 @@ class PlatformViewIOS final : public PlatformView { std::mutex ios_surface_mutex_; std::unique_ptr ios_surface_; std::shared_ptr ios_context_; - std::shared_ptr ios_surface_factory_; PlatformMessageRouter platform_message_router_; AccessibilityBridgePtr accessibility_bridge_; fml::scoped_nsprotocol text_input_plugin_; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 43543c1e2fcde..faf764be7cb0c 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -3,7 +3,6 @@ // found in the LICENSE file. #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" -#include #include @@ -47,11 +46,9 @@ PlatformViewIOS::PlatformViewIOS(PlatformView::Delegate& delegate, IOSRenderingAPI rendering_api, - std::shared_ptr surface_factory, flutter::TaskRunners task_runners) : PlatformView(delegate, std::move(task_runners)), ios_context_(IOSContext::Create(rendering_api)), - ios_surface_factory_(surface_factory), accessibility_bridge_([this](bool enabled) { PlatformView::SetSemanticsEnabled(enabled); }) {} PlatformViewIOS::~PlatformViewIOS() = default; @@ -105,9 +102,8 @@ FML_DCHECK(owner_controller_.get().isViewLoaded) << "FlutterViewController's view should be loaded " "before attaching to PlatformViewIOS."; - auto flutter_view = static_cast(owner_controller_.get().view); - auto ca_layer = fml::scoped_nsobject{[[flutter_view layer] retain]}; - ios_surface_ = ios_surface_factory_->CreateSurface(ca_layer); + ios_surface_ = + [static_cast(owner_controller_.get().view) createSurface:ios_context_]; FML_DCHECK(ios_surface_ != nullptr); if (accessibility_bridge_) {