Skip to content

Commit 754c2d4

Browse files
dkwingsmtschwa423
authored andcommitted
[Multiwindow, macOS] FlutterCompositor::Present receives view_id (flutter#37391)
* Impl and test * Change to default view
1 parent 7716557 commit 754c2d4

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

shell/platform/darwin/macos/framework/Source/FlutterCompositor.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ class FlutterCompositor {
4747
virtual bool CollectBackingStore(
4848
const FlutterBackingStore* backing_store) = 0;
4949

50-
// Presents the FlutterLayers by updating FlutterView(s) using the
51-
// layer content.
50+
// Presents the FlutterLayers by updating the FlutterView specified by
51+
// `view_id` using the layer content.
5252
// Present sets frame_started_ to false.
53-
virtual bool Present(const FlutterLayer** layers, size_t layers_count) = 0;
53+
virtual bool Present(uint64_t view_id,
54+
const FlutterLayer** layers,
55+
size_t layers_count) = 0;
5456

5557
using PresentCallback = std::function<bool(bool has_flutter_content)>;
5658

shell/platform/darwin/macos/framework/Source/FlutterEngine.mm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,11 @@ - (FlutterCompositor*)createFlutterCompositor {
458458
size_t layers_count, //
459459
void* user_data //
460460
) {
461-
return reinterpret_cast<flutter::FlutterCompositor*>(user_data)->Present(layers, layers_count);
461+
// TODO(dkwingsmt): This callback only supports single-view, therefore it
462+
// only operates on the default view. To support multi-view, we need a new
463+
// callback that also receives a view ID.
464+
return reinterpret_cast<flutter::FlutterCompositor*>(user_data)->Present(kFlutterDefaultViewId,
465+
layers, layers_count);
462466
};
463467

464468
_compositor.avoid_backing_store_cache = true;

shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@ class FlutterMetalCompositor : public FlutterCompositor {
4040
// for this FlutterBackingStore object in CreateBackingStore.
4141
bool CollectBackingStore(const FlutterBackingStore* backing_store) override;
4242

43-
// Composites the provided FlutterLayer objects and presents the composited
44-
// frame to the FlutterView(s).
45-
bool Present(const FlutterLayer** layers, size_t layers_count) override;
43+
// Presents the FlutterLayers by updating the FlutterView specified by
44+
// `view_id` using the layer content.
45+
// Present sets frame_started_ to false.
46+
bool Present(uint64_t view_id,
47+
const FlutterLayer** layers,
48+
size_t layers_count) override;
4649

4750
private:
4851
// Presents the platform view layer represented by `layer`. `layer_index` is

shell/platform/darwin/macos/framework/Source/FlutterMetalCompositor.mm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,10 @@
8080
return true;
8181
}
8282

83-
bool FlutterMetalCompositor::Present(const FlutterLayer** layers, size_t layers_count) {
84-
// TODO(dkwingsmt): This class only supports single-view for now. As more
85-
// classes are gradually converted to multi-view, it should get the view ID
86-
// from somewhere.
87-
FlutterView* view = GetView(kFlutterDefaultViewId);
83+
bool FlutterMetalCompositor::Present(uint64_t view_id,
84+
const FlutterLayer** layers,
85+
size_t layers_count) {
86+
FlutterView* view = GetView(view_id);
8887
if (!view) {
8988
return false;
9089
}

shell/platform/darwin/macos/framework/Source/FlutterMetalCompositorUnittests.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ - (nullable FlutterView*)getView:(uint64_t)viewId {
7373
return true;
7474
});
7575

76-
ASSERT_TRUE(macos_compositor->Present(nil, 0));
76+
ASSERT_TRUE(macos_compositor->Present(0, nil, 0));
7777
ASSERT_TRUE(flag);
7878
}
7979

0 commit comments

Comments
 (0)