diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 60e56ffb8f7..9c2453fb471 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -43431,12 +43431,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context.h + ../../../flut ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_software.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_context_software.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.h + ../../../flutter/LICENSE @@ -43445,12 +43441,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface.h + ../../../flut ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm + ../../../flutter/LICENSE @@ -46420,12 +46412,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_context.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm -FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.h -FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_noop.mm -FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.h -FILE: ../../../flutter/shell/platform/darwin/ios/ios_context_software.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_texture_metal.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_external_view_embedder.h @@ -46434,12 +46422,8 @@ 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_metal_impeller.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.h FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_noop.mm -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.h -FILE: ../../../flutter/shell/platform/darwin/ios/ios_surface_software.mm FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.h FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios.mm FILE: ../../../flutter/shell/platform/darwin/ios/platform_message_handler_ios_test.mm diff --git a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn index 6020365844a..508d7c11420 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn @@ -130,12 +130,8 @@ source_set("flutter_framework_source") { "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_noop.h", "ios_context_noop.mm", - "ios_context_software.h", - "ios_context_software.mm", "ios_external_texture_metal.h", "ios_external_texture_metal.mm", "ios_external_view_embedder.h", @@ -144,12 +140,8 @@ source_set("flutter_framework_source") { "ios_surface.mm", "ios_surface_metal_impeller.h", "ios_surface_metal_impeller.mm", - "ios_surface_metal_skia.h", - "ios_surface_metal_skia.mm", "ios_surface_noop.h", "ios_surface_noop.mm", - "ios_surface_software.h", - "ios_surface_software.mm", "platform_message_handler_ios.h", "platform_message_handler_ios.mm", "platform_view_ios.h", @@ -260,7 +252,6 @@ shared_library("ios_test_flutter") { "//flutter/shell/platform/darwin/common:framework_common", "//flutter/shell/platform/embedder:embedder_as_internal_library", "//flutter/shell/platform/embedder:embedder_test_utils", - "//flutter/skia", "//flutter/third_party/ocmock:ocmock_shared", "//flutter/third_party/rapidjson", "//flutter/third_party/spring_animation", diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h index 5b55ce6d72f..165808cc69f 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h @@ -14,7 +14,6 @@ #include "flutter/fml/task_runner.h" #include "flutter/fml/trace_event.h" #include "impeller/base/thread_safety.h" -#include "third_party/skia/include/core/SkRect.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterChannels.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlatformViews.h" @@ -99,8 +98,7 @@ NS_ASSUME_NONNULL_BEGIN /// /// Called from the raster thread. - (BOOL)submitFrame:(std::unique_ptr)frame - withIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext* _Nullable)grContext; + withIosContext:(const std::shared_ptr&)iosContext; /// @brief Handler for platform view message channels. - (void)onMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm index abe3571ae5a..647f68d47a7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm @@ -15,12 +15,6 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -// The number of frames the rasterizer task runner will continue -// to run on the platform thread after no platform view is rendered. -// -// Note: this is an arbitrary number. -static constexpr int kDefaultMergedLeaseDuration = 10; - static constexpr NSUInteger kFlutterClippingMaskViewPoolCapacity = 5; struct LayerData { @@ -202,8 +196,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, /// /// This requires posting a task to the platform thread and blocking on its completion. - (void)createMissingOverlays:(size_t)requiredOverlayLayers - withIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext*)grContext; + withIosContext:(const std::shared_ptr&)iosContext; /// Update the buffers and mutate the platform views in CATransaction on the platform thread. - (void)performSubmit:(const LayersMap&)platformViewLayers @@ -248,7 +241,6 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, /// Runs on the platform thread. - (void)createLayerWithIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext*)grContext pixelFormat:(MTLPixelFormat)pixelFormat screenScale:(CGFloat)screenScale; @@ -458,49 +450,12 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, - (flutter::PostPrerollResult)postPrerollActionWithThreadMerger: (const fml::RefPtr&)rasterThreadMerger impellerEnabled:(BOOL)impellerEnabled { - // TODO(jonahwilliams): remove this once Software backend is removed for iOS Sim. -#ifdef FML_OS_IOS_SIMULATOR - const bool mergeThreads = true; -#else - const bool mergeThreads = !impellerEnabled; -#endif // FML_OS_IOS_SIMULATOR - - if (mergeThreads) { - if (self.compositionOrder.empty()) { - return flutter::PostPrerollResult::kSuccess; - } - if (!rasterThreadMerger->IsMerged()) { - // The raster thread merger may be disabled if the rasterizer is being - // created or teared down. - // - // In such cases, the current frame is dropped, and a new frame is attempted - // with the same layer tree. - // - // Eventually, the frame is submitted once this method returns `kSuccess`. - // At that point, the raster tasks are handled on the platform thread. - [self cancelFrame]; - return flutter::PostPrerollResult::kSkipAndRetryFrame; - } - // If the post preroll action is successful, we will display platform views in the current - // frame. In order to sync the rendering of the platform views (quartz) with skia's rendering, - // We need to begin an explicit CATransaction. This transaction needs to be submitted - // after the current frame is submitted. - rasterThreadMerger->ExtendLeaseTo(kDefaultMergedLeaseDuration); - } return flutter::PostPrerollResult::kSuccess; } - (void)endFrameWithResubmit:(BOOL)shouldResubmitFrame threadMerger:(const fml::RefPtr&)rasterThreadMerger impellerEnabled:(BOOL)impellerEnabled { -#if FML_OS_IOS_SIMULATOR - BOOL runCheck = YES; -#else - BOOL runCheck = !impellerEnabled; -#endif // FML_OS_IOS_SIMULATOR - if (runCheck && shouldResubmitFrame) { - rasterThreadMerger->MergeWithLease(kDefaultMergedLeaseDuration); - } } - (void)pushFilterToVisitedPlatformViews:(const std::shared_ptr&)filter @@ -733,8 +688,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } - (BOOL)submitFrame:(std::unique_ptr)background_frame - withIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext*)grContext { + withIosContext:(const std::shared_ptr&)iosContext { TRACE_EVENT0("flutter", "PlatformViewsController::SubmitFrame"); // No platform views to render; we're done. @@ -769,7 +723,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, // If there are not sufficient overlay layers, we must construct them on the platform // thread, at least until we've refactored iOS surface creation to use IOSurfaces // instead of CALayers. - [self createMissingOverlays:requiredOverlayLayers withIosContext:iosContext grContext:grContext]; + [self createMissingOverlays:requiredOverlayLayers withIosContext:iosContext]; int64_t overlayId = 0; for (int64_t viewId : self.compositionOrder) { @@ -847,8 +801,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } - (void)createMissingOverlays:(size_t)requiredOverlayLayers - withIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext*)grContext { + withIosContext:(const std::shared_ptr&)iosContext { TRACE_EVENT0("flutter", "PlatformViewsController::CreateMissingLayers"); if (requiredOverlayLayers <= self.layerPool->size()) { @@ -860,10 +813,9 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, // complete. auto latch = std::make_shared(1u); fml::TaskRunner::RunNowOrPostTask( - self.platformTaskRunner, [self, missingLayerCount, iosContext, grContext, latch]() { + self.platformTaskRunner, [self, missingLayerCount, iosContext, latch]() { for (auto i = 0u; i < missingLayerCount; i++) { [self createLayerWithIosContext:iosContext - grContext:grContext pixelFormat:((FlutterView*)self.flutterView).pixelFormat screenScale:((FlutterView*)self.flutterView).screen.scale]; } @@ -969,10 +921,9 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } - (void)createLayerWithIosContext:(const std::shared_ptr&)iosContext - grContext:(GrDirectContext*)grContext pixelFormat:(MTLPixelFormat)pixelFormat screenScale:(CGFloat)screenScale { - self.layerPool->CreateLayer(grContext, iosContext, pixelFormat, screenScale); + self.layerPool->CreateLayer(iosContext, pixelFormat, screenScale); } - (void)removeUnusedLayers:(const std::vector>&)unusedLayers diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 2f0e413be1f..78f2d4ce513 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -3573,8 +3573,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertFalse([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); auto embeddedViewParams_2 = std::make_unique(finalMatrix, SkSize::Make(300, 300), stack); @@ -3591,8 +3590,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface_submit_true) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); } - (void) @@ -3645,7 +3643,7 @@ fml::RefPtr GetDefaultTaskRunner() { [flutterPlatformViewsController prerollCompositeEmbeddedView:2 withParams:std::move(embeddedViewParams)]; - // Not calling |[flutterPlatformViewsController submitFrame:withIosContext:grContext:]| so that + // Not calling |[flutterPlatformViewsController submitFrame:withIosContext:]| so that // the platform views are not added to flutter_view_. XCTAssertNotNil(gMockPlatformView); @@ -3806,8 +3804,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); // platform view is wrapped by touch interceptor, which itself is wrapped by clipping view. UIView* clippingView1 = view1.superview.superview; @@ -3837,8 +3834,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] > [flutterView.subviews indexOfObject:clippingView2], @@ -3924,8 +3920,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); // platform view is wrapped by touch interceptor, which itself is wrapped by clipping view. UIView* clippingView1 = view1.superview.superview; @@ -3955,8 +3950,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); XCTAssertTrue([flutterView.subviews indexOfObject:clippingView1] < [flutterView.subviews indexOfObject:clippingView2], @@ -4439,8 +4433,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); // Disposing won't remove embedded views until the view is removed from the composition_order_ XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 2UL); @@ -4469,8 +4462,7 @@ fml::RefPtr GetDefaultTaskRunner() { /*frame_size=*/SkISize::Make(800, 600)); XCTAssertTrue([flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]); + withIosContext:std::make_shared()]); // Disposing won't remove embedded views until the view is removed from the composition_order_ XCTAssertEqual(flutterPlatformViewsController.embeddedViewCount, 1UL); @@ -4547,8 +4539,7 @@ fml::RefPtr GetDefaultTaskRunner() { [](const flutter::SurfaceFrame& surface_frame) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); [flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]; + withIosContext:std::make_shared()]; UIView* someView = [[UIView alloc] init]; [flutterView addSubview:someView]; @@ -4628,8 +4619,7 @@ fml::RefPtr GetDefaultTaskRunner() { [](const flutter::SurfaceFrame& surface_frame) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); [flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]; + withIosContext:std::make_shared()]; XCTAssertEqual(flutterView.subviews.count, 1u); } @@ -4642,19 +4632,18 @@ fml::RefPtr GetDefaultTaskRunner() { } - (void)testLayerPool { - // Create an IOSContext and GrDirectContext. + // Create an IOSContext. FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"]; [engine run]; XCTAssertTrue(engine.platformView != nullptr); auto ios_context = engine.platformView->GetIosContext(); - auto gr_context = ios_context->GetMainContext(); auto pool = flutter::OverlayLayerPool{}; // Add layers to the pool. - pool.CreateLayer(gr_context.get(), ios_context, MTLPixelFormatBGRA8Unorm, 1); + pool.CreateLayer(ios_context, MTLPixelFormatBGRA8Unorm, 1); XCTAssertEqual(pool.size(), 1u); - pool.CreateLayer(gr_context.get(), ios_context, MTLPixelFormatBGRA8Unorm, 1); + pool.CreateLayer(ios_context, MTLPixelFormatBGRA8Unorm, 1); XCTAssertEqual(pool.size(), 2u); // Mark all layers as unused. @@ -4751,8 +4740,7 @@ fml::RefPtr GetDefaultTaskRunner() { }); [flutterPlatformViewsController submitFrame:std::move(mock_surface) - withIosContext:std::make_shared() - grContext:nil]; + withIosContext:std::make_shared()]; XCTAssertTrue(submit_info.has_value()); XCTAssertEqual(*submit_info->frame_damage, SkIRect::MakeWH(800, 600)); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 0ac51f45595..ca23ced6a1b 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -19,7 +19,6 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h" #include "flutter/shell/platform/darwin/ios/ios_context.h" -#include "third_party/skia/include/core/SkRect.h" // A UIView that acts as a clipping mask for the |ChildClippingView|. // diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h index e808b88d20f..b397d42f418 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h @@ -22,7 +22,6 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" #import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge_ios.h" -#include "third_party/skia/include/core/SkRect.h" namespace flutter { class PlatformViewIOS; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h index c9137d0d2a3..7f35880fafe 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.h @@ -35,11 +35,6 @@ struct OverlayLayer { // Whether a frame for this layer was submitted. bool did_submit_last_frame; - // The GrContext that is currently used by the overlay surfaces. - // We track this to know when the GrContext for the Flutter app has changed - // so we can update the overlay with the new context. - GrDirectContext* gr_context; - void UpdateViewState(UIView* flutter_view, SkRect rect, int64_t view_id, int64_t overlay_id); }; @@ -63,8 +58,7 @@ class OverlayLayerPool { /// @brief Create a new overlay layer. /// /// This method can only be called on the Platform thread. - void CreateLayer(GrDirectContext* gr_context, - const std::shared_ptr& ios_context, + void CreateLayer(const std::shared_ptr& ios_context, MTLPixelFormat pixel_format, CGFloat screenScale); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm index da5c518a04d..89b61ca3578 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm @@ -53,8 +53,7 @@ std::shared_ptr OverlayLayerPool::GetNextLayer() { return result; } -void OverlayLayerPool::CreateLayer(GrDirectContext* gr_context, - const std::shared_ptr& ios_context, +void OverlayLayerPool::CreateLayer(const std::shared_ptr& ios_context, MTLPixelFormat pixel_format, CGFloat screenScale) { FML_DCHECK([[NSThread currentThread] isMainThread]); @@ -62,31 +61,17 @@ void OverlayLayerPool::CreateLayer(GrDirectContext* gr_context, UIView* overlay_view; UIView* overlay_view_wrapper; - bool impeller_enabled = !!ios_context->GetImpellerContext(); - if (!gr_context && !impeller_enabled) { - overlay_view = [[FlutterOverlayView alloc] init]; - overlay_view_wrapper = [[FlutterOverlayView alloc] init]; + overlay_view = [[FlutterOverlayView alloc] initWithContentsScale:screenScale + pixelFormat:pixel_format]; + overlay_view_wrapper = [[FlutterOverlayView alloc] initWithContentsScale:screenScale + pixelFormat:pixel_format]; - CALayer* ca_layer = overlay_view.layer; - std::unique_ptr ios_surface = IOSSurface::Create(ios_context, ca_layer); - std::unique_ptr surface = ios_surface->CreateGPUSurface(); + CALayer* ca_layer = overlay_view.layer; + std::unique_ptr ios_surface = IOSSurface::Create(ios_context, ca_layer); + std::unique_ptr surface = ios_surface->CreateGPUSurface(); - layer = std::make_shared(overlay_view, overlay_view_wrapper, - std::move(ios_surface), std::move(surface)); - } else { - overlay_view = [[FlutterOverlayView alloc] initWithContentsScale:screenScale - pixelFormat:pixel_format]; - overlay_view_wrapper = [[FlutterOverlayView alloc] initWithContentsScale:screenScale - pixelFormat:pixel_format]; - - CALayer* ca_layer = overlay_view.layer; - std::unique_ptr ios_surface = IOSSurface::Create(ios_context, ca_layer); - std::unique_ptr surface = ios_surface->CreateGPUSurface(gr_context); - - layer = std::make_shared(overlay_view, overlay_view_wrapper, - std::move(ios_surface), std::move(surface)); - layer->gr_context = gr_context; - } + layer = std::make_shared(overlay_view, overlay_view_wrapper, std::move(ios_surface), + std::move(surface)); // The overlay view wrapper masks the overlay view. // This is required to keep the backing surface size unchanged between frames. // diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context.h b/engine/src/flutter/shell/platform/darwin/ios/ios_context.h index a1ab3616297..ef9a1a878f9 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context.h @@ -15,7 +15,6 @@ #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterTexture.h" #import "flutter/shell/platform/darwin/ios/rendering_api_selection.h" #include "impeller/display_list/aiks_context.h" -#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h" namespace impeller { class Context; @@ -70,46 +69,6 @@ class IOSContext { /// virtual IOSRenderingBackend GetBackend() const; - //---------------------------------------------------------------------------- - /// @brief Create a resource context for use on the IO task runner. This - /// resource context is used by Skia to upload texture to - /// asynchronously and collect resources that are no longer needed - /// on the render task runner. - /// - /// @attention Client rendering APIs for which a GrDirectContext cannot be realized - /// (software rendering), this method will always return null. - /// - /// @return A non-null Skia context on success. `nullptr` on failure. - /// - virtual sk_sp CreateResourceContext() = 0; - - //---------------------------------------------------------------------------- - /// @brief When using client rendering APIs whose contexts need to be - /// bound to a specific thread, the engine will call this method - /// to give the on-screen context a chance to bind to the current - /// thread. - /// - /// @attention Client rendering APIs that have no-concept of thread local - /// bindings (anything that is not OpenGL) will always return - /// `true`. - /// - /// @attention Client rendering APIs for which a GrDirectContext cannot be created - /// (software rendering) will always return `false`. - /// - /// @attention This binds the on-screen context to the current thread. To - /// bind the off-screen context to the thread, use the - /// `ResoruceMakeCurrent` method instead. - /// - /// @attention Only one context may be bound to a thread at any given time. - /// Making a binding on a thread, clears the old binding. - /// - /// @return A GLContextResult that represents the result of the method. - /// The GetResult() returns a bool that indicates If the on-screen context could be - /// bound to the current - /// thread. - /// - virtual std::unique_ptr MakeCurrent() = 0; - //---------------------------------------------------------------------------- /// @brief Creates an external texture proxy of the appropriate client /// rendering API. @@ -123,20 +82,6 @@ class IOSContext { virtual std::unique_ptr CreateExternalTexture(int64_t texture_id, NSObject* texture) = 0; - //---------------------------------------------------------------------------- - /// @brief Accessor for the Skia context associated with IOSSurfaces and - /// the raster thread. - /// @details There can be any number of resource contexts but this is the - /// one context that will be used by surfaces to draw to the - /// screen from the raster thread. - /// @returns `nullptr` on failure. - /// @attention The software context doesn't have a Skia context, so this - /// value will be nullptr. - /// @see For contexts which are used for offscreen work like loading - /// textures see IOSContext::CreateResourceContext. - /// - virtual sk_sp GetMainContext() const = 0; - virtual std::shared_ptr GetImpellerContext() const; virtual std::shared_ptr GetAiksContext() const; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm index 4bd87fe7fa5..9517ed85446 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm @@ -8,9 +8,7 @@ #include "flutter/fml/logging.h" #include "flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h" -#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h" #include "flutter/shell/platform/darwin/ios/ios_context_noop.h" -#include "flutter/shell/platform/darwin/ios/ios_context_software.h" FLUTTER_ASSERT_ARC @@ -26,25 +24,18 @@ std::unique_ptr IOSContext::Create( const std::shared_ptr& is_gpu_disabled_sync_switch) { switch (api) { case IOSRenderingAPI::kSoftware: - if (backend == IOSRenderingBackend::kImpeller) { - FML_LOG(IMPORTANT) - << "Software rendering is incompatible with Impeller.\n" - "Software rendering may have been automatically selected when running on a " - "simulator " - "in an environment that does not support Metal. Enabling GPU passthrough in your " - "environment may fix this."; - return std::make_unique(); - } - return std::make_unique(); + FML_LOG(IMPORTANT) + << "Software rendering is incompatible with Impeller.\n" + "Software rendering may have been automatically selected when running on a " + "simulator " + "in an environment that does not support Metal. Enabling GPU passthrough in your " + "environment may fix this."; + return std::make_unique(); case IOSRenderingAPI::kMetal: switch (backend) { case IOSRenderingBackend::kSkia: -#if !SLIMPELLER - return std::make_unique(); -#else // !SLIMPELLER FML_LOG(FATAL) << "Impeller opt-out unavailable."; return nullptr; -#endif // !SLIMPELLER case IOSRenderingBackend::kImpeller: return std::make_unique(is_gpu_disabled_sync_switch); } diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h index c3edc7c8f9f..a672d831306 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.h @@ -28,21 +28,10 @@ class IOSContextMetalImpeller final : public IOSContext { IOSRenderingBackend GetBackend() const override; - // |IOSContext| - sk_sp GetMainContext() const override; - - sk_sp GetResourceContext() const; - private: FlutterDarwinContextMetalImpeller* darwin_context_metal_impeller_; std::shared_ptr aiks_context_; - // |IOSContext| - sk_sp CreateResourceContext() override; - - // |IOSContext| - std::unique_ptr MakeCurrent() override; - // |IOSContext| std::unique_ptr CreateExternalTexture(int64_t texture_id, NSObject* texture) override; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm index f6f89a34c12..3b9aa5c1392 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_impeller.mm @@ -29,19 +29,6 @@ IOSRenderingBackend IOSContextMetalImpeller::GetBackend() const { return IOSRenderingBackend::kImpeller; } -sk_sp IOSContextMetalImpeller::GetMainContext() const { - return nullptr; -} - -sk_sp IOSContextMetalImpeller::GetResourceContext() const { - return nullptr; -} - -// |IOSContext| -sk_sp IOSContextMetalImpeller::CreateResourceContext() { - return nullptr; -} - // |IOSContext| std::shared_ptr IOSContextMetalImpeller::GetImpellerContext() const { return darwin_context_metal_impeller_.context; @@ -52,12 +39,6 @@ std::shared_ptr IOSContextMetalImpeller::GetAiksContext() return aiks_context_; } -// |IOSContext| -std::unique_ptr IOSContextMetalImpeller::MakeCurrent() { - // This only makes sense for contexts that need to be bound to a specific thread. - return std::make_unique(true); -} - // |IOSContext| std::unique_ptr IOSContextMetalImpeller::CreateExternalTexture( int64_t texture_id, diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.h b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.h deleted file mode 100644 index c02302e734c..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.h +++ /dev/null @@ -1,56 +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_CONTEXT_METAL_SKIA_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_ - -#if !SLIMPELLER - -#include - -#include "flutter/fml/macros.h" -#include "flutter/fml/platform/darwin/cf_utils.h" -#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" -#import "flutter/shell/platform/darwin/ios/ios_context.h" -#include "third_party/skia/include/gpu/ganesh/GrDirectContext.h" - -namespace flutter { - -class IOSContextMetalSkia final : public IOSContext { - public: - explicit IOSContextMetalSkia(); - - ~IOSContextMetalSkia(); - - FlutterDarwinContextMetalSkia* GetDarwinContext() const; - - // |IOSContext| - IOSRenderingBackend GetBackend() const override; - - // |IOSContext| - sk_sp GetMainContext() const override; - - sk_sp GetResourceContext() const; - - private: - FlutterDarwinContextMetalSkia* darwin_context_metal_; - - // |IOSContext| - sk_sp CreateResourceContext() override; - - // |IOSContext| - std::unique_ptr MakeCurrent() override; - - // |IOSContext| - std::unique_ptr CreateExternalTexture(int64_t texture_id, - NSObject* texture) override; - - FML_DISALLOW_COPY_AND_ASSIGN(IOSContextMetalSkia); -}; - -} // namespace flutter - -#endif // !SLIMPELLER - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_METAL_SKIA_H_ diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm deleted file mode 100644 index 6b83cf0d8a0..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_metal_skia.mm +++ /dev/null @@ -1,62 +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. - -#if !SLIMPELLER - -#import "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h" - -#include "flutter/common/graphics/persistent_cache.h" -#include "flutter/fml/logging.h" -#import "flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalSkia.h" -#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" -#include "third_party/skia/include/gpu/ganesh/GrContextOptions.h" - -FLUTTER_ASSERT_ARC - -namespace flutter { - -IOSContextMetalSkia::IOSContextMetalSkia() { - darwin_context_metal_ = [[FlutterDarwinContextMetalSkia alloc] initWithDefaultMTLDevice]; -} - -IOSContextMetalSkia::~IOSContextMetalSkia() = default; - -FlutterDarwinContextMetalSkia* IOSContextMetalSkia::GetDarwinContext() const { - return darwin_context_metal_; -} - -IOSRenderingBackend IOSContextMetalSkia::GetBackend() const { - return IOSRenderingBackend::kSkia; -} - -sk_sp IOSContextMetalSkia::GetMainContext() const { - return darwin_context_metal_.mainContext; -} - -sk_sp IOSContextMetalSkia::GetResourceContext() const { - return darwin_context_metal_.resourceContext; -} - -// |IOSContext| -sk_sp IOSContextMetalSkia::CreateResourceContext() { - return darwin_context_metal_.resourceContext; -} - -// |IOSContext| -std::unique_ptr IOSContextMetalSkia::MakeCurrent() { - // This only makes sense for context that need to be bound to a specific thread. - return std::make_unique(true); -} - -// |IOSContext| -std::unique_ptr IOSContextMetalSkia::CreateExternalTexture( - int64_t texture_id, - NSObject* texture) { - return std::make_unique( - [darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]); -} - -} // namespace flutter - -#endif // !SLIMPELLER diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.h b/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.h index b331b9013cc..71ee138705a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.h @@ -17,15 +17,6 @@ class IOSContextNoop final : public IOSContext { // |IOSContext| ~IOSContextNoop(); - // |IOSContext| - sk_sp CreateResourceContext() override; - - // |IOSContext| - sk_sp GetMainContext() const override; - - // |IOSContext| - std::unique_ptr MakeCurrent() override; - // |IOSContext| std::unique_ptr CreateExternalTexture(int64_t texture_id, NSObject* texture) override; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.mm index 254b0d4536f..8c50308924a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context_noop.mm @@ -15,27 +15,11 @@ IOSContextNoop::IOSContextNoop() = default; // |IOSContext| IOSContextNoop::~IOSContextNoop() = default; -// |IOSContext| -sk_sp IOSContextNoop::CreateResourceContext() { - return nullptr; -} - -// |IOSContext| -sk_sp IOSContextNoop::GetMainContext() const { - return nullptr; -} - // |IOSContext| IOSRenderingBackend IOSContextNoop::GetBackend() const { return IOSRenderingBackend::kImpeller; } -// |IOSContext| -std::unique_ptr IOSContextNoop::MakeCurrent() { - // This only makes sense for context that need to be bound to a specific thread. - return std::make_unique(false); -} - // |IOSContext| std::unique_ptr IOSContextNoop::CreateExternalTexture(int64_t texture_id, NSObject* texture) { diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.h b/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.h deleted file mode 100644 index 5ed73930fe9..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.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_CONTEXT_SOFTWARE_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_SOFTWARE_H_ - -#include "flutter/fml/macros.h" -#import "flutter/shell/platform/darwin/ios/ios_context.h" - -namespace flutter { - -class IOSContextSoftware final : public IOSContext { - public: - IOSContextSoftware(); - - // |IOSContext| - ~IOSContextSoftware(); - - // |IOSContext| - sk_sp CreateResourceContext() override; - - // |IOSContext| - sk_sp GetMainContext() const override; - - // |IOSContext| - std::unique_ptr MakeCurrent() override; - - // |IOSContext| - std::unique_ptr CreateExternalTexture(int64_t texture_id, - NSObject* texture) override; - - private: - FML_DISALLOW_COPY_AND_ASSIGN(IOSContextSoftware); -}; - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_CONTEXT_SOFTWARE_H_ diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.mm deleted file mode 100644 index 545c56a7e56..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context_software.mm +++ /dev/null @@ -1,47 +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_context_software.h" -#include "ios_context.h" - -FLUTTER_ASSERT_ARC - -namespace flutter { - -IOSContextSoftware::IOSContextSoftware() = default; - -// |IOSContext| -IOSContextSoftware::~IOSContextSoftware() = default; - -// |IOSContext| -sk_sp IOSContextSoftware::CreateResourceContext() { - return nullptr; -} - -// |IOSContext| -sk_sp IOSContextSoftware::GetMainContext() const { - return nullptr; -} - -// |IOSContext| -std::unique_ptr IOSContextSoftware::MakeCurrent() { - // This only makes sense for context that need to be bound to a specific thread. - return std::make_unique(false); -} - -// |IOSContext| -std::unique_ptr IOSContextSoftware::CreateExternalTexture( - int64_t texture_id, - NSObject* texture) { - // Don't use FML for logging as it will contain engine specific details. This is a user facing - // message. - NSLog(@"Flutter: Attempted to composite external texture sources using the software backend. " - @"This backend is only used on simulators. This feature is only available on actual " - @"devices where Metal is used for rendering."); - - // Not supported in this backend. - return nullptr; -} - -} // namespace flutter diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm index ebde36386b3..fa274438ba7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_external_view_embedder.mm @@ -85,9 +85,7 @@ void IOSExternalViewEmbedder::SubmitFlutterView( // Properly support multi-view in the future. FML_DCHECK(flutter_view_id == kFlutterImplicitViewId); FML_CHECK(platform_views_controller_); - [platform_views_controller_ submitFrame:std::move(frame) - withIosContext:ios_context_ - grContext:context]; + [platform_views_controller_ submitFrame:std::move(frame) withIosContext:ios_context_]; TRACE_EVENT0("flutter", "IOSExternalViewEmbedder::DidSubmitFrame"); } @@ -104,12 +102,7 @@ void IOSExternalViewEmbedder::EndFrame( // |ExternalViewEmbedder| bool IOSExternalViewEmbedder::SupportsDynamicThreadMerging() { -// TODO(jonahwilliams): remove this once Software backend is removed for iOS Sim. -#if FML_OS_IOS_SIMULATOR - return true; -#else - return ios_context_->GetBackend() == IOSRenderingBackend::kSkia; -#endif // FML_OS_IOS_SIMULATOR + return false; } // |ExternalViewEmbedder| diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface.h index 1c74ac1014c..a9fd3f5f5d2 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface.h @@ -29,12 +29,7 @@ class IOSSurface { virtual void UpdateStorageSizeIfNecessary() = 0; - // Creates a GPU surface. If no GrDirectContext is supplied and the rendering mode - // supports one, a new one will be created; otherwise, the software backend - // will be used. - // - // If a GrDirectContext is supplied, creates a secondary surface. - virtual std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) = 0; + virtual std::unique_ptr CreateGPUSurface() = 0; protected: explicit IOSSurface(std::shared_ptr ios_context); diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface.mm index 437e0658571..f4abe826f72 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface.mm @@ -7,9 +7,7 @@ #include #import "flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h" -#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h" #import "flutter/shell/platform/darwin/ios/ios_surface_noop.h" -#import "flutter/shell/platform/darwin/ios/ios_surface_software.h" #include "flutter/shell/platform/darwin/ios/rendering_api_selection.h" FLUTTER_ASSERT_ARC @@ -25,16 +23,8 @@ std::unique_ptr IOSSurface::Create(std::shared_ptr conte if ([layer isKindOfClass:[CAMetalLayer class]]) { switch (context->GetBackend()) { case IOSRenderingBackend::kSkia: -#if !SLIMPELLER - return std::make_unique( - static_cast(layer), // Metal layer - std::move(context) // context - ); -#else // !SLIMPELLER FML_LOG(FATAL) << "Impeller opt-out unavailable."; return nullptr; -#endif // !SLIMPELLER - break; case IOSRenderingBackend::kImpeller: return std::make_unique( static_cast(layer), // Metal layer @@ -43,13 +33,7 @@ std::unique_ptr IOSSurface::Create(std::shared_ptr conte } } } - if (context->GetBackend() == IOSRenderingBackend::kImpeller) { - return std::make_unique(std::move(context)); - } - - return std::make_unique(layer, // layer - std::move(context) // context - ); + return std::make_unique(std::move(context)); } IOSSurface::IOSSurface(std::shared_ptr ios_context) diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h index 527e0f9947b..f071e08a136 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.h @@ -39,7 +39,7 @@ class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalImpeller final void UpdateStorageSizeIfNecessary() override; // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; + std::unique_ptr CreateGPUSurface() override; // |GPUSurfaceMetalDelegate| GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm index fdca57bfa5c..8ec9bb8eef0 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_impeller.mm @@ -42,7 +42,7 @@ void IOSSurfaceMetalImpeller::UpdateStorageSizeIfNecessary() { } // |IOSSurface| -std::unique_ptr IOSSurfaceMetalImpeller::CreateGPUSurface(GrDirectContext*) { +std::unique_ptr IOSSurfaceMetalImpeller::CreateGPUSurface() { impeller_context_->UpdateOffscreenLayerPixelFormat( impeller::FromMTLPixelFormat(layer_.pixelFormat)); return std::make_unique(this, // diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h deleted file mode 100644 index 3a3a20bd3d7..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h +++ /dev/null @@ -1,70 +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_METAL_SKIA_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_ - -#if !SLIMPELLER - -#include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" -#import "flutter/shell/platform/darwin/ios/ios_surface.h" -#include "third_party/skia/include/gpu/ganesh/mtl/GrMtlTypes.h" - -@class CAMetalLayer; - -namespace flutter { - -class SK_API_AVAILABLE_CA_METAL_LAYER IOSSurfaceMetalSkia final : public IOSSurface, - public GPUSurfaceMetalDelegate { - public: - IOSSurfaceMetalSkia(CAMetalLayer* layer, std::shared_ptr context); - - // |IOSSurface| - ~IOSSurfaceMetalSkia(); - - private: - CAMetalLayer* layer_; - id device_; - id command_queue_; - bool is_valid_ = false; - - // |IOSSurface| - bool IsValid() const override; - - // |IOSSurface| - void UpdateStorageSizeIfNecessary() override; - - // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context) override; - - // |GPUSurfaceMetalDelegate| - GPUCAMetalLayerHandle GetCAMetalLayer(const SkISize& frame_info) const override - __attribute__((cf_audited_transfer)); - - // |GPUSurfaceMetalDelegate| - bool PresentDrawable(GrMTLHandle drawable) const override __attribute__((cf_audited_transfer)); - - // |GPUSurfaceMetalDelegate| - bool PreparePresent(GrMTLHandle drawable) const override; - - // |GPUSurfaceMetalDelegate| - GPUMTLTextureInfo GetMTLTexture(const SkISize& frame_info) const override - __attribute__((cf_audited_transfer)); - - // |GPUSurfaceMetalDelegate| - bool PresentTexture(GPUMTLTextureInfo texture) const override - __attribute__((cf_audited_transfer)); - - // |GPUSurfaceMetalDelegate| - bool AllowsDrawingWhenGpuDisabled() const override; - - FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceMetalSkia); -}; - -} // namespace flutter - -#endif // !SLIMPELLER - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_METAL_SKIA_H_ diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm deleted file mode 100644 index 61266abc7d5..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_metal_skia.mm +++ /dev/null @@ -1,118 +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. - -#if !SLIMPELLER - -#import "flutter/shell/platform/darwin/ios/ios_surface_metal_skia.h" - -#include "flutter/shell/gpu/gpu_surface_metal_delegate.h" -#include "flutter/shell/gpu/gpu_surface_metal_skia.h" -#include "flutter/shell/platform/darwin/ios/ios_context_metal_skia.h" - -FLUTTER_ASSERT_ARC - -@protocol FlutterMetalDrawable -- (void)flutterPrepareForPresent:(nonnull id)commandBuffer; -@end - -namespace flutter { - -IOSSurfaceMetalSkia::IOSSurfaceMetalSkia(CAMetalLayer* layer, std::shared_ptr context) - : IOSSurface(std::move(context)), - GPUSurfaceMetalDelegate(MTLRenderTargetType::kCAMetalLayer), - layer_(layer) { - is_valid_ = layer_; - IOSContextMetalSkia* metal_context = static_cast(GetContext().get()); - FlutterDarwinContextMetalSkia* darwin_context = metal_context->GetDarwinContext(); - command_queue_ = darwin_context.commandQueue; - device_ = darwin_context.device; -} - -// |IOSSurface| -IOSSurfaceMetalSkia::~IOSSurfaceMetalSkia() = default; - -// |IOSSurface| -bool IOSSurfaceMetalSkia::IsValid() const { - return is_valid_; -} - -// |IOSSurface| -void IOSSurfaceMetalSkia::UpdateStorageSizeIfNecessary() { - // Nothing to do. -} - -// |IOSSurface| -std::unique_ptr IOSSurfaceMetalSkia::CreateGPUSurface(GrDirectContext* context) { - FML_DCHECK(context); - return std::make_unique(this, // delegate - sk_ref_sp(context) // context - ); -} - -// |GPUSurfaceMetalDelegate| -GPUCAMetalLayerHandle IOSSurfaceMetalSkia::GetCAMetalLayer(const SkISize& frame_info) const { - layer_.device = device_; - - layer_.pixelFormat = MTLPixelFormatBGRA8Unorm; - // Flutter needs to read from the color attachment in cases where there are effects such as - // backdrop filters. Flutter plugins that create platform views may also read from the layer. - layer_.framebufferOnly = NO; - - const auto drawable_size = CGSizeMake(frame_info.width(), frame_info.height()); - if (!CGSizeEqualToSize(drawable_size, layer_.drawableSize)) { - layer_.drawableSize = drawable_size; - } - - // When there are platform views in the scene, the drawable needs to be presented in the same - // transaction as the one created for platform views. When the drawable are being presented from - // the raster thread, there is no such transaction. - layer_.presentsWithTransaction = [[NSThread currentThread] isMainThread]; - - return (__bridge GPUCAMetalLayerHandle)layer_; -} - -// |GPUSurfaceMetalDelegate| -bool IOSSurfaceMetalSkia::PreparePresent(GrMTLHandle drawable) const { - id command_buffer = [command_queue_ commandBuffer]; - id metal_drawable = (__bridge id)drawable; - if ([metal_drawable conformsToProtocol:@protocol(FlutterMetalDrawable)]) { - [(id)metal_drawable flutterPrepareForPresent:command_buffer]; - } - [command_buffer commit]; - [command_buffer waitUntilScheduled]; - return true; -} - -// |GPUSurfaceMetalDelegate| -bool IOSSurfaceMetalSkia::PresentDrawable(GrMTLHandle drawable) const { - if (drawable == nullptr) { - FML_DLOG(ERROR) << "Could not acquire next Metal drawable from the SkSurface."; - return false; - } - - id metal_drawable = (__bridge id)drawable; - [metal_drawable present]; - return true; -} - -// |GPUSurfaceMetalDelegate| -GPUMTLTextureInfo IOSSurfaceMetalSkia::GetMTLTexture(const SkISize& frame_info) const { - FML_CHECK(false) << "render to texture not supported on ios"; - return {.texture_id = -1, .texture = nullptr}; -} - -// |GPUSurfaceMetalDelegate| -bool IOSSurfaceMetalSkia::PresentTexture(GPUMTLTextureInfo texture) const { - FML_CHECK(false) << "render to texture not supported on ios"; - return false; -} - -// |GPUSurfaceMetalDelegate| -bool IOSSurfaceMetalSkia::AllowsDrawingWhenGpuDisabled() const { - return false; -} - -} // namespace flutter - -#endif // !SLIMPELLER diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.h index 94b223216e2..c97c80c356d 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.h +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.h @@ -8,8 +8,6 @@ #import "flutter/shell/platform/darwin/ios/ios_context.h" #import "flutter/shell/platform/darwin/ios/ios_surface.h" -#include "third_party/skia/include/core/SkSurface.h" - @class CALayer; namespace flutter { @@ -32,7 +30,7 @@ class IOSSurfaceNoop final : public IOSSurface { void UpdateStorageSizeIfNecessary() override; // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) override; + std::unique_ptr CreateGPUSurface() override; private: IOSSurfaceNoop(const IOSSurfaceNoop&) = delete; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.mm index 813e2e1a21f..a41c5e53cd5 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_noop.mm @@ -13,9 +13,6 @@ #include "flutter/fml/platform/darwin/cf_utils.h" #include "flutter/fml/trace_event.h" -#include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/utils/mac/SkCGUtils.h" - FLUTTER_ASSERT_ARC namespace flutter { @@ -31,7 +28,7 @@ bool IOSSurfaceNoop::IsValid() const { void IOSSurfaceNoop::UpdateStorageSizeIfNecessary() {} -std::unique_ptr IOSSurfaceNoop::CreateGPUSurface(GrDirectContext* gr_context) { +std::unique_ptr IOSSurfaceNoop::CreateGPUSurface() { return std::make_unique(); } diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h deleted file mode 100644 index 8f0088cb671..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.h +++ /dev/null @@ -1,50 +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_SOFTWARE_H_ -#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_ - -#include "flutter/flow/embedded_views.h" -#include "flutter/fml/macros.h" -#include "flutter/shell/gpu/gpu_surface_software.h" -#import "flutter/shell/platform/darwin/ios/ios_context.h" -#import "flutter/shell/platform/darwin/ios/ios_surface.h" - -#include "third_party/skia/include/core/SkSurface.h" - -@class CALayer; - -namespace flutter { - -class IOSSurfaceSoftware final : public IOSSurface, public GPUSurfaceSoftwareDelegate { - public: - IOSSurfaceSoftware(CALayer* layer, std::shared_ptr context); - - ~IOSSurfaceSoftware() override; - - // |IOSSurface| - bool IsValid() const override; - - // |IOSSurface| - void UpdateStorageSizeIfNecessary() override; - - // |IOSSurface| - std::unique_ptr CreateGPUSurface(GrDirectContext* gr_context = nullptr) override; - - // |GPUSurfaceSoftwareDelegate| - sk_sp AcquireBackingStore(const SkISize& size) override; - - // |GPUSurfaceSoftwareDelegate| - bool PresentBackingStore(sk_sp backing_store) override; - - private: - CALayer* layer_; - sk_sp sk_surface_; - - FML_DISALLOW_COPY_AND_ASSIGN(IOSSurfaceSoftware); -}; - -} // namespace flutter - -#endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_IOS_SURFACE_SOFTWARE_H_ diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm deleted file mode 100644 index cfc05b8f0b5..00000000000 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_surface_software.mm +++ /dev/null @@ -1,128 +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_software.h" - -#include - -#include - -#include "flutter/fml/logging.h" -#include "flutter/fml/platform/darwin/cf_utils.h" -#include "flutter/fml/trace_event.h" - -#include "third_party/skia/include/core/SkColorSpace.h" -#include "third_party/skia/include/core/SkSurface.h" -#include "third_party/skia/include/utils/mac/SkCGUtils.h" - -FLUTTER_ASSERT_ARC - -namespace flutter { - -IOSSurfaceSoftware::IOSSurfaceSoftware(CALayer* layer, std::shared_ptr context) - : IOSSurface(std::move(context)), layer_(layer) {} - -IOSSurfaceSoftware::~IOSSurfaceSoftware() = default; - -bool IOSSurfaceSoftware::IsValid() const { - return layer_; -} - -void IOSSurfaceSoftware::UpdateStorageSizeIfNecessary() { - // Nothing to do here. We don't need an external entity to tell us when our - // backing store needs to be updated. Instead, we let the frame tell us its - // size so we can update to match. This method was added to work around - // Android oddities. -} - -std::unique_ptr IOSSurfaceSoftware::CreateGPUSurface(GrDirectContext* gr_context) { - if (!IsValid()) { - return nullptr; - } - - auto surface = std::make_unique(this, true /* render to surface */); - - if (!surface->IsValid()) { - return nullptr; - } - - return surface; -} - -sk_sp IOSSurfaceSoftware::AcquireBackingStore(const SkISize& size) { - TRACE_EVENT0("flutter", "IOSSurfaceSoftware::AcquireBackingStore"); - if (!IsValid()) { - return nullptr; - } - - if (sk_surface_ != nullptr && - SkISize::Make(sk_surface_->width(), sk_surface_->height()) == size) { - // The old and new surface sizes are the same. Nothing to do here. - return sk_surface_; - } - - SkImageInfo info = SkImageInfo::MakeN32(size.fWidth, size.fHeight, kPremul_SkAlphaType, - SkColorSpace::MakeSRGB()); - sk_surface_ = SkSurfaces::Raster(info, nullptr); - return sk_surface_; -} - -bool IOSSurfaceSoftware::PresentBackingStore(sk_sp backing_store) { - TRACE_EVENT0("flutter", "IOSSurfaceSoftware::PresentBackingStore"); - if (!IsValid() || backing_store == nullptr) { - return false; - } - - SkPixmap pixmap; - if (!backing_store->peekPixels(&pixmap)) { - return false; - } - - // Some basic sanity checking. - uint64_t expected_pixmap_data_size = pixmap.width() * pixmap.height() * 4; - - const size_t pixmap_size = pixmap.computeByteSize(); - - if (expected_pixmap_data_size != pixmap_size) { - return false; - } - - fml::CFRef colorspace(CGColorSpaceCreateDeviceRGB()); - - // Setup the data provider that gives CG a view into the pixmap. - fml::CFRef pixmap_data_provider(CGDataProviderCreateWithData( - nullptr, // info - pixmap.addr32(), // data - pixmap_size, // size - nullptr // release callback - )); - - if (!pixmap_data_provider) { - return false; - } - - // Create the CGImageRef representation on the pixmap. - fml::CFRef pixmap_image(CGImageCreate(pixmap.width(), // width - pixmap.height(), // height - 8, // bits per component - 32, // bits per pixel - pixmap.rowBytes(), // bytes per row - colorspace, // colorspace - kCGImageAlphaPremultipliedLast, // bitmap info - pixmap_data_provider, // data provider - nullptr, // decode array - false, // should interpolate - kCGRenderingIntentDefault // rendering intent - )); - - if (!pixmap_image) { - return false; - } - - layer_.contents = (__bridge id) static_cast(pixmap_image); - - return true; -} - -} // namespace flutter diff --git a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.h b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.h index 3100637a1d5..74968d5629c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.h +++ b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.h @@ -96,9 +96,6 @@ class PlatformViewIOS final : public PlatformView { // |PlatformView| std::shared_ptr CreateExternalViewEmbedder() override; - // |PlatformView| - sk_sp CreateResourceContext() const override; - // |PlatformView| std::shared_ptr GetImpellerContext() const override; diff --git a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm index b726fd8fc1e..3e12bd1f452 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/platform_view_ios.mm @@ -145,7 +145,7 @@ std::unique_ptr PlatformViewIOS::CreateRenderingSurface() { "has no ViewController."; return nullptr; } - return ios_surface_->CreateGPUSurface(ios_context_->GetMainContext().get()); + return ios_surface_->CreateGPUSurface(); } // |PlatformView| @@ -153,11 +153,6 @@ std::shared_ptr PlatformViewIOS::CreateExternalViewEmbedde return std::make_shared(platform_views_controller_, ios_context_); } -// |PlatformView| -sk_sp PlatformViewIOS::CreateResourceContext() const { - return ios_context_->CreateResourceContext(); -} - // |PlatformView| std::shared_ptr PlatformViewIOS::GetImpellerContext() const { return ios_context_->GetImpellerContext();