[client] wayland: harden native HDR colour state

Serialize asynchronous image-description state and publish compositor
capabilities safely across the Wayland and render threads.

Use the predefined Windows-scRGB description, query each output image
description for its configured reference white, and reapply HDR when the
surface moves to an output with different colour settings.
This commit is contained in:
Geoffrey McRae
2026-07-19 04:42:46 +10:00
parent 70b795c5ba
commit 99ab6448f9
6 changed files with 391 additions and 39 deletions

View File

@@ -109,12 +109,12 @@ static bool waylandInit(const LG_DSInitParams params)
{
memset(&wlWm, 0, sizeof(wlWm));
LG_LOCK_INIT(wlWm.pendingHDRLock);
LG_LOCK_INIT(wlWm.hdrLock);
wlWm.desktop = WL_Desktops[0];
wlWm.hdrWhiteLevels = (LG_DSHDRWhiteLevels)
{
.pq = 203,
.scRGB = 80,
};
atomic_init(&wlWm.cmFeaturesDone, false);
atomic_init(&wlWm.cmCanDoHDR, false);
atomic_init(&wlWm.hdrPQWhiteLevel, 203);
atomic_init(&wlWm.hdrScRGBWhiteLevel, 80);
wlWm.display = wl_display_connect(NULL);
if (!wlWm.display)
@@ -212,6 +212,7 @@ static void waylandFree(void)
waylandRegistryFree();
waylandCursorFree();
wl_display_disconnect(wlWm.display);
LG_LOCK_FREE(wlWm.hdrLock);
LG_LOCK_FREE(wlWm.pendingHDRLock);
}
@@ -234,7 +235,11 @@ static bool waylandGetProp(LG_DSProperty prop, void * ret)
if (prop == LG_DS_HDR_WHITE_LEVELS)
{
*(LG_DSHDRWhiteLevels *)ret = wlWm.hdrWhiteLevels;
*(LG_DSHDRWhiteLevels *)ret = (LG_DSHDRWhiteLevels)
{
.pq = atomic_load(&wlWm.hdrPQWhiteLevel),
.scRGB = atomic_load(&wlWm.hdrScRGBWhiteLevel),
};
return true;
}