From 92db8902d9c3229a13d104bba71dd74f14d6dfac 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/1351 --- 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 +++++++++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c b/src/backends/meta-screen-cast-monitor-stream-src.c index 4b72416ff..70edb229c 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 * @@ -181,6 +183,7 @@ sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src) { MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src); ClutterStage *stage = get_stage (monitor_src); + MetaScreenCastRecordFlag flags; if (!is_cursor_in_stream (monitor_src)) return; @@ -188,7 +191,8 @@ sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src) if (clutter_stage_is_redraw_queued (stage)) 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 2454f93cb..7f124bfff 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 0eda02f71..6c73d05c1 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); MetaScreenCastStream * meta_screen_cast_stream_src_get_stream (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