monitor-stream-src: Add before-paint watch to catch scanouts

Scanouts are taken away after painting. However, when we're
streaming, what we actually want is to capture whatever is
going to end up on screen - and that includes the scanout
if there's any.

Add a before-paint watch that only records new frames if a
scanout is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1421
This commit is contained in:
Georges Basile Stavracas Neto 2020-08-29 15:41:57 -03:00
parent aed286aa46
commit e6a13e5d57

View File

@ -127,6 +127,25 @@ stage_painted (MetaStage *stage,
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
}
static void
before_stage_painted (MetaStage *stage,
ClutterStageView *view,
ClutterPaintContext *paint_context,
gpointer user_data)
{
MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (user_data);
CoglScanout *scanout;
scanout = clutter_stage_view_peek_scanout (view);
if (scanout)
{
MetaScreenCastRecordFlag flags;
flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
meta_screen_cast_stream_src_maybe_record_frame (src, flags);
}
}
static MetaBackend *
get_backend (MetaScreenCastMonitorStreamSrc *monitor_src)
{
@ -344,6 +363,9 @@ meta_screen_cast_monitor_stream_src_enable (MetaScreenCastStreamSrc *src)
meta_cursor_tracker_track_position (cursor_tracker);
G_GNUC_FALLTHROUGH;
case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
add_view_watches (monitor_src,
META_STAGE_WATCH_BEFORE_PAINT,
before_stage_painted);
add_view_watches (monitor_src,
META_STAGE_WATCH_AFTER_ACTOR_PAINT,
stage_painted);