Clarify thread-safety information for surface functions

This commit is contained in:
Sam Lantinga
2025-10-23 07:52:48 -07:00
parent 02c4478f93
commit 6d095575e8

View File

@@ -29,13 +29,12 @@
* provides a reasonable toolbox for transforming the data, including copying * provides a reasonable toolbox for transforming the data, including copying
* between surfaces, filling rectangles in the image data, etc. * between surfaces, filling rectangles in the image data, etc.
* *
* There is also a simple .bmp loader, SDL_LoadBMP(). SDL itself does not * There is also a simple .bmp loader, SDL_LoadBMP(), and a simple .png loader, SDL_LoadPNG(). SDL itself does not
* provide loaders for various other file formats, but there are several * provide loaders for other file formats, but there are several
* excellent external libraries that do, including its own satellite library, * excellent external libraries that do, including its own satellite library,
* [SDL_image](https://wiki.libsdl.org/SDL3_image) * [SDL_image](https://wiki.libsdl.org/SDL3_image).
* :
* *
* https://github.com/libsdl-org/SDL_image * In general these functions are thread-safe in that they can be called on different threads with different surfaces. You should not try to modify any surface from two threads simultaneously.
*/ */
#ifndef SDL_surface_h_ #ifndef SDL_surface_h_
@@ -267,7 +266,7 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSurfaceProperties(SDL_Surfac
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -286,7 +285,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorspace(SDL_Surface *surface,
* \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if * \returns the colorspace used by the surface, or SDL_COLORSPACE_UNKNOWN if
* the surface is NULL. * the surface is NULL.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -316,7 +315,7 @@ extern SDL_DECLSPEC SDL_Colorspace SDLCALL SDL_GetSurfaceColorspace(SDL_Surface
* the surface didn't have an index format); call SDL_GetError() for * the surface didn't have an index format); call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -337,7 +336,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_CreateSurfacePalette(SDL_Surface *
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -378,7 +377,7 @@ extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetSurfacePalette(SDL_Surface *sur
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -421,7 +420,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasAlternateImages(SDL_Surface *surf
* failure; call SDL_GetError() for more information. This should be * failure; call SDL_GetError() for more information. This should be
* freed with SDL_free() when it is no longer needed. * freed with SDL_free() when it is no longer needed.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -439,7 +438,7 @@ extern SDL_DECLSPEC SDL_Surface ** SDLCALL SDL_GetSurfaceImages(SDL_Surface *sur
* *
* \param surface the SDL_Surface structure to update. * \param surface the SDL_Surface structure to update.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -465,7 +464,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_RemoveSurfaceAlternateImages(SDL_Surface *s
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. The locking referred to by * \threadsafety This function can be called on different threads with different surfaces. The locking referred to by
* this function is making the pixels available for direct * this function is making the pixels available for direct
* access, not thread-safe locking. * access, not thread-safe locking.
* *
@@ -549,7 +548,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *file);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -572,7 +571,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStre
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -633,7 +632,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_LoadPNG(const char *file);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.4.0. * \since This function is available since SDL 3.4.0.
* *
@@ -650,7 +649,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG_IO(SDL_Surface *surface, SDL_IOStre
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.4.0. * \since This function is available since SDL 3.4.0.
* *
@@ -670,7 +669,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SavePNG(SDL_Surface *surface, const char *f
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -712,7 +711,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SurfaceHasRLE(SDL_Surface *surface);
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -777,7 +776,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorKey(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -797,7 +796,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -819,7 +818,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -857,7 +856,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Ui
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -896,7 +895,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface, S
* \returns true if the rectangle intersects the surface, otherwise false and * \returns true if the rectangle intersects the surface, otherwise false and
* blits will be completely clipped. * blits will be completely clipped.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -917,7 +916,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetSurfaceClipRect(SDL_Surface *surface, co
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -933,7 +932,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetSurfaceClipRect(SDL_Surface *surface, SD
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -953,7 +952,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FlipSurface(SDL_Surface *surface, SDL_FlipM
* \returns a rotated copy of the surface or NULL on failure; call * \returns a rotated copy of the surface or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.4.0. * \since This function is available since SDL 3.4.0.
*/ */
@@ -971,7 +970,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RotateSurface(SDL_Surface *surface
* \returns a copy of the surface or NULL on failure; call SDL_GetError() for * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -992,7 +991,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_DuplicateSurface(SDL_Surface *surf
* \returns a copy of the surface or NULL on failure; call SDL_GetError() for * \returns a copy of the surface or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1019,7 +1018,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ScaleSurface(SDL_Surface *surface,
* \returns the new SDL_Surface structure that is created or NULL on failure; * \returns the new SDL_Surface structure that is created or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1047,7 +1046,7 @@ extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface(SDL_Surface *surfac
* \returns the new SDL_Surface structure that is created or NULL on failure; * \returns the new SDL_Surface structure that is created or NULL on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1150,7 +1149,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplyAlpha(int width, int height, SDL
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1172,7 +1171,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_PremultiplySurfaceAlpha(SDL_Surface *surfac
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1197,7 +1196,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ClearSurface(SDL_Surface *surface, float r,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1224,7 +1223,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_FillSurfaceRect(SDL_Surface *dst, const SDL
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1515,7 +1514,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_BlitSurface9Grid(SDL_Surface *src, const SD
* \param b the blue component of the pixel in the range 0-255. * \param b the blue component of the pixel in the range 0-255.
* \returns a pixel value. * \returns a pixel value.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1548,7 +1547,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8
* \param a the alpha component of the pixel in the range 0-255. * \param a the alpha component of the pixel in the range 0-255.
* \returns a pixel value. * \returns a pixel value.
* *
* \threadsafety It is safe to call this function from any thread. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
* *
@@ -1579,7 +1578,7 @@ extern SDL_DECLSPEC Uint32 SDLCALL SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1605,7 +1604,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1630,7 +1629,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_ReadSurfacePixelFloat(SDL_Surface *surface,
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */
@@ -1652,7 +1651,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_WriteSurfacePixel(SDL_Surface *surface, int
* \returns true on success or false on failure; call SDL_GetError() for more * \returns true on success or false on failure; call SDL_GetError() for more
* information. * information.
* *
* \threadsafety This function is not thread safe. * \threadsafety This function can be called on different threads with different surfaces.
* *
* \since This function is available since SDL 3.2.0. * \since This function is available since SDL 3.2.0.
*/ */