From b6bf6572a145ca620d3dd39ebc5fd9e87c97f9c4 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 11 Aug 2023 16:03:53 -0300 Subject: [PATCH] screen-cast/src: Add get_preferred_format vfunc This allows subclasses to hint which pixel format they would prefer to be used. It may or may not be respected, depending on the available hardware capabilities. Part-of: --- src/backends/meta-screen-cast-stream-src.c | 20 ++++++++++++++++++++ src/backends/meta-screen-cast-stream-src.h | 4 ++++ 2 files changed, 24 insertions(+) diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index 946cf65f6..79b3f0571 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -60,6 +60,8 @@ #define MIN_FRAME_RATE SPA_FRACTION (1, 1) #define MAX_FRAME_RATE SPA_FRACTION (1000, 1) +#define DEFAULT_COGL_PIXEL_FORMAT COGL_PIXEL_FORMAT_BGRX_8888 + enum { PROP_0, @@ -1514,6 +1516,12 @@ meta_screen_cast_stream_src_get_stream (MetaScreenCastStreamSrc *src) return priv->stream; } +static CoglPixelFormat +meta_screen_cast_stream_src_default_get_preferred_format (MetaScreenCastStreamSrc *src) +{ + return DEFAULT_COGL_PIXEL_FORMAT; +} + static void meta_screen_cast_stream_src_dispose (GObject *object) { @@ -1593,6 +1601,9 @@ meta_screen_cast_stream_src_class_init (MetaScreenCastStreamSrcClass *klass) object_class->set_property = meta_screen_cast_stream_src_set_property; object_class->get_property = meta_screen_cast_stream_src_get_property; + klass->get_preferred_format = + meta_screen_cast_stream_src_default_get_preferred_format; + g_object_class_install_property (object_class, PROP_STREAM, g_param_spec_object ("stream", NULL, NULL, @@ -1624,3 +1635,12 @@ meta_screen_cast_stream_src_uses_dma_bufs (MetaScreenCastStreamSrc *src) return priv->uses_dma_bufs; } + +CoglPixelFormat +meta_screen_cast_stream_src_get_preferred_format (MetaScreenCastStreamSrc *src) +{ + MetaScreenCastStreamSrcClass *klass = + META_SCREEN_CAST_STREAM_SRC_GET_CLASS (src); + + return klass->get_preferred_format (src); +} diff --git a/src/backends/meta-screen-cast-stream-src.h b/src/backends/meta-screen-cast-stream-src.h index 53f59d631..1ec7bcfb3 100644 --- a/src/backends/meta-screen-cast-stream-src.h +++ b/src/backends/meta-screen-cast-stream-src.h @@ -83,6 +83,8 @@ struct _MetaScreenCastStreamSrcClass void (* notify_params_updated) (MetaScreenCastStreamSrc *src, struct spa_video_info_raw *video_format); + + CoglPixelFormat (* get_preferred_format) (MetaScreenCastStreamSrc *src); }; void meta_screen_cast_stream_src_close (MetaScreenCastStreamSrc *src); @@ -132,3 +134,5 @@ void meta_screen_cast_stream_src_set_cursor_sprite_metadata (MetaScreenCastStrea gboolean meta_screen_cast_stream_src_uses_dma_bufs (MetaScreenCastStreamSrc *src); +CoglPixelFormat +meta_screen_cast_stream_src_get_preferred_format (MetaScreenCastStreamSrc *src);