diff --git a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h index 498d8c85e378a..9a7249d7dc1d6 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterCompositor.h @@ -47,10 +47,12 @@ class FlutterCompositor { virtual bool CollectBackingStore( const FlutterBackingStore* backing_store) = 0; - // Presents the FlutterLayers by updating FlutterView(s) using the - // layer content. + // Presents the FlutterLayers by updating the FlutterView specified by + // `view_id` 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 view_id, + const FlutterLayer** layers, + size_t layers_count) = 0; using PresentCallback = std::function; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm index 632bda5033349..7dd0c864841eb 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterEngine.mm @@ -458,7 +458,11 @@ - (FlutterCompositor*)createFlutterCompositor { size_t layers_count, // void* user_data // ) { - return reinterpret_cast(user_data)->Present(layers, layers_count); + // TODO(dkwingsmt): This callback only supports single-view, therefore it + // only operates on the default view. To support multi-view, we need a new + // callback that also receives a view ID. + return reinterpret_cast(user_data)->Present(kFlutterDefaultViewId, + layers, layers_count); }; _compositor.avoid_backing_store_cache = true; diff --git a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h index 9a4d462d81f2c..b2406baf91dea 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h @@ -40,9 +40,12 @@ class FlutterMetalCompositor : public FlutterCompositor { // for this FlutterBackingStore object in CreateBackingStore. bool CollectBackingStore(const FlutterBackingStore* backing_store) override; - // Composites the provided FlutterLayer objects and presents the composited - // frame to the FlutterView(s). - bool Present(const FlutterLayer** layers, size_t layers_count) override; + // Presents the FlutterLayers by updating the FlutterView specified by + // `view_id` using the layer content. + // Present sets frame_started_ to false. + bool Present(uint64_t view_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 74eae76f8e885..2e8ff9b176c5b 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm @@ -80,11 +80,10 @@ 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 view_id, + const FlutterLayer** layers, + size_t layers_count) { + FlutterView* view = GetView(view_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 4a2884cf61432..4084a61395d3f 100644 --- a/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm +++ b/shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm @@ -73,7 +73,7 @@ - (nullable FlutterView*)getView:(uint64_t)viewId { return true; }); - ASSERT_TRUE(macos_compositor->Present(nil, 0)); + ASSERT_TRUE(macos_compositor->Present(0, nil, 0)); ASSERT_TRUE(flag); }