SDL API renaming: SDL_pixels.h

Fixes https://github.com/libsdl-org/SDL/issues/6886
main
Sam Lantinga 2022-12-27 06:08:13 -08:00
parent 3d063d7295
commit 083e436a1a
18 changed files with 126 additions and 96 deletions

View File

@ -17,12 +17,16 @@ General:
* RW_SEEK_SET -> SDL_RW_SEEK_SET * RW_SEEK_SET -> SDL_RW_SEEK_SET
* SDL_FreeWAV has been removed and calls can be replaced with SDL_free * SDL_FreeWAV has been removed and calls can be replaced with SDL_free
* The following functions have been renamed: * The following functions have been renamed:
* SDL_AllocFormat => SDL_CreatePixelFormat
* SDL_AllocPalette => SDL_CreatePalette
* SDL_AudioStreamAvailable => SDL_GetAudioStreamAvailable * SDL_AudioStreamAvailable => SDL_GetAudioStreamAvailable
* SDL_AudioStreamClear => SDL_ClearAudioStream * SDL_AudioStreamClear => SDL_ClearAudioStream
* SDL_AudioStreamFlush => SDL_FlushAudioStream * SDL_AudioStreamFlush => SDL_FlushAudioStream
* SDL_AudioStreamGet => SDL_GetAudioStreamData * SDL_AudioStreamGet => SDL_GetAudioStreamData
* SDL_AudioStreamPut => SDL_PutAudioStreamData * SDL_AudioStreamPut => SDL_PutAudioStreamData
* SDL_FreeAudioStream => SDL_DestroyAudioStream * SDL_FreeAudioStream => SDL_DestroyAudioStream
* SDL_FreeFormat => SDL_DestroyPixelFormat
* SDL_FreePalette => SDL_DestroyPalette
* SDL_JoystickAttachVirtual => SDL_AttachVirtualJoystick * SDL_JoystickAttachVirtual => SDL_AttachVirtualJoystick
* SDL_JoystickAttachVirtualEx => SDL_AttachVirtualJoystickEx * SDL_JoystickAttachVirtualEx => SDL_AttachVirtualJoystickEx
* SDL_JoystickClose => SDL_CloseJoystick * SDL_JoystickClose => SDL_CloseJoystick
@ -72,8 +76,10 @@ General:
* SDL_JoystickSetVirtualButton => SDL_SetJoystickVirtualButton * SDL_JoystickSetVirtualButton => SDL_SetJoystickVirtualButton
* SDL_JoystickSetVirtualHat => SDL_SetJoystickVirtualHat * SDL_JoystickSetVirtualHat => SDL_SetJoystickVirtualHat
* SDL_JoystickUpdate => SDL_UpdateJoysticks * SDL_JoystickUpdate => SDL_UpdateJoysticks
* SDL_MasksToPixelFormatEnum => SDL_GetPixelFormatEnumForMasks
* SDL_NewAudioStream => SDL_CreateAudioStream * SDL_NewAudioStream => SDL_CreateAudioStream
* SDL_NumJoysticks => SDL_GetNumJoysticks * SDL_NumJoysticks => SDL_GetNumJoysticks
* SDL_PixelFormatEnumToMasks => SDL_GetMasksForPixelFormatEnum
* Removed the following functions from the API, see docs/README-migration.md for details: * Removed the following functions from the API, see docs/README-migration.md for details:
* SDL_AudioInit() * SDL_AudioInit()
* SDL_AudioQuit() * SDL_AudioQuit()

View File

