Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET MAUI and/or WinUI 3 SKGLView is not transparent #2871

Open
1 task done
janne-hmp opened this issue May 27, 2024 · 11 comments
Open
1 task done

.NET MAUI and/or WinUI 3 SKGLView is not transparent #2871

janne-hmp opened this issue May 27, 2024 · 11 comments

Comments

@janne-hmp
Copy link

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

image

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TommiGustafsson-HMP
Copy link

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.

@taublast
Copy link
Contributor

Indeed this is not a bug but unfortunately by design as windows GL hardware-accelerated view cannot be transparent.

@TommiGustafsson-HMP
Copy link

This is surely the limitation of the WinUI 3 composition engine, because WinUI 2 and UWP supported transparent backgrounds for swap chains.

@janne-hmp
Copy link
Author

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.

@TommiGustafsson-HMP
Copy link

It's already been done here:

microsoft/microsoft-ui-xaml#5025

It's a long standing issue requested by many users already.

@TommiGustafsson-HMP
Copy link

A similar thread is here:

microsoft/microsoft-ui-xaml#8130 (comment)

@TommiGustafsson-HMP
Copy link

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.

@taublast
Copy link
Contributor

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. =)

@mattleibow mattleibow changed the title On Windows in .NET MAUI 9.0 Preview 4, SkiaSharp 3.0 Preview 3.1 SKGLView draws a gray background instead of a transparent background. SKCanvasView works fine .NET MAUI / WinUI 3 SKGLView does not support a transparent background May 31, 2024
@mattleibow mattleibow changed the title .NET MAUI / WinUI 3 SKGLView does not support a transparent background .NET MAUI / WinUI 3 SKGLView is not transparent May 31, 2024
@mattleibow
Copy link
Contributor

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.

@mattleibow mattleibow changed the title .NET MAUI / WinUI 3 SKGLView is not transparent .NET MAUI and/or WinUI 3 SKGLView is not transparent May 31, 2024
@TommiGustafsson-HMP
Copy link

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.

@TommiGustafsson-HMP
Copy link

Here's an example in C++ how to make a transparent DirectX SwapChainPanel:

https://github.com/brabebhin/MayazucMediaPlayer/blob/main/source/MayazucNativeFramework/SubtitleRenderer.cpp

Info from here: microsoft/microsoft-ui-xaml#9684 (reply in thread)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants