[mutter/gnome-42] screen-cast/monitor: Always use clutter_stage_paint_to_framebuffer()



commit 9fba0fbb7c272cc432d60a1e6e5d035446c4992f
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Jun 13 18:41:17 2022 +0200

    screen-cast/monitor: Always use clutter_stage_paint_to_framebuffer()
    
    'screen-cast/monitor-src: Use clutter_stage_paint_to_buffer'
    (6c818cd8d5d29a21288d64fcbb13eae6a69d65df) made the non-dma-buf path use
    clutter_stage_paint_to_buffer() to avoid running into direct scanout
    issues. At a glance, the dma-buf paths didn't have the same issue since
    it explicitly handled dma-bufs by blitting them.
    
    What it also did was move the recording to an idle callback, to avoid
    paint reentry issues. A side effect of this, however, is that it also
    broke the dma-buf paths, as they rely on the back buffer existing, and
    the stage view direct scanout already being setup, which it isn't in an
    idle callback.
    
    Fix this by using the dma-buf variant of
    clutter_stage_paint_to_buffer(): clutter_stage_paint_to_framebuffer().
    This has some negative performance impact, but we can't use
    cogl_blit_framebuffer() when using an idle callback for recording.
    
    Potential performance improvements to make things work more as they did
    before is to enhance 'cogl_blit_framebuffer()' a bit, making it a vfunc
    that could be implemented by MetaOnscreenNative. A flag to say whether
    to look at the back or front buffer would let MetaOnscreenNative know
    whether to use the already committed-to-KMS buffer, or the current back
    buffer.
    
    Fixes: 6c818cd8d5d29a21288d64fcbb13eae6a69d65df
    Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2282
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2462>

 src/backends/meta-screen-cast-monitor-stream-src.c | 54 +++++++---------------
 1 file changed, 16 insertions(+), 38 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index f30a52d1d0..3c449e0225 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -552,13 +552,13 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
 {
   MetaScreenCastMonitorStreamSrc *monitor_src =
     META_SCREEN_CAST_MONITOR_STREAM_SRC (src);
-  MetaBackend *backend = get_backend (monitor_src);
-  MetaRenderer *renderer = meta_backend_get_renderer (backend);
+  MetaScreenCastStream *stream = meta_screen_cast_stream_src_get_stream (src);
+  ClutterStage *stage = get_stage (monitor_src);
   MetaMonitor *monitor;
   MetaLogicalMonitor *logical_monitor;
   MetaRectangle logical_monitor_layout;
-  GList *l;
   float view_scale;
+  ClutterPaintFlag paint_flags = CLUTTER_PAINT_FLAG_CLEAR;
 
   monitor = get_monitor (monitor_src);
   logical_monitor = meta_monitor_get_logical_monitor (monitor);
@@ -569,44 +569,22 @@ meta_screen_cast_monitor_stream_src_record_to_framebuffer (MetaScreenCastStreamS
   else
     view_scale = 1.0;
 
-  for (l = meta_renderer_get_views (renderer); l; l = l->next)
+  switch (meta_screen_cast_stream_get_cursor_mode (stream))
     {
-      ClutterStageView *view = CLUTTER_STAGE_VIEW (l->data);
-      CoglFramebuffer *view_framebuffer;
-      CoglScanout *scanout;
-      MetaRectangle view_layout;
-      int x, y;
-
-      clutter_stage_view_get_layout (view, &view_layout);
-
-      if (!meta_rectangle_overlap (&logical_monitor_layout, &view_layout))
-        continue;
-
-      x = (int) roundf ((view_layout.x - logical_monitor_layout.x) * view_scale);
-      y = (int) roundf ((view_layout.y - logical_monitor_layout.y) * view_scale);
+    case META_SCREEN_CAST_CURSOR_MODE_METADATA:
+    case META_SCREEN_CAST_CURSOR_MODE_HIDDEN:
+      paint_flags |= CLUTTER_PAINT_FLAG_NO_CURSORS;
+      break;
+    case META_SCREEN_CAST_CURSOR_MODE_EMBEDDED:
+      paint_flags |= CLUTTER_PAINT_FLAG_FORCE_CURSORS;
+      break;
+    }
 
-      scanout = clutter_stage_view_peek_scanout (view);
-      if (scanout)
-        {
-          if (!cogl_scanout_blit_to_framebuffer (scanout,
-                                                 framebuffer,
-                                                 x, y,
-                                                 error))
-            return FALSE;
-        }
-      else
-        {
-          view_framebuffer = clutter_stage_view_get_framebuffer (view);
-          if (!cogl_blit_framebuffer (view_framebuffer,
+  clutter_stage_paint_to_framebuffer (stage,
                                       framebuffer,
-                                      0, 0,
-                                      x, y,
-                                      cogl_framebuffer_get_width (view_framebuffer),
-                                      cogl_framebuffer_get_height (view_framebuffer),
-                                      error))
-            return FALSE;
-        }
-    }
+                                      &logical_monitor_layout,
+                                      view_scale,
+                                      paint_flags);
 
   cogl_framebuffer_flush (framebuffer);
 


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