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:
Frank Praznik
2024-06-17 19:23:10 -04:00
parent 0383333b54
commit 2f276a2eea
18 changed files with 526 additions and 104 deletions

View File

@@ -94,14 +94,13 @@ typedef enum SDL_EventType
/* Display events */
/* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */
SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */
SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */
SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */
SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */
SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */
SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */
SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
SDL_EVENT_DISPLAY_HDR_STATE_CHANGED, /**< Display HDR properties have changed */
SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION,
SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_HDR_STATE_CHANGED,
SDL_EVENT_DISPLAY_LAST = SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED,
/* Window events */
/* 0x200 was SDL_WINDOWEVENT, reserve the number for sdl2-compat */
@@ -134,6 +133,7 @@ typedef enum SDL_EventType
associated with it are invalid */
SDL_EVENT_WINDOW_PEN_ENTER, /**< Window has gained focus of the pressure-sensitive pen with ID "data1" */
SDL_EVENT_WINDOW_PEN_LEAVE, /**< Window has lost focus of the pressure-sensitive pen with ID "data1" */
SDL_EVENT_WINDOW_HDR_STATE_CHANGED, /**< Window HDR properties have changed */
SDL_EVENT_WINDOW_FIRST = SDL_EVENT_WINDOW_SHOWN,
SDL_EVENT_WINDOW_LAST = SDL_EVENT_WINDOW_PEN_LEAVE,

View File

@@ -411,17 +411,9 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
* The following read-only properties are provided by SDL:
*
* - `SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN`: true if the display has HDR
* headroom above the SDR white point. This property can change dynamically
* when SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
* - `SDL_PROP_DISPLAY_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the
* SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the
* SDR white level in scRGB colorspace, and on Apple platforms this is
* always 1.0 for EDR content. This property can change dynamically when
* SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
* - `SDL_PROP_DISPLAY_HDR_HEADROOM_FLOAT`: the additional high dynamic range
* that can be displayed, in terms of the SDR white point. When HDR is not
* enabled, this will be 1.0. This property can change dynamically when
* SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
* headroom above the SDR white point. This is for informational and diagnostic
* purposes only, as not all platforms provide this information at the display
* level.
*
* On KMS/DRM:
*
@@ -443,8 +435,6 @@ extern SDL_DECLSPEC SDL_DisplayID SDLCALL SDL_GetPrimaryDisplay(void);
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetDisplayProperties(SDL_DisplayID displayID);
#define SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN "SDL.display.HDR_enabled"
#define SDL_PROP_DISPLAY_SDR_WHITE_POINT_FLOAT "SDL.display.SDR_white_point"
#define SDL_PROP_DISPLAY_HDR_HEADROOM_FLOAT "SDL.display.HDR_headroom"
#define SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER "SDL.display.KMSDRM.panel_orientation"
/**
@@ -1113,6 +1103,18 @@ extern SDL_DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window);
*
* - `SDL_PROP_WINDOW_SHAPE_POINTER`: the surface associated with a shaped
* window
* - `SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN`: true if the window has HDR
* headroom above the SDR white point. This property can change dynamically
* when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
* - `SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT`: the value of SDR white in the
* SDL_COLORSPACE_SRGB_LINEAR colorspace. On Windows this corresponds to the
* SDR white level in scRGB colorspace, and on Apple platforms this is
* always 1.0 for EDR content. This property can change dynamically when
* SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
* - `SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT`: the additional high dynamic range
* that can be displayed, in terms of the SDR white point. When HDR is not
* enabled, this will be 1.0. This property can change dynamically when
* SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent.
*
* On Android:
*
@@ -1216,6 +1218,9 @@ extern SDL_DECLSPEC SDL_Window *SDLCALL SDL_GetWindowParent(SDL_Window *window);
extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetWindowProperties(SDL_Window *window);
#define SDL_PROP_WINDOW_SHAPE_POINTER "SDL.window.shape"
#define SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN "SDL.window.HDR_enabled"
#define SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT "SDL.window.SDR_white_level"
#define SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT "SDL.window.HDR_headroom"
#define SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER "SDL.window.android.window"
#define SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER "SDL.window.android.surface"
#define SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER "SDL.window.uikit.window"