From cea0722e721c7a6faa3a6ea4684d1575174a9837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 3 Jul 2020 16:48:52 +0200 Subject: [PATCH] screen-cast/src: Add flag to maybe_record() Will later be used to make recording avoid recording actual pixel content if e.g. only the cursor moved. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361 --- src/backends/meta-screen-cast-area-stream-src.c | 8 ++++++-- src/backends/meta-screen-cast-monitor-stream-src.c | 8 ++++++-- src/backends/meta-screen-cast-stream-src.c | 3 ++- src/backends/meta-screen-cast-stream-src.h | 8 +++++++- src/backends/meta-screen-cast-window-stream-src.c | 12 +++++++++--- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c index 1a2f369a7..fb365f5c6 100644 --- a/src/backends/meta-screen-cast-area-stream-src.c +++ b/src/backends/meta-screen-cast-area-stream-src.c @@ -170,6 +170,7 @@ static void sync_cursor_state (MetaScreenCastAreaStreamSrc *area_src) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (area_src); + MetaScreenCastRecordFlag flags; if (!is_cursor_in_stream (area_src)) return; @@ -177,7 +178,8 @@ sync_cursor_state (MetaScreenCastAreaStreamSrc *area_src) if (is_redraw_queued (area_src)) return; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static void @@ -233,10 +235,12 @@ maybe_record_frame_on_idle (gpointer user_data) MetaScreenCastAreaStreamSrc *area_src = META_SCREEN_CAST_AREA_STREAM_SRC (user_data); MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (area_src); + MetaScreenCastRecordFlag flags; area_src->maybe_record_idle_id = 0; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); return G_SOURCE_REMOVE; } diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index bcf0afc4b..955c6ca7a 100644 --- a/src/backends/meta-screen-cast-monitor-stream-src.c +++ b/src/backends/meta-screen-cast-monitor-stream-src.c @@ -121,8 +121,10 @@ stage_painted (MetaStage *stage, gpointer user_data) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (user_data); + MetaScreenCastRecordFlag flags; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static MetaBackend * @@ -202,6 +204,7 @@ static void sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src); + MetaScreenCastRecordFlag flags; if (!is_cursor_in_stream (monitor_src)) return; @@ -209,7 +212,8 @@ sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src) if (is_redraw_queued (monitor_src)) return; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static void diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c index 617aff4d0..78b7c693d 100644 --- a/src/backends/meta-screen-cast-stream-src.c +++ b/src/backends/meta-screen-cast-stream-src.c @@ -437,7 +437,8 @@ do_record_frame (MetaScreenCastStreamSrc *src, } void -meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src) +meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src, + MetaScreenCastRecordFlag flags) { MetaScreenCastStreamSrcPrivate *priv = meta_screen_cast_stream_src_get_instance_private (src); diff --git a/src/backends/meta-screen-cast-stream-src.h b/src/backends/meta-screen-cast-stream-src.h index 26d291980..d7c39a7e2 100644 --- a/src/backends/meta-screen-cast-stream-src.h +++ b/src/backends/meta-screen-cast-stream-src.h @@ -37,6 +37,11 @@ typedef struct _MetaScreenCastStream MetaScreenCastStream; +typedef enum _MetaScreenCastRecordFlag +{ + META_SCREEN_CAST_RECORD_FLAG_NONE = 0, +} MetaScreenCastRecordFlag; + #define META_TYPE_SCREEN_CAST_STREAM_SRC (meta_screen_cast_stream_src_get_type ()) G_DECLARE_DERIVABLE_TYPE (MetaScreenCastStreamSrc, meta_screen_cast_stream_src, @@ -63,7 +68,8 @@ struct _MetaScreenCastStreamSrcClass struct spa_meta_cursor *spa_meta_cursor); }; -void meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src); +void meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc *src, + MetaScreenCastRecordFlag flags); int meta_screen_cast_stream_src_get_stride (MetaScreenCastStreamSrc *src); diff --git a/src/backends/meta-screen-cast-window-stream-src.c b/src/backends/meta-screen-cast-window-stream-src.c index 3f141d264..b3217330f 100644 --- a/src/backends/meta-screen-cast-window-stream-src.c +++ b/src/backends/meta-screen-cast-window-stream-src.c @@ -327,8 +327,10 @@ screen_cast_window_damaged (MetaWindowActor *actor, MetaScreenCastWindowStreamSrc *window_src) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (window_src); + MetaScreenCastRecordFlag flags; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static void @@ -365,6 +367,7 @@ static void sync_cursor_state (MetaScreenCastWindowStreamSrc *window_src) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (window_src); + MetaScreenCastRecordFlag flags; if (!is_cursor_in_stream (window_src)) return; @@ -372,7 +375,8 @@ sync_cursor_state (MetaScreenCastWindowStreamSrc *window_src) if (meta_screen_cast_window_has_damage (window_src->screen_cast_window)) return; - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static void @@ -401,6 +405,7 @@ meta_screen_cast_window_stream_src_enable (MetaScreenCastStreamSrc *src) MetaCursorTracker *cursor_tracker = meta_backend_get_cursor_tracker (backend); MetaWindowActor *window_actor; MetaScreenCastStream *stream; + MetaScreenCastRecordFlag flags; window_actor = meta_window_actor_from_window (get_window (window_src)); if (!window_actor) @@ -438,7 +443,8 @@ meta_screen_cast_window_stream_src_enable (MetaScreenCastStreamSrc *src) break; } - meta_screen_cast_stream_src_maybe_record_frame (src); + flags = META_SCREEN_CAST_RECORD_FLAG_NONE; + meta_screen_cast_stream_src_maybe_record_frame (src, flags); } static void