SDL API renaming: SDL_pixels.h

Fixes https://github.com/libsdl-org/SDL/issues/6886
This commit is contained in:
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

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

View File

@@ -263,14 +263,14 @@
#define SDL_CondWait SDL_CondWait_REAL
#define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL
#define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL
#define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_REAL
#define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_REAL
#define SDL_AllocFormat SDL_AllocFormat_REAL
#define SDL_FreeFormat SDL_FreeFormat_REAL
#define SDL_AllocPalette SDL_AllocPalette_REAL
#define SDL_GetMasksForPixelFormatEnum SDL_GetMasksForPixelFormatEnum_REAL
#define SDL_GetPixelFormatEnumForMasks SDL_GetPixelFormatEnumForMasks_REAL
#define SDL_CreatePixelFormat SDL_CreatePixelFormat_REAL
#define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
#define SDL_CreatePalette SDL_CreatePalette_REAL
#define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_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_MapRGBA SDL_MapRGBA_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_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(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(Uint32,SDL_MasksToPixelFormatEnum,(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(void,SDL_FreeFormat,(SDL_PixelFormat *a),(a),)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_AllocPalette,(int a),(a),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_GetPixelFormatEnumForMasks,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
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_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_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),)

View File

@@ -1436,13 +1436,13 @@ SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface)
SDL_Surface *temp = NULL;
/* Set up a destination surface for the texture update */
dst_fmt = SDL_AllocFormat(format);
dst_fmt = SDL_CreatePixelFormat(format);
if (dst_fmt == NULL) {
SDL_DestroyTexture(texture);
return NULL;
}
temp = SDL_ConvertSurface(surface, dst_fmt);
SDL_FreeFormat(dst_fmt);
SDL_DestroyPixelFormat(dst_fmt);
if (temp) {
SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch);
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.
*/
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->Gmask,
src_rotated->format->Bmask,

View File

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

View File

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

View File

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