Open janne-hmp opened 1 month ago
This is most likely because SwapChainPanel does not support transparency:
https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/composition
SKGLView uses it on MAUI Windows.
Indeed this is not a bug but unfortunately by design as windows GL hardware-accelerated view cannot be transparent.
This is surely the limitation of the WinUI 3 composition engine, because WinUI 2 and UWP supported transparent backgrounds for swap chains.
Indeed this is not a bug but unfortunately by design as windows GL hardware-accelerated view cannot be transparent.
Would you be able to make a feature request for the WinUI3 team to add support for transparency?
Without transparency, Windows SKGLView is pretty useless. Both Android and iOS support transparency for SKGLView. If transparency worked in WinUI2, I don't see why it would be impossible to implement for WinUI3.
It's already been done here:
https://github.com/microsoft/microsoft-ui-xaml/issues/5025
It's a long standing issue requested by many users already.
A similar thread is here:
https://github.com/microsoft/microsoft-ui-xaml/issues/8130#issuecomment-1817217110
An interesting thing is that some of the use-cases, such as a transparent WebView2 over a MediaPlayerElement, could be done with the current composition engine, if there were a way to activate transparency for external content that is over other external content.
Well, we all would sure want to render an accelerated canvas over a usual MAUI content, so.. Not until we have a different backend for WinUI what would be close to a miracle. =)
Maybe this PR will expose Direct3D and then we can add a new D3D view to be used as a backing element:
Anyone that can help test or review will make things go faster. Also, if there are any folks that know how to hook up the WinUI + Direct3D + Composition, then please feel very free to help in any way.
I'm not sure how we could best help here, but at least we could test new views, if they are available as a NuGet package for .NET MAUI on Windows.
Here's an example in C++ how to make a transparent DirectX SwapChainPanel:
Info from here: https://github.com/microsoft/microsoft-ui-xaml/discussions/9684#discussioncomment-9640311
Description
SKGLView always draws an opaque gray background instead of a transparent background when specified to be transparent. SKCanvasView works fine.
Code
https://github.com/hyvanmielenpelit/GnollHack
Expected Behavior
Both SKGLView and SKCanvasView draw a transparent background upon
canvas.Clear()
.Actual Behavior
SKCanvasView draws a transparent background upon
canvas.Clear()
but SKGLView draws an opaque gray background.Version of SkiaSharp
3.x (Alpha)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
Windows 11 Home, version 10.0.22631
Devices
Micro-Star International Co., Ltd. Pulse GL66 11UDK
Relevant Screenshots
Relevant Log Output
No response
Code of Conduct