mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
wayland/surface: Make cached subsurface state generic
This moves the cached subsurface surface state into the generic MetaWaylandSurface namespace. Eventually it'll be used by other surface roles which as well aim to implement synhcronization. https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
This commit is contained in:
parent
bbec8abb68
commit
f7e256e9a1
@ -189,7 +189,7 @@ meta_wayland_subsurface_parent_state_applied (MetaWaylandSubsurface *subsurface)
|
||||
}
|
||||
|
||||
if (is_surface_effectively_synchronized (surface))
|
||||
meta_wayland_surface_apply_state (surface, surface->sub.pending);
|
||||
meta_wayland_surface_apply_cached_state (surface);
|
||||
|
||||
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
||||
}
|
||||
@ -356,7 +356,6 @@ wl_subsurface_destructor (struct wl_resource *resource)
|
||||
surface->sub.parent = NULL;
|
||||
}
|
||||
|
||||
g_clear_object (&surface->sub.pending);
|
||||
surface->wl_subsurface = NULL;
|
||||
}
|
||||
|
||||
@ -485,7 +484,7 @@ wl_subsurface_set_desync (struct wl_client *client,
|
||||
|
||||
if (was_effectively_synchronized &&
|
||||
!is_surface_effectively_synchronized (surface))
|
||||
meta_wayland_surface_apply_state (surface, surface->sub.pending);
|
||||
meta_wayland_surface_apply_cached_state (surface);
|
||||
}
|
||||
|
||||
static const struct wl_subsurface_interface meta_wayland_wl_subsurface_interface = {
|
||||
@ -561,7 +560,6 @@ wl_subcompositor_get_subsurface (struct wl_client *client,
|
||||
surface,
|
||||
wl_subsurface_destructor);
|
||||
|
||||
surface->sub.pending = g_object_new (META_TYPE_WAYLAND_SURFACE_STATE, NULL);
|
||||
surface->sub.synchronous = TRUE;
|
||||
surface->sub.parent = parent;
|
||||
surface->sub.parent_destroy_listener.notify =
|
||||
|
@ -616,7 +616,7 @@ meta_wayland_surface_cache_pending_frame_callbacks (MetaWaylandSurface *sur
|
||||
wl_list_init (&pending->frame_callback_list);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
|
||||
MetaWaylandSurfaceState *state)
|
||||
{
|
||||
@ -817,12 +817,30 @@ cleanup:
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_wayland_surface_apply_cached_state (MetaWaylandSurface *surface)
|
||||
{
|
||||
if (!surface->cached_state)
|
||||
return;
|
||||
|
||||
meta_wayland_surface_apply_state (surface, surface->cached_state);
|
||||
}
|
||||
|
||||
MetaWaylandSurfaceState *
|
||||
meta_wayland_surface_get_pending_state (MetaWaylandSurface *surface)
|
||||
{
|
||||
return surface->pending_state;
|
||||
}
|
||||
|
||||
MetaWaylandSurfaceState *
|
||||
meta_wayland_surface_ensure_cached_state (MetaWaylandSurface *surface)
|
||||
{
|
||||
if (!surface->cached_state)
|
||||
surface->cached_state = g_object_new (META_TYPE_WAYLAND_SURFACE_STATE,
|
||||
NULL);
|
||||
return surface->cached_state;
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_surface_commit (MetaWaylandSurface *surface)
|
||||
{
|
||||
@ -844,9 +862,16 @@ meta_wayland_surface_commit (MetaWaylandSurface *surface)
|
||||
* surface is in effective desynchronized mode.
|
||||
*/
|
||||
if (meta_wayland_surface_should_cache_state (surface))
|
||||
meta_wayland_surface_state_merge_into (pending, surface->sub.pending);
|
||||
{
|
||||
MetaWaylandSurfaceState *cached_state;
|
||||
|
||||
cached_state = meta_wayland_surface_ensure_cached_state (surface);
|
||||
meta_wayland_surface_state_merge_into (pending, cached_state);
|
||||
}
|
||||
else
|
||||
meta_wayland_surface_apply_state (surface, surface->pending_state);
|
||||
{
|
||||
meta_wayland_surface_apply_state (surface, surface->pending_state);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1344,6 +1369,7 @@ wl_surface_destructor (struct wl_resource *resource)
|
||||
g_clear_pointer (&surface->texture, cogl_object_unref);
|
||||
g_clear_object (&surface->buffer_ref.buffer);
|
||||
|
||||
g_clear_object (&surface->cached_state);
|
||||
g_clear_object (&surface->pending_state);
|
||||
|
||||
if (surface->opaque_region)
|
||||
|
@ -176,6 +176,8 @@ struct _MetaWaylandSurface
|
||||
|
||||
/* All the pending state that wl_surface.commit will apply. */
|
||||
MetaWaylandSurfaceState *pending_state;
|
||||
/* State cached due to inter-surface synchronization such. */
|
||||
MetaWaylandSurfaceState *cached_state;
|
||||
|
||||
/* Extension resources. */
|
||||
struct wl_resource *wl_subsurface;
|
||||
@ -197,7 +199,6 @@ struct _MetaWaylandSurface
|
||||
* state here.
|
||||
*/
|
||||
gboolean synchronous;
|
||||
MetaWaylandSurfaceState *pending;
|
||||
|
||||
int32_t pending_x;
|
||||
int32_t pending_y;
|
||||
@ -232,8 +233,10 @@ MetaWaylandSurface *meta_wayland_surface_create (MetaWaylandCompositor *composit
|
||||
MetaWaylandSurfaceState *
|
||||
meta_wayland_surface_get_pending_state (MetaWaylandSurface *surface);
|
||||
|
||||
void meta_wayland_surface_apply_state (MetaWaylandSurface *surface,
|
||||
MetaWaylandSurfaceState *state);
|
||||
MetaWaylandSurfaceState *
|
||||
meta_wayland_surface_ensure_cached_state (MetaWaylandSurface *surface);
|
||||
|
||||
void meta_wayland_surface_apply_cached_state (MetaWaylandSurface *surface);
|
||||
|
||||
gboolean meta_wayland_surface_is_effectively_synchronized (MetaWaylandSurface *surface);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user