Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Multiwindow, macOS] FlutterCompositor::Present receives view_id #37391

Merged
merged 5 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool(bool has_flutter_content)>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ - (FlutterCompositor*)createFlutterCompositor {
size_t layers_count, //
void* user_data //
) {
return reinterpret_cast<flutter::FlutterCompositor*>(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<flutter::FlutterCompositor*>(user_data)->Present(kFlutterDefaultViewId,
layers, layers_count);
};

_compositor.avoid_backing_store_cache = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down