[Multiwindow, macOS] FlutterCompositor::Present receives view_id (flutter/engine#37391)
* Impl and test * Change to default view
This commit is contained in:
@@ -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)>;
|
||||
|
||||
|
||||
@@ -458,7 +458,11 @@ static void OnPlatformMessage(const FlutterPlatformMessage* message, FlutterEngi
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -80,11 +80,10 @@ bool FlutterMetalCompositor::CollectBackingStore(const FlutterBackingStore* back
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST(FlutterMetalCompositorTest, TestPresent) {
|
||||
return true;
|
||||
});
|
||||
|
||||
ASSERT_TRUE(macos_compositor->Present(nil, 0));
|
||||
ASSERT_TRUE(macos_compositor->Present(0, nil, 0));
|
||||
ASSERT_TRUE(flag);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user