[mutter] window-actor: Make meta_window_actor_get_image fastpath reachable



commit c6b4b33570cbe18514c3b87c3708541f69b31508
Author: Sebastian Wick <sebastian wick redhat com>
Date:   Tue Mar 15 12:21:17 2022 +0100

    window-actor: Make meta_window_actor_get_image fastpath reachable
    
    MetaWindowActor previously peeked at the number of child Actors to
    determine the number of surfaces. The following commit rearranged the
    tree such that MetaWindowActorWayland always has two Actors. This change
    lets the subclass determine if the main surface describes the whole
    window.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2338>

 src/compositor/meta-window-actor-private.h | 2 ++
 src/compositor/meta-window-actor-wayland.c | 7 +++++++
 src/compositor/meta-window-actor-x11.c     | 7 +++++++
 src/compositor/meta-window-actor.c         | 8 +++++++-
 4 files changed, 23 insertions(+), 1 deletion(-)
---
diff --git a/src/compositor/meta-window-actor-private.h b/src/compositor/meta-window-actor-private.h
index 8bcd727992..a2b8eb1942 100644
--- a/src/compositor/meta-window-actor-private.h
+++ b/src/compositor/meta-window-actor-private.h
@@ -33,6 +33,8 @@ struct _MetaWindowActorClass
                       gboolean         frozen);
   void (*update_regions) (MetaWindowActor *actor);
   gboolean (*can_freeze_commits) (MetaWindowActor *actor);
+
+  gboolean (*is_single_surface_actor) (MetaWindowActor *actor);
 };
 
 typedef enum
diff --git a/src/compositor/meta-window-actor-wayland.c b/src/compositor/meta-window-actor-wayland.c
index 6fbd154a3b..93f12a7d67 100644
--- a/src/compositor/meta-window-actor-wayland.c
+++ b/src/compositor/meta-window-actor-wayland.c
@@ -207,6 +207,12 @@ meta_window_actor_wayland_can_freeze_commits (MetaWindowActor *actor)
   return FALSE;
 }
 
+static gboolean
+meta_window_actor_wayland_is_single_surface_actor (MetaWindowActor *actor)
+{
+  return clutter_actor_get_n_children (CLUTTER_ACTOR (actor)) == 1;
+}
+
 static void
 meta_window_actor_wayland_dispose (GObject *object)
 {
@@ -245,6 +251,7 @@ meta_window_actor_wayland_class_init (MetaWindowActorWaylandClass *klass)
   window_actor_class->set_frozen = meta_window_actor_wayland_set_frozen;
   window_actor_class->update_regions = meta_window_actor_wayland_update_regions;
   window_actor_class->can_freeze_commits = meta_window_actor_wayland_can_freeze_commits;
+  window_actor_class->is_single_surface_actor = meta_window_actor_wayland_is_single_surface_actor;
 
   object_class->dispose = meta_window_actor_wayland_dispose;
 }
diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c
index 82eaa428b5..1b591df46a 100644
--- a/src/compositor/meta-window-actor-x11.c
+++ b/src/compositor/meta-window-actor-x11.c
@@ -1534,6 +1534,12 @@ meta_window_actor_x11_can_freeze_commits (MetaWindowActor *actor)
   return clutter_actor_is_mapped (clutter_actor);
 }
 
+static gboolean
+meta_window_actor_x11_is_single_surface_actor (MetaWindowActor *actor)
+{
+  return clutter_actor_get_n_children (CLUTTER_ACTOR (actor)) == 1;
+}
+
 static void
 meta_window_actor_x11_set_property (GObject      *object,
                                     guint         prop_id,
@@ -1710,6 +1716,7 @@ meta_window_actor_x11_class_init (MetaWindowActorX11Class *klass)
   window_actor_class->set_frozen = meta_window_actor_x11_set_frozen;
   window_actor_class->update_regions = meta_window_actor_x11_update_regions;
   window_actor_class->can_freeze_commits = meta_window_actor_x11_can_freeze_commits;
+  window_actor_class->is_single_surface_actor = meta_window_actor_x11_is_single_surface_actor;
 
   actor_class->paint = meta_window_actor_x11_paint;
   actor_class->get_paint_volume = meta_window_actor_x11_get_paint_volume;
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
index 85e439a0ea..650fe12ef9 100644
--- a/src/compositor/meta-window-actor.c
+++ b/src/compositor/meta-window-actor.c
@@ -1508,6 +1508,12 @@ create_framebuffer_from_window_actor (MetaWindowActor  *self,
   return framebuffer;
 }
 
+static gboolean
+meta_window_actor_is_single_surface_actor (MetaWindowActor *self)
+{
+  return META_WINDOW_ACTOR_GET_CLASS (self)->is_single_surface_actor (self);
+}
+
 /**
  * meta_window_actor_get_image:
  * @self: A #MetaWindowActor
@@ -1541,7 +1547,7 @@ meta_window_actor_get_image (MetaWindowActor *self,
 
   stex = meta_surface_actor_get_texture (priv->surface);
   if (!meta_shaped_texture_should_get_via_offscreen (stex) &&
-      clutter_actor_get_n_children (actor) == 1)
+      meta_window_actor_is_single_surface_actor (self))
     {
       MetaRectangle *surface_clip = NULL;
 


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