> I finally got around to looking into this. I see two requests here, one to 
> add per-pixel window transparency to EXTENDED stages and another to support 
> backdrop materials like Windows’ Mica and Acrylic.
>
> On the Mac adding per-pixel transparency to all stage styles is easy. On 
> Windows it would take a lot more work and as far as I know can’t be done with 
> the existing DX9 back end (the necessary DirectComposition API’s are tied to 
> DX11). We would also need to reconcile platform differences related to hit 
> testing and drop shadows. So it’s a big ask.

I think we can probably get there by using a WS_EX_LAYERED window like
we do for StageStyle.TRANSPARENT, if we accept the significant
performance impact. With DirectComposition, we can directly interface
with the DWM composition engine and skip the GDI window surface
completely. This requires a fair bit of integration with JavaFX that
goes beyond changes in the Glass toolkit. However, it doesn't require
a D3D11 rendering pipeline. It works with the existing D3D9 pipeline
by having D3D9 render into a shared off-screen surface, which is then
accessed by DirectComposition with ID3D11Device::OpenSharedResource.



> (I know there’s a DX12 version of JavaFX in the works but it’s hard for me to 
> get enthused. I run Windows in a VM and it’s likely to be stuck on DX11 for a 
> long time.)
>
> Supporting translucent backdrop materials is simpler since we can ask the OS 
> to draw the effect and then composite the JavaFX content over it all within 
> an opaque window. This is how the UNIFIED stage style works so we can 
> leverage that logic. On Mac this is easy to set up. On Windows 11 22H2 and 
> beyond we can easily access a couple of materials. For earlier Windows 
> versions or for a more extensive list of materials we would need to roll our 
> own using DirectComposition.

That's correct, it's reasonably simple to support platform-provided
backdrop materials. Anything custom is a lot more difficult.
I have a prototype of JavaFX with DirectComposition, along with a
custom acrylic implementation. It's very old, and looks like this
(running on Windows 10):
https://github.com/user-attachments/assets/cd702a74-603a-4d7e-9078-52f915a4448a

In the end, there doesn't seem to be much common ground between the
various OS platforms for any reasonably powerful cross-platform API.
Maybe we could have the supporting infrastructure in JavaFX, but only
exposing API in a platform-specific module (either as part of OpenJFX
or 3rd party)? This certainly requires quite a bit of work.



> I know nothing about DirectComposition but I’m pretty sure someone on this 
> list has used it to prototype an Acrylic effect for JavaFX. I’ll see if I can 
> find that e-mail. I’m particularly interested in whether this can easily be 
> turned on and off on-the-fly and how dark mode would be handled (the 
> platform-provided materials respond to dark mode).

I've never heard of any previous effort, and it couldn't have been me
beacuse I haven't talked about this up util now. I'd be interested to
learn about other attempts at solving this.

Reply via email to