[mutter/gbsneto/more-screencast: 10/10] monitor-stream-src: Add before-paint watch to catch scanouts




commit f6756232d1ca110f22b190dd80ec4add862b5cd5
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sat Aug 29 15:41:57 2020 -0300

    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

 src/backends/meta-screen-cast-monitor-stream-src.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 6983587993..4d21d309e1 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]