Commit Graph

1910 Commits

Author SHA1 Message Date
Sam Lantinga
8830b466d0 Improve handling of surfaces with NULL pixels
Fixes https://github.com/libsdl-org/SDL/issues/14059
2025-10-08 12:40:29 -07:00
Sam Lantinga
244ae39b30 Optimized the 16-bit -> 32-bit SSE pixel conversion
Test code:
---
int main( int argc, char *argv[] )
{
    SDL_Surface *orig = SDL_LoadPNG("testyuv.png");
    SDL_Surface *surf16 = SDL_ConvertSurface(orig, SDL_PIXELFORMAT_RGB565);
    SDL_Surface *surf32 = SDL_ConvertSurface(surf16, SDL_PIXELFORMAT_ARGB8888);

    Uint64 then = SDL_GetTicks();
    for (int i = 0; i < 100000; ++i) {
        SDL_BlitSurface(surf16, NULL, surf32, NULL);
    }
    Uint64 now = SDL_GetTicks();
    SDL_Log("Blit took %d ms\n", (int)(now - then));
    return 0;
}
---

Results on my system:
BlitNtoN: Blit took 34522 ms
Blit_RGB565_32 (3 LUT): Blit took 9316 ms
Blit_RGB565_32 (1 LUT): Blit took 5268 ms
Blit_RGB565_32_SSE41: Blit took 1619 ms
2025-10-07 16:31:14 -07:00
Sam Lantinga
dbd5dd8c75 Ensure 16-bit -> 32-bit conversion is consistent between blitters
The SSE, LUT, and other blitters should have the same results for 16-bit -> 32-bit conversion
2025-10-07 16:31:14 -07:00
Cameron Cawley
2c79ecfb8a Use texture palettes with testoverlay 2025-10-07 11:12:31 -07:00
Cameron Cawley
0f62b7c3b4 Remove teststreaming 2025-10-07 11:12:31 -07:00
Sam Lantinga
9f9be1425d Fixed permissions 2025-10-06 17:24:56 -07:00
Sam Lantinga
bb0d6221c1 Use PNG files for tests and examples
These are much smaller than the previous BMP files

