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] Group per-view information in FlutterCompositor into a class
#51738
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,8 +27,7 @@ | |
| FlutterPlatformViewController* platform_view_controller) | ||
| : view_provider_(view_provider), | ||
| time_converter_(time_converter), | ||
| platform_view_controller_(platform_view_controller), | ||
| mutator_views_([NSMapTable strongToStrongObjectsMapTable]) { | ||
| platform_view_controller_(platform_view_controller) { | ||
| FML_CHECK(view_provider != nullptr) << "view_provider cannot be nullptr"; | ||
| } | ||
|
|
||
|
|
@@ -55,6 +54,10 @@ | |
| bool FlutterCompositor::Present(FlutterViewId view_id, | ||
| const FlutterLayer** layers, | ||
| size_t layers_count) { | ||
| // TODO(dkwingsmt): The macOS embedder only supports rendering to the implicit | ||
| // view for now. As it supports adding more views, this assertion should be | ||
| // lifted. https://github.com/flutter/flutter/issues/142845 | ||
| FML_DCHECK(view_id == kFlutterImplicitViewId); | ||
| FlutterView* view = [view_provider_ viewForId:view_id]; | ||
| if (!view) { | ||
| return false; | ||
|
|
@@ -98,24 +101,32 @@ | |
| [view.surfaceManager presentSurfaces:surfaces | ||
| atTime:presentation_time | ||
| notify:^{ | ||
| PresentPlatformViews(view, *platform_views_layers); | ||
| // Gets a presenter or create a new one for the view. | ||
| ViewPresenter& presenter = presenters_[view_id]; | ||
| presenter.PresentPlatformViews(view, *platform_views_layers, | ||
| platform_view_controller_); | ||
| }]; | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| void FlutterCompositor::PresentPlatformViews( | ||
| FlutterCompositor::ViewPresenter::ViewPresenter() | ||
| : mutator_views_([NSMapTable strongToStrongObjectsMapTable]) {} | ||
|
|
||
| void FlutterCompositor::ViewPresenter::PresentPlatformViews( | ||
| FlutterView* default_base_view, | ||
| const std::vector<PlatformViewLayerWithIndex>& platform_views) { | ||
| const std::vector<PlatformViewLayerWithIndex>& platform_views, | ||
| const FlutterPlatformViewController* platform_view_controller) { | ||
| FML_DCHECK([[NSThread currentThread] isMainThread]) | ||
| << "Must be on the main thread to present platform views"; | ||
|
|
||
| // Active mutator views for this frame. | ||
| NSMutableArray<FlutterMutatorView*>* present_mutators = [NSMutableArray array]; | ||
|
|
||
| for (const auto& platform_view : platform_views) { | ||
| [present_mutators addObject:PresentPlatformView(default_base_view, platform_view.first, | ||
|
Member
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. Just a nit - The formatting looks bit weird after adding additional argument. Maybe use a temporary variable for the result of PresentPlatformView? |
||
| platform_view.second)]; | ||
| FlutterMutatorView* container = PresentPlatformView( | ||
| default_base_view, platform_view.first, platform_view.second, platform_view_controller); | ||
| [present_mutators addObject:container]; | ||
| } | ||
|
|
||
| NSMutableArray<FlutterMutatorView*>* obsolete_mutators = | ||
|
|
@@ -127,17 +138,19 @@ | |
| [mutator removeFromSuperview]; | ||
| } | ||
|
|
||
| [platform_view_controller_ disposePlatformViews]; | ||
| [platform_view_controller disposePlatformViews]; | ||
| } | ||
|
|
||
| FlutterMutatorView* FlutterCompositor::PresentPlatformView(FlutterView* default_base_view, | ||
| const PlatformViewLayer& layer, | ||
| size_t index) { | ||
| FlutterMutatorView* FlutterCompositor::ViewPresenter::PresentPlatformView( | ||
| FlutterView* default_base_view, | ||
| const PlatformViewLayer& layer, | ||
| size_t index, | ||
| const FlutterPlatformViewController* platform_view_controller) { | ||
| FML_DCHECK([[NSThread currentThread] isMainThread]) | ||
| << "Must be on the main thread to present platform views"; | ||
|
|
||
| int64_t platform_view_id = layer.identifier(); | ||
| NSView* platform_view = [platform_view_controller_ platformViewWithID:platform_view_id]; | ||
| NSView* platform_view = [platform_view_controller platformViewWithID:platform_view_id]; | ||
|
|
||
| FML_DCHECK(platform_view) << "Platform view not found for id: " << platform_view_id; | ||
|
|
||
|
|
||
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.