mirror of https://github.com/libsdl-org/SDL
Keep SDR white point and HDR headroom defaults in one place
This commit is contained in:
parent
aeae202207
commit
1fb5b9672e
|
@ -1239,8 +1239,6 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
|
||||||
int w = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, 0);
|
int w = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER, 0);
|
||||||
int h = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, 0);
|
int h = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER, 0);
|
||||||
SDL_Colorspace default_colorspace;
|
SDL_Colorspace default_colorspace;
|
||||||
float SDR_white_point_default = 1.0f;
|
|
||||||
float HDR_headroom_default = 1.0f;
|
|
||||||
SDL_bool texture_is_fourcc_and_target;
|
SDL_bool texture_is_fourcc_and_target;
|
||||||
|
|
||||||
CHECK_RENDERER_MAGIC(renderer, NULL);
|
CHECK_RENDERER_MAGIC(renderer, NULL);
|
||||||
|
@ -1298,14 +1296,8 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
|
||||||
}
|
}
|
||||||
renderer->textures = texture;
|
renderer->textures = texture;
|
||||||
|
|
||||||
if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_PQ) {
|
texture->SDR_white_point = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT, SDL_GetDefaultSDRWhitePoint(texture->colorspace));
|
||||||
SDR_white_point_default = 100.0f;
|
texture->HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT, SDL_GetDefaultHDRHeadroom(texture->colorspace));
|
||||||
HDR_headroom_default = 4.0f;
|
|
||||||
} else if (SDL_COLORSPACETRANSFER(texture->colorspace) == SDL_TRANSFER_CHARACTERISTICS_LINEAR) {
|
|
||||||
HDR_headroom_default = 0.0f;
|
|
||||||
}
|
|
||||||
texture->SDR_white_point = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT, SDR_white_point_default);
|
|
||||||
texture->HDR_headroom = SDL_GetFloatProperty(props, SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT, HDR_headroom_default);
|
|
||||||
|
|
||||||
/* FOURCC format cannot be used directly by renderer back-ends for target texture */
|
/* FOURCC format cannot be used directly by renderer back-ends for target texture */
|
||||||
texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(format));
|
texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(format));
|
||||||
|
|
|
@ -51,7 +51,9 @@ extern void SDL_FreeBlitMap(SDL_BlitMap *map);
|
||||||
extern void SDL_InvalidateAllBlitMap(SDL_Surface *surface);
|
extern void SDL_InvalidateAllBlitMap(SDL_Surface *surface);
|
||||||
|
|
||||||
/* Surface functions */
|
/* Surface functions */
|
||||||
|
extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace);
|
||||||
extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
|
extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||||
|
extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace);
|
||||||
extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
|
extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace);
|
||||||
|
|
||||||
/* Miscellaneous functions */
|
/* Miscellaneous functions */
|
||||||
|
|
|
@ -303,6 +303,11 @@ int SDL_GetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace *colorspace)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace)
|
||||||
|
{
|
||||||
|
return SDL_GetSurfaceSDRWhitePoint(NULL, colorspace);
|
||||||
|
}
|
||||||
|
|
||||||
float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace)
|
float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace)
|
||||||
{
|
{
|
||||||
SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace);
|
SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace);
|
||||||
|
@ -312,7 +317,7 @@ float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspac
|
||||||
SDL_PropertiesID props;
|
SDL_PropertiesID props;
|
||||||
float default_value = 1.0f;
|
float default_value = 1.0f;
|
||||||
|
|
||||||
if (surface->flags & SDL_SURFACE_USES_PROPERTIES) {
|
if (surface && surface->flags & SDL_SURFACE_USES_PROPERTIES) {
|
||||||
props = SDL_GetSurfaceProperties(surface);
|
props = SDL_GetSurfaceProperties(surface);
|
||||||
} else {
|
} else {
|
||||||
props = 0;
|
props = 0;
|
||||||
|
@ -326,6 +331,11 @@ float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspac
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace)
|
||||||
|
{
|
||||||
|
return SDL_GetSurfaceHDRHeadroom(NULL, colorspace);
|
||||||
|
}
|
||||||
|
|
||||||
float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace)
|
float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace)
|
||||||
{
|
{
|
||||||
SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace);
|
SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace);
|
||||||
|
@ -335,7 +345,7 @@ float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace)
|
||||||
SDL_PropertiesID props;
|
SDL_PropertiesID props;
|
||||||
float default_value = 0.0f;
|
float default_value = 0.0f;
|
||||||
|
|
||||||
if (surface->flags & SDL_SURFACE_USES_PROPERTIES) {
|
if (surface && surface->flags & SDL_SURFACE_USES_PROPERTIES) {
|
||||||
props = SDL_GetSurfaceProperties(surface);
|
props = SDL_GetSurfaceProperties(surface);
|
||||||
} else {
|
} else {
|
||||||
props = 0;
|
props = 0;
|
||||||
|
|
Loading…
Reference in New Issue