gtk4: Support RGBx formats in SW paths

GTK4 has matching enums and thus should handle them fine. Further more
it should allow renderers to reduce memory bandwidth by applying
occlusion culling.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1661>
This commit is contained in:
Robert Mader 2024-07-08 19:00:31 +02:00 committed by Backport Bot
parent 4dfce290f2
commit 49774f0f36
2 changed files with 20 additions and 0 deletions

View file

@ -169,6 +169,14 @@ impl AsRef<[u8]> for FrameWrapper {
fn video_format_to_memory_format(f: gst_video::VideoFormat) -> gdk::MemoryFormat {
match f {
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Bgrx => gdk::MemoryFormat::B8g8r8x8,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Xrgb => gdk::MemoryFormat::X8r8g8b8,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Rgbx => gdk::MemoryFormat::R8g8b8x8,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Xbgr => gdk::MemoryFormat::X8b8g8r8,
gst_video::VideoFormat::Bgra => gdk::MemoryFormat::B8g8r8a8,
gst_video::VideoFormat::Argb => gdk::MemoryFormat::A8r8g8b8,
gst_video::VideoFormat::Rgba => gdk::MemoryFormat::R8g8b8a8,
@ -256,6 +264,10 @@ fn video_frame_to_gl_texture(
gdk::MemoryFormat::R8g8b8a8 => gdk::MemoryFormat::R8g8b8a8Premultiplied,
gdk::MemoryFormat::A8b8g8r8 => gdk::MemoryFormat::A8r8g8b8Premultiplied,
gdk::MemoryFormat::R8g8b8 | gdk::MemoryFormat::B8g8r8 => format,
gdk::MemoryFormat::B8g8r8x8
| gdk::MemoryFormat::X8r8g8b8
| gdk::MemoryFormat::R8g8b8x8
| gdk::MemoryFormat::X8b8g8r8 => format,
_ => unreachable!(),
}
} else {

View file

@ -223,6 +223,14 @@ impl ElementImpl for PaintableSink {
const GL_FORMATS: &[gst_video::VideoFormat] =
&[gst_video::VideoFormat::Rgba, gst_video::VideoFormat::Rgb];
const NON_GL_FORMATS: &[gst_video::VideoFormat] = &[
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Bgrx,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Xrgb,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Rgbx,
#[cfg(feature = "gtk_v4_14")]
gst_video::VideoFormat::Xbgr,
gst_video::VideoFormat::Bgra,
gst_video::VideoFormat::Argb,
gst_video::VideoFormat::Rgba,