From 27b415ec593457e50c4c4c90f31ecc348084e359 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 23 Sep 2022 14:33:37 -0700 Subject: [PATCH 01/10] Impl --- .../framework/Source/FlutterCompositor.h | 10 ++++-- .../framework/Source/FlutterCompositor.mm | 18 ++++++---- .../macos/framework/Source/FlutterEngine.mm | 18 ++++++---- .../framework/Source/FlutterGLCompositor.h | 2 +- .../framework/Source/FlutterGLCompositor.mm | 10 +++--- .../Source/FlutterGLCompositorUnittests.mm | 8 +++-- .../framework/Source/FlutterMetalCompositor.h | 9 +++-- .../Source/FlutterMetalCompositor.mm | 25 ++++++++----- .../Source/FlutterMetalCompositorUnittests.mm | 36 ++++++++++++------- 9 files changed, 89 insertions(+), 47 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 141e27509dd44..99431f1a5378f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -9,7 +9,7 @@ #include #include "flutter/fml/macros.h" -#include "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewController_Internal.h" +#include "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" #include "flutter/shell/platform/embedder/embedder.h" namespace flutter { @@ -19,7 +19,9 @@ namespace flutter { // Platform views are not yet supported. class FlutterCompositor { public: - explicit FlutterCompositor(FlutterViewController* view_controller); + using GetViewCallback = std::function; + + explicit FlutterCompositor(GetViewCallback get_view_callback); virtual ~FlutterCompositor() = default; @@ -62,7 +64,7 @@ class FlutterCompositor { typedef enum { kStarted, kPresenting, kEnded } FrameStatus; protected: - __weak const FlutterViewController* view_controller_; + FlutterView* GetView(uint64_t view_id); // Gets and sets the FrameStatus for the current frame. void SetFrameStatus(FrameStatus frame_status); @@ -85,6 +87,8 @@ class FlutterCompositor { // A list of the active CALayer objects for the frame that need to be removed. std::list active_ca_layers_; + GetViewCallback get_view_callback_; + // Callback set by the embedder to be called when the layer tree has been // correctly set up for this frame. PresentCallback present_callback_; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 3015a716c6ca6..c18a589c55855 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -7,10 +7,8 @@ namespace flutter { -FlutterCompositor::FlutterCompositor(FlutterViewController* view_controller) { - FML_CHECK(view_controller != nullptr) << "FlutterViewController* cannot be nullptr"; - - view_controller_ = view_controller; +FlutterCompositor::FlutterCompositor(GetViewCallback get_view_callback) { + get_view_callback_ = std::move(get_view_callback); } void FlutterCompositor::SetPresentCallback( @@ -35,6 +33,10 @@ return status; } +FlutterView* FlutterCompositor::GetView(uint64_t view_id) { + return get_view_callback_(view_id); +} + void FlutterCompositor::SetFrameStatus(FlutterCompositor::FrameStatus frame_status) { frame_status_ = frame_status; } @@ -45,12 +47,16 @@ void FlutterCompositor::InsertCALayerForIOSurface(const IOSurfaceRef& io_surface, CATransform3D transform) { + FlutterView* view = GetView(0); + if (!view) { + return; + } // FlutterCompositor manages the lifecycle of CALayers. CALayer* content_layer = [[CALayer alloc] init]; content_layer.transform = transform; - content_layer.frame = view_controller_.flutterView.layer.bounds; + content_layer.frame = view.layer.bounds; [content_layer setContents:(__bridge id)io_surface]; - [view_controller_.flutterView.layer addSublayer:content_layer]; + [view.layer addSublayer:content_layer]; active_ca_layers_.push_back(content_layer); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index f638e0fe79578..339d8f8a2a7ee 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -428,16 +428,22 @@ - (FlutterCompositor*)createFlutterCompositor { // TODO(richardjcai): Add support for creating a FlutterCompositor // with a nil _viewController for headless engines. // https://github.com/flutter/flutter/issues/71606 - if (!_viewController) { + FlutterViewController* viewController = _viewController; + if (!viewController) { return nil; } __weak FlutterEngine* weakSelf = self; + flutter::FlutterCompositor::GetViewCallback get_view_callback = + [&viewController](uint64_t view_id) { + return viewController == nullptr ? nullptr : viewController.flutterView; + }; + if ([FlutterRenderingBackend renderUsingMetal]) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); _macOSCompositor = std::make_unique( - _viewController, _platformViewController, metalRenderer.device); + std::move(get_view_callback), _platformViewController, metalRenderer.device); _macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(weakSelf.renderer); @@ -451,7 +457,7 @@ - (FlutterCompositor*)createFlutterCompositor { } else { FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(_renderer); [openGLRenderer.openGLContext makeCurrentContext]; - _macOSCompositor = std::make_unique(_viewController, + _macOSCompositor = std::make_unique(std::move(get_view_callback), openGLRenderer.openGLContext); _macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) { @@ -645,9 +651,9 @@ - (void)sendUserLocales { // Convert to a list of pointers, and send to the engine. std::vector flutterLocaleList; flutterLocaleList.reserve(flutterLocales.size()); - std::transform( - flutterLocales.begin(), flutterLocales.end(), std::back_inserter(flutterLocaleList), - [](const auto& arg) -> const auto* { return &arg; }); + std::transform(flutterLocales.begin(), flutterLocales.end(), + std::back_inserter(flutterLocaleList), + [](const auto& arg) -> const auto* { return &arg; }); _embedderAPI.UpdateLocales(_engine, flutterLocaleList.data(), flutterLocaleList.size()); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h index 385099a66d1b5..24abfc2eda3fc 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h @@ -19,7 +19,7 @@ namespace flutter { // FlutterGLCompositor is created and destroyed by FlutterEngine. class FlutterGLCompositor : public FlutterCompositor { public: - FlutterGLCompositor(FlutterViewController* view_controller, + FlutterGLCompositor(GetViewCallback get_view_callback, NSOpenGLContext* opengl_context); virtual ~FlutterGLCompositor() = default; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index c8c6ce7f93056..187152160669f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -19,13 +19,14 @@ namespace flutter { -FlutterGLCompositor::FlutterGLCompositor(FlutterViewController* view_controller, +FlutterGLCompositor::FlutterGLCompositor(GetViewCallback get_view_callback, NSOpenGLContext* opengl_context) - : FlutterCompositor(view_controller), open_gl_context_(opengl_context) {} + : FlutterCompositor(get_view_callback), open_gl_context_(opengl_context) {} bool FlutterGLCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { - if (!view_controller_) { + FlutterView* view = GetView(0); + if (!view) { return false; } @@ -36,8 +37,7 @@ // If the backing store is for the first layer, return the fbo for the // FlutterView. FlutterOpenGLRenderBackingStore* backingStore = - reinterpret_cast( - [view_controller_.flutterView backingStoreForSize:size]); + reinterpret_cast([view backingStoreForSize:size]); backing_store_out->open_gl.framebuffer.name = backingStore.frameBufferID; } else { FlutterFrameBufferProvider* fb_provider = diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm index 93e76ea5f251d..2a9da0e49072a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm @@ -3,6 +3,7 @@ // found in the LICENSE file. #import +#import #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h" #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTestUtils.h" @@ -11,10 +12,13 @@ namespace flutter::testing { TEST(FlutterGLCompositorTest, TestPresent) { - id mockViewController = CreateMockViewController(); + id mock_view = OCMClassMock([FlutterView class]); + flutter::FlutterCompositor::GetViewCallback get_view_callback = [&mock_view](uint64_t view_id) { + return mock_view; + }; std::unique_ptr macos_compositor = - std::make_unique(mockViewController, nullptr); + std::make_unique(get_view_callback, nullptr); bool flag = false; macos_compositor->SetPresentCallback([f = &flag](bool has_flutter_content) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h index 84e67710fc445..1c142673a6e1e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h @@ -14,7 +14,7 @@ namespace flutter { class FlutterMetalCompositor : public FlutterCompositor { public: explicit FlutterMetalCompositor( - FlutterViewController* view_controller, + GetViewCallback get_view_callback, FlutterPlatformViewController* platform_views_controller, id mtl_device); @@ -46,8 +46,11 @@ class FlutterMetalCompositor : public FlutterCompositor { private: // Presents the platform view layer represented by `layer`. `layer_index` is - // used to position the layer in the z-axis. - void PresentPlatformView(const FlutterLayer* layer, size_t layer_index); + // used to position the layer in the z-axis. If the layer does not have a + // superview, it will become subview of `default_super_view`. + void PresentPlatformView(FlutterView* default_super_view, + const FlutterLayer* layer, + size_t layer_position); const id mtl_device_; const FlutterPlatformViewController* platform_views_controller_; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index e1bcf9bab1f6b..824e66044d049 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -11,16 +11,17 @@ namespace flutter { FlutterMetalCompositor::FlutterMetalCompositor( - FlutterViewController* view_controller, + GetViewCallback get_view_callback, FlutterPlatformViewController* platform_views_controller, id mtl_device) - : FlutterCompositor(view_controller), + : FlutterCompositor(get_view_callback), mtl_device_(mtl_device), platform_views_controller_(platform_views_controller) {} bool FlutterMetalCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { - if (!view_controller_) { + FlutterView* view = GetView(0); + if (!view) { return false; } @@ -34,8 +35,7 @@ // If the backing store is for the first layer, return the MTLTexture for the // FlutterView. FlutterMetalRenderBackingStore* backingStore = - reinterpret_cast( - [view_controller_.flutterView backingStoreForSize:size]); + reinterpret_cast([view backingStoreForSize:size]); backing_store_out->metal.texture.texture = (__bridge FlutterMetalTextureHandle)backingStore.texture; } else { @@ -96,16 +96,23 @@ has_flutter_content = true; break; } - case kFlutterLayerContentTypePlatformView: - PresentPlatformView(layer, i); + case kFlutterLayerContentTypePlatformView: { + FlutterView* view = GetView(0); + if (!view) { + return false; + } + PresentPlatformView(view, layer, i); break; + } }; } return EndFrame(has_flutter_content); } -void FlutterMetalCompositor::PresentPlatformView(const FlutterLayer* layer, size_t layer_position) { +void FlutterMetalCompositor::PresentPlatformView(FlutterView* default_super_view, + const FlutterLayer* layer, + size_t layer_position) { // TODO (https://github.com/flutter/flutter/issues/96668) // once the issue is fixed, this check will pass. FML_DCHECK([[NSThread currentThread] isMainThread]) @@ -120,7 +127,7 @@ platform_view.frame = CGRectMake(layer->offset.x / scale, layer->offset.y / scale, layer->size.width / scale, layer->size.height / scale); if (platform_view.superview == nil) { - [view_controller_.flutterView addSubview:platform_view]; + [default_super_view addSubview:platform_view]; } platform_view.layer.zPosition = layer_position; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm index ac0e0330405bd..531c85fc1a047 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm @@ -3,19 +3,37 @@ // found in the LICENSE file. #import +#import #import "flutter/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h" -#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterViewControllerTestUtils.h" +#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterView.h" #import "flutter/testing/testing.h" namespace flutter::testing { -TEST(FlutterMetalCompositorTest, TestPresent) { - id mockViewController = CreateMockViewController(); +flutter::FlutterCompositor::GetViewCallback MockGetViewCallback() { + FlutterView* viewMock = OCMClassMock([FlutterView class]); + FlutterMetalRenderBackingStore* backingStoreMock = + OCMClassMock([FlutterMetalRenderBackingStore class]); + __block id textureMock = OCMProtocolMock(@protocol(MTLTexture)); + OCMStub([backingStoreMock texture]).andReturn(textureMock); + + OCMStub([viewMock backingStoreForSize:CGSize{}]) + .ignoringNonObjectArgs() + .andDo(^(NSInvocation* invocation) { + CGSize size; + [invocation getArgument:&size atIndex:2]; + OCMStub([textureMock width]).andReturn(size.width); + OCMStub([textureMock height]).andReturn(size.height); + }) + .andReturn(backingStoreMock); + return [viewMock](uint64_t view_id) { return viewMock; }; +} +TEST(FlutterMetalCompositorTest, TestPresent) { std::unique_ptr macos_compositor = std::make_unique( - mockViewController, /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); + MockGetViewCallback(), /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); bool flag = false; macos_compositor->SetPresentCallback([f = &flag](bool has_flutter_content) { @@ -28,12 +46,9 @@ } TEST(FlutterMetalCompositorTest, TestCreate) { - id mockViewController = CreateMockViewController(); - [mockViewController loadView]; - std::unique_ptr macos_compositor = std::make_unique( - mockViewController, /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); + MockGetViewCallback(), /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); FlutterBackingStore backing_store; FlutterBackingStoreConfig config; @@ -50,12 +65,9 @@ } TEST(FlutterMetalCompositorTest, TestCompositing) { - id mockViewController = CreateMockViewController(); - [mockViewController loadView]; - std::unique_ptr macos_compositor = std::make_unique( - mockViewController, /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); + MockGetViewCallback(), /*platform_view_controller*/ nullptr, /*mtl_device*/ nullptr); FlutterBackingStore backing_store; FlutterBackingStoreConfig config; From 7c4676fd01037966ef55441a7b8b13caf0f5051c Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 23 Sep 2022 14:49:06 -0700 Subject: [PATCH 02/10] Explain 0 --- .../darwin/macos/framework/Source/FlutterCompositor.mm | 2 ++ .../darwin/macos/framework/Source/FlutterGLCompositor.mm | 2 ++ .../darwin/macos/framework/Source/FlutterMetalCompositor.mm | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index c18a589c55855..7d6c93f7c754f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -47,6 +47,8 @@ void FlutterCompositor::InsertCALayerForIOSurface(const IOSurfaceRef& io_surface, CATransform3D transform) { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. FlutterView* view = GetView(0); if (!view) { return; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index 187152160669f..6969118d6aa80 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -25,6 +25,8 @@ bool FlutterGLCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. FlutterView* view = GetView(0); if (!view) { return false; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index 824e66044d049..34b60da002a5a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -20,6 +20,8 @@ bool FlutterMetalCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. FlutterView* view = GetView(0); if (!view) { return false; @@ -97,6 +99,8 @@ break; } case kFlutterLayerContentTypePlatformView: { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. FlutterView* view = GetView(0); if (!view) { return false; From 954c501a42f28b3fb9e552c802bd0d75adec6ebe Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 23 Sep 2022 16:48:29 -0700 Subject: [PATCH 03/10] InsertCALayerForIOSurface use view --- .../macos/framework/Source/FlutterCompositor.h | 3 ++- .../macos/framework/Source/FlutterCompositor.mm | 9 ++------- .../framework/Source/FlutterMetalCompositor.mm | 15 ++++++++------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 99431f1a5378f..6999be7e54b73 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -78,8 +78,9 @@ class FlutterCompositor { bool EndFrame(bool has_flutter_content); // Creates a CALayer object which is backed by the supplied IOSurface, and - // adds it to the root CALayer for this FlutterViewController's view. + // adds it to the root CALayer for the given view. void InsertCALayerForIOSurface( + FlutterView* view, const IOSurfaceRef& io_surface, CATransform3D transform = CATransform3DIdentity); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 7d6c93f7c754f..cf3fcc478268c 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -45,14 +45,9 @@ return frame_status_; } -void FlutterCompositor::InsertCALayerForIOSurface(const IOSurfaceRef& io_surface, +void FlutterCompositor::InsertCALayerForIOSurface(FlutterView* view, + const IOSurfaceRef& io_surface, CATransform3D transform) { - // Always gets the first view, #0. After Flutter supports multi-view, it - // should get the view ID from somewhere. - FlutterView* view = GetView(0); - if (!view) { - return; - } // FlutterCompositor manages the lifecycle of CALayers. CALayer* content_layer = [[CALayer alloc] init]; content_layer.transform = transform; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index 34b60da002a5a..a1cd6e63decbb 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -80,6 +80,13 @@ } bool FlutterMetalCompositor::Present(const FlutterLayer** layers, size_t layers_count) { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. + FlutterView* view = GetView(0); + if (!view) { + return false; + } + SetFrameStatus(FrameStatus::kPresenting); bool has_flutter_content = false; @@ -93,18 +100,12 @@ FlutterIOSurfaceHolder* io_surface_holder = (__bridge FlutterIOSurfaceHolder*)backing_store->metal.texture.user_data; IOSurfaceRef io_surface = [io_surface_holder ioSurface]; - InsertCALayerForIOSurface(io_surface); + InsertCALayerForIOSurface(view, io_surface); } has_flutter_content = true; break; } case kFlutterLayerContentTypePlatformView: { - // Always gets the first view, #0. After Flutter supports multi-view, it - // should get the view ID from somewhere. - FlutterView* view = GetView(0); - if (!view) { - return false; - } PresentPlatformView(view, layer, i); break; } From 3bed3d19a0256a2c1b91a450f67e15ee9b4edb73 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 23 Sep 2022 18:20:52 -0700 Subject: [PATCH 04/10] Fix compile --- .../darwin/macos/framework/Source/FlutterGLCompositor.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index 6969118d6aa80..de8b76a387cd4 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -77,6 +77,13 @@ } bool FlutterGLCompositor::Present(const FlutterLayer** layers, size_t layers_count) { + // Always gets the first view, #0. After Flutter supports multi-view, it + // should get the view ID from somewhere. + FlutterView* view = GetView(0); + if (!view) { + return false; + } + SetFrameStatus(FrameStatus::kPresenting); bool has_flutter_content = false; @@ -95,7 +102,7 @@ // The surface is an OpenGL texture, which means it has origin in bottom left corner // and needs to be flipped vertically - InsertCALayerForIOSurface(io_surface, CATransform3DMakeScale(1, -1, 1)); + InsertCALayerForIOSurface(view, io_surface, CATransform3DMakeScale(1, -1, 1)); } has_flutter_content = true; break; From 812e2a216f8a4e9e9b09f7c4f78a12a3eb10fae9 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 27 Sep 2022 20:24:12 -0700 Subject: [PATCH 05/10] Fix comment --- .../darwin/macos/framework/Source/FlutterEngine.mm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 339d8f8a2a7ee..0db49428d2107 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -428,22 +428,21 @@ - (FlutterCompositor*)createFlutterCompositor { // TODO(richardjcai): Add support for creating a FlutterCompositor // with a nil _viewController for headless engines. // https://github.com/flutter/flutter/issues/71606 - FlutterViewController* viewController = _viewController; - if (!viewController) { + if (!_viewController) { return nil; } __weak FlutterEngine* weakSelf = self; - flutter::FlutterCompositor::GetViewCallback get_view_callback = - [&viewController](uint64_t view_id) { - return viewController == nullptr ? nullptr : viewController.flutterView; + flutter::FlutterCompositor::GetViewCallback getViewCallback = + [weakSelf](uint64_t view_id) { + return weakSelf.viewController == nullptr ? nullptr : weakSelf.viewController.flutterView; }; if ([FlutterRenderingBackend renderUsingMetal]) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); _macOSCompositor = std::make_unique( - std::move(get_view_callback), _platformViewController, metalRenderer.device); + std::move(getViewCallback), _platformViewController, metalRenderer.device); _macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(weakSelf.renderer); @@ -457,7 +456,7 @@ - (FlutterCompositor*)createFlutterCompositor { } else { FlutterOpenGLRenderer* openGLRenderer = reinterpret_cast(_renderer); [openGLRenderer.openGLContext makeCurrentContext]; - _macOSCompositor = std::make_unique(std::move(get_view_callback), + _macOSCompositor = std::make_unique(std::move(getViewCallback), openGLRenderer.openGLContext); _macOSCompositor->SetPresentCallback([weakSelf](bool has_flutter_content) { From 118fcdd03ab7640261d4d2ee9057db638579e342 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Tue, 27 Sep 2022 20:25:18 -0700 Subject: [PATCH 06/10] code ctyle --- .../darwin/macos/framework/Source/FlutterEngine.mm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 0db49428d2107..290cdcfcd15d7 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -434,10 +434,9 @@ - (FlutterCompositor*)createFlutterCompositor { __weak FlutterEngine* weakSelf = self; - flutter::FlutterCompositor::GetViewCallback getViewCallback = - [weakSelf](uint64_t view_id) { - return weakSelf.viewController == nullptr ? nullptr : weakSelf.viewController.flutterView; - }; + flutter::FlutterCompositor::GetViewCallback getViewCallback = [weakSelf](uint64_t view_id) { + return weakSelf.viewController == nullptr ? nullptr : weakSelf.viewController.flutterView; + }; if ([FlutterRenderingBackend renderUsingMetal]) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); From aaebfc32c800bad7a1eaeb1950e535b18c7db335 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 30 Sep 2022 11:01:52 -0700 Subject: [PATCH 07/10] ViewProvider --- .../darwin/macos/framework/Source/FlutterCompositor.h | 6 +++--- .../darwin/macos/framework/Source/FlutterCompositor.mm | 2 +- .../platform/darwin/macos/framework/Source/FlutterEngine.mm | 2 +- .../darwin/macos/framework/Source/FlutterGLCompositor.h | 2 +- .../darwin/macos/framework/Source/FlutterGLCompositor.mm | 2 +- .../macos/framework/Source/FlutterGLCompositorUnittests.mm | 2 +- .../darwin/macos/framework/Source/FlutterMetalCompositor.h | 2 +- .../darwin/macos/framework/Source/FlutterMetalCompositor.mm | 2 +- .../framework/Source/FlutterMetalCompositorUnittests.mm | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 6999be7e54b73..07792fbddb26b 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -19,9 +19,9 @@ namespace flutter { // Platform views are not yet supported. class FlutterCompositor { public: - using GetViewCallback = std::function; + using ViewProvider = std::function; - explicit FlutterCompositor(GetViewCallback get_view_callback); + explicit FlutterCompositor(ViewProvider get_view_callback); virtual ~FlutterCompositor() = default; @@ -88,7 +88,7 @@ class FlutterCompositor { // A list of the active CALayer objects for the frame that need to be removed. std::list active_ca_layers_; - GetViewCallback get_view_callback_; + ViewProvider get_view_callback_; // Callback set by the embedder to be called when the layer tree has been // correctly set up for this frame. diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index cf3fcc478268c..3c0490f1fcaa7 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -7,7 +7,7 @@ namespace flutter { -FlutterCompositor::FlutterCompositor(GetViewCallback get_view_callback) { +FlutterCompositor::FlutterCompositor(ViewProvider get_view_callback) { get_view_callback_ = std::move(get_view_callback); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 290cdcfcd15d7..52598b81ced11 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -434,7 +434,7 @@ - (FlutterCompositor*)createFlutterCompositor { __weak FlutterEngine* weakSelf = self; - flutter::FlutterCompositor::GetViewCallback getViewCallback = [weakSelf](uint64_t view_id) { + flutter::FlutterCompositor::ViewProvider getViewCallback = [weakSelf](uint64_t view_id) { return weakSelf.viewController == nullptr ? nullptr : weakSelf.viewController.flutterView; }; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h index 24abfc2eda3fc..4ed49110a635a 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h @@ -19,7 +19,7 @@ namespace flutter { // FlutterGLCompositor is created and destroyed by FlutterEngine. class FlutterGLCompositor : public FlutterCompositor { public: - FlutterGLCompositor(GetViewCallback get_view_callback, + FlutterGLCompositor(ViewProvider get_view_callback, NSOpenGLContext* opengl_context); virtual ~FlutterGLCompositor() = default; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index de8b76a387cd4..f6113b9ad0c1b 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -19,7 +19,7 @@ namespace flutter { -FlutterGLCompositor::FlutterGLCompositor(GetViewCallback get_view_callback, +FlutterGLCompositor::FlutterGLCompositor(ViewProvider get_view_callback, NSOpenGLContext* opengl_context) : FlutterCompositor(get_view_callback), open_gl_context_(opengl_context) {} diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm index 2a9da0e49072a..b4693ce136966 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm @@ -13,7 +13,7 @@ TEST(FlutterGLCompositorTest, TestPresent) { id mock_view = OCMClassMock([FlutterView class]); - flutter::FlutterCompositor::GetViewCallback get_view_callback = [&mock_view](uint64_t view_id) { + flutter::FlutterCompositor::ViewProvider get_view_callback = [&mock_view](uint64_t view_id) { return mock_view; }; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h index 1c142673a6e1e..1cbd21d2a437c 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h @@ -14,7 +14,7 @@ namespace flutter { class FlutterMetalCompositor : public FlutterCompositor { public: explicit FlutterMetalCompositor( - GetViewCallback get_view_callback, + ViewProvider get_view_callback, FlutterPlatformViewController* platform_views_controller, id mtl_device); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index a1cd6e63decbb..901f8464071fb 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -11,7 +11,7 @@ namespace flutter { FlutterMetalCompositor::FlutterMetalCompositor( - GetViewCallback get_view_callback, + ViewProvider get_view_callback, FlutterPlatformViewController* platform_views_controller, id mtl_device) : FlutterCompositor(get_view_callback), diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm index 531c85fc1a047..a5c4170b1a7b0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm @@ -11,7 +11,7 @@ namespace flutter::testing { -flutter::FlutterCompositor::GetViewCallback MockGetViewCallback() { +flutter::FlutterCompositor::ViewProvider MockGetViewCallback() { FlutterView* viewMock = OCMClassMock([FlutterView class]); FlutterMetalRenderBackingStore* backingStoreMock = OCMClassMock([FlutterMetalRenderBackingStore class]); From 6155d8118a1952b1188e44667812718b3c6e7831 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Fri, 23 Sep 2022 19:18:55 -0700 Subject: [PATCH 08/10] Impl Format view -> surface --- flow/embedded_views.cc | 1 + flow/embedded_views.h | 1 + shell/common/rasterizer.cc | 5 +++- shell/common/rasterizer_unittests.cc | 3 ++- .../shell_test_external_view_embedder.cc | 1 + .../shell_test_external_view_embedder.h | 1 + .../external_view_embedder.cc | 1 + .../external_view_embedder.h | 1 + .../external_view_embedder_unittests.cc | 16 ++++++------- .../framework/Source/FlutterCompositor.h | 6 +++-- .../framework/Source/FlutterCompositor.mm | 4 ++-- .../macos/framework/Source/FlutterEngine.mm | 12 ++++++---- .../framework/Source/FlutterGLCompositor.h | 4 +++- .../framework/Source/FlutterGLCompositor.mm | 8 +++---- .../Source/FlutterGLCompositorUnittests.mm | 2 +- .../framework/Source/FlutterMetalCompositor.h | 4 +++- .../Source/FlutterMetalCompositor.mm | 12 ++++------ .../Source/FlutterMetalCompositorUnittests.mm | 2 +- shell/platform/embedder/embedder.cc | 10 ++++---- shell/platform/embedder/embedder.h | 16 +++++++++---- .../embedder_external_view_embedder.cc | 9 +++++--- .../embedder_external_view_embedder.h | 4 +++- shell/platform/embedder/embedder_layers.cc | 6 ++--- shell/platform/embedder/embedder_layers.h | 6 +++-- .../embedder/tests/embedder_config_builder.cc | 23 +++++++++++-------- .../tests/embedder_test_compositor.cc | 3 ++- .../embedder/tests/embedder_test_compositor.h | 4 +++- .../embedder/tests/embedder_unittests_gl.cc | 2 +- 28 files changed, 102 insertions(+), 65 deletions(-) diff --git a/flow/embedded_views.cc b/flow/embedded_views.cc index ebc1812755488..caa75b4e7914d 100644 --- a/flow/embedded_views.cc +++ b/flow/embedded_views.cc @@ -70,6 +70,7 @@ void DisplayListEmbedderViewSlice::render_into(DisplayListBuilder* builder) { } void ExternalViewEmbedder::SubmitFrame(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) { frame->Submit(); }; diff --git a/flow/embedded_views.h b/flow/embedded_views.h index 14ca2ba12b348..54ef3a5264093 100644 --- a/flow/embedded_views.h +++ b/flow/embedded_views.h @@ -405,6 +405,7 @@ class ExternalViewEmbedder { // // It can also allocate frames for overlay surfaces to compose hybrid views. virtual void SubmitFrame(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame); // This method provides the embedder a way to do additional tasks after diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 7f66f93ff8830..cf28ac634b29a 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -488,6 +488,9 @@ RasterStatus Rasterizer::DrawToSurface( RasterStatus Rasterizer::DrawToSurfaceUnsafe( FrameTimingsRecorder& frame_timings_recorder, flutter::LayerTree& layer_tree) { + // Always gets the first surface, #0. After Flutter supports multi-view, it + // should get the surface ID from layer_tree. + uint64_t surface_id = 0; FML_DCHECK(surface_); compositor_context_->ui_time().SetLapTime( @@ -594,7 +597,7 @@ RasterStatus Rasterizer::DrawToSurfaceUnsafe( if (external_view_embedder_ && (!raster_thread_merger_ || raster_thread_merger_->IsMerged())) { FML_DCHECK(!frame->IsSubmitted()); - external_view_embedder_->SubmitFrame(surface_->GetContext(), + external_view_embedder_->SubmitFrame(surface_->GetContext(), surface_id, std::move(frame)); } else { frame->Submit(); diff --git a/shell/common/rasterizer_unittests.cc b/shell/common/rasterizer_unittests.cc index a6f7ab7159e5d..1daa29a2cfe9f 100644 --- a/shell/common/rasterizer_unittests.cc +++ b/shell/common/rasterizer_unittests.cc @@ -69,8 +69,9 @@ class MockExternalViewEmbedder : public ExternalViewEmbedder { MOCK_METHOD0(GetCurrentCanvases, std::vector()); MOCK_METHOD0(GetCurrentBuilders, std::vector()); MOCK_METHOD1(CompositeEmbeddedView, EmbedderPaintContext(int view_id)); - MOCK_METHOD2(SubmitFrame, + MOCK_METHOD3(SubmitFrame, void(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame)); MOCK_METHOD2(EndFrame, void(bool should_resubmit_frame, diff --git a/shell/common/shell_test_external_view_embedder.cc b/shell/common/shell_test_external_view_embedder.cc index 789ebc22d72b8..9051a78e5aa50 100644 --- a/shell/common/shell_test_external_view_embedder.cc +++ b/shell/common/shell_test_external_view_embedder.cc @@ -106,6 +106,7 @@ EmbedderPaintContext ShellTestExternalViewEmbedder::CompositeEmbeddedView( // |ExternalViewEmbedder| void ShellTestExternalViewEmbedder::SubmitFrame( GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) { if (!frame) { return; diff --git a/shell/common/shell_test_external_view_embedder.h b/shell/common/shell_test_external_view_embedder.h index 583a09182e5fc..17b847422d460 100644 --- a/shell/common/shell_test_external_view_embedder.h +++ b/shell/common/shell_test_external_view_embedder.h @@ -80,6 +80,7 @@ class ShellTestExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFrame(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) override; // |ExternalViewEmbedder| diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.cc b/shell/platform/android/external_view_embedder/external_view_embedder.cc index c1054c78b9ee6..be7d6c6f05ed3 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder.cc @@ -99,6 +99,7 @@ SkRect AndroidExternalViewEmbedder::GetViewRect(int view_id) const { // |ExternalViewEmbedder| void AndroidExternalViewEmbedder::SubmitFrame( GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) { TRACE_EVENT0("flutter", "AndroidExternalViewEmbedder::SubmitFrame"); diff --git a/shell/platform/android/external_view_embedder/external_view_embedder.h b/shell/platform/android/external_view_embedder/external_view_embedder.h index 0b258854408d6..d3655b98091ba 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder.h +++ b/shell/platform/android/external_view_embedder/external_view_embedder.h @@ -55,6 +55,7 @@ class AndroidExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFrame(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) override; // |ExternalViewEmbedder| diff --git a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc index b174cd92703f9..c71425451ee74 100644 --- a/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc +++ b/shell/platform/android/external_view_embedder/external_view_embedder_unittests.cc @@ -371,7 +371,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); // Submits frame if no Android view in the current frame. EXPECT_TRUE(did_submit_frame); // Doesn't resubmit frame. @@ -439,7 +439,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); // Doesn't submit frame if there aren't Android views in the previous frame. EXPECT_FALSE(did_submit_frame); // Resubmits frame. @@ -504,7 +504,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); // Submits frame if there are Android views in the previous frame. EXPECT_TRUE(did_submit_frame); // Doesn't resubmit frame. @@ -614,7 +614,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFrameOverlayComposition) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); @@ -683,7 +683,7 @@ TEST(AndroidExternalViewEmbedder, SubmitFramePlatformViewWithoutAnyOverlay) { }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); @@ -785,7 +785,7 @@ TEST(AndroidExternalViewEmbedder, DestroyOverlayLayersOnSizeChange) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); @@ -873,7 +873,7 @@ TEST(AndroidExternalViewEmbedder, DoesNotDestroyOverlayLayersOnSizeChange) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); EXPECT_CALL(*jni_mock, FlutterViewEndFrame()); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); @@ -985,7 +985,7 @@ TEST(AndroidExternalViewEmbedder, Teardown) { SkSurface::MakeNull(1000, 1000), framebuffer_info, [](const SurfaceFrame& surface_frame, SkCanvas* canvas) { return true; }, /*frame_size=*/SkISize::Make(800, 600)); - embedder->SubmitFrame(gr_context.get(), std::move(surface_frame)); + embedder->SubmitFrame(gr_context.get(), 0, std::move(surface_frame)); embedder->EndFrame(/*should_resubmit_frame=*/false, raster_thread_merger); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 07792fbddb26b..6758aaf3e07ee 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -46,7 +46,9 @@ class FlutterCompositor { // Presents the FlutterLayers by updating FlutterView(s) using the // layer content. // Present sets frame_started_ to false. - virtual bool Present(const FlutterLayer** layers, size_t layers_count) = 0; + virtual bool Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) = 0; using PresentCallback = std::function; @@ -64,7 +66,7 @@ class FlutterCompositor { typedef enum { kStarted, kPresenting, kEnded } FrameStatus; protected: - FlutterView* GetView(uint64_t view_id); + FlutterView* GetView(uint64_t surface_id); // Gets and sets the FrameStatus for the current frame. void SetFrameStatus(FrameStatus frame_status); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm index 3c0490f1fcaa7..fe15d798dc62e 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm @@ -33,8 +33,8 @@ return status; } -FlutterView* FlutterCompositor::GetView(uint64_t view_id) { - return get_view_callback_(view_id); +FlutterView* FlutterCompositor::GetView(uint64_t surface_id) { + return get_view_callback_(surface_id); } void FlutterCompositor::SetFrameStatus(FlutterCompositor::FrameStatus frame_status) { diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 8931ab1432d19..820fa59b5b910 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -476,11 +476,13 @@ - (FlutterCompositor*)createFlutterCompositor { backing_store); }; - _compositor.present_layers_callback = [](const FlutterLayer** layers, // - size_t layers_count, // - void* user_data // - ) { - return reinterpret_cast(user_data)->Present(layers, layers_count); + _compositor.present_layers_surface_callback = [](uint64_t surface_id, // + const FlutterLayer** layers, // + size_t layers_count, // + void* user_data // + ) { + return reinterpret_cast(user_data)->Present(surface_id, layers, + layers_count); }; _compositor.avoid_backing_store_cache = true; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h index 4ed49110a635a..64f816b2e8d2d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.h @@ -44,7 +44,9 @@ class FlutterGLCompositor : public FlutterCompositor { // Presents the FlutterLayers by updating FlutterView(s) using the // layer content. // Present sets frame_started_ to false. - bool Present(const FlutterLayer** layers, size_t layers_count) override; + bool Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) override; private: const NSOpenGLContext* open_gl_context_; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index f6113b9ad0c1b..b718bb34b42e0 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -25,9 +25,7 @@ bool FlutterGLCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { - // Always gets the first view, #0. After Flutter supports multi-view, it - // should get the view ID from somewhere. - FlutterView* view = GetView(0); + FlutterView* view = GetView(config->surface_id); if (!view) { return false; } @@ -76,7 +74,9 @@ return true; } -bool FlutterGLCompositor::Present(const FlutterLayer** layers, size_t layers_count) { +bool FlutterGLCompositor::Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) { // Always gets the first view, #0. After Flutter supports multi-view, it // should get the view ID from somewhere. FlutterView* view = GetView(0); diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm index b4693ce136966..9d5031828a09d 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositorUnittests.mm @@ -26,7 +26,7 @@ return true; }); - ASSERT_TRUE(macos_compositor->Present(nil, 0)); + ASSERT_TRUE(macos_compositor->Present(0, nil, 0)); ASSERT_TRUE(flag); } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h index 1cbd21d2a437c..d5181cce1daab 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h @@ -42,7 +42,9 @@ class FlutterMetalCompositor : public FlutterCompositor { // Composites the provided FlutterLayer objects and presents the composited // frame to the FlutterView(s). - bool Present(const FlutterLayer** layers, size_t layers_count) override; + bool Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) override; private: // Presents the platform view layer represented by `layer`. `layer_index` is diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index 901f8464071fb..edc57ac367f83 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -20,9 +20,7 @@ bool FlutterMetalCompositor::CreateBackingStore(const FlutterBackingStoreConfig* config, FlutterBackingStore* backing_store_out) { - // Always gets the first view, #0. After Flutter supports multi-view, it - // should get the view ID from somewhere. - FlutterView* view = GetView(0); + FlutterView* view = GetView(config->surface_id); if (!view) { return false; } @@ -79,10 +77,10 @@ return true; } -bool FlutterMetalCompositor::Present(const FlutterLayer** layers, size_t layers_count) { - // Always gets the first view, #0. After Flutter supports multi-view, it - // should get the view ID from somewhere. - FlutterView* view = GetView(0); +bool FlutterMetalCompositor::Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) { + FlutterView* view = GetView(surface_id); if (!view) { return false; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm index a5c4170b1a7b0..2a63b38335ade 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm @@ -41,7 +41,7 @@ return true; }); - ASSERT_TRUE(macos_compositor->Present(nil, 0)); + ASSERT_TRUE(macos_compositor->Present(0, nil, 0)); ASSERT_TRUE(flag); } diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index dcb19c02028ff..d090343ee8479 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -1034,7 +1034,7 @@ InferExternalViewEmbedderFromArgs(const FlutterCompositor* compositor) { auto c_collect_callback = SAFE_ACCESS(compositor, collect_backing_store_callback, nullptr); auto c_present_callback = - SAFE_ACCESS(compositor, present_layers_callback, nullptr); + SAFE_ACCESS(compositor, present_layers_surface_callback, nullptr); bool avoid_backing_store_cache = SAFE_ACCESS(compositor, avoid_backing_store_cache, false); @@ -1054,12 +1054,12 @@ InferExternalViewEmbedderFromArgs(const FlutterCompositor* compositor) { }; flutter::EmbedderExternalViewEmbedder::PresentCallback present_callback = - [c_present_callback, - user_data = compositor->user_data](const auto& layers) { + [c_present_callback, user_data = compositor->user_data]( + uint64_t surface_id, const auto& layers) { TRACE_EVENT0("flutter", "FlutterCompositorPresentLayers"); return c_present_callback( - const_cast(layers.data()), layers.size(), - user_data); + surface_id, const_cast(layers.data()), + layers.size(), user_data); }; return {std::make_unique( diff --git a/shell/platform/embedder/embedder.h b/shell/platform/embedder/embedder.h index c12452c788490..72a66d2385f89 100644 --- a/shell/platform/embedder/embedder.h +++ b/shell/platform/embedder/embedder.h @@ -1371,6 +1371,8 @@ typedef struct { size_t struct_size; /// The size of the render target the engine expects to render into. FlutterSize size; + /// Indicates the view that owns the layer this store is backing. + uint64_t surface_id; } FlutterBackingStoreConfig; typedef enum { @@ -1414,6 +1416,10 @@ typedef bool (*FlutterBackingStoreCollectCallback)( typedef bool (*FlutterLayersPresentCallback)(const FlutterLayer** layers, size_t layers_count, void* user_data); +typedef bool (*FlutterLayersPresentSurfaceCallback)(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count, + void* user_data); typedef struct { /// This size of this struct. Must be sizeof(FlutterCompositor). @@ -1421,7 +1427,7 @@ typedef struct { /// A baton that in not interpreted by the engine in any way. If it passed /// back to the embedder in `FlutterCompositor.create_backing_store_callback`, /// `FlutterCompositor.collect_backing_store_callback` and - /// `FlutterCompositor.present_layers_callback` + /// `FlutterCompositor.present_layers_surface_callback` void* user_data; /// A callback invoked by the engine to obtain a backing store for a specific /// `FlutterLayer`. @@ -1434,11 +1440,13 @@ typedef struct { /// A callback invoked by the engine to release the backing store. The /// embedder may collect any resources associated with the backing store. FlutterBackingStoreCollectCallback collect_backing_store_callback; - /// Callback invoked by the engine to composite the contents of each layer - /// onto the screen. - FlutterLayersPresentCallback present_layers_callback; + /// A deprecated callback. It is not used and should not be set. + void* _deprecated_present_layers_callback; /// Avoid caching backing stores provided by this compositor. bool avoid_backing_store_cache; + /// Callback invoked by the engine to composite the contents of each layer + /// onto the screen. + FlutterLayersPresentSurfaceCallback present_layers_surface_callback; } FlutterCompositor; typedef struct { diff --git a/shell/platform/embedder/embedder_external_view_embedder.cc b/shell/platform/embedder/embedder_external_view_embedder.cc index 0e61db48ce8d8..0371abdd09f68 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.cc +++ b/shell/platform/embedder/embedder_external_view_embedder.cc @@ -131,13 +131,15 @@ EmbedderPaintContext EmbedderExternalViewEmbedder::CompositeEmbeddedView( } static FlutterBackingStoreConfig MakeBackingStoreConfig( - const SkISize& backing_store_size) { + const SkISize& backing_store_size, + uint64_t surface_id) { FlutterBackingStoreConfig config = {}; config.struct_size = sizeof(config); config.size.width = backing_store_size.width(); config.size.height = backing_store_size.height(); + config.surface_id = surface_id; return config; } @@ -145,6 +147,7 @@ static FlutterBackingStoreConfig MakeBackingStoreConfig( // |ExternalViewEmbedder| void EmbedderExternalViewEmbedder::SubmitFrame( GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) { auto [matched_render_targets, pending_keys] = render_target_cache_.GetExistingTargetsInCache(pending_views_); @@ -184,7 +187,7 @@ void EmbedderExternalViewEmbedder::SubmitFrame( const auto render_surface_size = external_view->GetRenderSurfaceSize(); const auto backing_store_config = - MakeBackingStoreConfig(render_surface_size); + MakeBackingStoreConfig(render_surface_size, frame_view_id); // This is where the embedder will create render targets for us. Control // flow to the embedder makes the engine susceptible to having the embedder @@ -263,7 +266,7 @@ void EmbedderExternalViewEmbedder::SubmitFrame( // Flush the layer description down to the embedder for presentation. // // @warning: Embedder may trample on our OpenGL context here. - presented_layers.InvokePresentCallback(present_callback_); + presented_layers.InvokePresentCallback(present_callback_, frame_view_id); } // See why this is necessary in the comment where this collection in realized. diff --git a/shell/platform/embedder/embedder_external_view_embedder.h b/shell/platform/embedder/embedder_external_view_embedder.h index 7921cb8b78255..8edad877dd2c7 100644 --- a/shell/platform/embedder/embedder_external_view_embedder.h +++ b/shell/platform/embedder/embedder_external_view_embedder.h @@ -33,7 +33,8 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { GrDirectContext* context, const FlutterBackingStoreConfig& config)>; using PresentCallback = - std::function& layers)>; + std::function& layers)>; using SurfaceTransformationCallback = std::function; //---------------------------------------------------------------------------- @@ -101,6 +102,7 @@ class EmbedderExternalViewEmbedder final : public ExternalViewEmbedder { // |ExternalViewEmbedder| void SubmitFrame(GrDirectContext* context, + uint64_t frame_view_id, std::unique_ptr frame) override; // |ExternalViewEmbedder| diff --git a/shell/platform/embedder/embedder_layers.cc b/shell/platform/embedder/embedder_layers.cc index 6465293748f9f..e612779dd73b9 100644 --- a/shell/platform/embedder/embedder_layers.cc +++ b/shell/platform/embedder/embedder_layers.cc @@ -199,14 +199,14 @@ void EmbedderLayers::PushPlatformViewLayer( presented_layers_.push_back(layer); } -void EmbedderLayers::InvokePresentCallback( - const PresentCallback& callback) const { +void EmbedderLayers::InvokePresentCallback(const PresentCallback& callback, + uint64_t frame_view_id) const { std::vector presented_layers_pointers; presented_layers_pointers.reserve(presented_layers_.size()); for (const auto& layer : presented_layers_) { presented_layers_pointers.push_back(&layer); } - callback(presented_layers_pointers); + callback(frame_view_id, presented_layers_pointers); } } // namespace flutter diff --git a/shell/platform/embedder/embedder_layers.h b/shell/platform/embedder/embedder_layers.h index c1cb2907588c9..9ad7bb64c3b70 100644 --- a/shell/platform/embedder/embedder_layers.h +++ b/shell/platform/embedder/embedder_layers.h @@ -30,8 +30,10 @@ class EmbedderLayers { const EmbeddedViewParams& params); using PresentCallback = - std::function& layers)>; - void InvokePresentCallback(const PresentCallback& callback) const; + std::function& layers)>; + void InvokePresentCallback(const PresentCallback& callback, + uint64_t frame_view_id) const; private: const SkISize frame_size_; diff --git a/shell/platform/embedder/tests/embedder_config_builder.cc b/shell/platform/embedder/tests/embedder_config_builder.cc index 58e48c4b594d8..dfa32fa7bcb44 100644 --- a/shell/platform/embedder/tests/embedder_config_builder.cc +++ b/shell/platform/embedder/tests/embedder_config_builder.cc @@ -355,16 +355,19 @@ void EmbedderConfigBuilder::SetCompositor(bool avoid_backing_store_cache) { return reinterpret_cast(user_data) ->CollectBackingStore(backing_store); }; - compositor_.present_layers_callback = [](const FlutterLayer** layers, // - size_t layers_count, // - void* user_data // - ) { - return reinterpret_cast(user_data)->Present( - layers, // - layers_count // - - ); - }; + compositor_.present_layers_surface_callback = + [](uint64_t surface_id, + const FlutterLayer** layers, // + size_t layers_count, // + void* user_data // + ) { + return reinterpret_cast(user_data)->Present( + surface_id, + layers, // + layers_count // + + ); + }; compositor_.avoid_backing_store_cache = avoid_backing_store_cache; project_args_.compositor = &compositor_; } diff --git a/shell/platform/embedder/tests/embedder_test_compositor.cc b/shell/platform/embedder/tests/embedder_test_compositor.cc index 23afb36f01e72..bdd2d4297cbe7 100644 --- a/shell/platform/embedder/tests/embedder_test_compositor.cc +++ b/shell/platform/embedder/tests/embedder_test_compositor.cc @@ -58,7 +58,8 @@ sk_sp EmbedderTestCompositor::GetLastComposition() { return last_composition_; } -bool EmbedderTestCompositor::Present(const FlutterLayer** layers, +bool EmbedderTestCompositor::Present(uint64_t view_id, + const FlutterLayer** layers, size_t layers_count) { if (!UpdateOffscrenComposition(layers, layers_count)) { FML_LOG(ERROR) diff --git a/shell/platform/embedder/tests/embedder_test_compositor.h b/shell/platform/embedder/tests/embedder_test_compositor.h index 26d96de6cda81..79393e0e54759 100644 --- a/shell/platform/embedder/tests/embedder_test_compositor.h +++ b/shell/platform/embedder/tests/embedder_test_compositor.h @@ -36,7 +36,9 @@ class EmbedderTestCompositor { bool CollectBackingStore(const FlutterBackingStore* backing_store); - bool Present(const FlutterLayer** layers, size_t layers_count); + bool Present(uint64_t view_id, + const FlutterLayer** layers, + size_t layers_count); void SetPlatformViewRendererCallback( const PlatformViewRendererCallback& callback); diff --git a/shell/platform/embedder/tests/embedder_unittests_gl.cc b/shell/platform/embedder/tests/embedder_unittests_gl.cc index 08f653495f379..cd2b8840a4946 100644 --- a/shell/platform/embedder/tests/embedder_unittests_gl.cc +++ b/shell/platform/embedder/tests/embedder_unittests_gl.cc @@ -71,7 +71,7 @@ TEST_F(EmbedderTest, builder.SetCompositor(); builder.GetCompositor().create_backing_store_callback = nullptr; builder.GetCompositor().collect_backing_store_callback = nullptr; - builder.GetCompositor().present_layers_callback = nullptr; + builder.GetCompositor().present_layers_surface_callback = nullptr; auto engine = builder.LaunchEngine(); ASSERT_FALSE(engine.is_valid()); } From 4c7fc3a3838c742faf3a3d64341a23363ba9f156 Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 3 Nov 2022 13:43:03 -0700 Subject: [PATCH 09/10] Compile --- .../darwin/macos/framework/Source/FlutterEngine.mm | 4 ---- .../darwin/macos/framework/Source/FlutterGLCompositor.mm | 7 ++----- .../macos/framework/Source/FlutterMetalCompositor.mm | 7 ++----- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 241e57c51bc8f..1df8303dc9a11 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -438,10 +438,6 @@ - (FlutterCompositor*)createFlutterCompositor { __weak FlutterEngine* weakSelf = self; - flutter::FlutterCompositor::ViewProvider getViewCallback = [weakSelf](uint64_t view_id) { - return weakSelf.viewController == nullptr ? nullptr : weakSelf.viewController.flutterView; - }; - if ([FlutterRenderingBackend renderUsingMetal]) { FlutterMetalRenderer* metalRenderer = reinterpret_cast(_renderer); _macOSCompositor = std::make_unique( diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index 8ab6a993f8c86..f5454cae7e499 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -77,11 +77,8 @@ return true; } -bool FlutterGLCompositor::Present(const FlutterLayer** layers, size_t layers_count) { - // TODO(dkwingsmt): This class only supports single-view for now. As more - // classes are gradually converted to multi-view, it should get the view ID - // from somewhere. - FlutterView* view = GetView(kFlutterDefaultViewId); +bool FlutterGLCompositor::Present(uint64_t surface_id, const FlutterLayer** layers, size_t layers_count) { + FlutterView* view = GetView(surface_id); if (!view) { return false; } diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index 74eae76f8e885..d7932294bee56 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -80,11 +80,8 @@ return true; } -bool FlutterMetalCompositor::Present(const FlutterLayer** layers, size_t layers_count) { - // TODO(dkwingsmt): This class only supports single-view for now. As more - // classes are gradually converted to multi-view, it should get the view ID - // from somewhere. - FlutterView* view = GetView(kFlutterDefaultViewId); +bool FlutterMetalCompositor::Present(uint64_t surface_id, const FlutterLayer** layers, size_t layers_count) { + FlutterView* view = GetView(surface_id); if (!view) { return false; } From ac057c03fd3118aaedfd466cfa902e4ab79d479b Mon Sep 17 00:00:00 2001 From: Tong Mu Date: Thu, 3 Nov 2022 13:45:34 -0700 Subject: [PATCH 10/10] Format --- .../darwin/macos/framework/Source/FlutterGLCompositor.mm | 4 +++- .../darwin/macos/framework/Source/FlutterMetalCompositor.mm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm index f5454cae7e499..7400196543fce 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterGLCompositor.mm @@ -77,7 +77,9 @@ return true; } -bool FlutterGLCompositor::Present(uint64_t surface_id, const FlutterLayer** layers, size_t layers_count) { +bool FlutterGLCompositor::Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) { FlutterView* view = GetView(surface_id); if (!view) { return false; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm index d7932294bee56..148341651ae38 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -80,7 +80,9 @@ return true; } -bool FlutterMetalCompositor::Present(uint64_t surface_id, const FlutterLayer** layers, size_t layers_count) { +bool FlutterMetalCompositor::Present(uint64_t surface_id, + const FlutterLayer** layers, + size_t layers_count) { FlutterView* view = GetView(surface_id); if (!view) { return false;