@ -221,6 +221,14 @@ used by additional platforms that didn't have a SDL_RunApp-like function before)
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)). SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).
The following functions have been renamed:
* SDL_AllocFormat => SDL_CreatePixelFormat
* SDL_AllocPalette => SDL_CreatePalette
* SDL_FreeFormat => SDL_DestroyPixelFormat
* SDL_FreePalette => SDL_DestroyPalette
* SDL_MasksToPixelFormatEnum => SDL_GetPixelFormatEnumForMasks
* SDL_PixelFormatEnumToMasks => SDL_GetMasksForPixelFormatEnum
## SDL_platform.h ## SDL_platform.h
The preprocessor symbol __MACOSX__ has been renamed __MACOS__, and __IPHONEOS__ has been renamed __IOS__ The preprocessor symbol __MACOSX__ has been renamed __MACOS__, and __IPHONEOS__ has been renamed __IOS__
@ -419,7 +427,7 @@ You can implement the old functions in your own code easily:
SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{ {
return SDL_CreateSurface(width, height, return SDL_CreateSurface(width, height,
SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask)); SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
} }
SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format) SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format)
@ -430,7 +438,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{ {
return SDL_CreateSurfaceFrom(pixels, width, height, pitch, return SDL_CreateSurfaceFrom(pixels, width, height, pitch,
SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask)); SDL_GetPixelFormatEnumForMasks(depth, Rmask, Gmask, Bmask, Amask));
} }
SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format) SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 format)

View File

@ -121,6 +121,14 @@
#define KMOD_SCROLL SDL_KMOD_SCROLL #define KMOD_SCROLL SDL_KMOD_SCROLL
#define KMOD_SHIFT SDL_KMOD_SHIFT #define KMOD_SHIFT SDL_KMOD_SHIFT
/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_CreatePalette
#define SDL_FreeFormat SDL_DestroyPixelFormat
#define SDL_FreePalette SDL_DestroyPalette
#define SDL_MasksToPixelFormatEnum SDL_GetPixelFormatEnumForMasks
#define SDL_PixelFormatEnumToMasks SDL_GetMasksForPixelFormatEnum
/* ##SDL_platform.h */ /* ##SDL_platform.h */
#ifdef __IOS__ #ifdef __IOS__
#define __IPHONEOS__ __IOS__ #define __IPHONEOS__ __IOS__
@ -218,6 +226,14 @@
#define KMOD_SCROLL KMOD_SCROLL_renamed_SDL_KMOD_SCROLL #define KMOD_SCROLL KMOD_SCROLL_renamed_SDL_KMOD_SCROLL
#define KMOD_SHIFT KMOD_SHIFT_renamed_SDL_KMOD_SHIFT #define KMOD_SHIFT KMOD_SHIFT_renamed_SDL_KMOD_SHIFT
/* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette
#define SDL_FreeFormat SDL_FreeFormat_renamed_SDL_DestroyPixelFormat
#define SDL_FreePalette SDL_FreePalette_renamed_SDL_DestroyPalette
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_renamed_SDL_GetPixelFormatEnumForMasks
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_renamed_SDL_GetMasksForPixelFormatEnum
/* ##SDL_platform.h */ /* ##SDL_platform.h */
#ifdef __IOS__ #ifdef __IOS__
#define __IPHONEOS__ __IPHONEOS___renamed___IOS__ #define __IPHONEOS__ __IPHONEOS___renamed___IOS__

View File

