Added support for the scRGB colorspace on D3D11 and D3D12

This commit is contained in:
Sam Lantinga
2024-01-31 17:25:25 -08:00
parent 12c31898c1
commit 6f443e2aca
22 changed files with 654 additions and 323 deletions

View File

@@ -216,8 +216,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySurface(SDL_Surface *surface);
*
* The following properties are understood by SDL:
*
* - `SDL_PROP_SURFACE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
* the surface colorspace
* - `SDL_PROP_SURFACE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing the surface colorspace, defaults to SDL_COLORSPACE_SCRGB for floating point formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.
* - `SDL_PROP_SURFACE_MAXCLL_NUMBER`: MaxCLL (Maximum Content Light Level)
* indicates the maximum light level of any single pixel (in cd/m2 or nits)
* of the entire playback sequence. MaxCLL is usually measured off the final
@@ -245,6 +244,34 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *s
#define SDL_PROP_SURFACE_MAXCLL_NUMBER "SDL.surface.maxCLL"
#define SDL_PROP_SURFACE_MAXFALL_NUMBER "SDL.surface.maxFALL"
/**
* Set the colorspace used by a surface.
*
* Setting the colorspace doesn't change the pixels, only how they are interpreted in color operations.
*
* \param surface the SDL_Surface structure to update
* \param colorspace an SDL_ColorSpace value describing the surface colorspace
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace);
/**
* Get the colorspace used by a surface.
*
* The colorspace defaults to SDL_COLORSPACE_SCRGB for floating point formats, SDL_COLORSPACE_HDR10 for 10-bit formats, SDL_COLORSPACE_SRGB for other RGB surfaces and SDL_COLORSPACE_BT709_FULL for YUV textures.
*
* \param surface the SDL_Surface structure to query
* \param colorspace a pointer filled in with an SDL_ColorSpace value describing the surface colorspace
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace *colorspace);
/**
* Set the palette used by a surface.
*
@@ -257,8 +284,7 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surface *s
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface,
SDL_Palette *palette);
extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette);
/**
* Set up a surface for directly accessing the pixels.
@@ -393,8 +419,7 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP(SDL_Surface *surface, const char *file);
* \sa SDL_LockSurface
* \sa SDL_UnlockSurface
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface,
int flag);
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
/**
* Returns whether the surface is RLE enabled
@@ -434,8 +459,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
* \sa SDL_BlitSurface
* \sa SDL_GetSurfaceColorKey
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface,
int flag, Uint32 key);
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key);
/**
* Returns whether the surface has a color key
@@ -470,8 +494,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SurfaceHasColorKey(SDL_Surface *surface);
* \sa SDL_BlitSurface
* \sa SDL_SetSurfaceColorKey
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface,
Uint32 *key);
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key);
/**
* Set an additional color value multiplied into blit operations.
@@ -494,8 +517,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface,
* \sa SDL_GetSurfaceColorMod
* \sa SDL_SetSurfaceAlphaMod
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface,
Uint8 r, Uint8 g, Uint8 b);
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b);
/**
@@ -513,9 +535,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface,
* \sa SDL_GetSurfaceAlphaMod
* \sa SDL_SetSurfaceColorMod
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface,
Uint8 *r, Uint8 *g,
Uint8 *b);
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b);
/**
* Set an additional alpha value used in blit operations.
@@ -535,8 +555,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface,
* \sa SDL_GetSurfaceAlphaMod
* \sa SDL_SetSurfaceColorMod
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface,
Uint8 alpha);
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha);
/**
* Get the additional alpha value used in blit operations.
@@ -551,8 +570,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface,
* \sa SDL_GetSurfaceColorMod
* \sa SDL_SetSurfaceAlphaMod
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface,
Uint8 *alpha);
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha);
/**
* Set the blend mode used for blit operations.
@@ -570,8 +588,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface,
*
* \sa SDL_GetSurfaceBlendMode
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface,
SDL_BlendMode blendMode);
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode);
/**
* Get the blend mode used for blit operations.
@@ -585,8 +602,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface,
*
* \sa SDL_SetSurfaceBlendMode
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface,
SDL_BlendMode *blendMode);
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode);
/**
* Set the clipping rectangle for a surface.
@@ -608,8 +624,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface,
* \sa SDL_BlitSurface
* \sa SDL_GetSurfaceClipRect
*/
extern DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface,
const SDL_Rect *rect);
extern DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect);
/**
* Get the clipping rectangle for a surface.
@@ -629,8 +644,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface,
* \sa SDL_BlitSurface
* \sa SDL_SetSurfaceClipRect
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface,
SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect);
/*
* Flip a surface vertically or horizontally.
@@ -677,11 +691,10 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface *surface);
* \sa SDL_ConvertSurfaceFormat
* \sa SDL_CreateSurface
*/
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
const SDL_PixelFormat *format);
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *format);
/**
* Copy an existing surface to a new surface of the specified format enum.
* Copy an existing surface to a new surface of the specified format.
*
* This function operates just like SDL_ConvertSurface(), but accepts an
* SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As such,
@@ -689,8 +702,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
* information for the destination surface, in case that would be important.
*
* \param surface the existing SDL_Surface structure to convert
* \param pixel_format the SDL_PixelFormatEnum that the new surface is
* optimized for
* \param pixel_format the new pixel format
* \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information.
*
@@ -700,8 +712,26 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
* \sa SDL_ConvertSurface
* \sa SDL_CreateSurface
*/
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surface,
Uint32 pixel_format);
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format);
/**
* Copy an existing surface to a new surface of the specified format and colorspace.
*
* This function converts an existing surface to a new format and colorspace and returns the new surface. This will perform any pixel format and colorspace conversion needed.
*
* \param surface the existing SDL_Surface structure to convert
* \param pixel_format the new pixel format
* \param colorspace the new colorspace
* \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreatePixelFormat
* \sa SDL_ConvertSurface
* \sa SDL_CreateSurface
*/
extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormatAndColorspace(SDL_Surface *surface, Uint32 pixel_format, SDL_Colorspace colorspace);
/**
* Copy a block of pixels of one format to another format.
@@ -719,11 +749,27 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat(SDL_Surface *surfa
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
Uint32 src_format,
const void *src, int src_pitch,
Uint32 dst_format,
void *dst, int dst_pitch);
extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
/**
* Copy a block of pixels of one format and colorspace to another format and colorspace.
*
* \param width the width of the block to copy, in pixels
* \param height the height of the block to copy, in pixels
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format
* \param src_colorspace an SDL_ColorSpace value describing the colorspace of the `src` pixels
* \param src a pointer to the source pixels
* \param src_pitch the pitch of the source pixels, in bytes
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format
* \param dst_colorspace an SDL_ColorSpace value describing the colorspace of the `dst` pixels
* \param dst a pointer to be filled in with new pixel data
* \param dst_pitch the pitch of the destination pixels, in bytes
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_ConvertPixelsAndColorspace(int width, int height, Uint32 src_format, SDL_Colorspace src_colorspace, const void *src, int src_pitch, Uint32 dst_format, SDL_Colorspace dst_colorspace, void *dst, int dst_pitch);
/**
* Premultiply the alpha on a block of pixels.
@@ -745,11 +791,7 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
Uint32 src_format,
const void *src, int src_pitch,
Uint32 dst_format,
void *dst, int dst_pitch);
extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
/**
* Perform a fast fill of a rectangle with a specific color.
@@ -774,8 +816,7 @@ extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
*
* \sa SDL_FillSurfaceRects
*/
extern DECLSPEC int SDLCALL SDL_FillSurfaceRect
(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
extern DECLSPEC int SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color);
/**
* Perform a fast fill of a set of rectangles with a specific color.
@@ -800,8 +841,7 @@ extern DECLSPEC int SDLCALL SDL_FillSurfaceRect
*
* \sa SDL_FillSurfaceRect
*/
extern DECLSPEC int SDLCALL SDL_FillSurfaceRects
(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
extern DECLSPEC int SDLCALL SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color);
/**
* Performs a fast blit from the source surface to the destination surface.
@@ -871,9 +911,7 @@ extern DECLSPEC int SDLCALL SDL_FillSurfaceRects
*
* \sa SDL_BlitSurfaceScaled
*/
extern DECLSPEC int SDLCALL SDL_BlitSurface
(SDL_Surface *src, const SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
extern DECLSPEC int SDLCALL SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
/**
* Perform low-level surface blitting only.
@@ -894,9 +932,7 @@ extern DECLSPEC int SDLCALL SDL_BlitSurface
*
* \sa SDL_BlitSurface
*/
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
(SDL_Surface *src, const SDL_Rect *srcrect,
SDL_Surface *dst, const SDL_Rect *dstrect);
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
/**
* Perform stretch blit between two surfaces of the same format.
@@ -918,11 +954,7 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
*
* \sa SDL_BlitSurfaceScaled
*/
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src,
const SDL_Rect *srcrect,
SDL_Surface *dst,
const SDL_Rect *dstrect,
SDL_ScaleMode scaleMode);
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
/**
* Perform a scaled surface copy to a destination surface.
@@ -942,11 +974,7 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src,
*
* \sa SDL_BlitSurface
*/
extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src,
const SDL_Rect *srcrect,
SDL_Surface *dst,
SDL_Rect *dstrect,
SDL_ScaleMode scaleMode);
extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
/**
* Perform low-level surface scaled blitting only.
@@ -968,11 +996,7 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceScaled(SDL_Surface *src,
*
* \sa SDL_BlitSurfaceScaled
*/
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src,
const SDL_Rect *srcrect,
SDL_Surface *dst,
const SDL_Rect *dstrect,
SDL_ScaleMode scaleMode);
extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode);
/**
* Retrieves a single pixel from a surface.
@@ -1001,7 +1025,6 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src,
*/
extern DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/**
* Set the YUV conversion mode
*