screen-cast/stream: Add DMABUF-only record flag

Next commits will reintroduce a certain behavior of stage
capturing that can only happen with DMA-BUF buffers. To
control this, add a new flag tp MetaScreenCastRecordFlags
for this behavior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2186>
This commit is contained in:
Georges Basile Stavracas Neto 2021-12-27 16:39:34 -03:00 committed by Marge Bot
parent 926c34cc89
commit 8fe45d7750
2 changed files with 8 additions and 3 deletions

View File

@ -430,15 +430,19 @@ maybe_record_cursor (MetaScreenCastStreamSrc *src,
static gboolean
do_record_frame (MetaScreenCastStreamSrc *src,
MetaScreenCastRecordFlag flags,
struct spa_buffer *spa_buffer,
uint8_t *data,
GError **error)
{
MetaScreenCastStreamSrcPrivate *priv =
meta_screen_cast_stream_src_get_instance_private (src);
gboolean dmabuf_only;
if (spa_buffer->datas[0].data ||
spa_buffer->datas[0].type == SPA_DATA_MemFd)
dmabuf_only = flags & META_SCREEN_CAST_RECORD_FLAG_DMABUF_ONLY;
if (!dmabuf_only &&
(spa_buffer->datas[0].data ||
spa_buffer->datas[0].type == SPA_DATA_MemFd))
{
int width = priv->video_format.size.width;
int height = priv->video_format.size.height;
@ -566,7 +570,7 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src,
if (!(flags & META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY))
{
g_clear_handle_id (&priv->follow_up_frame_source_id, g_source_remove);
if (do_record_frame (src, spa_buffer, data, &error))
if (do_record_frame (src, flags, spa_buffer, data, &error))
{
struct spa_meta_region *spa_meta_video_crop;

View File

@ -41,6 +41,7 @@ typedef enum _MetaScreenCastRecordFlag
{
META_SCREEN_CAST_RECORD_FLAG_NONE = 0,
META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY = 1 << 0,
META_SCREEN_CAST_RECORD_FLAG_DMABUF_ONLY = 1 << 1,
} MetaScreenCastRecordFlag;
#define META_TYPE_SCREEN_CAST_STREAM_SRC (meta_screen_cast_stream_src_get_type ())