Skip to content

Commit

Permalink
Updated to the latest version of SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Sep 18, 2024
1 parent b56e6c4 commit 5b4a3e2
Show file tree
Hide file tree
Showing 26 changed files with 425 additions and 425 deletions.
4 changes: 2 additions & 2 deletions examples/showimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main(int argc, char *argv[])
goto done;
}

if (SDL_GetBooleanProperty(SDL_GetDisplayProperties(SDL_GetPrimaryDisplay()), SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, SDL_FALSE)) {
if (SDL_GetBooleanProperty(SDL_GetDisplayProperties(SDL_GetPrimaryDisplay()), SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, false)) {
SDL_PropertiesID props = SDL_CreateProperties();

SDL_SetPointerProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window);
Expand Down Expand Up @@ -173,7 +173,7 @@ int main(int argc, char *argv[])
SDL_Surface *surface = IMG_Load(argv[i]);
if (surface) {
const char *ext = SDL_strrchr(saveFile, '.');
SDL_bool saved = SDL_FALSE;
bool saved = false;
if (ext && SDL_strcasecmp(ext, ".avif") == 0) {
saved = IMG_SaveAVIF(surface, saveFile, 90);
} else if (ext && SDL_strcasecmp(ext, ".bmp") == 0) {
Expand Down
2 changes: 1 addition & 1 deletion external/SDL
Submodule SDL updated 272 files
114 changes: 57 additions & 57 deletions include/SDL3_image/SDL_image.h

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions src/IMG.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_IMAGE_MICRO_VERSION_max, SDL_IMAGE_MICRO_VERSION <=
/* Table of image detection and loading functions */
static struct {
const char *type;
SDL_bool (SDLCALL *is)(SDL_IOStream *src);
bool (SDLCALL *is)(SDL_IOStream *src);
SDL_Surface *(SDLCALL *load)(SDL_IOStream *src);
} supported[] = {
/* keep magicless formats first */
Expand Down Expand Up @@ -76,7 +76,7 @@ static struct {
/* Table of animation detection and loading functions */
static struct {
const char *type;
SDL_bool (SDLCALL *is)(SDL_IOStream *src);
bool (SDLCALL *is)(SDL_IOStream *src);
IMG_Animation *(SDLCALL *load)(SDL_IOStream *src);
} supported_anims[] = {
/* keep magicless formats first */
Expand Down Expand Up @@ -182,18 +182,18 @@ SDL_Surface *IMG_Load(const char *file)
/* The error message has been set in SDL_IOFromFile */
return NULL;
}
return IMG_LoadTyped_IO(src, SDL_TRUE, ext);
return IMG_LoadTyped_IO(src, true, ext);
}
#endif

/* Load an image from an SDL datasource (for compatibility) */
SDL_Surface *IMG_Load_IO(SDL_IOStream *src, SDL_bool closeio)
SDL_Surface *IMG_Load_IO(SDL_IOStream *src, bool closeio)
{
return IMG_LoadTyped_IO(src, closeio, NULL);
}

/* Load an image from an SDL datasource, optionally specifying the type */
SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type)
SDL_Surface *IMG_LoadTyped_IO(SDL_IOStream *src, bool closeio, const char *type)
{
size_t i;
SDL_Surface *image;
Expand Down Expand Up @@ -276,7 +276,7 @@ SDL_Texture *IMG_LoadTexture(SDL_Renderer *renderer, const char *file)
return texture;
}

SDL_Texture *IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio)
SDL_Texture *IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, bool closeio)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_Load_IO(src, closeio);
Expand All @@ -287,7 +287,7 @@ SDL_Texture *IMG_LoadTexture_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_b
return texture;
}

SDL_Texture *IMG_LoadTextureTyped_IO(SDL_Renderer *renderer, SDL_IOStream *src, SDL_bool closeio, const char *type)
SDL_Texture *IMG_LoadTextureTyped_IO(SDL_Renderer *renderer, SDL_IOStream *src, bool closeio, const char *type)
{
SDL_Texture *texture = NULL;
SDL_Surface *surface = IMG_LoadTyped_IO(src, closeio, type);
Expand All @@ -311,17 +311,17 @@ IMG_Animation *IMG_LoadAnimation(const char *file)
/* The error message has been set in SDL_IOFromFile */
return NULL;
}
return IMG_LoadAnimationTyped_IO(src, SDL_TRUE, ext);
return IMG_LoadAnimationTyped_IO(src, true, ext);
}

