-
Notifications
You must be signed in to change notification settings - Fork 6k
Add option to use Direct Composition for presenting flutter surface #24629
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
clarkezone
left a comment
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.
I would prefer a SetCompositionMode API that is not conditionalized to win32, with an enum of values None, DirectComposition, WinUIComposition returning a bool. The success failure would be delegated via WindowBindingHandler to either win32 or UWP subsystem which would each run the appropriate checks to see if the requested mode is supported. Would also be good to have a default mode for each respective platform; that could be part of this change or come in a subsequent patch. In the failure case, the mode isn't changed and false is returned.
Please make sure that win7 support isn't broken by this change.
|
|
||
| #ifndef WINUWP | ||
|
|
||
| FLUTTER_EXPORT void FlutterDesktopViewControllerEnableDirectComposition( |
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.
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
| } | ||
| } | ||
|
|
||
| #ifndef WINUWP |
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.
If we have a SetCompositionMode style API, then that should be indirected through WindowBindingHandler to the respective win32 or winuwp window. rather than ifdef'ing here. Each underlying impl can figure out if the requested mode is supported and configure, return true else false. For Win32 it would succeed if composition mode is DirectComposition and OS version >= win8. In the future we can also succeed for WinUIComp once the angle parts land with a version check. For Win32 mode, only WinUIComp mode would succeed. It would also be good to have a prefereddefault method on the binding handler to allow each platform to express a preference for the default for the case when setcompositionmode isn't called. for win32 that can default to none initially and we can then flip it to DirectComposition at the point we're happy with the stability.
We should also verify that linking changes don't break win7.. will need to loadlibrary / getprocaddress and dcomp calls
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.
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.
| } | ||
|
|
||
| #ifndef WINUWP | ||
| void FlutterWindowsView::EnableDirectComposition(bool enable) { |
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.
SetCompositionMode and not conditionalized
| // 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 comment
The reason will be displayed to describe this comment to others. Learn more.
SetCompositionMode and not conditionalized
|
|
||
| // 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 comment
The reason will be displayed to describe this comment to others. Learn more.
SetCompositionMode and not conditionalized
| // Target represents the visual entity to bind to. Width and | ||
| // height represent dimensions surface is created at. | ||
| bool CreateSurface(WindowsRenderTarget* render_target, | ||
| #ifndef WINUWP |
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.
|
Closed in favor of #24705 |
flutter/flutter#76789
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.