This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS, multiwindow] Compositor gets FlutterView lazily #36392
Merged
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
27b415e
Impl
dkwingsmt 7c4676f
Explain 0
dkwingsmt 954c501
InsertCALayerForIOSurface use view
dkwingsmt 3bed3d1
Fix compile
dkwingsmt 812e2a2
Fix comment
dkwingsmt 4a16d01
Merge remote-tracking branch 'origin/main' into lazy-compositor-view
dkwingsmt 118fcdd
code ctyle
dkwingsmt aaebfc3
ViewProvider
dkwingsmt 0edd3e0
Merge remote-tracking branch 'origin/main' into lazy-compositor-view
dkwingsmt 06b8296
Use ViewProvider class
dkwingsmt d965084
tests, and kFlutterDefaultViewId
dkwingsmt 0184845
Format
dkwingsmt 5d5be96
Better comment
dkwingsmt aa58383
Comment
dkwingsmt 7142687
Merge remote-tracking branch 'origin/main' into lazy-compositor-view
dkwingsmt e24ab4e
Fix build
dkwingsmt 020cd7a
license
dkwingsmt 4457dde
Merge remote-tracking branch 'origin/main' into lazy-compositor-view
dkwingsmt 894fb1d
Change the remaining 0 to kFlutterDefaultViewId
dkwingsmt 06753fb
Merge commit 'a849372171cff27f6e3e3f1e019c0433cab0dc72' into lazy-com…
dkwingsmt a5369a6
Make provider protocol
dkwingsmt 74ca6c1
Merge remote-tracking branch 'dkwingsmt/lazy-compositor-view' into la…
dkwingsmt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,16 +11,19 @@ | |
namespace flutter { | ||
|
||
FlutterMetalCompositor::FlutterMetalCompositor( | ||
FlutterViewController* view_controller, | ||
ViewProvider get_view_callback, | ||
FlutterPlatformViewController* platform_views_controller, | ||
id<MTLDevice> 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_) { | ||
// 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When can this happen? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the caller sends a view ID that the engine does not recognize. When the engine is run as a whole, this should not happen. |
||
return false; | ||
} | ||
|
||
|
@@ -34,8 +37,7 @@ | |
// If the backing store is for the first layer, return the MTLTexture for the | ||
// FlutterView. | ||
FlutterMetalRenderBackingStore* backingStore = | ||
reinterpret_cast<FlutterMetalRenderBackingStore*>( | ||
[view_controller_.flutterView backingStoreForSize:size]); | ||
reinterpret_cast<FlutterMetalRenderBackingStore*>([view backingStoreForSize:size]); | ||
backing_store_out->metal.texture.texture = | ||
(__bridge FlutterMetalTextureHandle)backingStore.texture; | ||
} else { | ||
|
@@ -78,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; | ||
|
@@ -91,21 +100,24 @@ | |
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: | ||
PresentPlatformView(layer, i); | ||
case kFlutterLayerContentTypePlatformView: { | ||
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 +132,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; | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.