/* Load an animation from an SDL datasource (for compatibility) */
IMG_Animation *IMG_LoadAnimation_IO(SDL_IOStream *src, SDL_bool closeio)
IMG_Animation *IMG_LoadAnimation_IO(SDL_IOStream *src, bool closeio)
{
return IMG_LoadAnimationTyped_IO(src, closeio, NULL);
}

/* Load an animation from an SDL datasource, optionally specifying the type */
IMG_Animation *IMG_LoadAnimationTyped_IO(SDL_IOStream *src, SDL_bool closeio, const char *type)
IMG_Animation *IMG_LoadAnimationTyped_IO(SDL_IOStream *src, bool closeio, const char *type)
{
size_t i;
IMG_Animation *anim;
Expand Down
22 changes: 11 additions & 11 deletions src/IMG_ImageIO.m
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ void IMG_QuitTIF(void)
{
}

static SDL_bool Internal_isType (SDL_IOStream *rw_ops, CFStringRef uti_string_to_test)
static bool Internal_isType (SDL_IOStream *rw_ops, CFStringRef uti_string_to_test)
{
SDL_bool is_type = SDL_FALSE;
bool is_type = false;

if (rw_ops == NULL) {
return SDL_FALSE;
return false;
}

Sint64 start = SDL_TellIO(rw_ops);
Expand Down Expand Up @@ -433,33 +433,33 @@ static SDL_bool Internal_isType (SDL_IOStream *rw_ops, CFStringRef uti_string_to

#ifdef BMP_USES_IMAGEIO

SDL_bool IMG_isCUR(SDL_IOStream *src)
bool IMG_isCUR(SDL_IOStream *src)
{
/* FIXME: Is this a supported type? */
return Internal_isType(src, CFSTR("com.microsoft.cur"));
}

SDL_bool IMG_isICO(SDL_IOStream *src)
bool IMG_isICO(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypeICO);
}

SDL_bool IMG_isBMP(SDL_IOStream *src)
bool IMG_isBMP(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypeBMP);
}

#endif /* BMP_USES_IMAGEIO */

SDL_bool IMG_isGIF(SDL_IOStream *src)
bool IMG_isGIF(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypeGIF);
}

#ifdef JPG_USES_IMAGEIO

// Note: JPEG 2000 is kUTTypeJPEG2000
SDL_bool IMG_isJPG(SDL_IOStream *src)
bool IMG_isJPG(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypeJPEG);
}
Expand All @@ -468,20 +468,20 @@ SDL_bool IMG_isJPG(SDL_IOStream *src)

#ifdef PNG_USES_IMAGEIO

SDL_bool IMG_isPNG(SDL_IOStream *src)
bool IMG_isPNG(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypePNG);
}

#endif /* PNG_USES_IMAGEIO */

// This isn't a public API function. Apple seems to be able to identify tga's.
SDL_bool IMG_isTGA(SDL_IOStream *src)
bool IMG_isTGA(SDL_IOStream *src)
{
return Internal_isType(src, CFSTR("com.truevision.tga-image"));
}

SDL_bool IMG_isTIF(SDL_IOStream *src)
bool IMG_isTIF(SDL_IOStream *src)
{
return Internal_isType(src, kUTTypeTIFF);
}
Expand Down
46 changes: 23 additions & 23 deletions src/IMG_WIC.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,56 +84,56 @@ void IMG_QuitTIF(void)
WIC_Quit();
}

SDL_bool IMG_isPNG(SDL_IOStream *src)
bool IMG_isPNG(SDL_IOStream *src)
{
Sint64 start;
SDL_bool is_PNG;
bool is_PNG;
Uint8 magic[4];

if (!src) {
return SDL_FALSE;
return false;
}

start = SDL_TellIO(src);
is_PNG = SDL_FALSE;
is_PNG = false;
if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) {
if ( magic[0] == 0x89 &&
magic[1] == 'P' &&
magic[2] == 'N' &&
magic[3] == 'G' ) {
is_PNG = SDL_TRUE;
is_PNG = true;
}
}
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
return is_PNG;
}