Fixes https://github.com/libsdl-org/SDL/issues/14159
2025-10-06 16:45:53 -07:00
Sam Lantinga
73334b6bb4 Added support for loading and saving PNG images using stb_image 2025-10-06 16:45:53 -07:00
nmlgc
8df057fafc iostream: Properly support the "x" mode for SDL_IOFromFile()
The "x" mode for `fopen()` (open file only if it doesn't exist) used to
be a glibc-exclusive extension, but was later standardized in C11, and
is now also implemented as part of every other widely-used libc:

	* musl: https://git.musl-libc.org/cgit/musl/tree/src/stdio/__fmodeflags.c?id=0ccaf0572e9cccda2cced0f7ee659af4c1c6679a
	* Android Bionic / OpenBSD: 731631f300/libc/upstream-openbsd/lib/libc/stdio/flags.c (86)
	* Apple / FreeBSD: 63976b830a/stdio/FreeBSD/flags.c (L91-L92)

As a result, "x" has already been working on all our automatically
tested platforms that implement `SDL_IOFromFile()` via `fopen()`. So
all we'd be missing for proper support is a Windows implementation
using `CREATE_NEW`, and the documentation that this mode exists and is
intended to work.
2025-10-06 13:23:42 -07:00
Sam Lantinga
134b47730b Added support for linear and pixel art scaling for palettized textures 2025-10-04 15:12:08 -07:00
eafton
c2429e85ec X11TK: Add Arabic/Hebrew/Farsi support by increasing font size slightly and using FriBidi. (#14134) 2025-10-03 19:08:24 -07:00
Sam Lantinga
49d51a0d3c Removed TEXTURETYPE_PALETTE_PIXELART
This doesn't make any sense since the pixel art algorithm uses a box filter to get an average pixel value which isn't possible with indexed textures.
2025-10-03 18:54:07 -07:00
nmlgc
8824eace93 testautomation: Test SDL_snprintf() for doubles >LLONG_MAX and <ULLONG_MAX
The uclibc version of SDL_snprintf() is currently limited to values
<ULLONG_MAX due to the `unsigned long long` cast in SDL_PrintFloat(),
but it makes sense to at least ensure that it does support the full
unsigned 64-bit range. This also covers the one defined case where a
32-bit MSVC build can't assume that _ftoul2_legacy() == _ftol2().
2025-10-03 07:21:20 -07:00
Sam Lantinga
a864dcac25 Added support for using the GPU renderer as an offscreen renderer
SDL_CreateGPURenderer() now allows passing in an existing GPU device and passing in a NULL window to create an offscreen renderer.

Also renamed SDL_SetRenderGPUState() to SDL_SetGPURenderState().
2025-10-01 23:32:18 -07:00
Sam Lantinga
fe3b399b7e Added support for P010 pixel format in SDL_UpdateNVTexture() 2025-10-01 07:17:55 -07:00
Sam Lantinga
224b4917a3 testpalette: added a --renderer command line option 2025-10-01 07:17:55 -07:00
Anonymous Maarten
fd4c2f8cfd ci: build testffmpeg on MinGW (msys2) build bots 2025-09-30 17:42:11 +02:00
Simon McVittie
c81b4e8493 test: Space-separate arguments in as-installed tests' .test files
The "as-installed" tests have metadata files in the .desktop-like format
used by gnome-desktop-testing, which uses a subset of shell syntax for
the Exec field. The list of arguments is represented as a
semicolon-separated list by CMake, but we need to convert that into a
space-separated list for the Exec field.

Strictly speaking we should be quoting the arguments with the equivalent
of Python's shlex.quote, but I couldn't find a way to do that in CMake,
and currently none of the tests have arguments that need quoting.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2025-09-30 15:58:49 +02:00
Sam Lantinga
7dcc09986d Test changing the palette for a single texture 2025-09-28 22:10:06 -07:00
Sam Lantinga
264b436dba Fixed changing palettes while rendering is in flight 2025-09-28 22:10:06 -07:00
Sam Lantinga
0b4b254a53 Added support for textures with palettes
Closes https://github.com/libsdl-org/SDL/pull/6192
2025-09-28 22:10:06 -07:00
ProgramGamer
2c8c2d72b5 Allow in-memory IOStreams to be of length 0 (#13840) 2025-09-27 09:36:30 -07:00
Anonymous Maarten
9f721e8a9c Add test that verifies all SDL3 symbols are available 2025-09-26 21:42:04 +02:00
Sam Lantinga
1d2a482dde testgpurender_effects: use the grayscale algorithm from BT.709 2025-09-26 10:27:10 -07:00
eafton
f3a9f66292 Add more Unicode tests to testmessage, improve fallback fonts in X11TK (#14042) 2025-09-24 14:23:27 -07:00
Sam Lantinga
fe8c080713 testime: allow enabling/disabling text input on individual windows 2025-09-23 09:59:11 -07:00
Sam Lantinga
6f3ef22d19 Fixed build warning 2025-09-22 11:27:23 -07:00
Sam Lantinga
8a67a8a319 testautomation: fixed video tests on iOS 2025-09-22 10:09:30 -07:00
Sam Lantinga
5d9b9673b9 testautomation: use SDL functions for iostream test setup
This fixes the IOStream tests on iOS, since the current directory isn't writable
2025-09-22 10:09:30 -07:00
Sam Lantinga
c8f32b67ae testautomation: use the correct return type for clipboard APIs 2025-09-21 23:27:59 -07:00
Sam Lantinga
a5b070ba2d Skip render_testLogicalSize() if we didn't get a window of the expected size
We rely on that to validate the results of SDL_GetRenderLogicalPresentationRect()
2025-09-21 20:25:10 -07:00
Sam Lantinga
26dd4e3abb Fixed filesystem operations on Android
Full paths are used as-is, relative paths are prepended with SDL_GetAndroidInternalStoragePath(), and operations fall back to the asset system as appropriate.

This is consistent with the behavior of opening files on Android.
2025-09-21 18:23:34 -07:00
Sam Lantinga
005f10bd97 testautomation: fix video tests on Android
Like emscripten, window positioning and sizing is not supported on Android.
2025-09-21 16:25:51 -07:00
Sam Lantinga
400489c157 testcontroller: fixed memory leak 2025-09-20 18:21:26 -07:00
Frank Praznik
ac82534375 tests: Flush events after an SDL_WaitEvent() call
SDL_WaitEvent() will pump OS events if no poll sentinel is pending, so flush events before inserting a user event to ensure that the user event will be next in the queue.
2025-09-19 12:36:59 -04:00
Anonymous Maarten
7501f7194b testsprite: zero initialize textures
LoadSprite destroys current textures before allocating new ones.
So make sure the previous (=first) textures are valid.
2025-09-19 15:37:21 +02:00
Anonymous Maarten
b1b98b10d8 cmake: also install wasm debug map (optional) 2025-09-18 17:18:25 +02:00
Anonymous Maarten
447df411e6 cmake: install javascript and wasm of Emscripten tests 2025-09-18 05:28:22 +02:00
Sam Lantinga
937b7e6aea Fixed testprocess on 32-bit Windows
Previously the test would kill the child process while it was in the process of initializing (loading DLLs, etc) and this would cause the test to fail.
2025-09-14 15:09:07 -07:00
nightmareci
2f5bc17ea6 Fix support for Windows XP and up (#13904) 2025-09-08 13:00:26 -07:00
Sam Lantinga
9ccdaa49f4 Removed reference to icon-alpha.bmp
This file was never added, and I believe this just had a 50% alpha channel added to the standard icon.bmp

Fixes https://github.com/libsdl-org/SDL/issues/13394
2025-09-07 12:54:14 -07:00
Sam Lantinga
cd6b68a9fb Define the behavior of a negative width or height passed to SDL_RenderFillRect()
The software renderer now matches the 3D renderer behavior by rendering a reversed rectangle (extending width or height in the opposite direction) when width or height is negative. It also now renders no rectangle if the width and height are 0.

Fixes https://github.com/libsdl-org/SDL/issues/13400
2025-09-07 12:28:37 -07:00
Sam Lantinga
2304047c95 testyuv: enable testing planar YUV texture update functions 2025-09-07 10:19:00 -07:00
Sam Lantinga
a9b5a1e785 Simplified the transparent software renderer test 2025-09-04 10:31:22 -07:00
Sam Lantinga
f48c20f481 Added testsoftwaretransparent to the CMake build system 2025-09-04 09:25:05 -07:00
Qiang
f2d2cd8152 fix: Blending rendering anomaly when using the software renderer with SDL_WINDOW_TRANSPARENT on Windows. (#13866) 2025-09-04 07:41:45 -07:00
Sam Lantinga
ea1a769322 Fixed the perspective matrix calculation (thanks @KonkolyTamas!)
Fixes https://github.com/libsdl-org/SDL/issues/13867
2025-09-04 06:04:01 -07:00
Sylvain
b084999d40 testautomation_events: initialize variable to prevent undefined read 2025-09-03 10:15:01 +02:00
Sam Lantinga
285df94623 Renamed SDL_GPURenderStateDesc to SDL_GPURenderStateCreateInfo for consistency with GPU API conventions
Fixes https://github.com/libsdl-org/SDL/issues/12817
2025-08-27 09:14:19 -07:00
Sylvain
26d6352500 Fixed bug #13794: prevent to use the onBackPressed callback API that is enabled on API36 2025-08-27 11:39:00 +02:00