testcolorspace: show a reasonable HDR gradient on Wayland

On some Wayland configurations, the SDR white level is 203 nits and the max luminance is 10000 nits, and HDR content in the PQ range is mapped by the compositor into the actual display capabilities. We don't want to show an HDR gradient up to 10000 nits, so let's cap it to ~1000 nits in this case.
This commit is contained in:
Sam Lantinga
2026-07-23 08:01:05 -07:00
parent 2a623fd224
commit 9f4a1215e2

View File

@@ -85,6 +85,12 @@ static void UpdateHDRState(void)
}
SDR_white_level = SDL_GetFloatProperty(props, SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT, 1.0f);
HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT, 1.0f);
if (((SDR_white_level * 80.0f) * HDR_headroom) == 10000.0f) {
// The system is advertising the PQ luminance range (10000 nits)
// and tone mapping into the actual display capabilities.
// Let's use a more reasonable range for the gradient test.
HDR_headroom = 5.0f;
}
} else {
SDR_white_level = 1.0f;
HDR_headroom = 1.0f;