SDL_bool IMG_isJPG(SDL_IOStream *src)
bool IMG_isJPG(SDL_IOStream *src)
{
Sint64 start;
SDL_bool is_JPG;
SDL_bool in_scan;
bool is_JPG;
bool in_scan;
Uint8 magic[4];

/* This detection code is by Steaphan Greene <[email protected]> */
/* Blame me, not Sam, if this doesn't work right. */
/* And don't forget to report the problem to the the sdl list too! */

if (!src) {
return SDL_FALSE;
return false;
}

start = SDL_TellIO(src);
is_JPG = SDL_FALSE;
in_scan = SDL_FALSE;
is_JPG = false;
in_scan = false;
if (SDL_ReadIO(src, magic, 2) == 2) {
if ( (magic[0] == 0xFF) && (magic[1] == 0xD8) ) {
is_JPG = SDL_TRUE;
is_JPG = true;
while (is_JPG) {
if (SDL_ReadIO(src, magic, 2) != 2) {
is_JPG = SDL_FALSE;
is_JPG = false;
} else if ( (magic[0] != 0xFF) && !in_scan ) {
is_JPG = SDL_FALSE;
is_JPG = false;
} else if ( (magic[0] != 0xFF) || (magic[1] == 0xFF) ) {
/* Extra padding in JPEG (legal) */
/* or this is data and we are scanning */
Expand All @@ -146,7 +146,7 @@ SDL_bool IMG_isJPG(SDL_IOStream *src)
} else if ( (magic[1] >= 0xD0) && (magic[1] < 0xD9) ) {
/* These have nothing else */
} else if (SDL_ReadIO(src, magic+2, 2) != 2) {
is_JPG = SDL_FALSE;
is_JPG = false;
} else {
/* Yes, it's big-endian */
Sint64 innerStart;
Expand All @@ -156,7 +156,7 @@ SDL_bool IMG_isJPG(SDL_IOStream *src)
size = (magic[2] << 8) + magic[3];
end = SDL_SeekIO(src, size-2, SDL_IO_SEEK_CUR);
if ( end != innerStart + size - 2 ) {
is_JPG = SDL_FALSE;
is_JPG = false;
}
if ( magic[1] == 0xDA ) {
/* Now comes the actual JPEG meat */
Expand All @@ -165,7 +165,7 @@ SDL_bool IMG_isJPG(SDL_IOStream *src)
break;
#else
/* I'm not convinced. Prove it! */
in_scan = SDL_TRUE;
in_scan = true;
#endif
}
}
Expand All @@ -176,18 +176,18 @@ SDL_bool IMG_isJPG(SDL_IOStream *src)
return is_JPG;
}

SDL_bool IMG_isTIF(SDL_IOStream * src)
bool IMG_isTIF(SDL_IOStream * src)
{
Sint64 start;
SDL_bool is_TIF;
bool is_TIF;
Uint8 magic[4];

if (!src) {
return SDL_FALSE;
return false;
}

start = SDL_TellIO(src);
is_TIF = SDL_FALSE;
is_TIF = false;
if (SDL_ReadIO(src, magic, sizeof(magic)) == sizeof(magic) ) {
if ( (magic[0] == 'I' &&
magic[1] == 'I' &&
Expand All @@ -197,7 +197,7 @@ SDL_bool IMG_isTIF(SDL_IOStream * src)
magic[1] == 'M' &&
magic[2] == 0x00 &&
magic[3] == 0x2a) ) {
is_TIF = SDL_TRUE;
is_TIF = true;
}
}
SDL_SeekIO(src, start, SDL_IO_SEEK_SET);
Expand All @@ -220,7 +220,7 @@ static SDL_Surface* WIC_LoadImage(SDL_IOStream *src)
}

size_t fileSize;
Uint8 *memoryBuffer = (Uint8 *)SDL_LoadFile_IO(src, &fileSize, SDL_FALSE);
Uint8 *memoryBuffer = (Uint8 *)SDL_LoadFile_IO(src, &fileSize, false);
if (!memoryBuffer) {
return NULL;
}
Expand Down
Loading

0 comments on commit 5b4a3e2

Please sign in to comment.