[mutter] wayland/surface: Move subsurface synchronization logic to role
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland/surface: Move subsurface synchronization logic to role
- Date: Mon, 9 Dec 2019 09:19:18 +0000 (UTC)
commit 8dc730e5cadd7cf91fa236ed65194869de736f50
Author: Jonas Ådahl <jadahl gmail com>
Date: Wed Mar 13 12:26:22 2019 +0100
wayland/surface: Move subsurface synchronization logic to role
It's an implementation detail of subsurfaces when to cache state
and when not to, so move that logic to the subsurface role
implementation.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
src/wayland/meta-wayland-subsurface.c | 31 ++++++++++++++++++---
src/wayland/meta-wayland-surface.c | 52 +++++++++++++++--------------------
src/wayland/meta-wayland-surface.h | 3 ++
3 files changed, 52 insertions(+), 34 deletions(-)
---
diff --git a/src/wayland/meta-wayland-subsurface.c b/src/wayland/meta-wayland-subsurface.c
index 6abfde19f..b8ef41fe1 100644
--- a/src/wayland/meta-wayland-subsurface.c
+++ b/src/wayland/meta-wayland-subsurface.c
@@ -112,6 +112,12 @@ is_sibling (MetaWaylandSurface *surface,
return FALSE;
}
+static gboolean
+is_surface_effectively_synchronized (MetaWaylandSurface *surface)
+{
+ return meta_wayland_surface_should_cache_state (surface);
+}
+
void
meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
{
@@ -182,7 +188,7 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
meta_window_actor_wayland_rebuild_surface_tree (window_actor);
}
- if (meta_wayland_surface_is_effectively_synchronized (surface))
+ if (is_surface_effectively_synchronized (surface))
meta_wayland_surface_apply_pending_state (surface, surface->sub.pending);
meta_wayland_actor_surface_sync_actor_state (actor_surface);
@@ -240,6 +246,23 @@ meta_wayland_subsurface_get_toplevel (MetaWaylandSurfaceRole *surface_role)
return NULL;
}
+static gboolean
+meta_wayland_subsurface_should_cache_state (MetaWaylandSurfaceRole *surface_role)
+{
+ MetaWaylandSurface *surface =
+ meta_wayland_surface_role_get_surface (surface_role);
+ MetaWaylandSurface *parent;
+
+ if (surface->sub.synchronous)
+ return TRUE;
+
+ parent = surface->sub.parent;
+ if (parent)
+ return meta_wayland_surface_should_cache_state (parent);
+
+ return TRUE;
+}
+
static double
meta_wayland_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
{
@@ -294,6 +317,7 @@ meta_wayland_subsurface_class_init (MetaWaylandSubsurfaceClass *klass)
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
surface_role_class->get_toplevel = meta_wayland_subsurface_get_toplevel;
+ surface_role_class->should_cache_state = meta_wayland_subsurface_should_cache_state;
actor_surface_class->get_geometry_scale =
meta_wayland_subsurface_get_geometry_scale;
@@ -456,12 +480,11 @@ wl_subsurface_set_desync (struct wl_client *client,
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
gboolean was_effectively_synchronized;
- was_effectively_synchronized =
- meta_wayland_surface_is_effectively_synchronized (surface);
+ was_effectively_synchronized = is_surface_effectively_synchronized (surface);
surface->sub.synchronous = FALSE;
if (was_effectively_synchronized &&
- !meta_wayland_surface_is_effectively_synchronized (surface))
+ !is_surface_effectively_synchronized (surface))
meta_wayland_surface_apply_pending_state (surface, surface->sub.pending);
}
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 841a2d33d..604e4d280 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -593,35 +593,6 @@ meta_wayland_pending_state_class_init (MetaWaylandPendingStateClass *klass)
G_TYPE_NONE, 0);
}
-/* A non-subsurface is always desynchronized.
- *
- * A subsurface is effectively synchronized if either its parent is
- * synchronized or itself is in synchronized mode. */
-gboolean
-meta_wayland_surface_is_effectively_synchronized (MetaWaylandSurface *surface)
-{
- if (surface->wl_subsurface == NULL)
- {
- return FALSE;
- }
- else
- {
- if (surface->sub.synchronous)
- {
- return TRUE;
- }
- else
- {
- MetaWaylandSurface *parent = surface->sub.parent;
-
- if (parent)
- return meta_wayland_surface_is_effectively_synchronized (parent);
-
- return TRUE;
- }
- }
-}
-
static void
parent_surface_state_applied (GNode *subsurface_node,
gpointer user_data)
@@ -864,7 +835,7 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
* 2) Its mode changes from synchronized to desynchronized and its parent
* surface is in effective desynchronized mode.
*/
- if (meta_wayland_surface_is_effectively_synchronized (surface))
+ if (meta_wayland_surface_should_cache_state (surface))
merge_pending_state (surface->pending, surface->sub.pending);
else
meta_wayland_surface_apply_pending_state (surface, surface->pending);
@@ -1846,6 +1817,27 @@ meta_wayland_surface_role_get_toplevel (MetaWaylandSurfaceRole *surface_role)
return NULL;
}
+static gboolean
+meta_wayland_surface_role_should_cache_state (MetaWaylandSurfaceRole *surface_role)
+{
+ MetaWaylandSurfaceRoleClass *klass;
+
+ klass = META_WAYLAND_SURFACE_ROLE_GET_CLASS (surface_role);
+ if (klass->should_cache_state)
+ return klass->should_cache_state (surface_role);
+ else
+ return FALSE;
+}
+
+gboolean
+meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface)
+{
+ if (!surface->role)
+ return FALSE;
+
+ return meta_wayland_surface_role_should_cache_state (surface->role);
+}
+
MetaWaylandSurface *
meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role)
{
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index 818e7b047..51f33c02e 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -63,6 +63,7 @@ struct _MetaWaylandSurfaceRoleClass
gboolean (*is_on_logical_monitor) (MetaWaylandSurfaceRole *surface_role,
MetaLogicalMonitor *logical_monitor);
MetaWaylandSurface * (*get_toplevel) (MetaWaylandSurfaceRole *surface_role);
+ gboolean (*should_cache_state) (MetaWaylandSurfaceRole *surface_role);
};
struct _MetaWaylandSerial {
@@ -273,6 +274,8 @@ void meta_wayland_surface_update_outputs (MetaWaylandSurface *sur
MetaWaylandSurface *meta_wayland_surface_get_toplevel (MetaWaylandSurface *surface);
+gboolean meta_wayland_surface_should_cache_state (MetaWaylandSurface *surface);
+
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);
void meta_wayland_surface_cache_pending_frame_callbacks (MetaWaylandSurface *surface,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]