mpv
mpv copied to clipboard
vo_gpu/vo_gpu_next: overhaul alpha related options
A spiritual successor to #9621 but it also implements vo_gpu_next support. This depends on this libplacebo MR.
This splits --alpha into two options: --alpha and --blend. alpha strictly controls whether or not draw the framebuffer with the alpha component if possible (default yes). blend is what controls blending the alpha component into either tiles, the background color, or nothing. This makes it possible to blend with a partially transparent background color e.g. something like mpv --background=0.5/0.5 --blend=background image.png.
I set the default blend to no so by default you actually get a transparent image when you open one. Didn't really see a reason to not try to open transparent images with transparency, but we can set it back to tiles if that's preferred.
TODO:
- [x] The vo_gpu colors are wrong when blending with transparency for some reason. It kind of works (which is better than not working at all), but haven't figured out what I'm missing. Fixed.
Edit: Nevermind. The alpha component in --background is bugged in vo_gpu period. --background=0.5/0.0 is not fully transparent and has a light grayish color for whatever reason. It's fully transparent in vo_gpu_next as expected. ~Probably won't bother fixing vo_gpu here but if someone wants to, feel free.~ Should work now.
Download the artifacts for this pull request:
--background=0.5/0.0is not fully transparent and has a light grayish color for whatever reason.
Looks like the window system expects pre-multiplied alpha for blending. If the color isn't alpha pre-multiplied it will look wrong. Maybe vo_gpu isn't pre-multiplying background alpha in this case.
Oh yeah that's all it was thanks.
Edit: Should be fixed now.
Now depends on https://code.videolan.org/videolan/libplacebo/-/merge_requests/640. I changed the name of some options as well. background -> background-color, etc.
The API changes have been merged into libplacebo now so unmarking the draft status.
Rewrote it to remove --alpha completely since it's useless and exactly the same as setting --background=color in practice. I also realized that I was setting want_alpha incorrectly before so it should hopefully be correct now.