[mutter/gnome-3-36] stage: Pass paint context in phase callbacks



commit e49297975a15ca1b742703cfd8a73037b2263b46
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Apr 20 22:24:55 2020 +0200

    stage: Pass paint context in phase callbacks
    
    If there is a paint context available (i.e. for the phases that are
    during the actual stage paint), pass it along the callbacks, so that
    the callback implementations can change their operation depending on the
    paint context state.
    
    This also means we can get the current view from the paint context,
    instead of the temporarily used field in the instance struct.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1222

 src/backends/meta-screen-cast-monitor-stream-src.c |  7 ++++---
 src/backends/meta-stage-private.h                  |  7 ++++---
 src/backends/meta-stage.c                          | 18 +++++++++++-------
 3 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/backends/meta-screen-cast-monitor-stream-src.c 
b/src/backends/meta-screen-cast-monitor-stream-src.c
index 5f93b3000..9d1d212d4 100644
--- a/src/backends/meta-screen-cast-monitor-stream-src.c
+++ b/src/backends/meta-screen-cast-monitor-stream-src.c
@@ -115,9 +115,10 @@ meta_screen_cast_monitor_stream_src_get_specs (MetaScreenCastStreamSrc *src,
 }
 
 static void
-stage_painted (MetaStage        *stage,
-               ClutterStageView *view,
-               gpointer          user_data)
+stage_painted (MetaStage           *stage,
+               ClutterStageView    *view,
+               ClutterPaintContext *paint_context,
+               gpointer             user_data)
 {
   MetaScreenCastStreamSrc *src = META_SCREEN_CAST_STREAM_SRC (user_data);
 
diff --git a/src/backends/meta-stage-private.h b/src/backends/meta-stage-private.h
index 428aec67f..6a264637c 100644
--- a/src/backends/meta-stage-private.h
+++ b/src/backends/meta-stage-private.h
@@ -38,9 +38,10 @@ typedef enum
   META_STAGE_WATCH_AFTER_PAINT,
 } MetaStageWatchPhase;
 
-typedef void (* MetaStageWatchFunc) (MetaStage        *stage,
-                                     ClutterStageView *view,
-                                     gpointer          user_data);
+typedef void (* MetaStageWatchFunc) (MetaStage           *stage,
+                                     ClutterStageView    *view,
+                                     ClutterPaintContext *paint_context,
+                                     gpointer             user_data);
 
 ClutterActor     *meta_stage_new                     (MetaBackend *backend);
 
diff --git a/src/backends/meta-stage.c b/src/backends/meta-stage.c
index 4df6a4261..bb8db7b63 100644
--- a/src/backends/meta-stage.c
+++ b/src/backends/meta-stage.c
@@ -65,7 +65,6 @@ struct _MetaStage
   ClutterStage parent;
 
   GPtrArray *watchers[N_WATCH_MODES];
-  ClutterStageView *current_view;
 
   GList *overlays;
   gboolean is_active;
@@ -169,6 +168,7 @@ meta_stage_finalize (GObject *object)
 static void
 notify_watchers_for_mode (MetaStage           *stage,
                           ClutterStageView    *view,
+                          ClutterPaintContext *paint_context,
                           MetaStageWatchPhase  watch_phase)
 {
   GPtrArray *watchers;
@@ -183,7 +183,7 @@ notify_watchers_for_mode (MetaStage           *stage,
       if (watch->view && view != watch->view)
         continue;
 
-      watch->callback (stage, view, watch->user_data);
+      watch->callback (stage, view, paint_context, watch->user_data);
     }
 }
 
@@ -192,11 +192,14 @@ meta_stage_paint (ClutterActor        *actor,
                   ClutterPaintContext *paint_context)
 {
   MetaStage *stage = META_STAGE (actor);
+  ClutterStageView *view;
   GList *l;
 
   CLUTTER_ACTOR_CLASS (meta_stage_parent_class)->paint (actor, paint_context);
 
-  notify_watchers_for_mode (stage, stage->current_view,
+  view = clutter_paint_context_get_stage_view (paint_context);
+
+  notify_watchers_for_mode (stage, view, paint_context,
                             META_STAGE_WATCH_AFTER_ACTOR_PAINT);
 
   g_signal_emit (stage, signals[ACTORS_PAINTED], 0);
@@ -204,7 +207,7 @@ meta_stage_paint (ClutterActor        *actor,
   for (l = stage->overlays; l; l = l->next)
     meta_overlay_paint (l->data, paint_context);
 
-  notify_watchers_for_mode (stage, stage->current_view,
+  notify_watchers_for_mode (stage, view, paint_context,
                             META_STAGE_WATCH_AFTER_OVERLAY_PAINT);
 }
 
@@ -215,13 +218,14 @@ meta_stage_paint_view (ClutterStage         *stage,
 {
   MetaStage *meta_stage = META_STAGE (stage);
 
-  notify_watchers_for_mode (meta_stage, view, META_STAGE_WATCH_BEFORE_PAINT);
+  notify_watchers_for_mode (meta_stage, view, NULL,
+                            META_STAGE_WATCH_BEFORE_PAINT);
 
-  meta_stage->current_view = view;
   CLUTTER_STAGE_CLASS (meta_stage_parent_class)->paint_view (stage, view,
                                                              redraw_clip);
 
-  notify_watchers_for_mode (meta_stage, view, META_STAGE_WATCH_AFTER_PAINT);
+  notify_watchers_for_mode (meta_stage, view, NULL,
+                            META_STAGE_WATCH_AFTER_PAINT);
 }
 
 static void


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