update sdl to 2.32.6

This commit is contained in:
AzaezelX 2025-05-24 13:39:03 -05:00
parent e557f5962b
commit ddc1f8c1e2
1339 changed files with 53966 additions and 19207 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -29,7 +29,7 @@
#ifdef HAVE_SDL_TTF
#ifdef __MACOSX__
#define DEFAULT_FONT "/System/Library/Fonts/华文细黑.ttf"
#elif __WIN32__
#elif defined(__WIN32__)
/* Some japanese font present on at least Windows 8.1. */
#define DEFAULT_FONT "C:\\Windows\\Fonts\\yugothic.ttf"
#else
@ -97,7 +97,7 @@ static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np)
}
n = (n << 4) | c;
}
if (np != NULL) {
if (np) {
*np = n;
}
return 1;
@ -116,7 +116,7 @@ static int unifont_init(const char *fontname)
/* Allocate memory for the glyph data so the file can be closed after initialization. */
unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize);
if (unifontGlyph == NULL) {
if (!unifontGlyph) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024);
return -1;
}
@ -124,20 +124,20 @@ static int unifont_init(const char *fontname)
/* Allocate memory for texture pointers for all renderers. */
unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize);
if (unifontTexture == NULL) {
if (!unifontTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024);
return -1;
}
SDL_memset(unifontTexture, 0, unifontTextureSize);
filename = GetResourceFilename(NULL, fontname);
if (filename == NULL) {
if (!filename) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n");
return -1;
}
hexFile = SDL_RWFromFile(filename, "rb");
SDL_free(filename);
if (hexFile == NULL) {
if (!hexFile) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname);
return -1;
}
@ -269,7 +269,7 @@ static int unifont_load_texture(Uint32 textureID)
}
textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE);
if (textureRGBA == NULL) {
if (!textureRGBA) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024);
return -1;
}
@ -324,7 +324,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
}
}
texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID];
if (texture != NULL) {
if (texture) {
const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE;
srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16;
srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16;
@ -333,17 +333,17 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst
return unifontGlyph[codepoint].width;
}
static void unifont_cleanup()
static void unifont_cleanup(void)
{
int i, j;
for (i = 0; i < state->num_windows; ++i) {
SDL_Renderer *renderer = state->renderers[i];
if (state->windows[i] == NULL || renderer == NULL) {
if (state->windows[i] == NULL || !renderer) {
continue;
}
for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) {
SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j];
if (tex != NULL) {
if (tex) {
SDL_DestroyTexture(tex);
}
}
@ -425,12 +425,12 @@ Uint32 utf8_decode(char *p, size_t len)
return codepoint;
}
void usage()
void usage(void)
{
SDL_Log("usage: testime [--font fontfile]\n");
}
void InitInput()
void InitInput(void)
{
/* Prepare a rect for text input */
textRect.x = textRect.y = 100;
@ -444,7 +444,7 @@ void InitInput()
SDL_StartTextInput();
}
void CleanupVideo()
void CleanupVideo(void)
{
SDL_StopTextInput();
#ifdef HAVE_SDL_TTF
@ -530,7 +530,7 @@ void _Redraw(int rendererID)
if (cursor) {
char *p = utf8_advance(markedText, cursor);
char c = 0;
if (p == NULL) {
if (!p) {
p = &markedText[SDL_strlen(markedText)];
}
@ -597,7 +597,7 @@ void _Redraw(int rendererID)
SDL_SetTextInputRect(&markedRect);
}
void Redraw()
void Redraw(void)
{
int i;
for (i = 0; i < state->num_windows; ++i) {
@ -626,7 +626,7 @@ int main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if (state == NULL) {
if (!state) {
return 1;
}
for (i = 1; i < argc; i++) {
@ -660,7 +660,7 @@ int main(int argc, char *argv[])
TTF_Init();
font = TTF_OpenFont(fontname, DEFAULT_PTSIZE);
if (font == NULL) {
if (!font) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError());
return -1;
}