From 63fa79c8780caa5896191bd6af0ab4f6f494cc2e Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Tue, 16 Jul 2024 17:36:03 +0200 Subject: [PATCH] wayland/surface: Add double-buffered color state This will be used by the color management protocol to set the color state of a surface. Part-of: --- src/wayland/meta-wayland-actor-surface.c | 5 +++++ src/wayland/meta-wayland-surface-private.h | 6 ++++++ src/wayland/meta-wayland-surface.c | 15 +++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/wayland/meta-wayland-actor-surface.c b/src/wayland/meta-wayland-actor-surface.c index 6c83fdce8..9a4502411 100644 --- a/src/wayland/meta-wayland-actor-surface.c +++ b/src/wayland/meta-wayland-actor-surface.c @@ -191,6 +191,11 @@ meta_wayland_actor_surface_real_sync_actor_state (MetaWaylandActorSurface *actor color_state = clutter_actor_get_color_state (CLUTTER_ACTOR (surface_actor)); + if (surface->color_state) + color_state = surface->color_state; + + clutter_actor_set_color_state (CLUTTER_ACTOR (surface_actor), + color_state); texture = meta_wayland_surface_get_texture (surface); meta_shaped_texture_set_texture (stex, texture); diff --git a/src/wayland/meta-wayland-surface-private.h b/src/wayland/meta-wayland-surface-private.h index 7fbfc5367..fb5f88eed 100644 --- a/src/wayland/meta-wayland-surface-private.h +++ b/src/wayland/meta-wayland-surface-private.h @@ -135,6 +135,9 @@ struct _MetaWaylandSurfaceState MetaWaylandSyncPoint *acquire; MetaWaylandSyncPoint *release; } drm_syncobj; + + gboolean has_new_color_state; + ClutterColorState *color_state; }; struct _MetaWaylandDragDestFuncs @@ -274,6 +277,9 @@ struct _MetaWaylandSurface } transaction; MetaLogicalMonitor *main_monitor; + + /* color-management */ + ClutterColorState *color_state; }; void meta_wayland_shell_init (MetaWaylandCompositor *compositor); diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c index a265a25c5..fa335b030 100644 --- a/src/wayland/meta-wayland-surface.c +++ b/src/wayland/meta-wayland-surface.c @@ -453,6 +453,9 @@ meta_wayland_surface_state_set_default (MetaWaylandSurfaceState *state) state->drm_syncobj.acquire = NULL; state->drm_syncobj.release = NULL; + + state->has_new_color_state = FALSE; + state->color_state = NULL; } static void @@ -475,6 +478,7 @@ meta_wayland_surface_state_clear (MetaWaylandSurfaceState *state) g_clear_object (&state->texture); g_clear_object (&state->drm_syncobj.acquire); g_clear_object (&state->drm_syncobj.release); + g_clear_object (&state->color_state); g_clear_pointer (&state->surface_damage, mtk_region_unref); g_clear_pointer (&state->buffer_damage, mtk_region_unref); @@ -645,6 +649,14 @@ meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from, g_clear_object (&from->drm_syncobj.acquire); g_set_object (&to->drm_syncobj.release, from->drm_syncobj.release); g_clear_object (&from->drm_syncobj.release); + + if (from->has_new_color_state) + { + g_set_object (&to->color_state, from->color_state); + g_clear_object (&from->color_state); + + to->has_new_color_state = TRUE; + } } static void @@ -840,6 +852,9 @@ meta_wayland_surface_apply_state (MetaWaylandSurface *surface, surface->input_region = mtk_region_ref (state->input_region); } + if (state->has_new_color_state) + g_set_object (&surface->color_state, state->color_state); + /* * A new commit indicates a new content update, so any previous * content update did not go on screen and needs to be discarded.