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>
This commit is contained in:
Sebastian Wick 2022-03-15 12:21:17 +01:00 committed by Marge Bot
parent 47c8063b30
commit c6b4b33570
4 changed files with 23 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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;