mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-24 00:06:10 +00:00
video: Expose HDR metadata per-window
Moves the HDR properties from the display to be per-window, and adds the frog_color protocol to enable HDR under Wayland.
This commit is contained in:
@@ -59,8 +59,8 @@ static void UpdateHDRState(void)
|
||||
SDL_PropertiesID props;
|
||||
SDL_bool HDR_enabled;
|
||||
|
||||
props = SDL_GetDisplayProperties(SDL_GetDisplayForWindow(window));
|
||||
HDR_enabled = SDL_GetBooleanProperty(props, SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, SDL_FALSE);
|
||||
props = SDL_GetWindowProperties(window);
|
||||
HDR_enabled = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN, SDL_FALSE);
|
||||
|
||||
SDL_Log("HDR %s\n", HDR_enabled ? "enabled" : "disabled");
|
||||
|
||||
@@ -523,7 +523,7 @@ static void loop(void)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if (event.type == SDL_EVENT_DISPLAY_HDR_STATE_CHANGED) {
|
||||
} else if (event.type == SDL_EVENT_WINDOW_HDR_STATE_CHANGED) {
|
||||
UpdateHDRState();
|
||||
} else if (event.type == SDL_EVENT_QUIT) {
|
||||
done = 1;
|
||||
|
||||
@@ -66,12 +66,14 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (i = 0; i < num_displays; i++) {
|
||||
SDL_DisplayID dpy = displays[i];
|
||||
SDL_PropertiesID props = SDL_GetDisplayProperties(dpy);
|
||||
SDL_Rect rect = { 0, 0, 0, 0 };
|
||||
int m, num_modes = 0;
|
||||
const SDL_bool has_HDR = SDL_GetBooleanProperty(props, SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, SDL_FALSE);
|
||||
|
||||
SDL_GetDisplayBounds(dpy, &rect);
|
||||
modes = SDL_GetFullscreenDisplayModes(dpy, &num_modes);
|
||||
SDL_Log("%" SDL_PRIu32 ": \"%s\" (%dx%d at %d,%d), content scale %.2f, %d fullscreen modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, SDL_GetDisplayContentScale(dpy), num_modes);
|
||||
SDL_Log("%" SDL_PRIu32 ": \"%s\" (%dx%d at %d,%d), content scale %.2f, %d fullscreen modes, HDR capable: %s.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, SDL_GetDisplayContentScale(dpy), num_modes, has_HDR ? "yes" : "no");
|
||||
|
||||
mode = SDL_GetCurrentDisplayMode(dpy);
|
||||
if (mode) {
|
||||
|
||||
@@ -155,7 +155,7 @@ static SDL_bool CreateWindowAndRenderer(SDL_WindowFlags window_flags, const char
|
||||
if (useVulkan) {
|
||||
SetupVulkanRenderProperties(vulkan_context, props);
|
||||
}
|
||||
if (SDL_GetBooleanProperty(SDL_GetDisplayProperties(SDL_GetDisplayForWindow(window)), SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, SDL_FALSE)) {
|
||||
if (SDL_GetBooleanProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN, SDL_FALSE)) {
|
||||
/* Try to create an HDR capable renderer */
|
||||
SDL_SetNumberProperty(props, SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER, SDL_COLORSPACE_SRGB_LINEAR);
|
||||
renderer = SDL_CreateRendererWithProperties(props);
|
||||
|
||||
Reference in New Issue
Block a user