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,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -1024,7 +1024,7 @@ static int RLEAlphaSurface(SDL_Surface *surface)
SDL_PixelFormat *, SDL_PixelFormat *);
dest = surface->map->dst;
if (dest == NULL) {
if (!dest) {
return -1;
}
df = dest->format;
@ -1081,7 +1081,7 @@ static int RLEAlphaSurface(SDL_Surface *surface)
maxsize += sizeof(RLEDestFormat);
rlebuf = (Uint8 *)SDL_malloc(maxsize);
if (rlebuf == NULL) {
if (!rlebuf) {
return SDL_OutOfMemory();
}
{
@ -1227,7 +1227,7 @@ static int RLEAlphaSurface(SDL_Surface *surface)
/* reallocate the buffer to release unused memory */
{
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
if (p == NULL) {
if (!p) {
p = rlebuf;
}
surface->map->data = p;
@ -1300,7 +1300,7 @@ static int RLEColorkeySurface(SDL_Surface *surface)
}
rlebuf = (Uint8 *)SDL_malloc(maxsize);
if (rlebuf == NULL) {
if (!rlebuf) {
return SDL_OutOfMemory();
}
@ -1395,7 +1395,7 @@ static int RLEColorkeySurface(SDL_Surface *surface)
{
/* If SDL_realloc returns NULL, the original block is left intact */
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
if (p == NULL) {
if (!p) {
p = rlebuf;
}
surface->map->data = p;
@ -1492,7 +1492,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface)
}
surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch);
if (surface->pixels == NULL) {
if (!surface->pixels) {
return SDL_FALSE;
}
surface->flags |= SDL_SIMD_ALIGNED;
@ -1558,7 +1558,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode)
/* re-create the original surface */
surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch);
if (surface->pixels == NULL) {
if (!surface->pixels) {
/* Oh crap... */
surface->flags |= SDL_RLEACCEL;
return;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -103,7 +103,7 @@ static int SDLCALL SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
#ifdef __MACOSX__
#include <sys/sysctl.h>
static SDL_bool SDL_UseAltivecPrefetch()
static SDL_bool SDL_UseAltivecPrefetch(void)
{
const char key[] = "hw.l3cachesize";
u_int64_t result = 0;
@ -116,7 +116,7 @@ static SDL_bool SDL_UseAltivecPrefetch()
}
}
#else
static SDL_bool SDL_UseAltivecPrefetch()
static SDL_bool SDL_UseAltivecPrefetch(void)
{
/* Just guess G4 */
return SDL_TRUE;
@ -251,7 +251,7 @@ int SDL_CalculateBlit(SDL_Surface *surface)
}
#endif
#if SDL_HAVE_BLIT_AUTO
if (blit == NULL) {
if (!blit) {
Uint32 src_format = surface->format->format;
Uint32 dst_format = dst->format->format;
@ -262,7 +262,7 @@ int SDL_CalculateBlit(SDL_Surface *surface)
#endif
#ifndef TEST_SLOW_BLIT
if (blit == NULL)
if (!blit)
#endif
{
Uint32 src_format = surface->format->format;
@ -278,7 +278,7 @@ int SDL_CalculateBlit(SDL_Surface *surface)
map->data = blit;
/* Make sure we have a blit function */
if (blit == NULL) {
if (!blit) {
SDL_InvalidateMap(map);
return SDL_SetError("Blit combination not supported");
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -471,6 +471,15 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
#else
#define USE_DUFFS_LOOP
#endif
#define DUFFS_LOOP1(pixel_copy_increment, width) \
{ \
int n; \
for (n = width; n > 0; --n) { \
pixel_copy_increment; \
} \
}
#ifdef USE_DUFFS_LOOP
/* 8-times unrolled loop */
@ -527,8 +536,26 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
} \
}
/* Use the 8-times version of the loop by default */
/* 2-times unrolled loop */
#define DUFFS_LOOP2(pixel_copy_increment, width) \
{ \
int n = (width + 1) / 2; \
switch (width & 1) { \
case 0: \
do { \
pixel_copy_increment; \
SDL_FALLTHROUGH; \
case 1: \
pixel_copy_increment; \
} while (--n > 0); \
} \
}
/* Use the 4-times version of the loop by default */
#define DUFFS_LOOP(pixel_copy_increment, width) \
DUFFS_LOOP4(pixel_copy_increment, width)
/* Use the 8-times version of the loop for simple routines */
#define DUFFS_LOOP_TRIVIAL(pixel_copy_increment, width) \
DUFFS_LOOP8(pixel_copy_increment, width)
/* Special version of Duff's device for even more optimization */
@ -562,20 +589,19 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface);
/* Don't use Duff's device to unroll loops */
#define DUFFS_LOOP(pixel_copy_increment, width) \
{ \
int n; \
for (n = width; n > 0; --n) { \
pixel_copy_increment; \
} \
}
DUFFS_LOOP1(pixel_copy_increment, width)
#define DUFFS_LOOP_TRIVIAL(pixel_copy_increment, width) \
DUFFS_LOOP1(pixel_copy_increment, width)
#define DUFFS_LOOP8(pixel_copy_increment, width) \
DUFFS_LOOP(pixel_copy_increment, width)
DUFFS_LOOP1(pixel_copy_increment, width)
#define DUFFS_LOOP4(pixel_copy_increment, width) \
DUFFS_LOOP(pixel_copy_increment, width)
DUFFS_LOOP1(pixel_copy_increment, width)
#define DUFFS_LOOP2(pixel_copy_increment, width) \
DUFFS_LOOP1(pixel_copy_increment, width)
#define DUFFS_LOOP_124(pixel_copy_increment1, \
pixel_copy_increment2, \
pixel_copy_increment4, width) \
DUFFS_LOOP(pixel_copy_increment1, width)
DUFFS_LOOP1(pixel_copy_increment1, width)
#endif /* USE_DUFFS_LOOP */

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -50,7 +50,7 @@ static void Blit1to1(SDL_BlitInfo *info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
*dst = map[*src];
}
@ -102,7 +102,7 @@ static void Blit1to2(SDL_BlitInfo *info)
#ifdef USE_DUFFS_LOOP
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
*(Uint16 *)dst = map[*src++];
dst += 2;
@ -258,7 +258,7 @@ static void Blit1to4(SDL_BlitInfo *info)
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
*dst++ = map[*src++];
, width);
/* *INDENT-ON* */ /* clang-format on */
@ -299,7 +299,7 @@ static void Blit1to1Key(SDL_BlitInfo *info)
if (palmap) {
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ( *src != ckey ) {
*dst = palmap[*src];
@ -315,7 +315,7 @@ static void Blit1to1Key(SDL_BlitInfo *info)
} else {
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ( *src != ckey ) {
*dst = *src;
@ -347,7 +347,7 @@ static void Blit1to2Key(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ( *src != ckey ) {
*dstp=palmap[*src];
@ -410,7 +410,7 @@ static void Blit1to4Key(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ( *src != ckey ) {
*dstp = palmap[*src];
@ -446,7 +446,7 @@ static void Blit1toNAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
sR = srcpal[*src].r;
sG = srcpal[*src].g;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -47,7 +47,7 @@ static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
dR = dstfmt->palette->colors[*dst].r;
@ -92,7 +92,7 @@ static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
dR = dstfmt->palette->colors[*dst].r;
@ -412,7 +412,7 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info)
#endif /* __MMX__ */
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
void BlitARGBto565PixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride);
static void BlitARGBto565PixelAlphaARMSIMD(SDL_BlitInfo *info)
@ -442,7 +442,7 @@ static void BlitRGBtoRGBPixelAlphaARMSIMD(SDL_BlitInfo *info)
}
#endif
#if SDL_ARM_NEON_BLITTERS
#ifdef SDL_ARM_NEON_BLITTERS
void BlitARGBto565PixelAlphaARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride);
static void BlitARGBto565PixelAlphaARMNEON(SDL_BlitInfo *info)
@ -484,7 +484,7 @@ static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
Uint32 s = *srcp++;
Uint32 d = *dstp;
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
@ -516,7 +516,7 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
s = *srcp;
d = *dstp;
s1 = s & 0xff00ff;
@ -1148,7 +1148,7 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
@ -1186,7 +1186,7 @@ static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
@ -1219,13 +1219,12 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
Uint32 s = *srcp;
unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
/* FIXME: Here we special-case opaque alpha since the
/* Here we special-case opaque alpha since the
compositioning used (>>8 instead of /255) doesn't handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
it correctly. */
if (alpha) {
if (alpha == (SDL_ALPHA_OPAQUE >> 3)) {
*dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
@ -1235,8 +1234,7 @@ static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
* convert source and destination to G0RAB65565
* and blend all components at the same time
*/
s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
+ (s >> 3 & 0x1f);
s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) + (s >> 3 & 0x1f);
d = (d | d << 16) & 0x07e0f81f;
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
@ -1264,25 +1262,23 @@ static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4({
DUFFS_LOOP({
unsigned alpha;
Uint32 s = *srcp;
alpha = s >> 27; /* downscale alpha to 5 bits */
/* FIXME: Here we special-case opaque alpha since the
/* Here we special-case opaque alpha since the
compositioning used (>>8 instead of /255) doesn't handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
it correctly. */
if (alpha) {
if (alpha == (SDL_ALPHA_OPAQUE >> 3)) {
*dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f));
} else {
Uint32 d = *dstp;
/*
* convert source and destination to G0RAB65565
* convert source and destination to G0RAB55555
* and blend all components at the same time
*/
s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
+ (s >> 3 & 0x1f);
s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) + (s >> 3 & 0x1f);
d = (d | d << 16) & 0x03e07c1f;
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
@ -1319,7 +1315,7 @@ static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
if (sA) {
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
@ -1357,7 +1353,7 @@ static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if (sA && Pixel != ckey) {
@ -1399,7 +1395,7 @@ static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP4(
DUFFS_LOOP(
{
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
if (sA) {
@ -1427,7 +1423,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
/* Per-pixel alpha blits */
switch (df->BytesPerPixel) {
case 1:
if (df->palette != NULL) {
if (df->palette) {
return BlitNto1PixelAlpha;
} else {
/* RGB332 has no palette ! */
@ -1435,14 +1431,14 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
}
case 2:
#if SDL_ARM_NEON_BLITTERS || SDL_ARM_SIMD_BLITTERS
#if defined(SDL_ARM_NEON_BLITTERS) || defined(SDL_ARM_SIMD_BLITTERS)
if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && df->Gmask == 0x7e0 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
#if SDL_ARM_NEON_BLITTERS
#ifdef SDL_ARM_NEON_BLITTERS
if (SDL_HasNEON()) {
return BlitARGBto565PixelAlphaARMNEON;
}
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
if (SDL_HasARMSIMD()) {
return BlitARGBto565PixelAlphaARMSIMD;
}
@ -1452,7 +1448,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
if (df->Gmask == 0x7e0) {
return BlitARGBto565PixelAlpha;
} else if (df->Gmask == 0x3e0) {
} else if (df->Gmask == 0x3e0 && !df->Amask) {
return BlitARGBto555PixelAlpha;
}
}
@ -1475,12 +1471,12 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
}
#endif /* __MMX__ || __3dNOW__ */
if (sf->Amask == 0xff000000) {
#if SDL_ARM_NEON_BLITTERS
#ifdef SDL_ARM_NEON_BLITTERS
if (SDL_HasNEON()) {
return BlitRGBtoRGBPixelAlphaARMNEON;
}
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
if (SDL_HasARMSIMD()) {
return BlitRGBtoRGBPixelAlphaARMSIMD;
}
@ -1505,7 +1501,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
/* Per-surface alpha blits */
switch (df->BytesPerPixel) {
case 1:
if (df->palette != NULL) {
if (df->palette) {
return BlitNto1SurfaceAlpha;
} else {
/* RGB332 has no palette ! */
@ -1560,7 +1556,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface)
if (sf->Amask == 0) {
if (df->BytesPerPixel == 1) {
if (df->palette != NULL) {
if (df->palette) {
return BlitNto1SurfaceAlphaKey;
} else {
/* RGB332 has no palette ! */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -48,7 +48,7 @@ enum blit_features
BLIT_FEATURE_HAS_ARM_SIMD = 8
};
#if SDL_ALTIVEC_BLITTERS
#ifdef SDL_ALTIVEC_BLITTERS
#ifdef HAVE_ALTIVEC_H
#include <altivec.h>
#endif
@ -903,7 +903,7 @@ static enum blit_features GetBlitFeatures(void)
return features;
}
#if __MWERKS__
#ifdef __MWERKS__
#pragma altivec_model off
#endif
#else
@ -911,7 +911,7 @@ static enum blit_features GetBlitFeatures(void)
#define GetBlitFeatures() ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0) | (SDL_HasARMSIMD() ? BLIT_FEATURE_HAS_ARM_SIMD : 0))
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
void Blit_BGR888_RGB888ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride);
static void Blit_BGR888_RGB888ARMSIMD(SDL_BlitInfo *info)
@ -977,7 +977,7 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info)
dstskip = info->dst_skip;
map = info->table;
if (map == NULL) {
if (!map) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */ /* clang-format off */
@ -1091,7 +1091,7 @@ static void Blit_RGB101010_index8(SDL_BlitInfo *info)
dstskip = info->dst_skip;
map = info->table;
if (map == NULL) {
if (!map) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */ /* clang-format off */
@ -2076,7 +2076,7 @@ static void Blit_RGB555_ARGB1555(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
*dst = *src | mask;
++dst;
@ -2115,7 +2115,7 @@ static void BlitNto1(SDL_BlitInfo *info)
srcfmt = info->src_fmt;
srcbpp = srcfmt->BytesPerPixel;
if (map == NULL) {
if (!map) {
while (height--) {
#ifdef USE_DUFFS_LOOP
/* *INDENT-OFF* */ /* clang-format off */
@ -2200,7 +2200,7 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
*dst = *src | mask;
++dst;
@ -2217,7 +2217,7 @@ static void Blit4to4MaskAlpha(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
*dst = *src & mask;
++dst;
@ -2513,7 +2513,7 @@ static void BlitNto1Key(SDL_BlitInfo *info)
srcbpp = srcfmt->BytesPerPixel;
ckey &= rgbmask;
if (palmap == NULL) {
if (!palmap) {
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
@ -2576,7 +2576,7 @@ static void Blit2to2Key(SDL_BlitInfo *info)
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ( (*srcp & rgbmask) != ckey ) {
*dstp = *srcp;
@ -2622,7 +2622,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift;
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ((*src32 & rgbmask) != ckey) {
*dst32 = *src32 | mask;
@ -2640,7 +2640,7 @@ static void BlitNtoNKey(SDL_BlitInfo *info)
Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ((*src32 & rgbmask) != ckey) {
*dst32 = *src32 & mask;
@ -2897,7 +2897,7 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
Uint32 *dst32 = (Uint32 *)dst;
while (height--) {
/* *INDENT-OFF* */ /* clang-format off */
DUFFS_LOOP(
DUFFS_LOOP_TRIVIAL(
{
if ((*src32 & rgbmask) != ckey) {
*dst32 = *src32;
@ -3221,14 +3221,14 @@ static const struct blit_table normal_blit_1[] = {
};
static const struct blit_table normal_blit_2[] = {
#if SDL_ALTIVEC_BLITTERS
#ifdef SDL_ALTIVEC_BLITTERS
/* has-altivec */
{ 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000,
BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
{ 0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000,
BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
{ 0x00000F00, 0x000000F0, 0x0000000F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF,
BLIT_FEATURE_HAS_ARM_SIMD, Blit_RGB444_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA },
#endif
@ -3288,7 +3288,7 @@ static const struct blit_table normal_blit_3[] = {
};
static const struct blit_table normal_blit_4[] = {
#if SDL_ALTIVEC_BLITTERS
#ifdef SDL_ALTIVEC_BLITTERS
/* has-altivec | dont-use-prefetch */
{ 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000,
BLIT_FEATURE_HAS_ALTIVEC | BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA },
@ -3299,7 +3299,7 @@ static const struct blit_table normal_blit_4[] = {
{ 0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F,
BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB888_RGB565Altivec, NO_ALPHA },
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
{ 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF,
BLIT_FEATURE_HAS_ARM_SIMD, Blit_BGR888_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA },
#endif
@ -3437,7 +3437,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface)
} else if (dstfmt->BytesPerPixel == 1) {
return BlitNto1Key;
} else {
#if SDL_ALTIVEC_BLITTERS
#ifdef SDL_ALTIVEC_BLITTERS
if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) {
return Blit32to32KeyAltivec;
} else

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -54,9 +54,9 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
Uint32 srcR, srcG, srcB, srcA;
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
int srcy, srcx;
Uint32 posy, posx;
int incy, incx;
Uint64 srcy, srcx;
Uint64 posy, posx;
Uint64 incy, incx;
SDL_PixelFormat *src_fmt = info->src_fmt;
SDL_PixelFormat *dst_fmt = info->dst_fmt;
int srcbpp = src_fmt->BytesPerPixel;
@ -69,8 +69,8 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
srcfmt_val = detect_format(src_fmt);
dstfmt_val = detect_format(dst_fmt);
incy = (info->src_h << 16) / info->dst_h;
incx = (info->src_w << 16) / info->dst_w;
incy = ((Uint64)info->src_h << 16) / info->dst_h;
incx = ((Uint64)info->src_w << 16) / info->dst_w;
posy = incy / 2; /* start at the middle of pixel */
while (info->dst_h--) {
@ -106,15 +106,20 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
continue;
}
}
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
dstA = 0xFF;
if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) {
if (FORMAT_HAS_ALPHA(dstfmt_val)) {
DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA);
} else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) {
DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB);
dstA = 0xFF;
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
dstpixel = *((Uint32 *) (dst));
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
}
} else {
/* SDL_PIXELFORMAT_ARGB2101010 */
dstpixel = *((Uint32 *)(dst));
RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA);
/* don't care */
dstR = dstG = dstB = dstA = 0;
}
if (flags & SDL_COPY_MODULATE_COLOR) {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -238,7 +238,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
/* Make sure we are passed a valid data source */
surface = NULL;
was_error = SDL_FALSE;
if (src == NULL) {
if (!src) {
SDL_InvalidParamError("src");
was_error = SDL_TRUE;
goto done;
@ -424,7 +424,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc)
surface =
SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
Bmask, Amask);
if (surface == NULL) {
if (!surface) {
was_error = SDL_TRUE;
goto done;
}
@ -667,7 +667,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
}
#endif /* SAVE_32BIT_BMP */
if (surface->format->palette != NULL && !save32bit) {
if (surface->format->palette && !save32bit) {
if (surface->format->BitsPerPixel == 8) {
intermediate_surface = surface;
} else {
@ -697,7 +697,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst)
SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24);
}
intermediate_surface = SDL_ConvertSurface(surface, &format, 0);
if (intermediate_surface == NULL) {
if (!intermediate_surface) {
SDL_SetError("Couldn't convert image to %d bpp",
format.BitsPerPixel);
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -27,11 +27,11 @@ int SDL_SetClipboardText(const char *text)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
return SDL_SetError("Video subsystem must be initialized to set clipboard text");
}
if (text == NULL) {
if (!text) {
text = "";
}
if (_this->SetClipboardText) {
@ -47,11 +47,11 @@ int SDL_SetPrimarySelectionText(const char *text)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
return SDL_SetError("Video subsystem must be initialized to set primary selection text");
}
if (text == NULL) {
if (!text) {
text = "";
}
if (_this->SetPrimarySelectionText) {
@ -67,7 +67,7 @@ char *SDL_GetClipboardText(void)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
SDL_SetError("Video subsystem must be initialized to get clipboard text");
return SDL_strdup("");
}
@ -76,7 +76,7 @@ char *SDL_GetClipboardText(void)
return _this->GetClipboardText(_this);
} else {
const char *text = _this->clipboard_text;
if (text == NULL) {
if (!text) {
text = "";
}
return SDL_strdup(text);
@ -87,7 +87,7 @@ char *SDL_GetPrimarySelectionText(void)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
SDL_SetError("Video subsystem must be initialized to get primary selection text");
return SDL_strdup("");
}
@ -96,7 +96,7 @@ char *SDL_GetPrimarySelectionText(void)
return _this->GetPrimarySelectionText(_this);
} else {
const char *text = _this->primary_selection_text;
if (text == NULL) {
if (!text) {
text = "";
}
return SDL_strdup(text);
@ -107,7 +107,7 @@ SDL_bool SDL_HasClipboardText(void)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
SDL_SetError("Video subsystem must be initialized to check clipboard text");
return SDL_FALSE;
}
@ -127,7 +127,7 @@ SDL_bool SDL_HasPrimarySelectionText(void)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (_this == NULL) {
if (!_this) {
SDL_SetError("Video subsystem must be initialized to check primary selection text");
return SDL_FALSE;
}

View file

@ -1,6 +1,6 @@
/*
* Simple DirectMedia Layer
* 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
@ -20,16 +20,16 @@
*/
#include "../SDL_internal.h"
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT)
#include "../core/windows/SDL_windows.h"
#endif
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include <android/native_window.h>
#include "../video/android/SDL_androidvideo.h"
#endif
#if SDL_VIDEO_DRIVER_RPI
#ifdef SDL_VIDEO_DRIVER_RPI
#include <unistd.h>
#endif
@ -57,7 +57,7 @@
#define EGL_PRESENT_OPAQUE_EXT 0x31DF
#endif /* EGL_EXT_present_opaque */
#if SDL_VIDEO_DRIVER_RPI
#ifdef SDL_VIDEO_DRIVER_RPI
/* Raspbian places the OpenGL ES/EGL binaries in a non standard path */
#define DEFAULT_EGL (vc4 ? "libEGL.so.1" : "libbrcmEGL.so")
#define DEFAULT_OGL_ES2 (vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so")
@ -66,21 +66,21 @@
#define DEFAULT_OGL_ES_PVR (vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so")
#define DEFAULT_OGL_ES (vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so")
#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
#elif defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_VIVANTE)
/* Android */
#define DEFAULT_EGL "libEGL.so"
#define DEFAULT_OGL_ES2 "libGLESv2.so"
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
#define DEFAULT_OGL_ES "libGLESv1_CM.so"
#elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
#elif defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT)
/* EGL AND OpenGL ES support via ANGLE */
#define DEFAULT_EGL "libEGL.dll"
#define DEFAULT_OGL_ES2 "libGLESv2.dll"
#define DEFAULT_OGL_ES_PVR "libGLES_CM.dll"
#define DEFAULT_OGL_ES "libGLESv1_CM.dll"
#elif SDL_VIDEO_DRIVER_COCOA
#elif defined(SDL_VIDEO_DRIVER_COCOA)
/* EGL AND OpenGL ES support via ANGLE */
#define DEFAULT_EGL "libEGL.dylib"
#define DEFAULT_OGL_ES2 "libGLESv2.dylib"
@ -105,7 +105,7 @@
#define DEFAULT_OGL_ES "libGLESv1_CM.so.1"
#endif /* SDL_VIDEO_DRIVER_RPI */
#if SDL_VIDEO_OPENGL && !SDL_VIDEO_VITA_PVR_OGL
#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_VITA_PVR_OGL)
#include "SDL_opengl.h"
#endif
@ -178,7 +178,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
const char *ext_start;
/* Invalid extensions can be rejected early */
if (ext == NULL || *ext == 0 || SDL_strchr(ext, ' ') != NULL) {
if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) {
/* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */
return SDL_FALSE;
}
@ -191,7 +191,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
* 1 If set, the client extension is masked and not present to SDL.
*/
ext_override = SDL_getenv(ext);
if (ext_override != NULL) {
if (ext_override) {
int disable_ext = SDL_atoi(ext_override);
if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) {
return SDL_FALSE;
@ -217,12 +217,12 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
return SDL_FALSE;
}
if (egl_extstr != NULL) {
if (egl_extstr) {
ext_start = egl_extstr;
while (*ext_start) {
ext_start = SDL_strstr(ext_start, ext);
if (ext_start == NULL) {
if (!ext_start) {
return SDL_FALSE;
}
/* Check if the match is not just a substring of one of the extensions */
@ -245,24 +245,24 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext
void *SDL_EGL_GetProcAddress(_THIS, const char *proc)
{
void *retval = NULL;
if (_this->egl_data != NULL) {
if (_this->egl_data) {
const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor);
const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5);
/* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */
if (retval == NULL && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
retval = _this->egl_data->eglGetProcAddress(proc);
}
#if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */
/* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */
if (retval == NULL) {
if (!retval) {
retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc);
}
#endif
/* Try eglGetProcAddress if we're on <= 1.4 and still searching... */
if (retval == NULL && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) {
retval = _this->egl_data->eglGetProcAddress(proc);
}
}
@ -295,14 +295,14 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
{
void *egl_dll_handle = NULL, *opengl_dll_handle = NULL;
const char *path = NULL;
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT)
const char *d3dcompiler;
#endif
#if SDL_VIDEO_DRIVER_RPI
#ifdef SDL_VIDEO_DRIVER_RPI
SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK));
#endif
#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT
#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT)
d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER);
if (d3dcompiler) {
if (SDL_strcasecmp(d3dcompiler, "none") != 0) {
@ -336,17 +336,17 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
#if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA)
/* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */
path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
if (path != NULL) {
if (path) {
opengl_dll_handle = SDL_LoadObject(path);
}
if (opengl_dll_handle == NULL) {
if (!opengl_dll_handle) {
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
if (_this->gl_config.major_version > 1) {
path = DEFAULT_OGL_ES2;
opengl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_OGL_ES2
if (opengl_dll_handle == NULL && !vc4) {
if (!opengl_dll_handle && !vc4) {
path = ALT_OGL_ES2;
opengl_dll_handle = SDL_LoadObject(path);
}
@ -355,12 +355,12 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
} else {
path = DEFAULT_OGL_ES;
opengl_dll_handle = SDL_LoadObject(path);
if (opengl_dll_handle == NULL) {
if (!opengl_dll_handle) {
path = DEFAULT_OGL_ES_PVR;
opengl_dll_handle = SDL_LoadObject(path);
}
#ifdef ALT_OGL_ES2
if (opengl_dll_handle == NULL && !vc4) {
if (!opengl_dll_handle && !vc4) {
path = ALT_OGL_ES2;
opengl_dll_handle = SDL_LoadObject(path);
}
@ -372,7 +372,7 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
path = DEFAULT_OGL;
opengl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_OGL
if (opengl_dll_handle == NULL) {
if (!opengl_dll_handle) {
path = ALT_OGL;
opengl_dll_handle = SDL_LoadObject(path);
}
@ -382,34 +382,34 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
}
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
if (opengl_dll_handle == NULL) {
if (!opengl_dll_handle) {
return SDL_SetError("Could not initialize OpenGL / GLES library");
}
/* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */
if (egl_path != NULL) {
if (egl_path) {
egl_dll_handle = SDL_LoadObject(egl_path);
}
/* Try loading a EGL symbol, if it does not work try the default library paths */
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle != NULL) {
if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle) {
SDL_UnloadObject(egl_dll_handle);
}
path = SDL_getenv("SDL_VIDEO_EGL_DRIVER");
if (path == NULL) {
if (!path) {
path = DEFAULT_EGL;
}
egl_dll_handle = SDL_LoadObject(path);
#ifdef ALT_EGL
if (egl_dll_handle == NULL && !vc4) {
if (!egl_dll_handle && !vc4) {
path = ALT_EGL;
egl_dll_handle = SDL_LoadObject(path);
}
#endif
if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle != NULL) {
if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) {
if (egl_dll_handle) {
SDL_UnloadObject(egl_dll_handle);
}
return SDL_SetError("Could not load EGL library");
@ -419,7 +419,7 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path)
#endif
_this->egl_data->egl_dll_handle = egl_dll_handle;
#if SDL_VIDEO_DRIVER_VITA
#ifdef SDL_VIDEO_DRIVER_VITA
_this->egl_data->opengl_dll_handle = opengl_dll_handle;
#endif
@ -535,7 +535,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di
}
#endif
/* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */
if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) {
if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay)) {
_this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display);
}
if (_this->egl_data->egl_display == EGL_NO_DISPLAY) {
@ -578,11 +578,11 @@ int SDL_EGL_InitializeOffscreen(_THIS, int device)
}
/* Check for all extensions that are optional until used and fail if any is missing */
if (_this->egl_data->eglQueryDevicesEXT == NULL) {
if (!_this->egl_data->eglQueryDevicesEXT) {
return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)");
}
if (_this->egl_data->eglGetPlatformDisplayEXT == NULL) {
if (!_this->egl_data->eglGetPlatformDisplayEXT) {
return SDL_SetError("eglGetPlatformDisplayEXT is missing (EXT_platform_base not supported by the drivers?)");
}
@ -954,7 +954,7 @@ SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
share_context = (EGLContext)SDL_GL_GetCurrentContext();
}
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
if (_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) {
/* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset.
* This is required because some Android devices like to complain about it
@ -1065,7 +1065,7 @@ SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface)
if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) {
_this->gl_allow_no_surface = SDL_TRUE;
}
#if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA)
#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_DRIVER_VITA)
} else {
/* Desktop OpenGL supports it by default from version 3.0 on. */
void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params);
@ -1179,7 +1179,7 @@ void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context)
EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
{
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
EGLint format_wanted;
EGLint format_got;
#endif
@ -1193,7 +1193,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
return EGL_NO_SURFACE;
}
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
/* On Android, EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is
* guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). */
_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display,
@ -1235,7 +1235,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw)
SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface");
}
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
format_got = ANativeWindow_getFormat(nw);
Android_SetFormat(format_wanted, format_got);
#endif

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -23,7 +23,7 @@
#ifndef SDL_egl_h_
#define SDL_egl_h_
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
#include "SDL_egl.h"
@ -42,7 +42,7 @@ typedef struct SDL_EGL_VideoData
EGLint egl_required_visual_id;
SDL_bool is_offscreen; /* whether EGL display was offscreen */
EGLenum apitype; /* EGL_OPENGL_ES_API, EGL_OPENGL_API, etc */
EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display);
EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform,
void *native_display,
@ -53,21 +53,21 @@ typedef struct SDL_EGL_VideoData
EGLBoolean(EGLAPIENTRY *eglInitialize) (EGLDisplay dpy, EGLint * major,
EGLint * minor);
EGLBoolean(EGLAPIENTRY *eglTerminate) (EGLDisplay dpy);
void *(EGLAPIENTRY *eglGetProcAddress) (const char * procName);
EGLBoolean(EGLAPIENTRY *eglChooseConfig) (EGLDisplay dpy,
const EGLint * attrib_list,
EGLConfig * configs,
EGLint config_size, EGLint * num_config);
EGLContext(EGLAPIENTRY *eglCreateContext) (EGLDisplay dpy,
EGLConfig config,
EGLContext share_list,
const EGLint * attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroyContext) (EGLDisplay dpy, EGLContext ctx);
EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config,
EGLint const* attrib_list);
@ -76,25 +76,25 @@ typedef struct SDL_EGL_VideoData
NativeWindowType window,
const EGLint * attrib_list);
EGLBoolean(EGLAPIENTRY *eglDestroySurface) (EGLDisplay dpy, EGLSurface surface);
EGLBoolean(EGLAPIENTRY *eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw,
EGLSurface read, EGLContext ctx);
EGLBoolean(EGLAPIENTRY *eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw);
EGLBoolean(EGLAPIENTRY *eglSwapInterval) (EGLDisplay dpy, EGLint interval);
const char *(EGLAPIENTRY *eglQueryString) (EGLDisplay dpy, EGLint name);
EGLenum(EGLAPIENTRY *eglQueryAPI)(void);
EGLBoolean(EGLAPIENTRY *eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config,
EGLint attribute, EGLint * value);
EGLBoolean(EGLAPIENTRY *eglWaitNative) (EGLint engine);
EGLBoolean(EGLAPIENTRY *eglWaitGL)(void);
EGLBoolean(EGLAPIENTRY *eglBindAPI)(EGLenum);
EGLint(EGLAPIENTRY *eglGetError)(void);
@ -109,7 +109,7 @@ typedef struct SDL_EGL_VideoData
EGLBoolean(EGLAPIENTRY *eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync);
EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync);
EGLint(EGLAPIENTRY *eglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -63,6 +63,13 @@ static void SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w
Uint8 *p = NULL; \
\
SSE_BEGIN; \
\
/* If the number of bytes per row is equal to the pitch, treat */ \
/* all rows as one long continuous row (for better performance) */ \
if ((w) * (bpp) == pitch) { \
w = w * h; \
h = 1; \
} \
\
while (h--) { \
n = w * bpp; \
@ -233,12 +240,12 @@ static void SDL_FillRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
*/
int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
{
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("SDL_FillRect(): dst");
}
/* If 'rect' == NULL, then fill the whole surface */
if (rect == NULL) {
if (!rect) {
rect = &dst->clip_rect;
/* Don't attempt to fill if the surface's clip_rect is empty */
if (SDL_RectEmpty(rect)) {
@ -249,7 +256,7 @@ int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color)
return SDL_FillRects(dst, rect, 1, color);
}
#if SDL_ARM_NEON_BLITTERS
#ifdef SDL_ARM_NEON_BLITTERS
void FillRect8ARMNEONAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, uint8_t src);
void FillRect16ARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src);
void FillRect32ARMNEONAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src);
@ -273,7 +280,7 @@ static void fill_32_neon(Uint8 *pixels, int pitch, Uint32 color, int w, int h)
}
#endif
#if SDL_ARM_SIMD_BLITTERS
#ifdef SDL_ARM_SIMD_BLITTERS
void FillRect8ARMSIMDAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, uint8_t src);
void FillRect16ARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src);
void FillRect32ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src);
@ -306,7 +313,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL;
int i;
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("SDL_FillRects(): dst");
}
@ -320,7 +327,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
return SDL_SetError("SDL_FillRects(): You must lock the surface");
}
if (rects == NULL) {
if (!rects) {
return SDL_InvalidParamError("SDL_FillRects(): rects");
}
@ -341,8 +348,8 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
return SDL_SetError("SDL_FillRects(): Unsupported surface format");
}
#if SDL_ARM_NEON_BLITTERS
if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && fill_function == NULL) {
#ifdef SDL_ARM_NEON_BLITTERS
if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && !fill_function) {
switch (dst->format->BytesPerPixel) {
case 1:
fill_function = fill_8_neon;
@ -356,8 +363,8 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
}
}
#endif
#if SDL_ARM_SIMD_BLITTERS
if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && fill_function == NULL) {
#ifdef SDL_ARM_SIMD_BLITTERS
if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && !fill_function) {
switch (dst->format->BytesPerPixel) {
case 1:
fill_function = fill_8_simd;
@ -372,7 +379,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count,
}
#endif
if (fill_function == NULL) {
if (!fill_function) {
switch (dst->format->BytesPerPixel) {
case 1:
{

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -91,6 +91,8 @@ const char *SDL_GetPixelFormatName(Uint32 format)
CASE(SDL_PIXELFORMAT_INDEX1LSB)
CASE(SDL_PIXELFORMAT_INDEX1MSB)
CASE(SDL_PIXELFORMAT_INDEX2LSB)
CASE(SDL_PIXELFORMAT_INDEX2MSB)
CASE(SDL_PIXELFORMAT_INDEX4LSB)
CASE(SDL_PIXELFORMAT_INDEX4MSB)
CASE(SDL_PIXELFORMAT_INDEX8)
@ -299,6 +301,9 @@ Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bm
case 1:
/* SDL defaults to MSB ordering */
return SDL_PIXELFORMAT_INDEX1MSB;
case 2:
/* SDL defaults to MSB ordering */
return SDL_PIXELFORMAT_INDEX2MSB;
case 4:
/* SDL defaults to MSB ordering */
return SDL_PIXELFORMAT_INDEX4MSB;
@ -518,7 +523,7 @@ SDL_PixelFormat *SDL_AllocFormat(Uint32 pixel_format)
/* Allocate an empty pixel format structure, and initialize it */
format = SDL_malloc(sizeof(*format));
if (format == NULL) {
if (!format) {
SDL_AtomicUnlock(&formats_lock);
SDL_OutOfMemory();
return NULL;
@ -616,7 +621,7 @@ void SDL_FreeFormat(SDL_PixelFormat *format)
{
SDL_PixelFormat *prev;
if (format == NULL) {
if (!format) {
SDL_InvalidParamError("format");
return;
}
@ -659,7 +664,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors)
}
palette = (SDL_Palette *)SDL_malloc(sizeof(*palette));
if (palette == NULL) {
if (!palette) {
SDL_OutOfMemory();
return NULL;
}
@ -681,7 +686,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors)
int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette)
{
if (format == NULL) {
if (!format) {
return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format");
}
@ -712,7 +717,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
int status = 0;
/* Verify the parameters */
if (palette == NULL) {
if (!palette) {
return -1;
}
if (ncolors > (palette->ncolors - firstcolor)) {
@ -734,7 +739,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors,
void SDL_FreePalette(SDL_Palette *palette)
{
if (palette == NULL) {
if (!palette) {
SDL_InvalidParamError("palette");
return;
}
@ -856,7 +861,7 @@ Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
SDL_InvalidParamError("format");
return 0;
}
if (format->palette == NULL) {
if (!format->palette) {
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask;
} else {
return SDL_FindColor(format->palette, r, g, b, SDL_ALPHA_OPAQUE);
@ -870,7 +875,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin
SDL_InvalidParamError("format");
return 0;
}
if (format->palette == NULL) {
if (!format->palette) {
return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
} else {
return SDL_FindColor(format->palette, r, g, b, a);
@ -880,7 +885,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin
void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g,
Uint8 *b)
{
if (format->palette == NULL) {
if (!format->palette) {
unsigned v;
v = (pixel & format->Rmask) >> format->Rshift;
*r = SDL_expand_byte[format->Rloss][v];
@ -902,7 +907,7 @@ void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g,
void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format,
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
{
if (format->palette == NULL) {
if (!format->palette) {
unsigned v;
v = (pixel & format->Rmask) >> format->Rshift;
*r = SDL_expand_byte[format->Rloss][v];
@ -943,7 +948,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
*identical = 0;
}
map = (Uint8 *)SDL_calloc(256, sizeof(Uint8));
if (map == NULL) {
if (!map) {
SDL_OutOfMemory();
return NULL;
}
@ -966,7 +971,7 @@ static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod,
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
map = (Uint8 *)SDL_calloc(256, bpp);
if (map == NULL) {
if (!map) {
SDL_OutOfMemory();
return NULL;
}
@ -1002,7 +1007,7 @@ SDL_BlitMap *SDL_AllocBlitMap(void)
/* Allocate the empty map */
map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map));
if (map == NULL) {
if (!map) {
SDL_OutOfMemory();
return NULL;
}
@ -1031,7 +1036,7 @@ void SDL_InvalidateAllBlitMap(SDL_Surface *surface)
void SDL_InvalidateMap(SDL_BlitMap *map)
{
if (map == NULL) {
if (!map) {
return;
}
if (map->dst) {
@ -1070,7 +1075,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
map->info.table =
Map1to1(srcfmt->palette, dstfmt->palette, &map->identity);
if (!map->identity) {
if (map->info.table == NULL) {
if (!map->info.table) {
return -1;
}
}
@ -1082,7 +1087,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
map->info.table =
Map1toN(srcfmt, src->map->info.r, src->map->info.g,
src->map->info.b, src->map->info.a, dstfmt);
if (map->info.table == NULL) {
if (!map->info.table) {
return -1;
}
}
@ -1091,7 +1096,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst)
/* BitField --> Palette */
map->info.table = MapNto1(srcfmt, dstfmt, &map->identity);
if (!map->identity) {
if (map->info.table == NULL) {
if (!map->info.table) {
return -1;
}
}
@ -1144,7 +1149,7 @@ void SDL_CalculateGammaRamp(float gamma, Uint16 * ramp)
SDL_InvalidParamError("gamma");
return;
}
if (ramp == NULL) {
if (!ramp) {
SDL_InvalidParamError("ramp");
return;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -38,10 +38,10 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
} else if (height < 1) {
SDL_InvalidParamError("height");
return SDL_FALSE;
} else if (rects == NULL) {
} else if (!rects) {
SDL_InvalidParamError("rects");
return SDL_FALSE;
} else if (span == NULL) {
} else if (!span) {
SDL_InvalidParamError("span");
return SDL_FALSE;
} else if (numrects < 1) {
@ -89,6 +89,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
#define RECTTYPE SDL_Rect
#define POINTTYPE SDL_Point
#define SCALARTYPE int
#define BIGSCALARTYPE Sint64
#define COMPUTEOUTCODE ComputeOutCode
#define SDL_HASINTERSECTION SDL_HasIntersection
#define SDL_INTERSECTRECT SDL_IntersectRect
@ -101,6 +102,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height,
#define RECTTYPE SDL_FRect
#define POINTTYPE SDL_FPoint
#define SCALARTYPE float
#define BIGSCALARTYPE double
#define COMPUTEOUTCODE ComputeOutCodeF
#define SDL_HASINTERSECTION SDL_HasIntersectionF
#define SDL_INTERSECTRECT SDL_IntersectFRect

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -25,10 +25,10 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (A == NULL) {
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (B == NULL) {
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) {
@ -70,13 +70,13 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (A == NULL) {
if (!A) {
SDL_InvalidParamError("A");
return SDL_FALSE;
} else if (B == NULL) {
} else if (!B) {
SDL_InvalidParamError("B");
return SDL_FALSE;
} else if (result == NULL) {
} else if (!result) {
SDL_InvalidParamError("result");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */
@ -120,13 +120,13 @@ void SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result)
{
SCALARTYPE Amin, Amax, Bmin, Bmax;
if (A == NULL) {
if (!A) {
SDL_InvalidParamError("A");
return;
} else if (B == NULL) {
} else if (!B) {
SDL_InvalidParamError("B");
return;
} else if (result == NULL) {
} else if (!result) {
SDL_InvalidParamError("result");
return;
} else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */
@ -180,7 +180,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c
SCALARTYPE x, y;
int i;
if (points == NULL) {
if (!points) {
SDL_InvalidParamError("points");
return SDL_FALSE;
} else if (count < 1) {
@ -210,7 +210,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c
}
if (!added) {
/* Special case: if no result was requested, we are done */
if (result == NULL) {
if (!result) {
return SDL_TRUE;
}
@ -236,7 +236,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c
}
} else {
/* Special case: if no result was requested, we are done */
if (result == NULL) {
if (!result) {
return SDL_TRUE;
}
@ -299,19 +299,19 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY
SCALARTYPE recty2;
int outcode1, outcode2;
if (rect == NULL) {
if (!rect) {
SDL_InvalidParamError("rect");
return SDL_FALSE;
} else if (X1 == NULL) {
} else if (!X1) {
SDL_InvalidParamError("X1");
return SDL_FALSE;
} else if (Y1 == NULL) {
} else if (!Y1) {
SDL_InvalidParamError("Y1");
return SDL_FALSE;
} else if (X2 == NULL) {
} else if (!X2) {
SDL_InvalidParamError("X2");
return SDL_FALSE;
} else if (Y2 == NULL) {
} else if (!Y2) {
SDL_InvalidParamError("Y2");
return SDL_FALSE;
} else if (SDL_RECTEMPTY(rect)) {
@ -378,16 +378,16 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY
if (outcode1) {
if (outcode1 & CODE_TOP) {
y = recty1;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1));
} else if (outcode1 & CODE_BOTTOM) {
y = recty2;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1));
} else if (outcode1 & CODE_LEFT) {
x = rectx1;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1));
} else if (outcode1 & CODE_RIGHT) {
x = rectx2;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1));
}
x1 = x;
y1 = y;
@ -396,23 +396,23 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY
if (outcode2 & CODE_TOP) {
SDL_assert(y2 != y1); /* if equal: division by zero. */
y = recty1;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1));
} else if (outcode2 & CODE_BOTTOM) {
SDL_assert(y2 != y1); /* if equal: division by zero. */
y = recty2;
x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1);
x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1));
} else if (outcode2 & CODE_LEFT) {
/* If this assertion ever fires, here's the static analysis that warned about it:
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */
SDL_assert(x2 != x1); /* if equal: division by zero. */
x = rectx1;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1));
} else if (outcode2 & CODE_RIGHT) {
/* If this assertion ever fires, here's the static analysis that warned about it:
http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */
SDL_assert(x2 != x1); /* if equal: division by zero. */
x = rectx2;
y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1);
y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1));
}
x2 = x;
y2 = y;
@ -429,6 +429,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY
#undef RECTTYPE
#undef POINTTYPE
#undef SCALARTYPE
#undef BIGSCALARTYPE
#undef COMPUTEOUTCODE
#undef SDL_HASINTERSECTION
#undef SDL_INTERSECTRECT

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -32,13 +32,13 @@ SDL_Window *SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned i
{
SDL_Window *result = NULL;
result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */);
if (result != NULL) {
if (result) {
if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) {
SDL_DestroyWindow(result);
return NULL;
}
result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result);
if (result->shaper != NULL) {
if (result->shaper) {
result->shaper->userx = x;
result->shaper->usery = y;
result->shaper->mode.mode = ShapeModeDefault;
@ -136,7 +136,7 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD
SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree));
SDL_Rect next = { 0, 0, 0, 0 };
if (result == NULL) {
if (!result) {
SDL_OutOfMemory();
return NULL;
}
@ -265,16 +265,16 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo
SDL_VideoDevice *_this = SDL_GetVideoDevice();
int result;
if (window == NULL || !SDL_IsShapedWindow(window)) {
if (!window || !SDL_IsShapedWindow(window)) {
/* The window given was not a shapeable window. */
return SDL_NONSHAPEABLE_WINDOW;
}
if (shape == NULL) {
if (!shape) {
/* Invalid shape argument. */
return SDL_INVALID_SHAPE_ARGUMENT;
}
if (shape_mode != NULL) {
if (shape_mode) {
window->shaper->mode = *shape_mode;
}
result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode);
@ -317,7 +317,7 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo
static SDL_bool SDL_WindowHasAShape(SDL_Window *window)
{
if (window == NULL || !SDL_IsShapedWindow(window)) {
if (!window || !SDL_IsShapedWindow(window)) {
return SDL_FALSE;
}
return window->shaper->hasshape;
@ -325,8 +325,8 @@ static SDL_bool SDL_WindowHasAShape(SDL_Window *window)
int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode)
{
if (window != NULL && SDL_IsShapedWindow(window)) {
if (shape_mode == NULL) {
if (window && SDL_IsShapedWindow(window)) {
if (!shape_mode) {
if (SDL_WindowHasAShape(window)) {
return 0; /* The window given has a shape. */
} else {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -149,9 +149,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
#define BILINEAR___START \
int i; \
int fp_sum_h, fp_step_h, left_pad_h, right_pad_h; \
int fp_sum_w, fp_step_w, left_pad_w, right_pad_w; \
int fp_sum_w_init, left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \
Sint64 fp_sum_h; \
int fp_step_h, left_pad_h, right_pad_h; \
Sint64 fp_sum_w; \
int fp_step_w, left_pad_w, right_pad_w; \
Sint64 fp_sum_w_init; \
int left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \
get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \
get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \
fp_sum_w_init = fp_sum_w + left_pad_w * fp_step_w; \
@ -163,7 +166,8 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
#define BILINEAR___HEIGHT \
int index_h, frac_h0, frac_h1, middle; \
const Uint32 *src_h0, *src_h1; \
int no_padding, incr_h0, incr_h1; \
int no_padding; \
Uint64 incr_h0, incr_h1; \
\
no_padding = !(i < left_pad_h || i > dst_h - 1 - right_pad_h); \
index_h = SRC_INDEX(fp_sum_h); \
@ -172,7 +176,7 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
index_h = no_padding ? index_h : (i < left_pad_h ? 0 : src_h - 1); \
frac_h0 = no_padding ? frac_h0 : 0; \
incr_h1 = no_padding ? src_pitch : 0; \
incr_h0 = index_h * src_pitch; \
incr_h0 = (Uint64)index_h * src_pitch; \
\
src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \
src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \
@ -193,12 +197,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect,
// OK with clang 12.0.0 / Xcode
__attribute__((noinline))
#endif
static void get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_pad, int *right_pad)
static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *fp_start, int *fp_step, int *left_pad, int *right_pad)
{
int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */
int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */
int fp_sum;
Sint64 fp_sum;
int i;
#if 0
/* scale to source coordinates */
@ -334,7 +338,7 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch,
}
#if defined(__SSE2__)
#define HAVE_SSE2_INTRINSICS 1
#define HAVE_SSE2_INTRINSICS
#endif
#if defined(__ARM_NEON)
@ -363,7 +367,7 @@ static void printf_128(const char *str, __m128i var)
}
#endif
static SDL_INLINE int hasSSE2()
static SDL_INLINE int hasSSE2(void)
{
static int val = -1;
if (val != -1) {
@ -532,7 +536,7 @@ static int scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch,
#if defined(HAVE_NEON_INTRINSICS)
static SDL_INLINE int hasNEON()
static SDL_INLINE int hasNEON(void)
{
static int val = -1;
if (val != -1) {
@ -824,16 +828,16 @@ int SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect,
return ret;
}
#define SDL_SCALE_NEAREST__START \
int i; \
Uint32 posy, incy; \
Uint32 posx, incx; \
int dst_gap; \
int srcy, n; \
const Uint32 *src_h0; \
incy = (src_h << 16) / dst_h; \
incx = (src_w << 16) / dst_w; \
dst_gap = dst_pitch - bpp * dst_w; \
#define SDL_SCALE_NEAREST__START \
int i; \
Uint64 posy, incy; \
Uint64 posx, incx; \
Uint64 srcy, srcx; \
int dst_gap, n; \
const Uint32 *src_h0; \
incy = ((Uint64)src_h << 16) / dst_h; \
incx = ((Uint64)src_w << 16) / dst_w; \
dst_gap = dst_pitch - bpp * dst_w; \
posy = incy / 2;
#define SDL_SCALE_NEAREST__HEIGHT \
@ -852,7 +856,7 @@ static int scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int
SDL_SCALE_NEAREST__HEIGHT
while (n--) {
const Uint8 *src;
int srcx = bpp * (posx >> 16);
srcx = bpp * (posx >> 16);
posx += incx;
src = (const Uint8 *)src_h0 + srcx;
*(Uint8 *)dst = *src;
@ -872,7 +876,7 @@ static int scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int
SDL_SCALE_NEAREST__HEIGHT
while (n--) {
const Uint16 *src;
int srcx = bpp * (posx >> 16);
srcx = bpp * (posx >> 16);
posx += incx;
src = (const Uint16 *)((const Uint8 *)src_h0 + srcx);
*(Uint16 *)dst = *src;
@ -892,7 +896,7 @@ static int scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int
SDL_SCALE_NEAREST__HEIGHT
while (n--) {
const Uint8 *src;
int srcx = bpp * (posx >> 16);
srcx = bpp * (posx >> 16);
posx += incx;
src = (const Uint8 *)src_h0 + srcx;
((Uint8 *)dst)[0] = src[0];
@ -914,7 +918,7 @@ static int scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int
SDL_SCALE_NEAREST__HEIGHT
while (n--) {
const Uint32 *src;
int srcx = bpp * (posx >> 16);
srcx = bpp * (posx >> 16);
posx += incx;
src = (const Uint32 *)((const Uint8 *)src_h0 + srcx);
*dst = *src;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -107,7 +107,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
/* Allocate the surface */
surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface));
if (surface == NULL) {
if (!surface) {
SDL_OutOfMemory();
return NULL;
}
@ -125,7 +125,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height,
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
SDL_Palette *palette =
SDL_AllocPalette((1 << surface->format->BitsPerPixel));
if (palette == NULL) {
if (!palette) {
SDL_FreeSurface(surface);
return NULL;
}
@ -238,7 +238,7 @@ SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels,
}
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
if (surface != NULL) {
if (surface) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
@ -284,7 +284,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
}
surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format);
if (surface != NULL) {
if (surface) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
@ -297,7 +297,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels,
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface");
}
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
@ -312,8 +312,8 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
{
int flags;
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
flags = surface->map->info.flags;
@ -330,7 +330,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
SDL_bool SDL_HasSurfaceRLE(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@ -345,7 +345,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
{
int flags;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@ -373,7 +373,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key)
SDL_bool SDL_HasColorKey(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@ -386,7 +386,7 @@ SDL_bool SDL_HasColorKey(SDL_Surface *surface)
int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@ -406,7 +406,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp
{
int x, y, bpp;
if (surface == NULL) {
if (!surface) {
return;
}
@ -495,8 +495,8 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
{
int flags;
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
surface->map->info.r = r;
@ -517,8 +517,8 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
{
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
if (r) {
@ -537,8 +537,8 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
{
int flags;
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
surface->map->info.a = alpha;
@ -557,8 +557,8 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
{
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
if (alpha) {
@ -571,8 +571,8 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
{
int flags, status;
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
status = 0;
@ -608,11 +608,11 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
{
if (surface == NULL) {
return -1;
if (!surface) {
return SDL_InvalidParamError("surface");
}
if (blendMode == NULL) {
if (!blendMode) {
return 0;
}
@ -641,7 +641,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
SDL_Rect full_rect;
/* Don't do anything if there's no surface to act on */
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@ -652,7 +652,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
full_rect.h = surface->h;
/* Set the clipping rectangle */
if (rect == NULL) {
if (!rect) {
surface->clip_rect = full_rect;
return SDL_TRUE;
}
@ -701,85 +701,65 @@ int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect,
int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
SDL_Rect fulldst;
int srcx, srcy, w, h;
SDL_Rect r_src, r_dst;
/* Make sure the surfaces aren't locked */
if (src == NULL || dst == NULL) {
return SDL_InvalidParamError("SDL_UpperBlit(): src/dst");
}
if (src->locked || dst->locked) {
if (!src) {
return SDL_InvalidParamError("src");
} else if (!dst) {
return SDL_InvalidParamError("dst");
} else if (src->locked || dst->locked) {
return SDL_SetError("Surfaces must not be locked during blit");
}
/* If the destination rectangle is NULL, use the entire dest surface */
if (dstrect == NULL) {
fulldst.x = fulldst.y = 0;
fulldst.w = dst->w;
fulldst.h = dst->h;
dstrect = &fulldst;
/* Full src surface */
r_src.x = 0;
r_src.y = 0;
r_src.w = src->w;
r_src.h = src->h;
if (dstrect) {
r_dst.x = dstrect->x;
r_dst.y = dstrect->y;
} else {
r_dst.x = 0;
r_dst.y = 0;
}
/* clip the source rectangle to the source surface */
if (srcrect) {
int maxw, maxh;
srcx = srcrect->x;
w = srcrect->w;
if (srcx < 0) {
w += srcx;
dstrect->x -= srcx;
srcx = 0;
}
maxw = src->w - srcx;
if (maxw < w) {
w = maxw;
SDL_Rect tmp;
if (SDL_IntersectRect(srcrect, &r_src, &tmp) == SDL_FALSE) {
goto end;
}
srcy = srcrect->y;
h = srcrect->h;
if (srcy < 0) {
h += srcy;
dstrect->y -= srcy;
srcy = 0;
}
maxh = src->h - srcy;
if (maxh < h) {
h = maxh;
}
/* Shift dstrect, if srcrect origin has changed */
r_dst.x += tmp.x - srcrect->x;
r_dst.y += tmp.y - srcrect->y;
} else {
srcx = srcy = 0;
w = src->w;
h = src->h;
/* Update srcrect */
r_src = tmp;
}
/* There're no dstrect.w/h parameters. It's the same as srcrect */
r_dst.w = r_src.w;
r_dst.h = r_src.h;
/* clip the destination rectangle against the clip rectangle */
{
SDL_Rect *clip = &dst->clip_rect;
int dx, dy;
dx = clip->x - dstrect->x;
if (dx > 0) {
w -= dx;
dstrect->x += dx;
srcx += dx;
}
dx = dstrect->x + w - clip->x - clip->w;
if (dx > 0) {
w -= dx;
SDL_Rect tmp;
if (SDL_IntersectRect(&r_dst, &dst->clip_rect, &tmp) == SDL_FALSE) {
goto end;
}
dy = clip->y - dstrect->y;
if (dy > 0) {
h -= dy;
dstrect->y += dy;
srcy += dy;
}
dy = dstrect->y + h - clip->y - clip->h;
if (dy > 0) {
h -= dy;
}
/* Shift srcrect, if dstrect has changed */
r_src.x += tmp.x - r_dst.x;
r_src.y += tmp.y - r_dst.y;
r_src.w = tmp.w;
r_src.h = tmp.h;
/* Update dstrect */
r_dst = tmp;
}
/* Switch back to a fast blit if we were previously stretching */
@ -788,15 +768,17 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect,
SDL_InvalidateMap(src->map);
}
if (w > 0 && h > 0) {
SDL_Rect sr;
sr.x = srcx;
sr.y = srcy;
sr.w = dstrect->w = w;
sr.h = dstrect->h = h;
return SDL_LowerBlit(src, &sr, dst, dstrect);
if (r_dst.w > 0 && r_dst.h > 0) {
if (dstrect) { /* update output parameter */
*dstrect = r_dst;
}
return SDL_LowerBlit(src, &r_src, dst, &r_dst);
}
end:
if (dstrect) { /* update output parameter */
dstrect->w = dstrect->h = 0;
}
dstrect->w = dstrect->h = 0;
return 0;
}
@ -817,14 +799,14 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
int dst_w, dst_h;
/* Make sure the surfaces aren't locked */
if (src == NULL || dst == NULL) {
if (!src || !dst) {
return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst");
}
if (src->locked || dst->locked) {
return SDL_SetError("Surfaces must not be locked during blit");
}
if (srcrect == NULL) {
if (!srcrect) {
src_w = src->w;
src_h = src->h;
} else {
@ -832,7 +814,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
src_h = srcrect->h;
}
if (dstrect == NULL) {
if (!dstrect) {
dst_w = dst->w;
dst_h = dst->h;
} else {
@ -848,7 +830,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
scaling_w = (double)dst_w / src_w;
scaling_h = (double)dst_h / src_h;
if (dstrect == NULL) {
if (!dstrect) {
dst_x0 = 0;
dst_y0 = 0;
dst_x1 = dst_w;
@ -860,7 +842,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect,
dst_y1 = dst_y0 + dst_h;
}
if (srcrect == NULL) {
if (!srcrect) {
src_x0 = 0;
src_y0 = 0;
src_x1 = src_w;
@ -1146,17 +1128,17 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f
Uint8 *palette_saved_alpha = NULL;
int palette_saved_alpha_ncolors = 0;
if (surface == NULL) {
if (!surface) {
SDL_InvalidParamError("surface");
return NULL;
}
if (format == NULL) {
if (!format) {
SDL_InvalidParamError("format");
return NULL;
}
/* Check for empty destination palette! (results in empty image) */
if (format->palette != NULL) {
if (format->palette) {
int i;
for (i = 0; i < format->palette->ncolors; ++i) {
if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) {
@ -1174,7 +1156,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f
format->BitsPerPixel, format->Rmask,
format->Gmask, format->Bmask,
format->Amask);
if (convert == NULL) {
if (!convert) {
return NULL;
}
@ -1429,13 +1411,13 @@ int SDL_ConvertPixels(int width, int height,
void *nonconst_src = (void *)src;
int ret;
if (src == NULL) {
if (!src) {
return SDL_InvalidParamError("src");
}
if (!src_pitch) {
return SDL_InvalidParamError("src_pitch");
}
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("dst");
}
if (!dst_pitch) {
@ -1511,13 +1493,13 @@ int SDL_PremultiplyAlpha(int width, int height,
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
if (src == NULL) {
if (!src) {
return SDL_InvalidParamError("src");
}
if (!src_pitch) {
return SDL_InvalidParamError("src_pitch");
}
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("dst");
}
if (!dst_pitch) {
@ -1559,7 +1541,7 @@ int SDL_PremultiplyAlpha(int width, int height,
*/
void SDL_FreeSurface(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return;
}
if (surface->flags & SDL_DONTFREE) {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -24,6 +24,7 @@
#define SDL_sysvideo_h_
#include "SDL_messagebox.h"
#include "SDL_mouse.h"
#include "SDL_shape.h"
#include "SDL_thread.h"
#include "SDL_metal.h"
@ -154,6 +155,7 @@ typedef enum
{
VIDEO_DEVICE_QUIRK_DISABLE_DISPLAY_MODE_SWITCHING = 0x01,
VIDEO_DEVICE_QUIRK_DISABLE_UNSET_FULLSCREEN_ON_MINIMIZE = 0x02,
VIDEO_DEVICE_QUIRK_FULLSCREEN_ONLY = 0x04,
} DeviceQuirkFlags;
struct SDL_VideoDevice
@ -433,11 +435,11 @@ struct SDL_VideoDevice
void *driverdata;
struct SDL_GLDriverData *gl_data;
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
struct SDL_EGL_VideoData *egl_data;
#endif
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)
struct SDL_PrivateGLESData *gles_data;
#endif
@ -451,6 +453,7 @@ typedef struct VideoBootStrap
const char *name;
const char *desc;
SDL_VideoDevice *(*create)(void);
int (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonid); /* can be done without initializing backend! */
} VideoBootStrap;
/* Not all of these are available in a given build. Use #ifdefs, etc. */
@ -509,6 +512,7 @@ extern void SDL_OnWindowShown(SDL_Window *window);
extern void SDL_OnWindowHidden(SDL_Window *window);
extern void SDL_OnWindowMoved(SDL_Window *window);
extern void SDL_OnWindowResized(SDL_Window *window);
extern void SDL_OnWindowLiveResizeUpdate(SDL_Window *window);
extern void SDL_OnWindowMinimized(SDL_Window *window);
extern void SDL_OnWindowRestored(SDL_Window *window);
extern void SDL_OnWindowEnter(SDL_Window *window);
@ -528,6 +532,10 @@ extern int SDL_GetPointDisplayIndex(const SDL_Point *point);
extern int SDL_GL_SwapWindowWithResult(SDL_Window *window);
#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN)
const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name);
#endif
#endif /* SDL_sysvideo_h_ */
/* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -25,34 +25,34 @@
#include "SDL_stdinc.h"
#if SDL_VIDEO_VULKAN
#if SDL_LOADSO_DISABLED || SDL_LOADSO_DUMMY
#ifdef SDL_VIDEO_VULKAN
#if defined(SDL_LOADSO_DISABLED) || defined(SDL_LOADSO_DUMMY)
#error You should not be here.
#endif
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#define VK_USE_PLATFORM_ANDROID_KHR
#endif
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#define VK_USE_PLATFORM_METAL_EXT
#define VK_USE_PLATFORM_MACOS_MVK
#endif
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#define VK_USE_PLATFORM_DIRECTFB_EXT
#endif
#if SDL_VIDEO_DRIVER_UIKIT
#ifdef SDL_VIDEO_DRIVER_UIKIT
#define VK_USE_PLATFORM_METAL_EXT
#define VK_USE_PLATFORM_IOS_MVK
#endif
#if SDL_VIDEO_DRIVER_WAYLAND
#ifdef SDL_VIDEO_DRIVER_WAYLAND
#define VK_USE_PLATFORM_WAYLAND_KHR
#include "wayland/SDL_waylanddyn.h"
#endif
#if SDL_VIDEO_DRIVER_WINDOWS
#ifdef SDL_VIDEO_DRIVER_WINDOWS
#define VK_USE_PLATFORM_WIN32_KHR
#include "../core/windows/SDL_windows.h"
#endif
#if SDL_VIDEO_DRIVER_X11
#ifdef SDL_VIDEO_DRIVER_X11
#define VK_USE_PLATFORM_XLIB_KHR
#define VK_USE_PLATFORM_XCB_KHR
#endif

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -23,7 +23,7 @@
#include "SDL_vulkan_internal.h"
#include "SDL_error.h"
#if SDL_VIDEO_VULKAN
#ifdef SDL_VIDEO_VULKAN
const char *SDL_Vulkan_GetResultString(VkResult result)
{
@ -149,7 +149,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList(
retval = SDL_calloc(count, sizeof(VkExtensionProperties));
}
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@ -232,7 +232,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
goto error;
}
chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY");
if (chosenDisplayId != NULL) {
if (chosenDisplayId) {
displayId = SDL_atoi(chosenDisplayId);
}
@ -249,7 +249,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
}
physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
if (physicalDevices == NULL) {
if (!physicalDevices) {
SDL_OutOfMemory();
goto error;
}
@ -292,7 +292,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
}
displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount);
if (displayProperties == NULL) {
if (!displayProperties) {
SDL_OutOfMemory();
goto error;
}
@ -321,7 +321,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount);
displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount);
if (displayModeProperties == NULL) {
if (!displayModeProperties) {
SDL_OutOfMemory();
goto error;
}
@ -368,7 +368,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount);
displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount);
if (displayPlaneProperties == NULL) {
if (!displayPlaneProperties) {
SDL_OutOfMemory();
goto error;
}
@ -399,7 +399,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_,
SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount);
planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount);
if (planeSupportedDisplays == NULL) {
if (!planeSupportedDisplays) {
SDL_free(displayPlaneProperties);
SDL_OutOfMemory();
goto error;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -40,7 +40,7 @@ void SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode)
SDL_YUV_ConversionMode = mode;
}
SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode()
SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode(void)
{
return SDL_YUV_ConversionMode;
}
@ -597,7 +597,7 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height,
int tmp_pitch = (width * sizeof(Uint32));
tmp = SDL_malloc((size_t)tmp_pitch * height);
if (tmp == NULL) {
if (!tmp) {
return SDL_OutOfMemory();
}
@ -978,7 +978,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
int tmp_pitch = (width * sizeof(Uint32));
tmp = SDL_malloc((size_t)tmp_pitch * height);
if (tmp == NULL) {
if (!tmp) {
return SDL_OutOfMemory();
}
@ -1067,7 +1067,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src
/* Allocate a temporary row for the swap */
tmp = (Uint8 *)SDL_malloc(UVwidth);
if (tmp == NULL) {
if (!tmp) {
return SDL_OutOfMemory();
}
for (y = 0; y < UVheight; ++y) {
@ -1127,7 +1127,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const voi
if (src == dst) {
/* Need to make a copy of the buffer so we don't clobber it while converting */
tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch);
if (tmp == NULL) {
if (!tmp) {
return SDL_OutOfMemory();
}
SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch);
@ -1200,7 +1200,7 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const vo
if (src == dst) {
/* Need to make a copy of the buffer so we don't clobber it while converting */
tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch);
if (tmp == NULL) {
if (!tmp) {
return SDL_OutOfMemory();
}
SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include "SDL_androidvideo.h"
#include "SDL_androidclipboard.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,10 +20,11 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include "SDL_androidevents.h"
#include "SDL_events.h"
#include "SDL_hints.h"
#include "SDL_androidkeyboard.h"
#include "SDL_androidwindow.h"
#include "../SDL_sysvideo.h"
@ -32,7 +33,7 @@
/* Can't include sysaudio "../../audio/android/SDL_androidaudio.h"
* because of THIS redefinition */
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_ANDROID
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_ANDROID)
extern void ANDROIDAUDIO_ResumeDevices(void);
extern void ANDROIDAUDIO_PauseDevices(void);
#else
@ -40,7 +41,7 @@ static void ANDROIDAUDIO_ResumeDevices(void) {}
static void ANDROIDAUDIO_PauseDevices(void) {}
#endif
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_OPENSLES
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_OPENSLES)
extern void openslES_ResumeDevices(void);
extern void openslES_PauseDevices(void);
#else
@ -50,7 +51,7 @@ static void openslES_ResumeDevices(void)
static void openslES_PauseDevices(void) {}
#endif
#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO
#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_AAUDIO)
extern void aaudio_ResumeDevices(void);
extern void aaudio_PauseDevices(void);
SDL_bool aaudio_DetectBrokenPlayState(void);
@ -68,12 +69,13 @@ static int SDL_NumberOfEvents(Uint32 type)
return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type);
}
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
static void android_egl_context_restore(SDL_Window *window)
{
if (window) {
SDL_Event event;
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
SDL_GL_MakeCurrent(window, NULL);
if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) {
/* The context is no longer valid, create a new one */
data->egl_context = (EGLContext)SDL_GL_CreateContext(window);
@ -112,7 +114,7 @@ void Android_PumpEvents_Blocking(_THIS)
if (videodata->isPaused) {
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
/* Make sure this is the last thing we do before pausing */
if (!isContextExternal) {
SDL_LockMutex(Android_ActivityMutex);
@ -139,7 +141,7 @@ void Android_PumpEvents_Blocking(_THIS)
aaudio_ResumeDevices();
/* Restore the GL Context from here, as this operation is thread dependent */
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
SDL_LockMutex(Android_ActivityMutex);
android_egl_context_restore(Android_Window);
@ -148,9 +150,7 @@ void Android_PumpEvents_Blocking(_THIS)
#endif
/* Make sure SW Keyboard is restored when an app becomes foreground */
if (SDL_IsTextInputActive()) {
Android_StartTextInput(_this); /* Only showTextInput */
}
Android_RestoreScreenKeyboardOnResume(_this, Android_Window);
}
} else {
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {
@ -190,7 +190,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
SDL_bool isContextExternal = SDL_IsVideoContextExternal();
if (backup_context) {
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
if (!isContextExternal) {
SDL_LockMutex(Android_ActivityMutex);
android_egl_context_backup(Android_Window);
@ -222,7 +222,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
aaudio_ResumeDevices();
}
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
/* Restore the GL Context from here, as this operation is thread dependent */
if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) {
SDL_LockMutex(Android_ActivityMutex);
@ -232,9 +232,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
#endif
/* Make sure SW Keyboard is restored when an app becomes foreground */
if (SDL_IsTextInputActive()) {
Android_StartTextInput(_this); /* Only showTextInput */
}
Android_RestoreScreenKeyboardOnResume(_this, Android_Window);
}
} else {
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID && SDL_VIDEO_OPENGL_EGL
#if defined(SDL_VIDEO_DRIVER_ANDROID) && defined(SDL_VIDEO_OPENGL_EGL)
/* Android SDL video driver implementation */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include <android/log.h>
@ -313,6 +313,8 @@ static SDL_Scancode Android_Keycodes[] = {
SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */
};
static SDL_bool SDL_screen_keyboard_shown;
static SDL_Scancode TranslateKeycode(int keycode)
{
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
@ -341,27 +343,36 @@ SDL_bool Android_HasScreenKeyboardSupport(_THIS)
return SDL_TRUE;
}
void Android_ShowScreenKeyboard(_THIS, SDL_Window *window)
{
SDL_VideoData *videodata = _this->driverdata;
Android_JNI_ShowScreenKeyboard(&videodata->textRect);
SDL_screen_keyboard_shown = SDL_TRUE;
}
void Android_HideScreenKeyboard(_THIS, SDL_Window *window)
{
Android_JNI_HideScreenKeyboard();
SDL_screen_keyboard_shown = SDL_FALSE;
}
void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window)
{
if (SDL_screen_keyboard_shown) {
Android_ShowScreenKeyboard(_this, window);
}
}
SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window)
{
return Android_JNI_IsScreenKeyboardShown();
}
void Android_StartTextInput(_THIS)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
Android_JNI_ShowTextInput(&videodata->textRect);
}
void Android_StopTextInput(_THIS)
{
Android_JNI_HideTextInput();
}
void Android_SetTextInputRect(_THIS, const SDL_Rect *rect)
{
SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata;
if (rect == NULL) {
if (!rect) {
SDL_InvalidParamError("rect");
return;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -26,10 +26,10 @@ extern int Android_OnKeyDown(int keycode);
extern int Android_OnKeyUp(int keycode);
extern SDL_bool Android_HasScreenKeyboardSupport(_THIS);
extern void Android_ShowScreenKeyboard(_THIS, SDL_Window *window);
extern void Android_HideScreenKeyboard(_THIS, SDL_Window *window);
extern void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window);
extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window);
extern void Android_StartTextInput(_THIS);
extern void Android_StopTextInput(_THIS);
extern void Android_SetTextInputRect(_THIS, const SDL_Rect *rect);
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include "SDL_messagebox.h"
#include "SDL_androidmessagebox.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -21,7 +21,7 @@
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include "SDL_androidmouse.h"
@ -78,7 +78,7 @@ static SDL_Cursor *Android_WrapCursor(int custom_cursor, int system_cursor)
return cursor;
}
static SDL_Cursor *Android_CreateDefaultCursor()
static SDL_Cursor *Android_CreateDefaultCursor(void)
{
return Android_WrapCursor(0, SDL_SYSTEM_CURSOR_ARROW);
}
@ -89,7 +89,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot
SDL_Surface *converted;
converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
if (converted == NULL) {
if (!converted) {
return NULL;
}
custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y);
@ -116,9 +116,9 @@ static void Android_FreeCursor(SDL_Cursor *cursor)
SDL_free(cursor);
}
static SDL_Cursor *Android_CreateEmptyCursor()
static SDL_Cursor *Android_CreateEmptyCursor(void)
{
if (empty_cursor == NULL) {
if (!empty_cursor) {
SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888);
if (empty_surface) {
SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch);
@ -129,7 +129,7 @@ static SDL_Cursor *Android_CreateEmptyCursor()
return empty_cursor;
}
static void Android_DestroyEmptyCursor()
static void Android_DestroyEmptyCursor(void)
{
if (empty_cursor) {
Android_FreeCursor(empty_cursor);
@ -139,7 +139,7 @@ static void Android_DestroyEmptyCursor()
static int Android_ShowCursor(SDL_Cursor *cursor)
{
if (cursor == NULL) {
if (!cursor) {
cursor = Android_CreateEmptyCursor();
}
if (cursor) {
@ -216,7 +216,7 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y
int changes;
Uint8 button;
if (window == NULL) {
if (!window) {
return;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include <android/log.h>
@ -54,7 +54,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin
SDL_TouchID touchDeviceId = 0;
SDL_FingerID fingerId = 0;
if (window == NULL) {
if (!window) {
return;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
/* Android SDL video driver implementation */
@ -41,6 +41,7 @@
#include "SDL_androidtouch.h"
#include "SDL_androidwindow.h"
#include "SDL_androidvulkan.h"
#include "SDL_androidmessagebox.h"
#define ANDROID_VID_DRIVER_NAME "Android"
@ -88,13 +89,13 @@ static SDL_VideoDevice *Android_CreateDevice(void)
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
if (device == NULL) {
if (!device) {
SDL_OutOfMemory();
return NULL;
}
data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
if (data == NULL) {
if (!data) {
SDL_OutOfMemory();
SDL_free(device);
return NULL;
@ -125,7 +126,7 @@ static SDL_VideoDevice *Android_CreateDevice(void)
device->free = Android_DeleteDevice;
/* GL pointers */
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
device->GL_LoadLibrary = Android_GLES_LoadLibrary;
device->GL_GetProcAddress = Android_GLES_GetProcAddress;
device->GL_UnloadLibrary = Android_GLES_UnloadLibrary;
@ -137,7 +138,7 @@ static SDL_VideoDevice *Android_CreateDevice(void)
device->GL_DeleteContext = Android_GLES_DeleteContext;
#endif
#if SDL_VIDEO_VULKAN
#ifdef SDL_VIDEO_VULKAN
device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary;
device->Vulkan_UnloadLibrary = Android_Vulkan_UnloadLibrary;
device->Vulkan_GetInstanceExtensions = Android_Vulkan_GetInstanceExtensions;
@ -148,12 +149,12 @@ static SDL_VideoDevice *Android_CreateDevice(void)
device->SuspendScreenSaver = Android_SuspendScreenSaver;
/* Text input */
device->StartTextInput = Android_StartTextInput;
device->StopTextInput = Android_StopTextInput;
device->SetTextInputRect = Android_SetTextInputRect;
/* Screen keyboard */
device->HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport;
device->ShowScreenKeyboard = Android_ShowScreenKeyboard;
device->HideScreenKeyboard = Android_HideScreenKeyboard;
device->IsScreenKeyboardShown = Android_IsScreenKeyboardShown;
/* Clipboard */
@ -166,7 +167,8 @@ static SDL_VideoDevice *Android_CreateDevice(void)
VideoBootStrap Android_bootstrap = {
ANDROID_VID_DRIVER_NAME, "SDL Android video driver",
Android_CreateDevice
Android_CreateDevice,
Android_ShowMessageBox
};
int Android_VideoInit(_THIS)

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -26,7 +26,7 @@
#include "../../SDL_internal.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_ANDROID
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID)
#include "SDL_androidvideo.h"
#include "SDL_androidwindow.h"
@ -47,10 +47,10 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path)
}
/* Load the Vulkan loader library */
if (path == NULL) {
if (!path) {
path = SDL_getenv("SDL_VULKAN_LIBRARY");
}
if (path == NULL) {
if (!path) {
path = "libvulkan.so";
}
_this->vulkan_config.loader_handle = SDL_LoadObject(path);
@ -75,7 +75,7 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path)
(PFN_vkEnumerateInstanceExtensionProperties)
_this->vulkan_config.vkEnumerateInstanceExtensionProperties,
&extensionCount);
if (extensions == NULL) {
if (!extensions) {
goto fail;
}
for (i = 0; i < extensionCount; i++) {

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -32,7 +32,7 @@
#include "../SDL_vulkan_internal.h"
#include "../SDL_sysvideo.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_ANDROID
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID)
int Android_Vulkan_LoadLibrary(_THIS, const char *path);
void Android_Vulkan_UnloadLibrary(_THIS);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_ANDROID
#ifdef SDL_VIDEO_DRIVER_ANDROID
#include "SDL_syswm.h"
#include "../SDL_sysvideo.h"
@ -65,7 +65,7 @@ int Android_CreateWindow(_THIS, SDL_Window *window)
SDL_SetKeyboardFocus(window);
data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data));
if (data == NULL) {
if (!data) {
retval = SDL_OutOfMemory();
goto endfunction;
}
@ -80,7 +80,7 @@ int Android_CreateWindow(_THIS, SDL_Window *window)
/* Do not create EGLSurface for Vulkan window since it will then make the window
incompatible with vkCreateAndroidSurfaceKHR */
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
if (window->flags & SDL_WINDOW_OPENGL) {
data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->native_window);
@ -132,7 +132,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di
}
data = (SDL_WindowData *)window->driverdata;
if (data == NULL || !data->native_window) {
if (!data || !data->native_window) {
if (data && !data->native_window) {
SDL_SetError("Missing native window");
}
@ -180,7 +180,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window)
if (window->driverdata) {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
if (data->egl_surface != EGL_NO_SURFACE) {
SDL_EGL_DestroySurface(_this, data->egl_surface);
}
@ -205,7 +205,7 @@ SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info)
info->subsystem = SDL_SYSWM_ANDROID;
info->info.android.window = data->native_window;
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
info->info.android.surface = data->egl_surface;
#endif

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -38,7 +38,7 @@ extern SDL_Window *Android_Window;
typedef struct
{
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
EGLSurface egl_surface;
EGLContext egl_context; /* We use this to preserve the context when losing focus */
#endif

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_cocoavideo.h"
#include "../../events/SDL_clipboardevents_c.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_timer.h"
@ -138,6 +138,7 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
- (id)init;
- (void)localeDidChange:(NSNotification *)notification;
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app;
@end
@implementation SDLAppDelegate : NSObject
@ -310,6 +311,22 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent)
SDL_SendDropComplete(NULL);
}
- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app
{
// This just tells Cocoa that we didn't do any custom save state magic for the app,
// so the system is safe to use NSSecureCoding internally, instead of using unencrypted
// save states for backwards compatibility. If we don't return YES here, we'll get a
// warning on the console at startup:
//
// ```
// WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
// ```
//
// More-detailed explanation:
// https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate/77320845#77320845
return YES;
}
@end
static SDLAppDelegate *appDelegate = nil;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_cocoavideo.h"
@ -437,9 +437,19 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
case NSEventTypeKeyUp:
SDL_SendKeyboardKey(SDL_RELEASED, code);
break;
case NSEventTypeFlagsChanged:
HandleModifiers(_this, code, (unsigned int)[event modifierFlags]);
case NSEventTypeFlagsChanged: {
// see if the new modifierFlags mean any existing keys should be pressed/released...
const unsigned int modflags = (unsigned int)[event modifierFlags];
HandleModifiers(_this, SDL_SCANCODE_LSHIFT, modflags);
HandleModifiers(_this, SDL_SCANCODE_LCTRL, modflags);
HandleModifiers(_this, SDL_SCANCODE_LALT, modflags);
HandleModifiers(_this, SDL_SCANCODE_LGUI, modflags);
HandleModifiers(_this, SDL_SCANCODE_RSHIFT, modflags);
HandleModifiers(_this, SDL_SCANCODE_RCTRL, modflags);
HandleModifiers(_this, SDL_SCANCODE_RALT, modflags);
HandleModifiers(_this, SDL_SCANCODE_RGUI, modflags);
break;
}
default: /* just to avoid compiler warnings */
break;
}
@ -460,7 +470,7 @@ extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection connection, CGSGlob
void Cocoa_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed)
{
#if SDL_MAC_NO_SANDBOX
#ifdef SDL_MAC_NO_SANDBOX
CGSSetGlobalHotKeyOperatingMode(_CGSDefaultConnection(), grabbed ? CGSGlobalHotKeyDisable : CGSGlobalHotKeyEnable);
#endif
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
extern int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_events.h"
#include "SDL_timer.h"
@ -33,6 +33,9 @@
NSWindow *nswindow;
}
- (id)initWithParentWindow:(SDL_Window *)window;
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
#endif
@end
@implementation SDLMessageBoxPresenter
@ -56,16 +59,32 @@
- (void)showAlert:(NSAlert*)alert
{
if (nswindow) {
[alert beginSheetModalForWindow:nswindow
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
[alert beginSheetModalForWindow:nswindow
completionHandler:^(NSModalResponse returnCode) {
[NSApp stopModalWithCode:returnCode];
}];
} else
#endif
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
[alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
#endif
}
clicked = [NSApp runModalForWindow:nswindow];
nswindow = nil;
} else {
clicked = [alert runModal];
}
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[NSApp stopModalWithCode:returnCode];
}
#endif
@end

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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 @@
#ifndef SDL_cocoametalview_h_
#define SDL_cocoametalview_h_
#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL))
#import "../SDL_sysvideo.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -28,7 +28,7 @@
#import "SDL_cocoametalview.h"
#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL))
#include "SDL_events.h"
#include "SDL_syswm.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_cocoavideo.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_events.h"
#include "SDL_cocoamouse.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -23,7 +23,7 @@
#ifndef SDL_cocoaopengl_h_
#define SDL_cocoaopengl_h_
#if SDL_VIDEO_OPENGL_CGL
#ifdef SDL_VIDEO_OPENGL_CGL
#include "SDL_atomic.h"
#import <Cocoa/Cocoa.h>

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -22,7 +22,7 @@
/* NSOpenGL implementation of SDL OpenGL support */
#if SDL_VIDEO_OPENGL_CGL
#ifdef SDL_VIDEO_OPENGL_CGL
#include "SDL_cocoavideo.h"
#include "SDL_cocoaopengl.h"
#include "SDL_cocoaopengles.h"
@ -270,7 +270,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window)
int interval;
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
/* Switch to EGL based functions */
Cocoa_GL_UnloadLibrary(_this);
_this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary;
@ -507,13 +507,31 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window * window)
return 0;
}}
void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
{ @autoreleasepool
static void DispatchedDeleteContext(SDL_GLContext context)
{
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
[nscontext cleanup];
CFRelease(context);
}}
@autoreleasepool {
SDLOpenGLContext *nscontext = (__bridge SDLOpenGLContext *)context;
[nscontext cleanup];
CFRelease(context);
}
}
void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context)
{
if ([NSThread isMainThread]) {
DispatchedDeleteContext(context);
} else {
if (SDL_opengl_async_dispatch) {
dispatch_async(dispatch_get_main_queue(), ^{
DispatchedDeleteContext(context);
});
} else {
dispatch_sync(dispatch_get_main_queue(), ^{
DispatchedDeleteContext(context);
});
}
}
}
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
#ifdef __clang__

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -23,7 +23,7 @@
#ifndef SDL_cocoaopengles_h_
#define SDL_cocoaopengles_h_
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
#include "../SDL_sysvideo.h"
#include "../SDL_egl_c.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA && SDL_VIDEO_OPENGL_EGL
#if defined(SDL_VIDEO_DRIVER_COCOA) && defined(SDL_VIDEO_OPENGL_EGL)
#include "SDL_cocoavideo.h"
#include "SDL_cocoaopengles.h"
@ -32,7 +32,7 @@ int Cocoa_GLES_LoadLibrary(_THIS, const char *path)
{
/* If the profile requested is not GL ES, switch over to WIN_GL functions */
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
#if SDL_VIDEO_OPENGL_CGL
#ifdef SDL_VIDEO_OPENGL_CGL
Cocoa_GLES_UnloadLibrary(_this);
_this->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
_this->GL_GetProcAddress = Cocoa_GL_GetProcAddress;
@ -62,7 +62,7 @@ SDL_GLContext Cocoa_GLES_CreateContext(_THIS, SDL_Window * window)
SDL_GLContext context;
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
#if SDL_VIDEO_OPENGL_CGL
#ifdef SDL_VIDEO_OPENGL_CGL
if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) {
/* Switch to CGL based functions */
Cocoa_GLES_UnloadLibrary(_this);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#include "SDL_cocoavideo.h"
#include "SDL_shape.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#if !__has_feature(objc_arc)
#error SDL must be built with Objective-C ARC (automatic reference counting) enabled
@ -33,6 +33,7 @@
#include "SDL_cocoavulkan.h"
#include "SDL_cocoametalview.h"
#include "SDL_cocoaopengles.h"
#include "SDL_cocoamessagebox.h"
@implementation SDL_VideoData
@ -127,7 +128,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape;
#if SDL_VIDEO_OPENGL_CGL
#ifdef SDL_VIDEO_OPENGL_CGL
device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
device->GL_GetProcAddress = Cocoa_GL_GetProcAddress;
device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary;
@ -137,7 +138,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval;
device->GL_SwapWindow = Cocoa_GL_SwapWindow;
device->GL_DeleteContext = Cocoa_GL_DeleteContext;
#elif SDL_VIDEO_OPENGL_EGL
#elif defined(SDL_VIDEO_OPENGL_EGL)
device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary;
device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress;
device->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary;
@ -149,7 +150,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->GL_DeleteContext = Cocoa_GLES_DeleteContext;
#endif
#if SDL_VIDEO_VULKAN
#ifdef SDL_VIDEO_VULKAN
device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary;
device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary;
device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions;
@ -157,7 +158,7 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
device->Vulkan_GetDrawableSize = Cocoa_Vulkan_GetDrawableSize;
#endif
#if SDL_VIDEO_METAL
#ifdef SDL_VIDEO_METAL
device->Metal_CreateView = Cocoa_Metal_CreateView;
device->Metal_DestroyView = Cocoa_Metal_DestroyView;
device->Metal_GetLayer = Cocoa_Metal_GetLayer;
@ -179,7 +180,8 @@ static SDL_VideoDevice *Cocoa_CreateDevice(void)
VideoBootStrap COCOA_bootstrap = {
"cocoa", "SDL Cocoa video driver",
Cocoa_CreateDevice
Cocoa_CreateDevice,
Cocoa_ShowMessageBox
};

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -33,7 +33,7 @@
#include "../SDL_vulkan_internal.h"
#include "../SDL_sysvideo.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA)
int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path);
void Cocoa_Vulkan_UnloadLibrary(_THIS);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -25,7 +25,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA)
#include "SDL_cocoavideo.h"
#include "SDL_cocoawindow.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -25,7 +25,7 @@
#import <Cocoa/Cocoa.h>
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
#include "../SDL_egl_c.h"
#endif
@ -54,6 +54,7 @@ typedef enum
NSInteger focusClickPending;
int pendingWindowWarpX, pendingWindowWarpY;
BOOL isDragAreaRunning;
NSTimer *liveResizeTimer;
}
-(BOOL) isTouchFromTrackpad:(NSEvent *)theEvent;
@ -77,6 +78,9 @@ typedef enum
/* Window delegate functionality */
-(BOOL) windowShouldClose:(id) sender;
-(void) windowDidExpose:(NSNotification *) aNotification;
-(void) onLiveResizeTimerFire:(id) sender;
-(void) windowWillStartLiveResize:(NSNotification *)aNotification;
-(void) windowDidEndLiveResize:(NSNotification *)aNotification;
-(void) windowDidMove:(NSNotification *) aNotification;
-(void) windowDidResize:(NSNotification *) aNotification;
-(void) windowDidMiniaturize:(NSNotification *) aNotification;
@ -132,7 +136,7 @@ typedef enum
@property (nonatomic) NSInteger flash_request;
@property (nonatomic) Cocoa_WindowListener *listener;
@property (nonatomic) SDL_VideoData *videodata;
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
@property (nonatomic) EGLSurface egl_surface;
#endif
@end

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_COCOA
#ifdef SDL_VIDEO_DRIVER_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
# error SDL for Mac OS X must be built with a 10.7 SDK or above.
@ -260,7 +260,7 @@ static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r)
static void ScheduleContextUpdates(SDL_WindowData *data)
{
/* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */
#if SDL_VIDEO_OPENGL
#ifdef SDL_VIDEO_OPENGL
#ifdef __clang__
#pragma clang diagnostic push
@ -460,6 +460,17 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
}
}
static NSCursor *Cocoa_GetDesiredCursor(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) {
return (__bridge NSCursor *)mouse->cur_cursor->driverdata;
}
return [NSCursor invisibleCursor];
}
@implementation Cocoa_WindowListener
@ -479,11 +490,14 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
isMoving = NO;
isDragAreaRunning = NO;
pendingWindowWarpX = pendingWindowWarpY = INT_MAX;
liveResizeTimer = nil;
center = [NSNotificationCenter defaultCenter];
if ([window delegate] != nil) {
[center addObserver:self selector:@selector(windowDidExpose:) name:NSWindowDidExposeNotification object:window];
[center addObserver:self selector:@selector(windowWillStartLiveResize:) name:NSWindowWillStartLiveResizeNotification object:window];
[center addObserver:self selector:@selector(windowDidEndLiveResize:) name:NSWindowDidEndLiveResizeNotification object:window];
[center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:window];
[center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:window];
[center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:window];
@ -617,6 +631,8 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
if ([window delegate] != self) {
[center removeObserver:self name:NSWindowDidExposeNotification object:window];
[center removeObserver:self name:NSWindowWillStartLiveResizeNotification object:window];
[center removeObserver:self name:NSWindowDidEndLiveResizeNotification object:window];
[center removeObserver:self name:NSWindowDidMoveNotification object:window];
[center removeObserver:self name:NSWindowDidResizeNotification object:window];
[center removeObserver:self name:NSWindowDidMiniaturizeNotification object:window];
@ -727,6 +743,36 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
SDL_SendWindowEvent(_data.window, SDL_WINDOWEVENT_EXPOSED, 0, 0);
}
- (void)onLiveResizeTimerFire:(id)sender
{
SDL_OnWindowLiveResizeUpdate(_data.window);
}
- (void)windowWillStartLiveResize:(NSNotification *)aNotification
{
// We'll try to maintain 60 FPS during live resizing
const NSTimeInterval interval = 1.0 / 60.0;
NSMethodSignature *invocationSig = [Cocoa_WindowListener
instanceMethodSignatureForSelector:@selector(onLiveResizeTimerFire:)];
NSInvocation *invocation = [NSInvocation
invocationWithMethodSignature:invocationSig];
[invocation setTarget:self];
[invocation setSelector:@selector(onLiveResizeTimerFire:)];
liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval
invocation:invocation
repeats:TRUE];
[[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes];
}
- (void)windowDidEndLiveResize:(NSNotification *)aNotification
{
[liveResizeTimer invalidate];
liveResizeTimer = nil;
}
- (void)windowWillMove:(NSNotification *)aNotification
{
if ([_data.nswindow isKindOfClass:[SDLWindow class]]) {
@ -922,11 +968,13 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window)
- (void)windowDidChangeScreen:(NSNotification *)aNotification
{
/*printf("WINDOWDIDCHANGESCREEN\n");*/
#ifdef SDL_VIDEO_OPENGL
if (_data && _data.nscontexts) {
for (SDLOpenGLContext *context in _data.nscontexts) {
[context movedToNewScreen];
}
}
#endif /* SDL_VIDEO_OPENGL */
}
- (void)windowWillEnterFullScreen:(NSNotification *)aNotification
@ -1323,6 +1371,7 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
NSPoint point;
int x, y;
SDL_Window *window;
NSView *contentView;
if (!mouse) {
return;
@ -1330,6 +1379,17 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
mouseID = mouse->mouseID;
window = _data.window;
contentView = _data.sdlContentView;
point = [theEvent locationInWindow];
if ([contentView mouse:[contentView convertPoint:point fromView:nil] inRect:[contentView bounds]] &&
[NSCursor currentCursor] != Cocoa_GetDesiredCursor()) {
// The wrong cursor is on screen, fix it. This fixes an macOS bug that is only known to
// occur in fullscreen windows on the built-in displays of newer MacBooks with camera
// notches. When the mouse is moved near the top of such a window (within about 44 units)
// and then moved back down, the cursor rects aren't respected.
[_data.nswindow invalidateCursorRectsForView:contentView];
}
if ([self processHitTest:theEvent]) {
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0);
@ -1340,7 +1400,6 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
return;
}
point = [theEvent locationInWindow];
x = (int)point.x;
y = (int)(window->h - point.y);
@ -1590,17 +1649,9 @@ static int Cocoa_SendMouseButtonClicks(SDL_Mouse * mouse, NSEvent *theEvent, SDL
- (void)resetCursorRects
{
SDL_Mouse *mouse;
[super resetCursorRects];
mouse = SDL_GetMouse();
if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) {
[self addCursorRect:[self bounds]
cursor:(__bridge NSCursor *)mouse->cur_cursor->driverdata];
} else {
[self addCursorRect:[self bounds]
cursor:[NSCursor invisibleCursor]];
}
[self addCursorRect:[self bounds]
cursor:Cocoa_GetDesiredCursor()];
}
- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
@ -1788,8 +1839,8 @@ int Cocoa_CreateWindow(_THIS, SDL_Window * window)
#pragma clang diagnostic pop
#endif
#if SDL_VIDEO_OPENGL_ES2
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_ES2
#ifdef SDL_VIDEO_OPENGL_EGL
if ((window->flags & SDL_WINDOW_OPENGL) &&
_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
[contentView setWantsLayer:TRUE];
@ -1807,9 +1858,9 @@ int Cocoa_CreateWindow(_THIS, SDL_Window * window)
}
/* The rest of this macro mess is for OpenGL or OpenGL ES windows */
#if SDL_VIDEO_OPENGL_ES2
#ifdef SDL_VIDEO_OPENGL_ES2
if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) {
#if SDL_VIDEO_OPENGL_EGL
#ifdef SDL_VIDEO_OPENGL_EGL
if (Cocoa_GLES_SetupWindow(_this, window) < 0) {
Cocoa_DestroyWindow(_this, window);
return -1;
@ -2332,7 +2383,10 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
SDL_WindowData *data = (SDL_WindowData *) CFBridgingRelease(window->driverdata);
if (data) {
#ifdef SDL_VIDEO_OPENGL
NSArray *contexts;
#endif
if ([data.listener isInFullscreenSpace]) {
[NSMenu setMenuBarVisible:YES];
}
@ -2344,15 +2398,13 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window)
[data.nswindow close];
}
#if SDL_VIDEO_OPENGL
#ifdef SDL_VIDEO_OPENGL
contexts = [data.nscontexts copy];
for (SDLOpenGLContext *context in contexts) {
/* Calling setWindow:NULL causes the context to remove itself from the context list. */
[context setWindow:NULL];
}
#endif /* SDL_VIDEO_OPENGL */
#endif /* SDL_VIDEO_OPENGL */
if (window->shaper) {
CFBridgingRelease(window->shaper->driverdata);

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_window.h"
@ -79,13 +79,13 @@ static void LoadFont(_THIS, SDL_Window * window)
SDL_DFB_DEVICEDATA(_this);
SDL_DFB_WINDOWDATA(window);
if (windata->font != NULL) {
if (windata->font) {
SDL_DFB_RELEASE(windata->font);
windata->font = NULL;
SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font));
}
if (windata->theme.font != NULL)
if (windata->theme.font)
{
DFBFontDescription fdesc;
@ -317,7 +317,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
SDL_FALLTHROUGH;
default:
windata->wm_grab = pos;
if (grabbed_window != NULL)
if (grabbed_window)
DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE);
DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE);
windata->wm_lastx = evt->cx;
@ -350,7 +350,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
}
}
DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE);
if (grabbed_window != NULL)
if (grabbed_window)
DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE);
windata->wm_grab = WM_POS_NONE;
return 1;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_dyn.h"
@ -93,7 +93,7 @@ int SDL_DirectFB_LoadLibrary(void)
void SDL_DirectFB_UnLoadLibrary(void)
{
if (handle != NULL) {
if (handle) {
SDL_UnloadObject(handle);
handle = NULL;
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
/* Handle the event stream, converting DirectFB input events into SDL events */
@ -308,7 +308,7 @@ static void ProcessInputEvent(_THIS, DFBInputEvent * ievt)
if (!devdata->use_linux_input) {
if (ievt->type == DIET_AXISMOTION) {
if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) {
if ((grabbed_window) && (ievt->flags & DIEF_AXISREL)) {
if (ievt->axis == DIAI_X)
SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1,
ievt->axisrel, 0, 0);
@ -405,7 +405,7 @@ void DirectFB_PumpEventsWindow(_THIS)
DFBInputEvent ievt;
SDL_Window *w;
for (w = devdata->firstwin; w != NULL; w = w->next) {
for (w = devdata->firstwin; w; w = w->next) {
SDL_DFB_WINDOWDATA(w);
DFBWindowEvent evt;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_modes.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,11 +20,11 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
#include "SDL_DirectFB_opengl.h"
#include "SDL_DirectFB_window.h"
@ -33,7 +33,7 @@
#include "SDL_loadso.h"
#endif
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
struct SDL_GLDriverData
{
@ -113,15 +113,15 @@ int DirectFB_GL_LoadLibrary(_THIS, const char *path)
}
if (path == NULL) {
if (!path) {
path = SDL_getenv("SDL_OPENGL_LIBRARY");
if (path == NULL) {
if (!path) {
path = "libGL.so.1";
}
}
handle = GL_LoadObject(path);
if (handle == NULL) {
if (!handle) {
SDL_DFB_ERR("Library not found: %s\n", path);
/* SDL_LoadObject() will call SDL_SetError() for us. */
return -1;
@ -210,7 +210,7 @@ int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
}
if (ctx != NULL) {
if (ctx) {
SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context));
ctx->is_locked = 1;
}
@ -242,7 +242,7 @@ int DirectFB_GL_SwapWindow(_THIS, SDL_Window * window)
devdata->glFlush();
#endif
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
for (p = _this->gl_data->firstgl; p; p = p->next)
if (p->sdl_window == window && p->is_locked)
{
SDL_DFB_CHECKERR(p->context->Unlock(p->context));
@ -278,7 +278,7 @@ void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
for (p = _this->gl_data->firstgl; p; p = p->next)
if (p->sdl_window == window)
{
if (p->is_locked)
@ -291,7 +291,7 @@ void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
for (p = _this->gl_data->firstgl; p; p = p->next)
if (p->sdl_window == window)
{
SDL_DFB_WINDOWDATA(window);
@ -306,7 +306,7 @@ void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window)
{
DirectFB_GLContext *p;
for (p = _this->gl_data->firstgl; p != NULL; p = p->next)
for (p = _this->gl_data->firstgl; p; p = p->next)
if (p->sdl_window == window)
DirectFB_GL_DeleteContext(_this, p);
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -25,7 +25,7 @@
#include "SDL_DirectFB_video.h"
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
#include "SDL_opengl.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_window.h"
#include "SDL_DirectFB_modes.h"
@ -561,7 +561,7 @@ static void DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * textur
}
}
static void DirectFB_SetTextureScaleMode()
static void DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode)
{
}

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
#include "SDL_DirectFB_video.h"
#include "SDL_DirectFB_shape.h"
@ -76,7 +76,7 @@ int DirectFB_ResizeWindowShape(SDL_Window* window)
int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode)
{
if(shaper == NULL || shape == NULL || shaper->driverdata == NULL)
if(!shaper || !shape || !shaper->driverdata)
return -1;
if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode))
return -2;

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
#if SDL_VIDEO_DRIVER_DIRECTFB
#ifdef SDL_VIDEO_DRIVER_DIRECTFB
/*
* #include "SDL_DirectFB_keyboard.h"
@ -65,7 +65,8 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void);
VideoBootStrap DirectFB_bootstrap = {
"directfb", "DirectFB",
DirectFB_CreateDevice
DirectFB_CreateDevice,
NULL /* no ShowMessageBox implementation */
};
static const DirectFBSurfaceDrawingFlagsNames(drawing_flags);
@ -118,7 +119,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void)
/* !!! FIXME: implement SetWindowBordered */
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
device->GL_LoadLibrary = DirectFB_GL_LoadLibrary;
device->GL_GetProcAddress = DirectFB_GL_GetProcAddress;
device->GL_MakeCurrent = DirectFB_GL_MakeCurrent;
@ -136,7 +137,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void)
device->shape_driver.SetWindowShape = DirectFB_SetWindowShape;
device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape;
#if SDL_VIDEO_VULKAN
#ifdef SDL_VIDEO_VULKAN
device->Vulkan_LoadLibrary = DirectFB_Vulkan_LoadLibrary;
device->Vulkan_UnloadLibrary = DirectFB_Vulkan_UnloadLibrary;
device->Vulkan_GetInstanceExtensions = DirectFB_Vulkan_GetInstanceExtensions;
@ -262,7 +263,7 @@ static int DirectFB_VideoInit(_THIS)
DirectFB_InitModes(_this);
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
DirectFB_GL_Initialize(_this);
#endif
@ -290,7 +291,7 @@ static void DirectFB_VideoQuit(_THIS)
SDL_DFB_RELEASE(devdata->events);
SDL_DFB_RELEASE(devdata->dfb);
#if SDL_DIRECTFB_OPENGL
#ifdef SDL_DIRECTFB_OPENGL
DirectFB_GL_Shutdown(_this);
#endif

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -21,7 +21,7 @@
#include "../../SDL_internal.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_DIRECTFB
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_DIRECTFB)
#include "SDL_DirectFB_window.h"

View file

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
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
@ -27,7 +27,7 @@
#include "../SDL_vulkan_internal.h"
#include "../SDL_sysvideo.h"
#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_DIRECTFB
#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_DIRECTFB)
int DirectFB_Vulkan_LoadLibrary(_THIS, const char *path);
void DirectFB_Vulkan_UnloadLibrary(_THIS);

Some files were not shown because too many files have changed in this diff Show more