[mutter] screen-cast: Let the reason for recording determine what to record



commit 882967d3ce33c11b47e13527b0c08e9c5bbadcf2
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jul 3 16:52:43 2020 +0200

    screen-cast: Let the reason for recording determine what to record
    
    E.g. we'll have pointer movement that, if no painting is already
    scheduled, should only send new cursor metadata without any new pixel
    buffer. When this happens, tell next step to not record the pixels if
    this was the case, instead of having it rediscover this itself.
    
    Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1323
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1361

 src/backends/meta-screen-cast-area-stream-src.c    |  2 +-
 src/backends/meta-screen-cast-monitor-stream-src.c |  5 +--
 src/backends/meta-screen-cast-stream-src.c         | 51 ++++++++++++----------
 src/backends/meta-screen-cast-stream-src.h         |  1 +
 src/backends/meta-screen-cast-window-stream-src.c  |  4 +-
 5 files changed, 34 insertions(+), 29 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c
index fb365f5c67..e28d52b46f 100644
--- a/src/backends/meta-screen-cast-area-stream-src.c
+++ b/src/backends/meta-screen-cast-area-stream-src.c
@@ -178,7 +178,7 @@ sync_cursor_state (MetaScreenCastAreaStreamSrc *area_src)
   if (is_redraw_queued (area_src))
     return;
 
-  flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
+  flags = META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY;
   meta_screen_cast_stream_src_maybe_record_frame (src, flags);
 }
 
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 955c6ca7a1..1aec6aaefd 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -212,7 +212,7 @@ sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src)
   if (is_redraw_queued (monitor_src))
     return;
 
-  flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
+  flags = META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY;
   meta_screen_cast_stream_src_maybe_record_frame (src, flags);
 }
 
@@ -396,9 +396,6 @@ meta_screen_cast_monitor_stream_src_record_to_buffer (MetaScreenCastStreamSrc *s
   MetaMonitor *monitor;
   MetaLogicalMonitor *logical_monitor;
 
-  if (!is_redraw_queued (monitor_src))
-    return FALSE;
-
   monitor = get_monitor (monitor_src);
   logical_monitor = meta_monitor_get_logical_monitor (monitor);
   stage = get_stage (monitor_src);
diff --git a/src/backends/meta-screen-cast-stream-src.c b/src/backends/meta-screen-cast-stream-src.c
index 78b7c693d3..6addd16c46 100644
--- a/src/backends/meta-screen-cast-stream-src.c
+++ b/src/backends/meta-screen-cast-stream-src.c
@@ -472,34 +472,41 @@ meta_screen_cast_stream_src_maybe_record_frame (MetaScreenCastStreamSrc  *src,
       return;
     }
 
-  if (do_record_frame (src, spa_buffer, data))
+  if (!(flags & META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY))
     {
-      struct spa_meta_region *spa_meta_video_crop;
+      if (do_record_frame (src, spa_buffer, data))
+        {
+          struct spa_meta_region *spa_meta_video_crop;
 
-      spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
-      spa_buffer->datas[0].chunk->stride = priv->video_stride;
+          spa_buffer->datas[0].chunk->size = spa_buffer->datas[0].maxsize;
+          spa_buffer->datas[0].chunk->stride = priv->video_stride;
 
-      /* Update VideoCrop if needed */
-      spa_meta_video_crop =
-        spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
-                                   sizeof (*spa_meta_video_crop));
-      if (spa_meta_video_crop)
-        {
-          if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
-            {
-              spa_meta_video_crop->region.position.x = crop_rect.x;
-              spa_meta_video_crop->region.position.y = crop_rect.y;
-              spa_meta_video_crop->region.size.width = crop_rect.width;
-              spa_meta_video_crop->region.size.height = crop_rect.height;
-            }
-          else
+          /* Update VideoCrop if needed */
+          spa_meta_video_crop =
+            spa_buffer_find_meta_data (spa_buffer, SPA_META_VideoCrop,
+                                       sizeof (*spa_meta_video_crop));
+          if (spa_meta_video_crop)
             {
-              spa_meta_video_crop->region.position.x = 0;
-              spa_meta_video_crop->region.position.y = 0;
-              spa_meta_video_crop->region.size.width = priv->stream_width;
-              spa_meta_video_crop->region.size.height = priv->stream_height;
+              if (meta_screen_cast_stream_src_get_videocrop (src, &crop_rect))
+                {
+                  spa_meta_video_crop->region.position.x = crop_rect.x;
+                  spa_meta_video_crop->region.position.y = crop_rect.y;
+                  spa_meta_video_crop->region.size.width = crop_rect.width;
+                  spa_meta_video_crop->region.size.height = crop_rect.height;
+                }
+              else
+                {
+                  spa_meta_video_crop->region.position.x = 0;
+                  spa_meta_video_crop->region.position.y = 0;
+                  spa_meta_video_crop->region.size.width = priv->stream_width;
+                  spa_meta_video_crop->region.size.height = priv->stream_height;
+                }
             }
         }
+      else
+        {
+          spa_buffer->datas[0].chunk->size = 0;
+        }
     }
   else
     {
diff --git a/src/backends/meta-screen-cast-stream-src.h b/src/backends/meta-screen-cast-stream-src.h
index d7c39a7e24..e43e701c17 100644
--- a/src/backends/meta-screen-cast-stream-src.h
+++ b/src/backends/meta-screen-cast-stream-src.h
@@ -40,6 +40,7 @@ typedef struct _MetaScreenCastStream MetaScreenCastStream;
 typedef enum _MetaScreenCastRecordFlag
 {
   META_SCREEN_CAST_RECORD_FLAG_NONE = 0,
+  META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY = 1 << 0,
 } MetaScreenCastRecordFlag;
 
 #define META_TYPE_SCREEN_CAST_STREAM_SRC (meta_screen_cast_stream_src_get_type ())
diff --git a/src/backends/meta-screen-cast-window-stream-src.c 
b/src/backends/meta-screen-cast-window-stream-src.c
index b3217330fb..dfc5baa1a2 100644
--- a/src/backends/meta-screen-cast-window-stream-src.c
+++ b/src/backends/meta-screen-cast-window-stream-src.c
@@ -329,7 +329,7 @@ screen_cast_window_damaged (MetaWindowActor               *actor,
   MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (window_src);
   MetaScreenCastRecordFlag flags;
 
-  flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
+  flags = META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY;
   meta_screen_cast_stream_src_maybe_record_frame (src, flags);
 }
 
@@ -375,7 +375,7 @@ sync_cursor_state (MetaScreenCastWindowStreamSrc *window_src)
   if (meta_screen_cast_window_has_damage (window_src->screen_cast_window))
     return;
 
-  flags = META_SCREEN_CAST_RECORD_FLAG_NONE;
+  flags = META_SCREEN_CAST_RECORD_FLAG_CURSOR_ONLY;
   meta_screen_cast_stream_src_maybe_record_frame (src, flags);
 }
 


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