SDL: testcolorspace: show a reasonable HDR gradient on Wayland

From 9f4a1215e26e558fc31309e79c0d82cd7a74c885 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 23 Jul 2026 08:01:05 -0700
Subject: [PATCH] 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.
---
 test/testcolorspace.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/test/testcolorspace.c b/test/testcolorspace.c
index f4f79881b6b79..5b3fb54fcbcba 100644
--- a/test/testcolorspace.c
+++ b/test/testcolorspace.c
@@ -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;