[mutter] screen-cast: Only check queued-redraw on the relevant views



commit b9a52ecfdfa350601cfcfa63836a77af0fbc8bf4
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Wed Apr 1 11:06:13 2020 +0200

    screen-cast: Only check queued-redraw on the relevant views
    
    We'd check if there was any queued redraw on the stage, but this is
    inappropriate for two reasons:
    
    1) A monitor and area screen cast source only cares about damage on a
       subset of the stage.
    2) The global pending-redraw is going away when paint scheduling will be
       more view centric.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1285

 clutter/clutter/clutter-stage.c                    |  9 ++++---
 clutter/clutter/clutter-stage.h                    |  3 ++-
 src/backends/meta-screen-cast-area-stream-src.c    | 20 +++++++++++++--
 src/backends/meta-screen-cast-monitor-stream-src.c | 29 +++++++++++++++++++---
 4 files changed, 50 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 8e602b8268..f46865e78e 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -2951,14 +2951,15 @@ _clutter_stage_maybe_setup_viewport (ClutterStage     *stage,
 #undef _DEG_TO_RAD
 
 /**
- * clutter_stage_is_redraw_queued: (skip)
+ * clutter_stage_is_redraw_queued_on_view: (skip)
  */
 gboolean
-clutter_stage_is_redraw_queued (ClutterStage *stage)
+clutter_stage_is_redraw_queued_on_view (ClutterStage     *stage,
+                                        ClutterStageView *view)
 {
-  ClutterStagePrivate *priv = stage->priv;
+  clutter_stage_maybe_finish_queue_redraws (stage);
 
-  return priv->redraw_pending;
+  return clutter_stage_view_has_redraw_clip (view);
 }
 
 void
diff --git a/clutter/clutter/clutter-stage.h b/clutter/clutter/clutter-stage.h
index f3006f093b..a7ba0ceddb 100644
--- a/clutter/clutter/clutter-stage.h
+++ b/clutter/clutter/clutter-stage.h
@@ -197,7 +197,8 @@ CLUTTER_EXPORT
 void            clutter_stage_ensure_viewport                   (ClutterStage          *stage);
 
 CLUTTER_EXPORT
-gboolean        clutter_stage_is_redraw_queued                  (ClutterStage          *stage);
+gboolean        clutter_stage_is_redraw_queued_on_view          (ClutterStage          *stage,
+                                                                 ClutterStageView      *view);
 
 #ifdef CLUTTER_ENABLE_EXPERIMENTAL_API
 CLUTTER_EXPORT
diff --git a/src/backends/meta-screen-cast-area-stream-src.c b/src/backends/meta-screen-cast-area-stream-src.c
index 1fe94d448b..e73cafc371 100644
--- a/src/backends/meta-screen-cast-area-stream-src.c
+++ b/src/backends/meta-screen-cast-area-stream-src.c
@@ -149,16 +149,32 @@ is_cursor_in_stream (MetaScreenCastAreaStreamSrc *area_src)
     }
 }
 
+static gboolean
+is_redraw_queued (MetaScreenCastAreaStreamSrc *area_src)
+{
+  ClutterStage *stage = get_stage (area_src);
+  GList *l;
+
+  for (l = clutter_stage_peek_stage_views (stage); l; l = l->next)
+    {
+      ClutterStageView *view = l->data;
+
+      if (clutter_stage_is_redraw_queued_on_view (stage, view))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 sync_cursor_state (MetaScreenCastAreaStreamSrc *area_src)
 {
   MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (area_src);
-  ClutterStage *stage = get_stage (area_src);
 
   if (!is_cursor_in_stream (area_src))
     return;
 
-  if (clutter_stage_is_redraw_queued (stage))
+  if (is_redraw_queued (area_src))
     return;
 
   meta_screen_cast_stream_src_maybe_record_frame (src);
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 9d1d212d4a..759d5bda83 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -176,16 +176,37 @@ is_cursor_in_stream (MetaScreenCastMonitorStreamSrc *monitor_src)
     }
 }
 
+static gboolean
+is_redraw_queued (MetaScreenCastMonitorStreamSrc *monitor_src)
+{
+  MetaBackend *backend = get_backend (monitor_src);
+  MetaRenderer *renderer = meta_backend_get_renderer (backend);
+  ClutterStage *stage = get_stage (monitor_src);
+  MetaMonitor *monitor = get_monitor (monitor_src);
+  g_autoptr (GList) views = NULL;
+  GList *l;
+
+  views = meta_renderer_get_views_for_monitor (renderer, monitor);
+  for (l = views; l; l = l->next)
+    {
+      MetaRendererView *view = l->data;
+
+      if (clutter_stage_is_redraw_queued_on_view (stage, CLUTTER_STAGE_VIEW (view)))
+        return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 sync_cursor_state (MetaScreenCastMonitorStreamSrc *monitor_src)
 {
   MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (monitor_src);
-  ClutterStage *stage = get_stage (monitor_src);
 
   if (!is_cursor_in_stream (monitor_src))
     return;
 
-  if (clutter_stage_is_redraw_queued (stage))
+  if (is_redraw_queued (monitor_src))
     return;
 
   meta_screen_cast_stream_src_maybe_record_frame (src);
@@ -371,12 +392,12 @@ meta_screen_cast_monitor_stream_src_record_frame (MetaScreenCastStreamSrc *src,
   MetaMonitor *monitor;
   MetaLogicalMonitor *logical_monitor;
 
-  stage = get_stage (monitor_src);
-  if (!clutter_stage_is_redraw_queued (stage))
+  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);
   clutter_stage_capture_into (stage, FALSE, &logical_monitor->rect, data);
 
   return TRUE;


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