@ -363,9 +363,9 @@ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_MasksToPixelFormatEnum * \sa SDL_GetPixelFormatEnumForMasks
*/ */
extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, extern DECLSPEC SDL_bool SDLCALL SDL_GetMasksForPixelFormatEnum(Uint32 format,
int *bpp, int *bpp,
Uint32 * Rmask, Uint32 * Rmask,
Uint32 * Gmask, Uint32 * Gmask,
@ -387,9 +387,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_PixelFormatEnumToMasks * \sa SDL_GetMasksForPixelFormatEnum
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, extern DECLSPEC Uint32 SDLCALL SDL_GetPixelFormatEnumForMasks(int bpp,
Uint32 Rmask, Uint32 Rmask,
Uint32 Gmask, Uint32 Gmask,
Uint32 Bmask, Uint32 Bmask,
@ -408,20 +408,20 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_FreeFormat * \sa SDL_DestroyPixelFormat
*/ */
extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_CreatePixelFormat(Uint32 pixel_format);
/** /**
* Free an SDL_PixelFormat structure allocated by SDL_AllocFormat(). * Free an SDL_PixelFormat structure allocated by SDL_CreatePixelFormat().
* *
* \param format the SDL_PixelFormat structure to free * \param format the SDL_PixelFormat structure to free
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocFormat * \sa SDL_CreatePixelFormat
*/ */
extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); extern DECLSPEC void SDLCALL SDL_DestroyPixelFormat(SDL_PixelFormat *format);
/** /**
* Create a palette structure with the specified number of color entries. * Create a palette structure with the specified number of color entries.
@ -435,9 +435,9 @@ extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_FreePalette * \sa SDL_DestroyPalette
*/ */
extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); extern DECLSPEC SDL_Palette *SDLCALL SDL_CreatePalette(int ncolors);
/** /**
* Set the palette for a pixel format structure. * Set the palette for a pixel format structure.
@ -449,8 +449,8 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocPalette * \sa SDL_CreatePalette
* \sa SDL_FreePalette * \sa SDL_DestroyPalette
*/ */
extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
SDL_Palette *palette); SDL_Palette *palette);
@ -467,7 +467,7 @@ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocPalette * \sa SDL_CreatePalette
* \sa SDL_CreateSurface * \sa SDL_CreateSurface
*/ */
extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
@ -475,15 +475,15 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
int firstcolor, int ncolors); int firstcolor, int ncolors);
/** /**
* Free a palette created with SDL_AllocPalette(). * Free a palette created with SDL_CreatePalette().
* *
* \param palette the SDL_Palette structure to be freed * \param palette the SDL_Palette structure to be freed
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocPalette * \sa SDL_CreatePalette
*/ */
extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); extern DECLSPEC void SDLCALL SDL_DestroyPalette(SDL_Palette * palette);
/** /**
* Map an RGB triple to an opaque pixel value for a given pixel format. * Map an RGB triple to an opaque pixel value for a given pixel format.

View File

@ -562,7 +562,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocFormat * \sa SDL_CreatePixelFormat
* \sa SDL_ConvertSurfaceFormat * \sa SDL_ConvertSurfaceFormat
* \sa SDL_CreateSurface * \sa SDL_CreateSurface
*/ */
@ -585,7 +585,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface(SDL_Surface *surface,
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_AllocFormat * \sa SDL_CreatePixelFormat
* \sa SDL_ConvertSurface * \sa SDL_ConvertSurface
* \sa SDL_CreateSurface * \sa SDL_CreateSurface
*/ */

View File

@ -182,14 +182,14 @@ SDL3_0.0.0 {
SDL_Vulkan_GetDrawableSize; SDL_Vulkan_GetDrawableSize;
SDL_GetPreferredLocales; SDL_GetPreferredLocales;
SDL_GetPixelFormatName; SDL_GetPixelFormatName;
SDL_PixelFormatEnumToMasks; SDL_GetMasksForPixelFormatEnum;
SDL_MasksToPixelFormatEnum; SDL_GetPixelFormatEnumForMasks;
SDL_AllocFormat; SDL_CreatePixelFormat;
SDL_FreeFormat; SDL_DestroyPixelFormat;
SDL_AllocPalette; SDL_CreatePalette;
SDL_SetPixelFormatPalette; SDL_SetPixelFormatPalette;
SDL_SetPaletteColors; SDL_SetPaletteColors;
SDL_FreePalette; SDL_DestroyPalette;
SDL_MapRGB; SDL_MapRGB;
SDL_MapRGBA; SDL_MapRGBA;
SDL_GetRGB; SDL_GetRGB;

View File

@ -263,14 +263,14 @@
#define SDL_CondWait SDL_CondWait_REAL #define SDL_CondWait SDL_CondWait_REAL
#define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL #define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL
#define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL #define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_REAL #define SDL_GetMasksForPixelFormatEnum SDL_GetMasksForPixelFormatEnum_REAL
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_REAL #define SDL_GetPixelFormatEnumForMasks SDL_GetPixelFormatEnumForMasks_REAL
#define SDL_AllocFormat SDL_AllocFormat_REAL #define SDL_CreatePixelFormat SDL_CreatePixelFormat_REAL
#define SDL_FreeFormat SDL_FreeFormat_REAL #define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
#define SDL_AllocPalette SDL_AllocPalette_REAL #define SDL_CreatePalette SDL_CreatePalette_REAL
#define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_REAL #define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_REAL
#define SDL_SetPaletteColors SDL_SetPaletteColors_REAL #define SDL_SetPaletteColors SDL_SetPaletteColors_REAL
#define SDL_FreePalette SDL_FreePalette_REAL #define SDL_DestroyPalette SDL_DestroyPalette_REAL
#define SDL_MapRGB SDL_MapRGB_REAL #define SDL_MapRGB SDL_MapRGB_REAL
#define SDL_MapRGBA SDL_MapRGBA_REAL #define SDL_MapRGBA SDL_MapRGBA_REAL
#define SDL_GetRGB SDL_GetRGB_REAL #define SDL_GetRGB SDL_GetRGB_REAL

View File

@ -290,14 +290,14 @@ SDL_DYNAPI_PROC(int,SDL_CondBroadcast,(SDL_cond *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(Uint32 a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_PixelFormatEnumToMasks,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetMasksForPixelFormatEnum,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(Uint32,SDL_MasksToPixelFormatEnum,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(Uint32,SDL_GetPixelFormatEnumForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_AllocFormat,(Uint32 a),(a),return) SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(void,SDL_FreeFormat,(SDL_PixelFormat *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_AllocPalette,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetPixelFormatPalette,(SDL_PixelFormat *a, SDL_Palette *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetPixelFormatPalette,(SDL_PixelFormat *a, SDL_Palette *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_FreePalette,(SDL_Palette *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return) SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),) SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),)

View File

@ -1436,13 +1436,13 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
SDL_Surface *temp = NULL; SDL_Surface *temp = NULL;
/* Set up a destination surface for the texture update */ /* Set up a destination surface for the texture update */
dst_fmt = SDL_AllocFormat(format); dst_fmt = SDL_CreatePixelFormat(format);
if (dst_fmt == NULL) { if (dst_fmt == NULL) {
SDL_DestroyTexture(texture); SDL_DestroyTexture(texture);
return NULL; return NULL;
} }
temp = SDL_ConvertSurface(surface, dst_fmt); temp = SDL_ConvertSurface(surface, dst_fmt);
SDL_FreeFormat(dst_fmt); SDL_DestroyPixelFormat(dst_fmt);
if (temp) { if (temp) {
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
SDL_FreeSurface(temp); SDL_FreeSurface(temp);

View File

@ -474,7 +474,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex
* to be created. This makes all source pixels opaque and the colors get copied correctly. * to be created. This makes all source pixels opaque and the colors get copied correctly.
*/ */
SDL_Surface *src_rotated_rgb; SDL_Surface *src_rotated_rgb;
int f = SDL_MasksToPixelFormatEnum(src_rotated->format->BitsPerPixel, int f = SDL_GetPixelFormatEnumForMasks(src_rotated->format->BitsPerPixel,
src_rotated->format->Rmask, src_rotated->format->Rmask,
src_rotated->format->Gmask, src_rotated->format->Gmask,
src_rotated->format->Bmask, src_rotated->format->Bmask,

View File

@ -1143,7 +1143,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_Log("DPI: %fx%f\n", hdpi, vdpi); SDL_Log("DPI: %fx%f\n", hdpi, vdpi);
SDL_GetDesktopDisplayMode(i, &mode); SDL_GetDesktopDisplayMode(i, &mode);
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask, &Gmask,
&Bmask, &Amask); &Bmask, &Amask);
SDL_Log(" Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n", SDL_Log(" Current mode: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
mode.w, mode.h, mode.refresh_rate, bpp, mode.w, mode.h, mode.refresh_rate, bpp,
@ -1165,7 +1165,7 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_Log(" Fullscreen video modes:\n"); SDL_Log(" Fullscreen video modes:\n");
for (j = 0; j < m; ++j) { for (j = 0; j < m; ++j) {
SDL_GetDisplayMode(i, j, &mode); SDL_GetDisplayMode(i, j, &mode);
SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, SDL_GetMasksForPixelFormatEnum(mode.format, &bpp, &Rmask,
&Gmask, &Bmask, &Amask); &Gmask, &Bmask, &Amask);
SDL_Log(" Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n", SDL_Log(" Mode %d: %dx%d@%dHz, %d bits-per-pixel (%s)\n",
j, mode.w, mode.h, mode.refresh_rate, bpp, j, mode.w, mode.h, mode.refresh_rate, bpp,

View File

@ -428,7 +428,7 @@ SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
Uint32 format; Uint32 format;
/* Get the pixel format */ /* Get the pixel format */
format = SDL_MasksToPixelFormatEnum(biBitCount, Rmask, Gmask, Bmask, Amask); format = SDL_GetPixelFormatEnumForMasks(biBitCount, Rmask, Gmask, Bmask, Amask);
surface = SDL_CreateSurface(biWidth, biHeight, format); surface = SDL_CreateSurface(biWidth, biHeight, format);
if (surface == NULL) { if (surface == NULL) {

View File

@ -135,7 +135,7 @@ SDL_GetPixelFormatName(Uint32 format)
#undef CASE #undef CASE
SDL_bool SDL_bool
SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask, SDL_GetMasksForPixelFormatEnum(Uint32 format, int *bpp, Uint32 *Rmask,
Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask) Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask)
{ {
Uint32 masks[4]; Uint32 masks[4];
@ -302,7 +302,7 @@ SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 *Rmask,
} }
Uint32 Uint32
SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, SDL_GetPixelFormatEnumForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
Uint32 Amask) Uint32 Amask)
{ {
switch (bpp) { switch (bpp) {
@ -512,7 +512,7 @@ static SDL_PixelFormat *formats;
static SDL_SpinLock formats_lock = 0; static SDL_SpinLock formats_lock = 0;
SDL_PixelFormat * SDL_PixelFormat *
SDL_AllocFormat(Uint32 pixel_format) SDL_CreatePixelFormat(Uint32 pixel_format)
{ {
SDL_PixelFormat *format; SDL_PixelFormat *format;
@ -557,7 +557,7 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
Uint32 Rmask, Gmask, Bmask, Amask; Uint32 Rmask, Gmask, Bmask, Amask;
Uint32 mask; Uint32 mask;
if (!SDL_PixelFormatEnumToMasks(pixel_format, &bpp, if (!SDL_GetMasksForPixelFormatEnum(pixel_format, &bpp,
&Rmask, &Gmask, &Bmask, &Amask)) { &Rmask, &Gmask, &Bmask, &Amask)) {
return -1; return -1;
} }
@ -623,7 +623,7 @@ int SDL_InitFormat(SDL_PixelFormat *format, Uint32 pixel_format)
return 0; return 0;
} }
void SDL_FreeFormat(SDL_PixelFormat *format) void SDL_DestroyPixelFormat(SDL_PixelFormat *format)
{ {
SDL_PixelFormat *prev; SDL_PixelFormat *prev;
@ -654,13 +654,13 @@ void SDL_FreeFormat(SDL_PixelFormat *format)
SDL_AtomicUnlock(&formats_lock); SDL_AtomicUnlock(&formats_lock);
if (format->palette) { if (format->palette) {
SDL_FreePalette(format->palette); SDL_DestroyPalette(format->palette);
} }
SDL_free(format); SDL_free(format);
} }
SDL_Palette * SDL_Palette *
SDL_AllocPalette(int ncolors) SDL_CreatePalette(int ncolors)
{ {
SDL_Palette *palette; SDL_Palette *palette;
@ -706,7 +706,7 @@ int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
} }
if (format->palette) { if (format->palette) {
SDL_FreePalette(format->palette); SDL_DestroyPalette(format->palette);
} }
format->palette = palette; format->palette = palette;
@ -744,7 +744,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
return status; return status;
} }
void SDL_FreePalette(SDL_Palette *palette) void SDL_DestroyPalette(SDL_Palette *palette)
{ {
if (palette == NULL) { if (palette == NULL) {
SDL_InvalidParamError("palette"); SDL_InvalidParamError("palette");

View File

@ -114,7 +114,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
return NULL; return NULL;
} }
surface->format = SDL_AllocFormat(format); surface->format = SDL_CreatePixelFormat(format);
if (!surface->format) { if (!surface->format) {
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
return NULL; return NULL;
@ -126,7 +126,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
SDL_Palette *palette = SDL_Palette *palette =
SDL_AllocPalette((1 << surface->format->BitsPerPixel)); SDL_CreatePalette((1 << surface->format->BitsPerPixel));
if (palette == NULL) { if (palette == NULL) {
SDL_FreeSurface(surface); SDL_FreeSurface(surface);
return NULL; return NULL;
@ -141,7 +141,7 @@ SDL_CreateSurface(int width, int height, Uint32 format)
palette->colors[1].b = 0x00; palette->colors[1].b = 0x00;
} }
SDL_SetSurfacePalette(surface, palette); SDL_SetSurfacePalette(surface, palette);
SDL_FreePalette(palette); SDL_DestroyPalette(palette);
} }
/* Get the pixels */ /* Get the pixels */
@ -1333,10 +1333,10 @@ SDL_ConvertSurfaceFormat(SDL_Surface *surface, Uint32 pixel_format)
SDL_PixelFormat *fmt; SDL_PixelFormat *fmt;
SDL_Surface *convert = NULL; SDL_Surface *convert = NULL;
fmt = SDL_AllocFormat(pixel_format); fmt = SDL_CreatePixelFormat(pixel_format);
if (fmt) { if (fmt) {
convert = SDL_ConvertSurface(surface, fmt); convert = SDL_ConvertSurface(surface, fmt);
SDL_FreeFormat(fmt); SDL_DestroyPixelFormat(fmt);
} }
return convert; return convert;
} }
@ -1546,7 +1546,7 @@ void SDL_FreeSurface(SDL_Surface *surface)
#endif #endif
if (surface->format) { if (surface->format) {
SDL_SetSurfacePalette(surface, NULL); SDL_SetSurfacePalette(surface, NULL);
SDL_FreeFormat(surface->format); SDL_DestroyPixelFormat(surface->format);
surface->format = NULL; surface->format = NULL;
} }
if (surface->flags & SDL_PREALLOC) { if (surface->flags & SDL_PREALLOC) {

View File

@ -63,7 +63,7 @@ int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void
bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount; bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount;
masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize); masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize);
*format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0); *format = SDL_GetPixelFormatEnumForMasks(bpp, masks[0], masks[1], masks[2], 0);
} }
if (*format == SDL_PIXELFORMAT_UNKNOWN) { if (*format == SDL_PIXELFORMAT_UNKNOWN) {
/* We'll use RGB format for now */ /* We'll use RGB format for now */

View File

@ -116,7 +116,7 @@ X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo)
} }
} }
return SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); return SDL_GetPixelFormatEnumForMasks(bpp, Rmask, Gmask, Bmask, Amask);
} }
if (vinfo->class == PseudoColor || vinfo->class == StaticColor) { if (vinfo->class == PseudoColor || vinfo->class == StaticColor) {

View File

@ -110,10 +110,10 @@ const char *_invalidPixelFormatsVerbose[] = {
/* Test case functions */ /* Test case functions */
/** /**
* @brief Call to SDL_AllocFormat and SDL_FreeFormat * @brief Call to SDL_CreatePixelFormat and SDL_DestroyPixelFormat
* *
* @sa http://wiki.libsdl.org/SDL_AllocFormat * @sa http://wiki.libsdl.org/SDL_CreatePixelFormat
* @sa http://wiki.libsdl.org/SDL_FreeFormat * @sa http://wiki.libsdl.org/SDL_DestroyPixelFormat
*/ */
int pixels_allocFreeFormat(void *arg) int pixels_allocFreeFormat(void *arg)
{ {
@ -130,8 +130,8 @@ int pixels_allocFreeFormat(void *arg)
SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format); SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", unknownFormat, format);
/* Allocate format */ /* Allocate format */
result = SDL_AllocFormat(format); result = SDL_CreatePixelFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()"); SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
@ -141,8 +141,8 @@ int pixels_allocFreeFormat(void *arg)
SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks); SDLTest_AssertCheck(masks == 0, "Verify value of result.[RGBA]mask combined; expected: 0, got %" SDL_PRIu32, masks);
/* Deallocate again */ /* Deallocate again */
SDL_FreeFormat(result); SDL_DestroyPixelFormat(result);
SDLTest_AssertPass("Call to SDL_FreeFormat()"); SDLTest_AssertPass("Call to SDL_DestroyPixelFormat()");
} }
/* RGB formats */ /* RGB formats */
@ -151,8 +151,8 @@ int pixels_allocFreeFormat(void *arg)
SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format); SDLTest_Log("RGB Format: %s (%" SDL_PRIu32 ")", _RGBPixelFormatsVerbose[i], format);
/* Allocate format */ /* Allocate format */
result = SDL_AllocFormat(format); result = SDL_CreatePixelFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()"); SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format); SDLTest_AssertCheck(result->format == format, "Verify value of result.format; expected: %" SDL_PRIu32 ", got %" SDL_PRIu32, format, result->format);
@ -164,8 +164,8 @@ int pixels_allocFreeFormat(void *arg)
} }
/* Deallocate again */ /* Deallocate again */
SDL_FreeFormat(result); SDL_DestroyPixelFormat(result);
SDLTest_AssertPass("Call to SDL_FreeFormat()"); SDLTest_AssertPass("Call to SDL_DestroyPixelFormat()");
} }
} }
@ -175,8 +175,8 @@ int pixels_allocFreeFormat(void *arg)
SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format); SDLTest_Log("non-RGB Format: %s (%" SDL_PRIu32 ")", _nonRGBPixelFormatsVerbose[i], format);
/* Try to allocate format */ /* Try to allocate format */
result = SDL_AllocFormat(format); result = SDL_CreatePixelFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat()"); SDLTest_AssertPass("Call to SDL_CreatePixelFormat()");
SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
} }
@ -187,8 +187,8 @@ int pixels_allocFreeFormat(void *arg)
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
format = _invalidPixelFormats[i]; format = _invalidPixelFormats[i];
result = SDL_AllocFormat(format); result = SDL_CreatePixelFormat(format);
SDLTest_AssertPass("Call to SDL_AllocFormat(%" SDL_PRIu32 ")", format); SDLTest_AssertPass("Call to SDL_CreatePixelFormat(%" SDL_PRIu32 ")", format);
SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");
@ -202,8 +202,8 @@ int pixels_allocFreeFormat(void *arg)
/* Invalid free pointer */ /* Invalid free pointer */
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
SDL_FreeFormat(NULL); SDL_DestroyPixelFormat(NULL);
SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)"); SDLTest_AssertPass("Call to SDL_DestroyPixelFormat(NULL)");
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
@ -299,10 +299,10 @@ int pixels_getPixelFormatName(void *arg)
} }
/** /**
* @brief Call to SDL_AllocPalette and SDL_FreePalette * @brief Call to SDL_CreatePalette and SDL_DestroyPalette
* *
* @sa http://wiki.libsdl.org/SDL_AllocPalette * @sa http://wiki.libsdl.org/SDL_CreatePalette
* @sa http://wiki.libsdl.org/SDL_FreePalette * @sa http://wiki.libsdl.org/SDL_DestroyPalette
*/ */
int pixels_allocFreePalette(void *arg) int pixels_allocFreePalette(void *arg)
{ {
@ -332,8 +332,8 @@ int pixels_allocFreePalette(void *arg)
break; break;
} }
result = SDL_AllocPalette(ncolors); result = SDL_CreatePalette(ncolors);
SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); SDLTest_AssertPass("Call to SDL_CreatePalette(%d)", ncolors);
SDLTest_AssertCheck(result != NULL, "Verify result is not NULL"); SDLTest_AssertCheck(result != NULL, "Verify result is not NULL");
if (result != NULL) { if (result != NULL) {
SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors); SDLTest_AssertCheck(result->ncolors == ncolors, "Verify value of result.ncolors; expected: %u, got %u", ncolors, result->ncolors);
@ -349,8 +349,8 @@ int pixels_allocFreePalette(void *arg)
} }
/* Deallocate again */ /* Deallocate again */
SDL_FreePalette(result); SDL_DestroyPalette(result);
SDLTest_AssertPass("Call to SDL_FreePalette()"); SDLTest_AssertPass("Call to SDL_DestroyPalette()");
} }
} }
@ -360,8 +360,8 @@ int pixels_allocFreePalette(void *arg)
for (ncolors = 0; ncolors > -3; ncolors--) { for (ncolors = 0; ncolors > -3; ncolors--) {
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
result = SDL_AllocPalette(ncolors); result = SDL_CreatePalette(ncolors);
SDLTest_AssertPass("Call to SDL_AllocPalette(%d)", ncolors); SDLTest_AssertPass("Call to SDL_CreatePalette(%d)", ncolors);
SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); SDLTest_AssertCheck(result == NULL, "Verify result is NULL");
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");
@ -375,8 +375,8 @@ int pixels_allocFreePalette(void *arg)
/* Invalid free pointer */ /* Invalid free pointer */
SDL_ClearError(); SDL_ClearError();
SDLTest_AssertPass("Call to SDL_ClearError()"); SDLTest_AssertPass("Call to SDL_ClearError()");
SDL_FreePalette(NULL); SDL_DestroyPalette(NULL);
SDLTest_AssertPass("Call to SDL_FreePalette(NULL)"); SDLTest_AssertPass("Call to SDL_DestroyPalette(NULL)");
error = SDL_GetError(); error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
@ -392,11 +392,11 @@ int pixels_allocFreePalette(void *arg)
/* Pixels test cases */ /* Pixels test cases */
static const SDLTest_TestCaseReference pixelsTest1 = { static const SDLTest_TestCaseReference pixelsTest1 = {
(SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_AllocFormat and SDL_FreeFormat", TEST_ENABLED (SDLTest_TestCaseFp)pixels_allocFreeFormat, "pixels_allocFreeFormat", "Call to SDL_CreatePixelFormat and SDL_DestroyPixelFormat", TEST_ENABLED
}; };
static const SDLTest_TestCaseReference pixelsTest2 = { static const SDLTest_TestCaseReference pixelsTest2 = {
(SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_AllocPalette and SDL_FreePalette", TEST_ENABLED (SDLTest_TestCaseFp)pixels_allocFreePalette, "pixels_allocFreePalette", "Call to SDL_CreatePalette and SDL_DestroyPalette", TEST_ENABLED
}; };
static const SDLTest_TestCaseReference pixelsTest3 = { static const SDLTest_TestCaseReference pixelsTest3 = {

View File

@ -352,12 +352,12 @@ int surface_testCompleteSurfaceConversion(void *arg)
for (i = 0; i < SDL_arraysize(pixel_formats); ++i) { for (i = 0; i < SDL_arraysize(pixel_formats); ++i) {
for (j = 0; j < SDL_arraysize(pixel_formats); ++j) { for (j = 0; j < SDL_arraysize(pixel_formats); ++j) {
fmt1 = SDL_AllocFormat(pixel_formats[i]); fmt1 = SDL_CreatePixelFormat(pixel_formats[i]);
SDL_assert(fmt1 != NULL); SDL_assert(fmt1 != NULL);
cvt1 = SDL_ConvertSurface(face, fmt1); cvt1 = SDL_ConvertSurface(face, fmt1);
SDL_assert(cvt1 != NULL); SDL_assert(cvt1 != NULL);
fmt2 = SDL_AllocFormat(pixel_formats[j]); fmt2 = SDL_CreatePixelFormat(pixel_formats[j]);
SDL_assert(fmt1 != NULL); SDL_assert(fmt1 != NULL);
cvt2 = SDL_ConvertSurface(cvt1, fmt2); cvt2 = SDL_ConvertSurface(cvt1, fmt2);
SDL_assert(cvt2 != NULL); SDL_assert(cvt2 != NULL);
@ -376,9 +376,9 @@ int surface_testCompleteSurfaceConversion(void *arg)
} }
SDL_FreeSurface(cvt1); SDL_FreeSurface(cvt1);
SDL_FreeFormat(fmt1); SDL_DestroyPixelFormat(fmt1);
SDL_FreeSurface(cvt2); SDL_FreeSurface(cvt2);
SDL_FreeFormat(fmt2); SDL_DestroyPixelFormat(fmt2);
} }
} }