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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3175>
This commit is contained in:
Georges Basile Stavracas Neto 2023-08-11 16:03:53 -03:00
parent e24be82c12
commit b6bf6572a1
2 changed files with 24 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);