-
Notifications
You must be signed in to change notification settings - Fork 6k
Add option to use Direct Composition for presenting flutter surface #24629
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,6 +81,16 @@ void FlutterDesktopViewControllerForceRedraw( | |
| controller->view->ForceRedraw(); | ||
| } | ||
|
|
||
| #ifndef WINUWP | ||
|
|
||
| FLUTTER_EXPORT void FlutterDesktopViewControllerEnableDirectComposition( | ||
|
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. I would rather this wasn't conditionalized but instead was a FlutterSetDesktopCompositionMode taking an enum with values None, DirectComposition, WinUIComposition returning a bool to indicate success |
||
| FlutterDesktopViewControllerRef controller, | ||
| bool enable_direct_composition) { | ||
| controller->view->EnableDirectComposition(enable_direct_composition); | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| FlutterDesktopEngineRef FlutterDesktopEngineCreate( | ||
| const FlutterDesktopEngineProperties& engine_properties) { | ||
| flutter::FlutterProjectBundle project(engine_properties); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,6 +105,16 @@ void FlutterWindowsView::ForceRedraw() { | |
| } | ||
| } | ||
|
|
||
| #ifndef WINUWP | ||
|
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. If we have a We should also verify that linking changes don't break win7.. will need to loadlibrary / getprocaddress and dcomp calls
Member
Author
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. Angle already does that. It loads the direct composition calls through loadlibrary. we could do the same to determine whether dcomp si supported so that API can return true if supported. |
||
| void FlutterWindowsView::EnableDirectComposition(bool enable) { | ||
|
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.
|
||
| if (enable != enable_direct_composition_) { | ||
| enable_direct_composition_ = enable; | ||
| DestroyRenderSurface(); | ||
| CreateRenderSurface(); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
| void FlutterWindowsView::OnWindowSizeChanged(size_t width, size_t height) { | ||
| // Called on the platform thread. | ||
| std::unique_lock<std::mutex> lock(resize_mutex_); | ||
|
|
@@ -403,8 +413,13 @@ bool FlutterWindowsView::SwapBuffers() { | |
|
|
||
| void FlutterWindowsView::CreateRenderSurface() { | ||
| PhysicalWindowBounds bounds = binding_handler_->GetPhysicalWindowBounds(); | ||
| #ifndef WINUWP | ||
| surface_manager_->CreateSurface(GetRenderTarget(), enable_direct_composition_, | ||
| bounds.width, bounds.height); | ||
| #else | ||
| surface_manager_->CreateSurface(GetRenderTarget(), bounds.width, | ||
| bounds.height); | ||
| #endif | ||
| } | ||
|
|
||
| void FlutterWindowsView::DestroyRenderSurface() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,12 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, | |
| // Tells the engine to generate a new frame | ||
| void ForceRedraw(); | ||
|
|
||
| #ifndef WINUWP | ||
|
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. SetCompositionMode and not conditionalized |
||
| // Determines whether view surface is posted to screen using the direct | ||
| // composition API | ||
| void EnableDirectComposition(bool enable); | ||
| #endif | ||
|
|
||
| // Callbacks for clearing context, settings context and swapping buffers, | ||
| // these are typically called on an engine-controlled (non-platform) thread. | ||
| bool ClearContext(); | ||
|
|
@@ -297,6 +303,10 @@ class FlutterWindowsView : public WindowBindingHandlerDelegate, | |
| // Target for the window width. Valid when resize_pending_ is set. Guarded by | ||
| // resize_mutex_. | ||
| size_t resize_target_height_ = 0; | ||
|
|
||
| #ifndef WINUWP | ||
| bool enable_direct_composition_ = false; | ||
| #endif | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,6 +112,13 @@ FLUTTER_EXPORT void FlutterDesktopViewControllerForceRedraw( | |
| FlutterDesktopViewControllerRef controller); | ||
|
|
||
| #ifndef WINUWP | ||
|
|
||
| // Enables or disables the use of Direct Composition API when presenting | ||
| // flutter view surface to screen. | ||
| FLUTTER_EXPORT void FlutterDesktopViewControllerEnableDirectComposition( | ||
|
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. SetCompositionMode and not conditionalized |
||
| FlutterDesktopViewControllerRef controller, | ||
| bool enable_direct_composition); | ||
|
|
||
| // Allows the Flutter engine and any interested plugins an opportunity to | ||
| // handle the given message. | ||
| // | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how much of the angle code will need to be conditionalized vs a case statement. Maybe the entrypoint won't but the internals will, that will become obvious as you work through it.