Compare commits

..
112 Commits
Author SHA1 Message Date
Sam Lantinga 4478ad67d2 Lock joysticks when they are connected/disconnected on emscripten
Fixes https://github.com/libsdl-org/SDL/issues/11499

(cherry picked from commit 0281071243)
(cherry picked from commit d9836d15e7)
2025-12-08 21:01:47 -08:00
Cameron Gutman 667e4e9020 egl: Fix X11 EGL window creation on Nvidia
This is a port of 808a3f5 to SDL2.

Fixes #13094

(cherry picked from commit 3146374e4a)
2025-12-05 23:20:45 -06:00
Ozkan Sezer 2430122b21 alsa: fix signature of snd_pcm_hw_params_get_rate()
Reference issue: https://github.com/libsdl-org/SDL/issues/13845.
2025-12-03 21:40:32 +03:00
Joshua Root 18c96e27d2 Guard use of @available in SDL_cocoaevents.m
Older compilers don't understand this syntax.

(cherry picked from commit eb974470ec)
2025-12-03 10:04:26 -05:00
vanfanel 0dcfa78be6 SDL2: Fill the SDL_AudioSpec in add_device()
(cherry picked from commit 34691de22b)
2025-12-03 10:02:20 -05:00
Cameron Gutman c636332031 quit: don't call signal() if we're using sigaction()
At best, this is a no-op.

At worst, it might:
 - Clobber a signal handler someone registered after us
 - Overwrite the signal mask or flags
 - Cause unregistration to fail (sigaction() isn't guaranteed to return the exact pointer passed to signal())

(cherry picked from commit 1d852d1c28)
2025-12-01 19:46:00 -06:00
Sam Lantinga 385e995790 Check for wine_get_version() to detect Wine/Proton
If this application is being run under Wine but Steam doesn't know that, Steam won't set STEAM_COMPAT_PROTON. So we'll use wine_get_version() to detect that we're running under Wine instead.

(cherry picked from commit e2e8f86076)
(cherry picked from commit f36d683b61)
2025-11-12 23:09:35 -08:00
Sam Lantinga a069ac41e5 Don't check SteamVirtualGamepadInfo when running as Wine
Wine will ignore the Steam Virtual Gamepad if it looks like it has the original (blocked) controller VID/PID.

Fixes https://github.com/libsdl-org/SDL/issues/14410

(cherry picked from commit 493bc621e4)
(cherry picked from commit 5bdf7bc625)
2025-11-12 23:09:35 -08:00
Ozkan Sezer dc086d6454 Revert "pipewire: disable -Wdeclaration-after-statement for pipewire headers"
This reverts commit 876baf6b0e.

Issue in pipewire release candidate 1.5.81 has been resolved in 1.5.82

Reference issue: Fixes: https://github.com/libsdl-org/SDL/issues/14343
2025-11-06 19:55:55 +03:00
yuanhecai 1acc405bd4 loongarch: add SDL_FillRect4LSX opt
(cherry picked from commit 14eebdab3c)
2025-11-06 07:29:07 -08:00
yuanhecai a07b00ccb0 loongarch: add BlitRGBtoRGBPixelAlphaLSX opt
(cherry picked from commit 686c18026b)
2025-11-06 07:29:07 -08:00
Sam Lantinga e458305c43 Clamp the audio drain delay to 100 ms
Fixes https://github.com/libsdl-org/SDL/issues/9829

(cherry picked from commit 0882623092)
(cherry picked from commit 6db23faa44)
2025-11-02 11:20:55 -08:00
Sam Lantinga 3ff58bf062 Don't consider USB devices which have already been skipped
Fixes https://github.com/libsdl-org/SDL/issues/14367

(cherry picked from commit 6570d9e23f)
2025-11-02 09:25:43 -08:00
Sam Lantinga 7eb78c5070 Fixed the right touchpad calculation for the BLE Steam Controller
Fixes https://github.com/libsdl-org/SDL/issues/14368

(cherry picked from commit eb87a36940)
(cherry picked from commit 2bb0eb4641)
2025-11-02 08:34:41 -08:00
Petar Popovic 6e5cad8e1e Fix leak in SDL_GameControllerTypeForIndex()
(cherry picked from commit 398bacbac3)
2025-11-01 08:40:37 -07:00
Ozkan Sezer 876baf6b0e pipewire: disable -Wdeclaration-after-statement for pipewire headers
Fixes: https://github.com/libsdl-org/SDL/issues/14343

(cherry picked from commit f9435eab16)
2025-11-01 00:45:32 +03:00
Ozkan Sezer c0d0b31d1c SDL_kmsdrmvideo.c: fix build in C90 mode
(cherry picked from commit 00d4f1c2c4)
2025-10-26 04:35:40 +03:00
Sam Lantinga 80cbc908a1 Perform full rectangle intersection for empty rects
If we don't do that, we leave the x and y values uninitialized.

Fixes https://github.com/libsdl-org/sdl12-compat/issues/365

(cherry picked from commit ffd0ca4391)
(cherry picked from commit 1c19bee000)
2025-10-25 13:52:34 -07:00
Frank Praznik 735d8a2dc8 wayland: Special-case relative warp mode to deliver accelerated relative motion
The Wayland backend lacks pointer warp functionality, so special-case the relative warp mode hint to deliver accelerated relative motion deltas, which is ultimately what the client wants by enabling this hint.

(cherry picked from commit 235e4870af)
2025-10-09 11:29:12 -04:00
AL2009man bc67702d8d Disable SDL_HINT_JOYSTICK_RAWINPUT by default
backported from SDL3 commit aa870d5

 Fixes #13047

(cherry picked from commit 8ef0a07a52)
2025-10-08 11:35:46 -07:00
Ozkan Sezer 40625e9e7e ci: bump cross-platform-actions.
(cherry-picked from commit 97c1df66a8)
2025-10-07 14:28:50 +03:00
Brad Smith a5f445dba1 Use elf_aux_info() on OpenBSD
NFC for ARMv7. For PowerPC move elf_aux_info() to higher priority over
sysctl for newer systems.

(cherry picked from commit b299e0de46)
(cherry picked from commit 641201a99a)
2025-09-27 09:01:58 -07:00
Fierelier f172ee3d0e [SDL3] [PS2] Framebuffer resolution + 240p/480p + PAL support (#13993)
* Do not override NTSC/PAL

* Fix PS2 build instructions

* Add PS2 GS hints
Allows for switching between NTSC/PAL, progressive/interlaced, etc

(cherry picked from commit 3fd0b46215)
(cherry picked from commit 7b28fb29bd)
2025-09-26 08:26:29 -07:00
Sam Lantinga 7fe49da380 Removed UWP workflow from CI
The GitHub runners no longer have the needed SDK for this

(cherry picked from commit ecb72142fd)
2025-09-19 08:34:09 -07:00
krnl32 0efcafc74d Added a default case to the switch statement in the HEADER FILE to prevent compiler warnings about missing defaults. This change helps avoid compilation breaks when warnings are treated as errors.
(cherry picked from commit 9859c05178)
2025-09-16 17:17:42 -07:00
Ozkan Sezer dcc72b43ba fix build.
(cherry picked from commit 07c3b3fb7c)
2025-09-15 20:30:20 +03:00
Ozkan Sezer b8430e4135 SDL_endian.h: don't add _m_prefetch hack for clang-cl if available as a builtin
Fixes: https://github.com/libsdl-org/SDL/issues/13952 .

(backport from SDL3 commit 81f2f44843)
(cherry picked from commit 9343246616)
2025-09-15 20:11:10 +03:00
Sam Lantinga 394d9bfa1a Remove Windows 32-bit ARM build from CI
This architecture is deprecated and is now failing with:
Windows SDK 10.0.22621.0 : 'C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um' not found or was incomplete

Fixes https://github.com/libsdl-org/SDL/issues/13949

(cherry picked from commit cc3274b6f1)
(cherry picked from commit b55059b487)
2025-09-14 18:03:32 -07:00
Sam Lantinga ecc71c02ea Only use a transparent cursor on Windows when connected via RDP
VMware relies on the cursor being set to NULL to optimize relative mouse motion for games.

We should also revisit whether current RDP works better with a NULL cursor or a transparent cursor.

Fixes https://github.com/libsdl-org/SDL/issues/13700

(cherry picked from commit dac6af4ba6)
(cherry picked from commit 55b599d693)
2025-09-14 17:32:38 -07:00
Gianfranco Berardi 60515350ae Provide Android targetsdk 35 support in SDL2 (#13776)
(cherry picked from commit be6ab7f9a6)
2025-09-13 07:19:52 -07:00
Ozkan Sezer 05c9b16183 alsa: fix signature of snd_pcm_info_free
Reference issue: https://github.com/libsdl-org/SDL/issues/13845.
2025-09-02 17:02:28 +03:00
Sam Lantinga 2db8436d8c Updated to version 2.32.11 for development 2025-09-01 15:12:02 -07:00
Sam Lantinga 5d24957039 Updated to version 2.32.10 for release 2025-09-01 14:33:27 -07:00
Ozkan Sezer fd5dcfba03 openslES: really fix build..
(cherry picked from commit d2ab01b8bb)
2025-09-01 20:38:56 +03:00
Ozkan Sezer 5806036c68 openslES: fix build
(cherry picked from commit f5246d0181)
2025-09-01 20:25:50 +03:00
Ryan C. Gordon 9f369a1736 openslES: OpenSL ES on Android only supports two formats, limit to that.
(Three with the floating point extension, which we use.)

This is according to:

https://developer.android.com/ndk/guides/audio/opensl/opensl-for-android

Previously, this would accept a request for Sint8 or Sint32 and disaster
would ensue.

Fixes #13779.

(cherry picked from commit 0b2a003a35)
(cherry picked from commit 7323104f97)
(cherry picked from commit b8c802632b)
2025-09-01 11:38:54 -04:00
Ozkan Sezer 1f6e0e3a23 regenerate configure script. 2025-08-31 20:20:50 +03:00
Gleb Mazovetskiy c8e984701e configure.ac: Fix AC_DEFINE HAVE_LIBUSB
Fixes an error with autoconf 2.72

(cherry picked from commit 5ed21d1ccb)
2025-08-31 09:38:27 -07:00
Ozkan Sezer 2a506c8778 SDL_hidapi.c: fix -Wundef failures due to HAVE_DRIVER_BACKEND check
(cherry picked from commit 7a34e14c8e)
2025-08-30 15:47:40 +03:00
Ozkan Sezer a455f023c2 CI: add OpenBSD workflow
(backported from commit c0e5fd55d2)
(cherry picked from commit 1a8e667f3d)
2025-08-30 15:47:20 +03:00
Frank Praznik 2a10b8c4e7 wayland: Add a sigtimedwait() implementation for OpenBSD
sigtimedwait() is an optional part of POSIX.1-2001, and OpenBSD doesn't implement it. Add a replacement implementation based on https://comp.unix.programmer.narkive.com/rEDH0sPT/sigtimedwait-implementation

(backported from commit 1049426a76)
(cherry picked from commit d31d98d436)
2025-08-30 15:47:00 +03:00
Ozkan Sezer f610a3d66b update config.guess and config.sub from git://git.sv.gnu.org/config.git
(cherry picked from commit 56d43ee296)
2025-08-28 11:25:30 +03:00
Sam Lantinga 54772f345a Support the "ambient" value for SDL_HINT_AUDIO_CATEGORY
Fixes https://github.com/libsdl-org/SDL/issues/13732

(cherry picked from commit 4725213eef)
(cherry picked from commit 5e85a29e75)
2025-08-12 09:55:27 -07:00
Sam Lantinga e257904eb3 Revert "autotools, android: Support Google Play 16 KB Page Size Requirement"
This reverts commit 9f1cc301a7.

If you need to support the Google Play 16 kiB page size requirement, the recommendation is to use NDK r28c or newer, which automatically aligns binaries correctly.
2025-08-07 11:37:57 -07:00
Sam Lantinga cc7a73e727 Revert "Support Google Play 16 KB Page Size Requirement (#13470)"
This reverts commit e321995244.

If you need to support the Google Play 16 kiB page size requirement, the recommendation is to use NDK r28c or newer, which automatically aligns binaries correctly.
2025-08-07 11:37:44 -07:00
Ozkan Sezer 9f1cc301a7 autotools, android: Support Google Play 16 KB Page Size Requirement
autotools port of commit 4b2aa3f102.

cherry picked from commit e7489a0931
2025-08-07 20:10:28 +03:00
Anonymous Maarten e321995244 Support Google Play 16 KB Page Size Requirement (#13470)
- See: https://developer.android.com/guide/practices/page-sizes#update-packaging
- Also, make min API uniform at 21 (from 16 and 23 in a few places)

Manual backport of dc2c83c383

(cherry picked from commit 4b2aa3f102)
2025-08-07 18:11:13 +02:00
Ryan C. Gordon 28e9533d34 SDL_enabled_assert(): Use NULL istead of 0 to explicity initialize the pointer members of SDL_AssertData
(cherry picked from commit 272b073323)
2025-08-03 13:41:13 -04:00
Ryan C. Gordon f9fc36be9e pipewire: Report correct device default formats instead of hardcoding Float32.
The comment in the source wasn't true; PipeWire doesn't _have_ to work in
float format. It presumably does if it has to mix, but if a game is the only
thing making noise on the system--a common scenario--then it might be able to
pass, say, Sint16 data straight through to the hardware without conversion.

Fixes #12129.

(cherry picked from commit afc1d9122b)
2025-07-29 18:23:33 -04:00
Dan Andrus f8119d4760 Check NSWindow::isVisible before sending SDL_WINDOWEVENT_RESTORED during Cocoa_WindowListener::windowDidResize
(cherry picked from commit e610529e84)
2025-07-28 11:59:06 -07:00
Ozkan Sezer 1b35c66aa8 sun audio: remove ifdefs, always include sys/audioio.h and sys/ioctl.h
(cherry picked from commit ead4a032d3)
2025-07-28 17:01:20 +03:00
Ozkan Sezer 553ea4e4ee autotools, cmake: fix the sys/audioio.h checks.
Reference issue: https://github.com/libsdl-org/SDL/issues/13405.
(cherry picked from commit 74df61530f)
2025-07-28 17:01:20 +03:00
Ryan C. Gordon c438953aa2 sunaudio: don't compile in the sun audio backend if sys/audioio.h is missing.
Newer Solaris-based releases, like OpenIndiana, don't include this, using
Open Sound System, or something layered over OSS like PulseAudio, instead.

Fixes #13405.
(cherry picked from commit cf1eb95fb1)
2025-07-28 17:01:20 +03:00
Anonymous Maarten 6e77327789 ci+n3ds: avoid apt-get package manager
- use Unix Makefiles (with parallelization) CMake generator
- use binutils strings binary from devkitpro

( Manual backport of commit e6d200e51c )
( cherry picked from commit b36252b120 )
2025-07-28 00:10:50 +03:00
vanfanel e25c61cda8 SDL2: Add missing symbol loading for SDL_GetDefaultAudioInfo() implementation on ALSA.
(cherry picked from commit 874ca5a678)
2025-07-17 11:15:25 -07:00
vanfanel 28f2944947 SDL2: Implement SDL_GetDefaultAudioInfo() on the ALSA backend.
(cherry picked from commit 8d5984464e)
2025-07-17 11:15:25 -07:00
Yorick Reum ab9f59e59a Xcode-iOS/Demos/src/fireworks.c: Make rendering CPU efficient
(cherry picked from commit 6c9c2a9ac2)
2025-07-12 07:46:36 -07:00
Anonymous Maarten f99f57ffd1 ci: build MSVC release binary on windows-2025
(cherry picked from commit 8605624158)
2025-07-12 13:08:54 +02:00
Ryan C. Gordon 7f371c7808 cocoa: Patched to compile.
(cherry picked from commit b537380065)
2025-07-11 09:56:20 -07:00
Ryan C. Gordon d98087a0c3 cocoa: Don't use trick of briefly focusing the Dock on newer macOS releases.
On newer systems, the trick isn't necessary, and if you do it, if the user is
moving the mouse when launching the app, it'll show a hidden Dock.

Fixes #10340.

(manually backported from SDL3 from commit 279dabfc96)

(cherry picked from commit b2c3e6fade)
2025-07-11 09:56:20 -07:00
Wouter Wijsman 933715fa45 PSP: Truncate thread name when passing to sceKernelCreateThread
(cherry picked from commit 309d1481a4)
2025-07-11 09:56:20 -07:00
Ozkan Sezer 73492c5570 fix ARM64 linkage with Visual Studio >= 17.14 when SDL_LIBC is disabled
Reference issue:  https://github.com/libsdl-org/SDL/issues/13254

(cherry picked from commit 2fb6abb9ad)
2025-07-09 01:25:19 +03:00
evgenydrainov 19fc5c2953 keyboard: Add reference to SDL_Keymod in the comments
(cherry picked from commit 2bc3ec44b1)
2025-06-24 07:37:01 -07:00
Mitch Cairns c2a62ee696 Fixed Nintendo Switch thumbstick calibration
(cherry picked from commit 3a6f9e01f8)
(cherry picked from commit e4475d1868)
2025-06-22 15:29:27 -07:00
Sam Lantinga c1b8ac9764 Fixed Nintendo Switch Pro thumbstick calibration
Fixes https://github.com/libsdl-org/SDL/issues/13246

(cherry picked from commit 038a3806eb)
(cherry picked from commit 6a71328638)
2025-06-21 20:06:37 -07:00
Wohlstand 7a43692bdf Vita Render: Limit the scope of cliprect to viewport
Don't allow cliprect be larger than viewport's scope

(cherry picked from commit 6701f938f7)
2025-06-20 13:16:59 -07:00
Wohlstand 99ad0871b1 Vita: Fixed absence of clipping when viewport is set
#13034

(cherry picked from commit 1c09a7117a)
2025-06-20 13:16:59 -07:00
ceski f901079dd5 Read Switch controller gyro/accel sensitivity coeffs (SDL2)
These vary by controller, so using the stored values should improve the accuracy of the sensor data.

(cherry picked from commit 9eb50a906a)
2025-06-13 12:19:16 -07:00
Sam Lantinga 98d1f3a45a Updated to version 2.32.8 for release 2025-06-02 16:00:39 -07:00
Ryan C. Gordon 1226e6b2bc Revert "opengles2: Restore previous default texture_formats."
This reverts commit 9f7ccbe8d4.

Fixes #13109.

(cherry picked from commit 3c08172d06)
2025-06-02 09:38:50 -07:00
Francisco Javier Trujillo Mata 213b074697 Fix wrong callback type
(cherry picked from commit c89357bf60)
(cherry picked from commit d0c2d8bc40)
2025-05-20 11:12:16 -07:00
Sam Lantinga 4177e06c09 Fixed rare crash trying to interrupt SDL_WaitEvent()
Fixes https://github.com/libsdl-org/SDL/issues/12797

(cherry picked from commit 992e4c59bd)
(cherry picked from commit 33eb167da8)
2025-05-19 14:24:41 -07:00
Joe [ReRezd] 4318013777 Fix: GameCube controller adapter hotplug not working
SDL_PrivateJoystickAdded was called before setting the InstanceId in the adapters ctx->joysticks array.  This would eventually broadcast the SDL_EVENT_JOYSTICK_ADDED event with the new InstanceId, if your program listens for the added events and opens joysticks at that point it would always fail because there would be no matching InstanceId in the ctx->joysticks array.

(cherry picked from commit afd1e51023)
(cherry picked from commit 4b4f6b3e22)
2025-05-19 08:26:52 -07:00
Sam Lantinga 3364486f56 Define illegal_instruction() when it will be actually used
(cherry picked from commit 29d2116495)
(cherry picked from commit 2163887f29)
2025-05-08 13:10:28 -07:00
Sam Clegg dc69988fdf [emscripten] Remove reference to Module['createContext']
Backported from https://github.com/libsdl-org/SDL/pull/12970

(cherry picked from commit c0f78dee5e)
2025-05-06 14:46:53 -07:00
A. Wilcox 4ed1fc5bff cpuinfo: Use auxv for AltiVec on Linux if possible
The SIGILL handler is not very reliable and can cause crashes.

Linux provides the CPU's AltiVec support status in getauxval.

(cherry picked from commit 7490471796)
(cherry picked from commit 17e6208c1b)
2025-05-04 14:02:12 -07:00
Ozkan Sezer 84081d884b don't prototype strdup() for __clang_analyzer__ case in windows builds.
Fixes:  https://github.com/libsdl-org/SDL/issues/12948.
(cherry picked from commit 17bba029ba)
2025-05-04 20:48:24 +03:00
Sam Lantinga a5fad8b0cb Updated to version 2.32.7 for development 2025-05-04 09:18:06 -07:00
Sam Lantinga 6510d6ccbf Updated to version 2.32.6 for release 2025-05-04 08:52:05 -07:00
Derek Schuff b0b50da4b6 Port #12581 to SDL2
This fixes undefined behavior resulting from adding offsets to nullptr.

(cherry picked from commit a220e7c422)
2025-05-01 21:36:53 -07:00
Sam Lantinga 8b7a088efc Call IOHIDDeviceClose() if needed in hid_close() on macOS
Unregistering the input report callback marks the device as disconnected, so IOHIDDeviceClose() would never be called if the device wasn't already disconnected  when hid_close() was called.

Fixes https://github.com/libsdl-org/SDL/issues/12255

(cherry picked from commit 2442c85cb8)
2025-04-29 11:24:27 -07:00
Sam Lantinga 7fc5edab8e Revert "Don't leak device handle in macOS 10.10 or newer"
This reverts commit 5925c27efb.

Fixes https://github.com/libsdl-org/SDL/issues/12807

(cherry picked from commit 5b951141d2)
2025-04-29 11:24:27 -07:00
Cameron Gutman 24ccde693e events: Fix undefined behavior when disabling some event types
Shifting a signed int left by 31 is UB.

(cherry picked from commit 15fd3fcdc2)
2025-04-29 00:32:43 -05:00
Sam Lantinga f46ef5d76d Fixed reliability of initializing Switch controllers on macOS
It looks like both macOS (15.1.1) and SDL are trying to talk to the controller at the same time, which can cause interleaved replies or even locking up the controller. Waiting a bit before talking to the controller seems to take care of this.

(cherry picked from commit 45b01d16b1)
2025-04-28 20:23:37 -07:00
Petar Popovic 5696677558 SDL_BlitSurface() comment: only dstrect is modified in function
(cherry picked from commit 035518d065)
2025-04-22 10:23:02 -07:00
Boris I. Bendovsky 093307f1f4 [SDL2] Fix using of DXSDK_DIR in older CMake
- Remove duplicate 'dollar' symbol in the path
- Use command 'file' to normalize file paths

(cherry picked from commit 40b1eac541)
2025-04-22 10:12:55 -07:00
Ozkan Sezer f54014e173 SDL_cpuinfo.h: only include immintrin.h for x86 targets.
Reference issue: https://github.com/libsdl-org/SDL_image/issues/537
Reference issue: https://github.com/libsdl-org/SDL_mixer/issues/648

(cherry picked from commit bfab0a968f)
2025-04-03 19:55:04 +03:00
Sam Lantinga 64ad33884d Updated to version 2.32.5 for development 2025-03-31 12:58:50 -07:00
Sam Lantinga 2359383fc1 Updated to version 2.32.4 for release 2025-03-31 09:12:51 -07:00
Sam Lantinga b2a95b2482 Default SDL_HINT_ACCELEROMETER_AS_JOYSTICK to 0 on Linux
The Linux joystick driver supports associating sensor devices with the related controller device, so enable that by default.

Fixes https://github.com/libsdl-org/SDL/issues/12043

(cherry picked from commit 3e47181800)
2025-03-25 09:09:59 -07:00
Carl Åstholm 2708e08f40 emscripten: Don't use legacy JS library functions for assertions
(cherry picked from commit 54f5b73333)
(cherry picked from commit a8f0eb4c33)
2025-03-20 16:36:25 -07:00
Dragon-Baroque 3f6efbf2df The posix4 library has been merged into the libc library
Backported from commit 07e4dea693.
Reference issue: https://github.com/libsdl-org/SDL/issues/12588.

(cherry picked from commit d63b3376a4)
2025-03-20 09:48:20 +03:00
Sam Lantinga 9b048e73a2 Fixed raw input device GUIDs changing randomly between runs
On Windows 11, apparently HidD_GetManufacturerString() and HidD_GetProductString() can return TRUE without actually filling in any string data.

Fixes https://github.com/libsdl-org/SDL/issues/12566

(cherry picked from commit 4fc9509ab7)
(cherry picked from commit 52146cf067)
2025-03-17 13:57:58 -07:00
Sam Lantinga d3bb91522f Fixed crash if info->path is NULL
(cherry picked from commit 715301cef5)
(cherry picked from commit 46a51b4298)
2025-03-17 09:48:13 -07:00
SDL Wiki Bot c8c4c97727 Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit fc536dcb7e)
2025-03-12 22:55:50 +03:00
Sam Lantinga f08a5cfcab Fixed sscanf("026", "%1x%1x%1x", &r, &g, &b)
Fixes https://github.com/libsdl-org/SDL/issues/12510

(cherry picked from commit be6ed6e9c4)
(cherry picked from commit 1caae3e9e4)
2025-03-10 15:45:43 -07:00
SDL Wiki Bot e9d2f60e1c Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit 22a87a22ca)
2025-03-07 22:45:02 +03:00
Neal Gompa 9e079fe9c7 pipewire: Ensure that the correct struct is used for enumeration APIs
PipeWire now requires the correct struct type is used, otherwise
it will fail to compile.

Reference: https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/188d920733f0791413d3386e5536ee7377f71b2f

Fixes: https://github.com/libsdl-org/SDL/issues/12224
(cherry picked from commit d35bef64e9)
(cherry picked from commit 6be87ceb33)
2025-03-06 14:37:46 -05:00
Sam Lantinga 53c022c880 Updated to version 2.32.3 for development 2025-03-01 18:13:50 -08:00
Sam Lantinga e11183ea6c Updated to version 2.32.2 for release 2025-03-01 18:03:11 -08:00
Sam Lantinga 024c27645a Added support for the "%n" sscanf format specifier
(cherry picked from commit 6980325310)
(cherry picked from commit ab44451578)
2025-02-25 08:08:55 -08:00
SDL Wiki Bot c2047f0496 Sync SDL2 wiki -> header
[ci skip]

(cherry picked from commit 52ac07d327)
2025-02-25 08:08:55 -08:00
Tomasz Pakuła 220895d4d2 [SDL2] Add SDL_HINT_JOYSTICK_HAPTIC_AXES
Allows users to overwrite the number of haptic axes defined for a given
joystick. Also supports a "wildcard" VID:PID of 0xFFFF/0xFFFF

(cherry picked from commit 0809be4ec5)
2025-02-25 08:08:55 -08:00
Petter Reinholdtsen 282f7a84fc Changed PULSEAUDIO_FlushRecording() to only flush audio present when called.
When the flushing is not able to keep up with the audio stream coming in,
it will end up flushing forever and block API clients from getting any audio.

Fixes #9706

(cherry picked from commit 24693ac285)
2025-02-25 08:08:55 -08:00
Cameron Gutman 9be8c2a899 keyboard: Fix comment regarding implicit calls to SDL_StartTextInput()
It was always done inside SDL_VideoInit().

(cherry picked from commit 92cadaf917)
2025-02-25 08:08:55 -08:00
Anonymous Maarten 51e20f1666 ci: drop classic Intel compiler
1) The classic Intel compiler is depreated in favor of the oneapi compiler
2) SPA_FALLTHROUGH is used in pipewire's spa/utils/json.h, and causes build errors

(cherry picked from commit d2eb72fd14)
2025-02-23 21:40:48 +01:00
Anonymous Maarten a34c8403e7 ci: GitHub is retiring Ubuntu 20.04 support
backport of 8d3db06ff2

(cherry picked from commit b4d733619a)
2025-02-23 21:40:48 +01:00
Anonymous Maarten dc74448014 ci: clang32 on msys2 is EOL
backport of 70f657e520

(cherry picked from commit ed2c004c8a)
2025-02-23 21:40:40 +01:00
Paper 155f99a4e6 thread/windows: fix stack overflow in exception naming
(cherry picked from commit 1a853973ab)
(cherry picked from commit 6421f12d7f)
2025-02-20 08:20:58 -08:00
Ozkan Sezer 63bb1a8583 dynapi: use DosScanEnv() for os/2.
(cherry picked from commit ee49025f80)
2025-02-20 11:50:04 +03:00
Sam Lantinga 8b0c9e1dce Don't leak device handle in macOS 10.10 or newer
Merged upstream fix for macOS:
https://github.com/libusb/hidapi/commit/cdc473dfe43f6432dda7ad53d7656b8ae8ff968b

In one of the early versions of macOS, when you try to close the device
with IOHIDDeviceClose() that is being physically disconnected.
Starting with some version of macOS, this crash bug was fixed,
and starting with macSO 10.15 the opposite effect took place:
in some environments crash happens if IOHIDDeviceClose() is _not_ called.

This patch is to keep a workaround for old versions of macOS,
and don't have a leak in new/tested environments.

Fixes https://github.com/libsdl-org/SDL/issues/12255

(cherry picked from commit 5925c27efb)
2025-02-19 17:00:05 -08:00
Sam Clegg 7f74c1ed63 Fix SDL_emscriptenaudio.c under wasm64
Verified locally by running `browser64.test_sdl2_mixer_wav` in
emscripten.

(cherry picked from commit aa00738a21)
2025-02-19 17:00:05 -08:00
50 changed files with 150 additions and 1354 deletions

No files matched your search

+1 -2
View File
@@ -23,8 +23,7 @@ manpageheaderfiletext = Defined in %fname%
# A handful of others we fix up in the header itself with /* WIKI CATEGORY: x */ comments.
headercategoryeval = s/\ASDL_config_.*?\.h\Z//; s/\ASDL_test_.*?\.h\Z//; s/\ASDL_?(.*?)\.h\Z/$1/; ucfirst();
# !!! FIXME: maybe later, but there are probably documentation gaps to fix first.
quickrefenabled = 0
quickrefenabled = 0 # !!! FIXME: maybe later, but there are probably documentation gaps to fix first.
quickrefcategoryorder = Init,Hints,Error,Version,Properties,Log,Video,Events,Keyboard,Mouse,Touch,Gesture,GameController,Joystick,Haptic,Audio,Timer,Render,LoadSO,Thread,Mutex,Atomic,Filesystem,RWOPS,Pixels,Surface,Blendmode,Rect,Clipboard,Messagebox,Vulkan,Metal,Platform,Power,Sensor,Bits,Endian,Assert,CPUInfo,Locale,System,Misc,GUID,Main,Stdinc
quickreftitle = SDL2 API Quick Reference
quickrefurl = https://libsdl.org/
+2 -2
View File
@@ -88,8 +88,8 @@ endif()
# See docs/release_checklist.md
set(SDL_MAJOR_VERSION 2)
set(SDL_MINOR_VERSION 33)
set(SDL_MICRO_VERSION 0)
set(SDL_MINOR_VERSION 32)
set(SDL_MICRO_VERSION 11)
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
# Set defaults preventing destination file conflicts
+2 -2
View File
@@ -14,8 +14,8 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 33
MICRO_VERSION = 0
MINOR_VERSION = 32
MICRO_VERSION = 11
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
DESCRIPTION = Simple DirectMedia Layer 2
+2 -2
View File
@@ -5,8 +5,8 @@
LIBNAME = SDL2
MAJOR_VERSION = 2
MINOR_VERSION = 33
MICRO_VERSION = 0
MINOR_VERSION = 32
MICRO_VERSION = 11
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
LIBHOME = .
+2 -3
View File
@@ -371,7 +371,6 @@
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.0.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@@ -392,7 +391,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
@@ -604,4 +603,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+2 -2
View File
@@ -19,10 +19,10 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.33.0</string>
<string>2.32.11</string>
<key>CFBundleSignature</key>
<string>SDLX</string>
<key>CFBundleVersion</key>
<string>2.33.0</string>
<string>2.32.11</string>
</dict>
</plist>
+10 -10
View File
@@ -9728,8 +9728,8 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
DYLIB_CURRENT_VERSION = 3301.0.0;
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.11.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -9770,7 +9770,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.33.0;
MARKETING_VERSION = 2.32.11;
OTHER_LDFLAGS = "-liconv";
};
name = Release;
@@ -9813,8 +9813,8 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
DYLIB_CURRENT_VERSION = 3301.0.0;
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.11.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -9856,7 +9856,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_LINK_OBJC_RUNTIME = NO;
MARKETING_VERSION = 2.33.0;
MARKETING_VERSION = 2.32.11;
OTHER_LDFLAGS = "-liconv";
};
name = Debug;
@@ -10062,8 +10062,8 @@
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
DYLIB_CURRENT_VERSION = 3301.0.0;
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.11.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
@@ -10114,8 +10114,8 @@
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = "";
DYLIB_COMPATIBILITY_VERSION = 3301.0.0;
DYLIB_CURRENT_VERSION = 3301.0.0;
DYLIB_COMPATIBILITY_VERSION = 3201.0.0;
DYLIB_CURRENT_VERSION = 3201.11.0;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_NS_ASSERTIONS = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
+1 -1
View File
@@ -1,4 +1,4 @@
Title SDL 2.33.0
Title SDL 2.32.11
Version 1
Description SDL Library for Mac OS X (http://www.libsdl.org)
DefaultLocation /Library/Frameworks
@@ -60,8 +60,8 @@ import java.util.Locale;
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
private static final String TAG = "SDL";
private static final int SDL_MAJOR_VERSION = 2;
private static final int SDL_MINOR_VERSION = 33;
private static final int SDL_MICRO_VERSION = 0;
private static final int SDL_MINOR_VERSION = 32;
private static final int SDL_MICRO_VERSION = 11;
/*
// Display InputType.SOURCE/CLASS of events and devices
//
+40 -131
View File
@@ -37,8 +37,6 @@ logger = logging.getLogger(__name__)
GIT_HASH_FILENAME = ".git-hash"
REVISION_TXT = "REVISION.txt"
RE_ILLEGAL_MINGW_LIBRARIES = re.compile(r"(?:lib)?(?:gcc|(?:std)?c[+][+]|(?:win)?pthread).*", flags=re.I)
def safe_isotime_to_datetime(str_isotime: str) -> datetime.datetime:
try:
@@ -341,12 +339,6 @@ class ArchiveFileTree:
def add_file(self, file: NodeInArchive):
self._tree[file.arcpath] = file
def __iter__(self) -> typing.Iterable[NodeInArchive]:
yield from self._tree.values()
def __contains__(self, value: str) -> bool:
return value in self._tree
def get_latest_mod_time(self) -> datetime.datetime:
return max(item.time for item in self._tree.values() if item.time)
@@ -534,16 +526,6 @@ class SourceCollector:
return path_times
class AndroidApiVersion:
def __init__(self, name: str, ints: tuple[int, ...]):
self.name = name
self.ints = ints
def __repr__(self) -> str:
return f"<{self.name} ({'.'.join(str(v) for v in self.ints)})>"
ANDROID_ABI_EXTRA_LINK_OPTIONS = {}
class Releaser:
def __init__(self, release_info: dict, commit: str, revision: str, root: Path, dist_path: Path, section_printer: SectionPrinter, executer: Executer, cmake_generator: str, deps_path: Path, overwrite: bool, github: bool, fast: bool):
self.release_info = release_info
@@ -604,22 +586,12 @@ class Releaser:
def create_source_archives(self) -> None:
source_collector = SourceCollector(root=self.root, commit=self.commit, executer=self.executer, filter=self._path_filter)
print(f"Collecting sources of {self.project}...")
archive_tree: ArchiveFileTree = source_collector.get_archive_file_tree()
archive_tree = source_collector.get_archive_file_tree()
latest_mod_time = archive_tree.get_latest_mod_time()
archive_tree.add_file(NodeInArchive.from_text(arcpath=REVISION_TXT, text=f"{self.revision}\n", time=latest_mod_time))
archive_tree.add_file(NodeInArchive.from_text(arcpath=f"{GIT_HASH_FILENAME}", text=f"{self.commit}\n", time=latest_mod_time))
archive_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["source"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=latest_mod_time)
if "Makefile.am" in archive_tree:
patched_time = latest_mod_time + datetime.timedelta(minutes=1)
print(f"Makefile.am detected -> touching aclocal.m4, */Makefile.in, configure")
for node_data in archive_tree:
arc_name = os.path.basename(node_data.arcpath)
arc_name_we, arc_name_ext = os.path.splitext(arc_name)
if arc_name in ("aclocal.m4", "configure", "Makefile.in"):
print(f"Bumping time of {node_data.arcpath}")
node_data.time = patched_time
archive_base = f"{self.project}-{self.version}"
zip_path = self.dist_path / f"{archive_base}.zip"
tgz_path = self.dist_path / f"{archive_base}.tar.gz"
@@ -696,15 +668,6 @@ class Releaser:
def git_hash_data(self) -> bytes:
return f"{self.commit}\n".encode()
def verify_mingw_library(self, triplet: str, path: Path):
objdump_output = self.executer.check_output([f"{triplet}-objdump", "-p", str(path)])
libraries = re.findall(r"DLL Name: ([^\n]+)", objdump_output)
logger.info("%s (%s) libraries: %r", path, triplet, libraries)
illegal_libraries = list(filter(RE_ILLEGAL_MINGW_LIBRARIES.match, libraries))
logger.error("Detected 'illegal' libraries: %r", illegal_libraries)
if illegal_libraries:
raise Exception(f"{path} links to illegal libraries: {illegal_libraries}")
def create_mingw_archives(self) -> None:
build_type = "Release"
build_parent_dir = self.root / "build-mingw"
@@ -801,6 +764,7 @@ class Releaser:
f"--includedir=${{prefix}}/include",
f"--libdir=${{prefix}}/lib",
f"--bindir=${{prefix}}/bin",
f"--exec-prefix=${{prefix}}/bin",
f"--host={triplet}",
f"--build=x86_64-none-linux-gnu",
"CFLAGS=-O2",
@@ -808,10 +772,9 @@ class Releaser:
"LDFLAGS=-Wl,-s",
] + extra_args, cwd=build_path, env=new_env)
with self.section_printer.group(f"Build MinGW {triplet} (autotools)"):
self.executer.run(["make", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
self.executer.run(["make", "V=1", f"-j{self.cpu_count}"], cwd=build_path, env=new_env)
with self.section_printer.group(f"Install MinGW {triplet} (autotools)"):
self.executer.run(["make", "install"], cwd=build_path, env=new_env)
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
print("Recording arch-dependent extra files for MinGW development archive ...")
@@ -867,7 +830,6 @@ class Releaser:
self.executer.run(["cmake", "--build", str(build_path), "--verbose", "--config", build_type], cwd=build_path, env=new_env)
with self.section_printer.group(f"Install MinGW {triplet} (CMake)"):
self.executer.run(["cmake", "--install", str(build_path)], cwd=build_path, env=new_env)
self.verify_mingw_library(triplet=ARCH_TO_TRIPLET[arch], path=install_path / "bin" / f"{self.project}.dll")
archive_file_tree.add_directory_tree(arc_dir=arc_join(arc_root, triplet), path=install_path, time=self.arc_time)
print("Recording arch-dependent extra files for MinGW development archive ...")
@@ -895,25 +857,22 @@ class Releaser:
self.artifacts["mingw-devel-tar-gz"] = tgz_path
self.artifacts["mingw-devel-tar-xz"] = txz_path
def _detect_android_api(self, android_home: str) -> typing.Optional[AndroidApiVersion]:
def _detect_android_api(self, android_home: str) -> typing.Optional[int]:
platform_dirs = list(Path(p) for p in glob.glob(f"{android_home}/platforms/android-*"))
re_platform = re.compile("^android-([0-9]+)(?:-ext([0-9]+))?$")
platform_versions: list[AndroidApiVersion] = []
re_platform = re.compile("android-([0-9]+)")
platform_versions = []
for platform_dir in platform_dirs:
logger.debug("Found Android Platform SDK: %s", platform_dir)
if not (platform_dir / "android.jar").is_file():
logger.debug("Skipping SDK, missing android.jar")
continue
if m:= re_platform.match(platform_dir.name):
platform_versions.append(AndroidApiVersion(name=platform_dir.name, ints=(int(m.group(1)), int(m.group(2) or 0))))
platform_versions.sort(key=lambda v: v.ints)
platform_versions.append(int(m.group(1)))
platform_versions.sort()
logger.info("Available platform versions: %s", platform_versions)
platform_versions = list(filter(lambda v: v.ints >= self._android_api_minimum.ints, platform_versions))
logger.info("Valid platform versions (>=%s): %s", self._android_api_minimum.ints, platform_versions)
platform_versions = list(filter(lambda v: v >= self._android_api_minimum, platform_versions))
logger.info("Valid platform versions (>=%d): %s", self._android_api_minimum, platform_versions)
if not platform_versions:
return None
android_api = platform_versions[0]
logger.info("Selected API version %s", android_api)
logger.info("Selected API version %d", android_api)
return android_api
def _get_prefab_json_text(self) -> str:
@@ -937,19 +896,8 @@ class Releaser:
return json.dumps(module_json_dict, indent=4)
@property
def _android_api_minimum(self) -> AndroidApiVersion:
value = self.release_info["android"]["api-minimum"]
if isinstance(value, int):
ints = (value, )
elif isinstance(value, str):
ints = tuple(split("."))
else:
raise ValueError("Invalid android.api-minimum: must be X or X.Y")
match len(ints):
case 1: name = f"android-{ints[0]}"
case 2: name = f"android-{ints[0]}-ext-{ints[1]}"
case _: raise ValueError("Invalid android.api-minimum: must be X or X.Y")
return AndroidApiVersion(name=name, ints=ints)
def _android_api_minimum(self):
return self.release_info["android"]["api-minimum"]
@property
def _android_api_target(self):
@@ -962,7 +910,7 @@ class Releaser:
def _get_prefab_abi_json_text(self, abi: str, cpp: bool, shared: bool) -> str:
abi_json_dict = {
"abi": abi,
"api": self._android_api_minimum.ints[0],
"api": self._android_api_minimum,
"ndk": self._android_ndk_minimum,
"stl": "c++_shared" if cpp else "none",
"static": not shared,
@@ -975,7 +923,7 @@ class Releaser:
xmlns:android="http://schemas.android.com/apk/res/android"
package="org.libsdl.android.{self.project}" android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="{self._android_api_minimum.ints[0]}"
<uses-sdk android:minSdkVersion="{self._android_api_minimum}"
android:targetSdkVersion="{self._android_api_target}" />
</manifest>
""")
@@ -985,8 +933,7 @@ class Releaser:
if not cmake_toolchain_file.exists():
logger.error("CMake toolchain file does not exist (%s)", cmake_toolchain_file)
raise SystemExit(1)
aar_path = self.root / "build-android" / f"{self.project}-{self.version}.aar"
android_dist_path = self.dist_path / f"{self.project}-devel-{self.version}-android.zip"
aar_path = self.dist_path / f"{self.project}-{self.version}.aar"
android_abis = self.release_info["android"]["abis"]
java_jars_added = False
module_data_added = False
@@ -994,27 +941,16 @@ class Releaser:
shutil.rmtree(android_deps_path, ignore_errors=True)
for dep, depinfo in self.release_info["android"].get("dependencies", {}).items():
dep_devel_zip = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
dep_extract_path = self.deps_path / f"extract/android/{dep}"
shutil.rmtree(dep_extract_path, ignore_errors=True)
dep_extract_path.mkdir(parents=True, exist_ok=True)
with self.section_printer.group(f"Extracting Android dependency {dep} ({dep_devel_zip})"):
with zipfile.ZipFile(dep_devel_zip, "r") as zf:
zf.extractall(dep_extract_path)
dep_devel_aar = dep_extract_path / glob.glob("*.aar", root_dir=dep_extract_path)[0]
self.executer.run([sys.executable, str(dep_devel_aar), "-o", str(android_deps_path)])
android_aar = self.deps_path / glob.glob(depinfo["artifact"], root_dir=self.deps_path)[0]
with self.section_printer.group(f"Extracting Android dependency {dep} ({android_aar.name})"):
self.executer.run([sys.executable, str(android_aar), "-o", str(android_deps_path)])
for module_name, module_info in self.release_info["android"]["modules"].items():
assert "type" in module_info and module_info["type"] in ("interface", "library"), f"module {module_name} must have a valid type"
aar_file_tree = ArchiveFileTree()
android_devel_file_tree = ArchiveFileTree()
archive_file_tree = ArchiveFileTree()
for android_abi in android_abis:
extra_link_options = ANDROID_ABI_EXTRA_LINK_OPTIONS.get(android_abi, "")
with self.section_printer.group(f"Building for Android {android_api} {android_abi}"):
build_dir = self.root / "build-android" / f"{android_abi}-build"
install_dir = self.root / "install-android" / f"{android_abi}-install"
@@ -1025,11 +961,8 @@ class Releaser:
"cmake",
"-S", str(self.root),
"-B", str(build_dir),
# NDK 21e does not support -ffile-prefix-map
# f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
# f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f"-DCMAKE_EXE_LINKER_FLAGS={extra_link_options}",
f"-DCMAKE_SHARED_LINKER_FLAGS={extra_link_options}",
f'''-DCMAKE_C_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f'''-DCMAKE_CXX_FLAGS="-ffile-prefix-map={self.root}=/src/{self.project}"''',
f"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}",
f"-DCMAKE_PREFIX_PATH={str(android_deps_path)}",
f"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH",
@@ -1066,20 +999,20 @@ class Releaser:
assert library.suffix in (".so", ".a")
assert library.is_file(), f"CMake should have built library '{library}' for module {module_name}"
arcdir_prefab_libs = f"{arcdir_prefab_module}/libs/android.{android_abi}"
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath=f"{arcdir_prefab_libs}/{library.name}", path=library, time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=f"{arcdir_prefab_libs}/abi.json", text=self._get_prefab_abi_json_text(abi=android_abi, cpp=False, shared=library.suffix == ".so"), time=self.arc_time))
if not module_data_added:
library_name = None
if module_info["type"] == "library":
library_name = Path(module_info["library"]).stem.removeprefix("lib")
export_libraries = module_info.get("export-libraries", [])
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_module, "module.json"), text=self._get_prefab_module_json_text(library_name=library_name, export_libraries=export_libraries), time=self.arc_time))
arcdir_prefab_include = f"prefab/modules/{module_name}/include"
if "includes" in module_info:
aar_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
archive_file_tree.add_file_mapping(arc_dir=arcdir_prefab_include, file_mapping=module_info["includes"], file_mapping_root=install_dir, context=self.get_context(), time=self.arc_time)
else:
aar_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_text(arcpath=arc_join(arcdir_prefab_include, ".keep"), text="\n", time=self.arc_time))
module_data_added = True
if not java_jars_added:
@@ -1092,28 +1025,21 @@ class Releaser:
assert sources_jar_path.is_file(), f"CMake should have archived the java sources into a JAR ({sources_jar_path})"
assert doc_jar_path.is_file(), f"CMake should have archived javadoc into a JAR ({doc_jar_path})"
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
aar_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes.jar", path=classes_jar_path, time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-sources.jar", path=sources_jar_path, time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_fs(arcpath="classes-doc.jar", path=doc_jar_path, time=self.arc_time))
assert ("jars" in self.release_info["android"] and java_jars_added) or "jars" not in self.release_info["android"], "Must have archived java JAR archives"
aar_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["aar-files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"].get("files", {}), file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
aar_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="prefab/prefab.json", text=self._get_prefab_json_text(), time=self.arc_time))
archive_file_tree.add_file(NodeInArchive.from_text(arcpath="AndroidManifest.xml", text=self._get_android_manifest_text(), time=self.arc_time))
with Archiver(zip_path=aar_path) as archiver:
aar_file_tree.add_to_archiver(archive_base="", archiver=archiver)
archive_file_tree.add_to_archiver(archive_base="", archiver=archiver)
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
android_devel_file_tree.add_file(NodeInArchive.from_fs(arcpath=aar_path.name, path=aar_path))
android_devel_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["android"]["files"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
with Archiver(zip_path=android_dist_path) as archiver:
android_devel_file_tree.add_to_archiver(archive_base="", archiver=archiver)
archiver.add_git_hash(arcdir="", commit=self.commit, time=self.arc_time)
self.artifacts[f"android-aar"] = android_dist_path
self.artifacts[f"android-aar"] = aar_path
def download_dependencies(self):
shutil.rmtree(self.deps_path, ignore_errors=True)
@@ -1150,7 +1076,7 @@ class Releaser:
assert len(msvc_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
if "android" in self.release_info:
android_matches = glob.glob(self.release_info["android"]["dependencies"][dep]["artifact"], root_dir=self.deps_path)
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {android_matches}"
assert len(android_matches) == 1, f"Exactly one archive matches msvc {dep} dependency: {msvc_matches}"
@staticmethod
def _arch_to_vs_platform(arch: str, configuration: str="Release") -> VsArchPlatformConfig:
@@ -1276,10 +1202,6 @@ class Releaser:
platform_context = self.get_context(extra_context=arch_platform.extra_context())
build_type = "Release"
extra_context = {
"ARCH": arch_platform.arch,
"PLATFORM": arch_platform.platform,
}
built_paths = set(install_path / configure_text(f, context=platform_context) for file_mapping in (self.release_info["msvc"]["cmake"]["files-lib"], self.release_info["msvc"]["cmake"]["files-devel"]) for files_list in file_mapping.values() for f in files_list)
logger.info("CMake builds these files, to be included in the package: %s", built_paths)
@@ -1330,7 +1252,7 @@ class Releaser:
logger.info("Collecting files...")
archive_file_tree = ArchiveFileTree()
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["cmake"]["files-lib"], file_mapping_root=install_path, context=platform_context, time=self.arc_time)
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["files-lib"], file_mapping_root=self.root, context=self.get_context(extra_context=extra_context), time=self.arc_time)
archive_file_tree.add_file_mapping(arc_dir="", file_mapping=self.release_info["msvc"]["files-lib"], file_mapping_root=self.root, context=self.get_context(), time=self.arc_time)
logger.info("Creating %s", zip_path)
with Archiver(zip_path=zip_path) as archiver:
@@ -1394,7 +1316,7 @@ def main(argv=None) -> int:
parser.add_argument("--actions", choices=["download", "source", "android", "mingw", "msvc", "dmg"], required=True, nargs="+", dest="actions", help="What to do?")
parser.set_defaults(loglevel=logging.INFO)
parser.add_argument('--vs-year', dest="vs_year", help="Visual Studio year")
parser.add_argument('--android-api', dest="android_api", help="Android API version")
parser.add_argument('--android-api', type=int, dest="android_api", help="Android API version")
parser.add_argument('--android-home', dest="android_home", default=os.environ.get("ANDROID_HOME"), help="Android Home folder")
parser.add_argument('--android-ndk-home', dest="android_ndk_home", default=os.environ.get("ANDROID_NDK_HOME"), help="Android NDK Home folder")
parser.add_argument('--cmake-generator', dest="cmake_generator", default="Ninja", help="CMake Generator")
@@ -1521,27 +1443,14 @@ def main(argv=None) -> int:
if args.android_api is None:
with section_printer.group("Detect Android APIS"):
args.android_api = releaser._detect_android_api(android_home=args.android_home)
else:
try:
android_api_ints = tuple(int(v) for v in args.android_api.split("."))
match len(android_api_ints):
case 1: android_api_name = f"android-{android_api_ints[0]}"
case 2: android_api_name = f"android-{android_api_ints[0]}-ext-{android_api_ints[1]}"
case _: raise ValueError
except ValueError:
logger.error("Invalid --android-api, must be a 'X' or 'X.Y' version")
args.android_api = AndroidApiVersion(ints=android_api_ints, name=android_api_name)
if args.android_api is None:
if args.android_api is None or not (Path(args.android_home) / f"platforms/android-{args.android_api}").is_dir():
parser.error("Invalid --android-api, and/or could not be detected")
android_api_path = Path(args.android_home) / f"platforms/{args.android_api.name}"
if not android_api_path.is_dir():
logger.warning(f"Android API directory does not exist ({android_api_path})")
with section_printer.group("Android arguments"):
print(f"android_home = {args.android_home}")
print(f"android_ndk_home = {args.android_ndk_home}")
print(f"android_api = {args.android_api}")
releaser.create_android_archives(
android_api=args.android_api.ints[0],
android_api=args.android_api,
android_home=args.android_home,
android_ndk_home=args.android_ndk_home,
)
Vendored
+2 -2
View File
@@ -3515,8 +3515,8 @@ orig_CFLAGS="$CFLAGS"
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=33
SDL_MICRO_VERSION=0
SDL_MINOR_VERSION=32
SDL_MICRO_VERSION=11
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
+2 -2
View File
@@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS"
dnl Set various version strings - taken gratefully from the GTk sources
# See docs/release_checklist.md
SDL_MAJOR_VERSION=2
SDL_MINOR_VERSION=33
SDL_MICRO_VERSION=0
SDL_MINOR_VERSION=32
SDL_MICRO_VERSION=11
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
+1 -1
View File
@@ -29,7 +29,7 @@ cmake --install build
## Compiling a HelloWorld
[PSP Hello World](https://pspdev.github.io/basic_programs.html#hello-world)
[PSP Hello World](https://psp-dev.org/doku.php?id=tutorial:hello_world)
## To Do
- PSP Screen Keyboard
+3
View File
@@ -14,6 +14,7 @@ Works out of box.
Windows:
Unfortunately there is no windows support as of yet. Support for Windows 7 is planned, but we currently have no way to test. If you have a Windows 7 WM_TOUCH supported device, and are willing to help test please contact me at jim.tla+sdl_touch@gmail.com
===========================================================================
Events
===========================================================================
SDL_FINGERDOWN:
@@ -38,6 +39,7 @@ Fields:
Same as SDL_FINGERDOWN.
===========================================================================
Functions
===========================================================================
SDL provides the ability to access the underlying SDL_Finger structures.
@@ -74,6 +76,7 @@ A SDL_Finger has the following fields:
The pressure of the touch.
===========================================================================
Notes
===========================================================================
For a complete example see test/testgesture.c
+1 -11
View File
@@ -648,7 +648,7 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* \param obtained an SDL_AudioSpec structure filled in with the actual output
* format; see SDL_OpenAudio() for more information.
* \param allowed_changes 0, or one or more flags OR'd together.
* \returns a valid device ID > 0 on success or 0 on failure; call
* \returns a valid device ID that is > 0 on success or 0 on failure; call
* SDL_GetError() for more information.
*
* For compatibility with SDL 1.2, this will never return 1, since
@@ -1059,9 +1059,6 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *bu
* resample correctly, so this number might be lower than what you expect, or
* even be zero. Add more data or flush the stream if you need the data now.
*
* \param stream the audio stream to query.
* \returns the number of bytes available.
*
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream
@@ -1081,9 +1078,6 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
* audio gaps in the output. Generally this is intended to signal the end of
* input, so the complete output becomes available.
*
* \param stream the audio stream to flush.
* \returns 0 on success, otherwise -1.
*
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream
@@ -1098,8 +1092,6 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
/**
* Clear any pending data in the stream without converting it
*
* \param stream the audio stream to clear.
*
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream
@@ -1114,8 +1106,6 @@ extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
/**
* Free an audio stream
*
* \param stream the audio stream to free.
*
* \since This function is available since SDL 2.0.7.
*
* \sa SDL_NewAudioStream
-17
View File
@@ -226,7 +226,6 @@ extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
/**
* Get the mapping at a particular index.
*
* \param mapping_index mapping index.
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* the index is out of range.
*
@@ -851,9 +850,6 @@ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *ga
/**
* Get the number of touchpads on a game controller.
*
* \param gamecontroller a controller.
* \returns number of touchpads.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
@@ -862,10 +858,6 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController
* Get the number of supported simultaneous fingers on a touchpad on a game
* controller.
*
* \param gamecontroller a controller.
* \param touchpad a touchpad.
* \returns number of supported simultaneous fingers.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
@@ -873,15 +865,6 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameCont
/**
* Get the current state of a finger on a touchpad on a game controller.
*
* \param gamecontroller a controller.
* \param touchpad a touchpad.
* \param finger a finger.
* \param state a pointer filled with the finger state.
* \param x a pointer filled with the x position.
* \param y a pointer filled with the y position.
* \param pressure a pointer filled with pressure value.
* \returns 0 on success or negative on failure.
*
* \since This function is available since SDL 2.0.14.
*/
extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
-1
View File
@@ -227,7 +227,6 @@ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id,
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
*
* \param path The path name of the device to open.
* \param bExclusive boolean exclusive.
* \returns a pointer to a SDL_hid_device object on success or NULL on
* failure.
*
-8
View File
@@ -214,9 +214,6 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickPathForIndex(int device_index);
* Get the player index of a joystick, or -1 if it's not available This can be
* called before any joysticks are opened.
*
* \param device_index device index.
* \returns player index, or -1 if not available.
*
* \since This function is available since SDL 2.0.9.
*/
extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
@@ -359,10 +356,6 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_ind
/**
* Attach a new virtual joystick.
*
* \param type joystick type.
* \param naxes number of axes.
* \param nbuttons number of buttons.
* \param nhats number of hats.
* \returns the joystick's device index, or -1 if an error occurred.
*
* \since This function is available since SDL 2.0.14.
@@ -416,7 +409,6 @@ typedef struct SDL_VirtualJoystickDesc
/**
* Attach a new virtual joystick with extended properties.
*
* \param desc joystick description.
* \returns the joystick's device index, or -1 if an error occurred.
*
* \since This function is available since SDL 2.24.0.
-3
View File
@@ -298,9 +298,6 @@ extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
/**
* Returns if an IME Composite or Candidate window is currently shown.
*
* \returns SDL_TRUE if an IME Composite or Candidate window is currently
* shown else SDL_FALSE.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
-6
View File
@@ -41,18 +41,12 @@
*
* A special exception is the number keys at the top of the keyboard which map
* to SDLK_0...SDLK_9 on AZERTY layouts.
*
* The actual values that might be set for this type are listed in the
* SDL_KeyCode (capital C) enumeration.
*/
typedef Sint32 SDL_Keycode;
#define SDLK_SCANCODE_MASK (1<<30)
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
/**
* The possible values for keycodes.
*/
typedef enum SDL_KeyCode
{
SDLK_UNKNOWN = 0,
+2 -1
View File
@@ -163,7 +163,8 @@ extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
/**
* Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO.
*
* \param fmt a printf() style message format string.
* = * \param fmt a printf() style message format string
*
* \param ... additional parameters matching % tokens in the `fmt` string, if
* any.
*
+2 -2
View File
@@ -187,8 +187,8 @@ extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
* \param name the window class name, in UTF-8 encoding. If NULL, SDL
* currently uses "SDL_app" but this isn't guaranteed.
* \param style the value to use in WNDCLASSEX::style. If `name` is NULL, SDL
* currently uses `(CS_BYTEALIGNCLIENT \| CS_OWNDC)` regardless
* of what is specified here.
* currently uses `(CS_BYTEALIGNCLIENT | CS_OWNDC)` regardless of
* what is specified here.
* \param hInst the HINSTANCE to use in WNDCLASSEX::hInstance. If zero, SDL
* will use `GetModuleHandle(NULL)` instead.
* \returns 0 on success, -1 on error. SDL_GetError() may have details.
-8
View File
@@ -59,9 +59,6 @@ typedef void *SDL_MetalView;
* The returned handle can be casted directly to a NSView or UIView. To access
* the backing CAMetalLayer, call SDL_Metal_GetLayer().
*
* \param window the window.
* \returns handle NSView or UIView.
*
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_Metal_DestroyView
@@ -75,8 +72,6 @@ extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
* This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
* called after SDL_CreateWindow.
*
* \param view the SDL_MetalView object.
*
* \since This function is available since SDL 2.0.12.
*
* \sa SDL_Metal_CreateView
@@ -86,9 +81,6 @@ extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
/**
* Get a pointer to the backing CAMetalLayer for the given view.
*
* \param view the SDL_MetalView object.
* \returns a pointer.
*
* \since This function is available since SDL 2.0.14.
*
* \sa SDL_Metal_CreateView
-27
View File
@@ -106,10 +106,6 @@ typedef struct SDL_FRect
/**
* Returns true if point resides inside a rectangle.
*
* \param p the point to test.
* \param r the rectangle to test.
* \returns SDL_TRUE if `p` is contained by `r`, SDL_FALSE otherwise.
*/
SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
{
@@ -119,9 +115,6 @@ SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
/**
* Returns true if the rectangle has no area.
*
* \param r the rectangle to test.
* \returns SDL_TRUE if the rectangle is "empty", SDL_FALSE otherwise.
*/
SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
{
@@ -130,10 +123,6 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
/**
* Returns true if the two rectangles are equal.
*
* \param a the first rectangle to test.
* \param b the second rectangle to test.
* \returns SDL_TRUE if the rectangles are equal, SDL_FALSE otherwise.
*/
SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
{
@@ -240,10 +229,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
/**
* Returns true if point resides inside a rectangle.
*
* \param p the point to test.
* \param r the rectangle to test.
* \returns SDL_TRUE if `p` is contained by `r`, SDL_FALSE otherwise.
*/
SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect *r)
{
@@ -253,9 +238,6 @@ SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect
/**
* Returns true if the rectangle has no area.
*
* \param r the rectangle to test.
* \returns SDL_TRUE if the rectangle is "empty", SDL_FALSE otherwise.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
{
@@ -265,11 +247,6 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
/**
* Returns true if the two rectangles are equal, within some given epsilon.
*
* \param a the first rectangle to test.
* \param b the second rectangle to test.
* \param epsilon the epsilon value for comparison.
* \returns SDL_TRUE if the rectangles are equal, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.22.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
@@ -285,10 +262,6 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_F
/**
* Returns true if the two rectangles are equal, using a default epsilon.
*
* \param a the first rectangle to test.
* \param b the second rectangle to test.
* \returns SDL_TRUE if the rectangles are equal, SDL_FALSE otherwise.
*
* \since This function is available since SDL 2.0.22.
*/
SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b)
+1 -2
View File
@@ -30,7 +30,6 @@
* - single pixel lines
* - filled rectangles
* - texture images
* - 2D polygons
*
* The primitives may be drawn in opaque, blended, or additive modes.
*
@@ -39,7 +38,7 @@
* may also be stretched with linear interpolation.
*
* This API is designed to accelerate simple 2D operations. You may want more
* functionality such as 3D polygons and particle effects and in that case you
* functionality such as polygons and particle effects and in that case you
* should use SDL's OpenGL/Direct3D support or one of the many good 3D
* engines.
*
-35
View File
@@ -467,11 +467,6 @@ typedef void (SDLCALL *SDL_free_func)(void *mem);
/**
* Get the original set of SDL memory functions
*
* \param malloc_func filled with malloc function.
* \param calloc_func filled with calloc function.
* \param realloc_func filled with realloc function.
* \param free_func filled with free function.
*
* \since This function is available since SDL 2.24.0.
*/
extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
@@ -482,11 +477,6 @@ extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *mal
/**
* Get the current set of SDL memory functions
*
* \param malloc_func filled with malloc function.
* \param calloc_func filled with calloc function.
* \param realloc_func filled with realloc function.
* \param free_func filled with free function.
*
* \since This function is available since SDL 2.0.7.
*/
extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
@@ -497,13 +487,6 @@ extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func
/**
* Replace SDL's memory allocation functions with a custom set
*
* \param malloc_func custom malloc function.
* \param calloc_func custom calloc function.
* \param realloc_func custom realloc function.
* \param free_func custom free function.
* \returns 0 on success or -1 on failure; call SDL_GetError() for more
* information.
*
* \since This function is available since SDL 2.0.7.
*/
extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
@@ -514,8 +497,6 @@ extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
/**
* Get the number of outstanding (unfreed) allocations
*
* \returns number of unfreed allocations.
*
* \since This function is available since SDL 2.0.7.
*/
extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
@@ -735,12 +716,6 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
* This function converts a buffer or string between encodings in one pass,
* returning a string that must be freed with SDL_free() or NULL on error.
*
* \param tocode the character encoding of the output string.
* \param fromcode the character encoding of data in `inbuf`.
* \param inbuf the string to convert to a different encoding.
* \param inbytesleft the size of the input string _in bytes_.
* \returns a new string, converted to the new encoding, or NULL on error.
*
* \since This function is available since SDL 2.0.0.
*/
extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
@@ -832,11 +807,6 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
*
* Otherwise store a * b via ret and return 0.
*
* \param a the multiplicand.
* \param b the multiplier.
* \param ret on non-overflow output, stores the multiplication result.
* \returns -1 on overflow, 0 if result is multiplied without overflow.
*
* \since This function is available since SDL 2.24.0.
*/
SDL_FORCE_INLINE int SDL_size_mul_overflow (size_t a,
@@ -868,11 +838,6 @@ SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
*
* Otherwise store a + b via ret and return 0.
*
* \param a the first addend.
* \param b the second addend.
* \param ret on non-overflow output, stores the addition result.
* \returns false on overflow, true if result is added without overflow.
*
* \since This function is available since SDL 2.24.0.
*/
SDL_FORCE_INLINE int SDL_size_add_overflow (size_t a,
+6 -58
View File
@@ -801,14 +801,15 @@ extern DECLSPEC int SDLCALL SDL_FillRect
extern DECLSPEC int SDLCALL SDL_FillRects
(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
/* !!! FIXME: merge this documentation with the wiki */
/**
* Performs a fast blit from the source surface to the destination surface.
*
* This assumes that the source and destination rectangles are the same size.
* `dstrect`'s width and height are ignored, only its position is used. If
* either `srcrect` or `dstrect` are NULL, the entire surface (`src` or `dst`)
* is copied. The final blit rectangle is saved in `dstrect` after all
* clipping is performed.
* If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
* `dst`) is copied. The final blit rectangle is saved in `dstrect` after
* all clipping is performed.
*
* The blit function should not be called on a locked surface.
*
@@ -858,17 +859,7 @@ extern DECLSPEC int SDLCALL SDL_FillRects
* You should call SDL_BlitSurface() unless you know exactly how SDL blitting
* works internally and how to use the other blit functions.
*
* \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied, or NULL to copy the entire surface.
* \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the x and y position in
* the destination surface, or NULL for (0,0). The width and
* height are ignored, and are copied from `srcrect`. If you
* want a specific width and height, you should use
* SDL_BlitScaled().
* \returns 0 if the blit is successful or a negative error code on failure;
* call SDL_GetError() for more information.
* \returns 0 if the blit is successful, otherwise it returns -1.
*/
#define SDL_BlitSurface SDL_UpperBlit
@@ -878,18 +869,6 @@ extern DECLSPEC int SDLCALL SDL_FillRects
* SDL_UpperBlit() has been replaced by SDL_BlitSurface(), which is merely a
* macro for this function with a less confusing name.
*
* \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied, or NULL to copy the entire surface.
* \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the x and y position in
* the destination surface, or NULL for (0,0). The width and
* height are ignored, and are copied from `srcrect`. If you
* want a specific width and height, you should use
* SDL_BlitScaled().
* \returns 0 if the blit is successful or a negative error code on failure;
* call SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitSurface
@@ -931,13 +910,6 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit
*
* Please use SDL_BlitScaled() instead.
*
* \param src the surface to be copied from.
* \param srcrect the rectangle to be copied.
* \param dst the surface that is the blit target.
* \param dstrect the rectangle that is copied into.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*/
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
@@ -948,13 +920,6 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src,
/**
* Perform bilinear scaling between two surfaces of the same format, 32BPP.
*
* \param src the surface to be copied from.
* \param srcrect the rectangle to be copied.
* \param dst the surface that is the blit target.
* \param dstrect the rectangle that is copied into.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.16.
*/
extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
@@ -969,15 +934,6 @@ extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
* SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is
* merely a macro for this function with a less confusing name.
*
* \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied, or NULL to copy the entire surface.
* \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the rectangle that is
* copied into, or NULL to copy into the entire surface.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_BlitScaled
@@ -1015,8 +971,6 @@ extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
/**
* Set the YUV conversion mode
*
* \param mode the YUV conversion mode.
*
* \since This function is available since SDL 2.0.8.
*/
extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
@@ -1024,8 +978,6 @@ extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mo
/**
* Get the YUV conversion mode
*
* \returns YUV conversion mode.
*
* \since This function is available since SDL 2.0.8.
*/
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
@@ -1034,10 +986,6 @@ extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
* Get the YUV conversion mode, returning the correct mode for the resolution
* when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
*
* \param width the resolution width.
* \param height the resolution height.
* \returns YUV conversion mode.
*
* \since This function is available since SDL 2.0.8.
*/
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
-21
View File
@@ -463,7 +463,6 @@ extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int durati
*
* \param command user command that must be greater or equal to 0x8000.
* \param param user parameter.
* \returns 0 on success, otherwise -1.
*
* \since This function is available since SDL 2.0.22.
*/
@@ -572,26 +571,6 @@ extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathT
*/
extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
/**
* Get the protocol activation URI if the app was launched via protocol
* activation.
*
* When a UWP/WinRT app is launched via a custom URI scheme (e.g.,
* myapp://action?param=value), this function retrieves the full activation
* URI string.
*
* The URI is only available once per activation - after the first successful
* call, subsequent calls will return NULL. This ensures the URI is processed
* only once.
*
* \returns the protocol activation URI as a UTF-8 string that must be freed
* with SDL_free(), or NULL if the app was not activated via protocol
* or the URI was already retrieved.
*
* \since This function is available since SDL 2.33.0.
*/
extern DECLSPEC char * SDLCALL SDL_WinRTGetProtocolActivationURI(void);
#endif /* __WINRT__ */
/**
-7
View File
@@ -99,10 +99,6 @@ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
* Get the touch device name as reported from the driver or NULL if the index
* is invalid.
*
* \param index the touch device index.
* \returns touch device name, or NULL on failure; call SDL_GetError() for
* more information.
*
* \since This function is available since SDL 2.0.22.
*/
extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index);
@@ -110,9 +106,6 @@ extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index);
/**
* Get the type of the given touch device.
*
* \param touchID the ID of a touch device.
* \returns touch device type.
*
* \since This function is available since SDL 2.0.10.
*/
extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID);
+2 -2
View File
@@ -57,8 +57,8 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
#define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 33
#define SDL_PATCHLEVEL 0
#define SDL_MINOR_VERSION 32
#define SDL_PATCHLEVEL 11
/**
* Macro to determine SDL version program was compiled against.
-3
View File
@@ -1008,8 +1008,6 @@ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window,
* \param h the height of the window in pixels, in screen coordinates, must be
* > 0.
*
* \threadsafety This function should only be called on the main thread.
*
* \since This function is available since SDL 2.0.0.
*
* \sa SDL_GetWindowSize
@@ -1317,7 +1315,6 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
/**
* Return whether the window has a surface associated with it.
*
* \param window the window to query.
* \returns SDL_TRUE if there is a surface associated with the window, or
* SDL_FALSE otherwise.
*
-94
View File
@@ -20,8 +20,6 @@
*/
#include "../../SDL_internal.h"
/* Standard C++11 includes: */
#include <string>
/* Windows includes */
#include "ppltasks.h"
using namespace concurrency;
@@ -45,7 +43,6 @@ extern "C" {
#include "SDL_hints.h"
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_system.h"
#include "SDL_render.h"
#include "../../video/SDL_sysvideo.h"
#include "../../events/SDL_events_c.h"
@@ -83,60 +80,6 @@ extern "C" void D3D11_Trim(SDL_Renderer *);
// SDL_CreateWindow().
SDL_WinRTApp ^ SDL_WinRTGlobalApp = nullptr;
// Protocol activation URI storage
static Platform::String^ WINRT_ProtocolActivationURI = nullptr;
// Store launchOnExit URI separately since WINRT_ProtocolActivationURI gets cleared
static std::wstring WINRT_LaunchOnExitURI;
// Helper function to extract and store launchOnExit from protocol URI
static void WINRT_ExtractLaunchOnExitURI(Platform::String^ fullUri)
{
if (fullUri == nullptr)
return;
std::wstring uri(fullUri->Data());
// Look for launchOnExit parameter in the URI
size_t launchPos = uri.find(L"launchOnExit=");
if (launchPos == std::wstring::npos)
return;
// Extract the launchOnExit URI value
launchPos += 13; // Skip past "launchOnExit="
size_t endPos = uri.find(L'&', launchPos);
if (endPos == std::wstring::npos)
endPos = uri.length();
std::wstring launchUri = uri.substr(launchPos, endPos - launchPos);
// URL decode the URI (convert %3A to :, etc.)
WINRT_LaunchOnExitURI.clear();
for (size_t i = 0; i < launchUri.length(); i++) {
if (launchUri[i] == L'%' && i + 2 < launchUri.length()) {
wchar_t hex[3] = { launchUri[i + 1], launchUri[i + 2], 0 };
WINRT_LaunchOnExitURI += (wchar_t)wcstol(hex, nullptr, 16);
i += 2;
} else {
WINRT_LaunchOnExitURI += launchUri[i];
}
}
}
// Helper function to launch URI on exit if protocol activation included launchOnExit parameter
static void WINRT_LaunchExitUriIfSet()
{
if (!WINRT_LaunchOnExitURI.empty()) {
try {
// Launch the URI
auto uri = ref new Windows::Foundation::Uri(ref new Platform::String(WINRT_LaunchOnExitURI.c_str()));
Windows::System::Launcher::LaunchUriAsync(uri);
} catch (...) {
// Silently ignore errors during termination
}
}
}
ref class SDLApplicationSource sealed : Windows::ApplicationModel::Core::IFrameworkViewSource
{
public:
@@ -164,22 +107,6 @@ int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **))
return 0;
}
extern "C" char* SDL_WinRTGetProtocolActivationURI(void)
{
if (WINRT_ProtocolActivationURI == nullptr)
return nullptr;
Platform::String^ uriStr = WINRT_ProtocolActivationURI;
const wchar_t* uriWide = uriStr->Data();
int uriLen = WideCharToMultiByte(CP_UTF8, 0, uriWide, -1, nullptr, 0, nullptr, nullptr);
char* uriUtf8 = (char*)SDL_malloc(uriLen);
if (uriUtf8)
WideCharToMultiByte(CP_UTF8, 0, uriWide, -1, uriUtf8, uriLen, nullptr, nullptr);
// Clear after first successful read (only return it once)
WINRT_ProtocolActivationURI = nullptr;
return uriUtf8;
}
static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identifying thing into WINRT_ProcessWindowSizeChange()
{
CoreWindow ^ coreWindow = CoreWindow::GetForCurrentThread();
@@ -237,12 +164,6 @@ SDL_WinRTApp::SDL_WinRTApp() : m_windowClosed(false),
{
}
SDL_WinRTApp::~SDL_WinRTApp()
{
// Launch exit URI if set (handles protocol activation returning to caller)
WINRT_LaunchExitUriIfSet();
}
void SDL_WinRTApp::Initialize(CoreApplicationView ^ applicationView)
{
applicationView->Activated +=
@@ -664,29 +585,15 @@ void SDL_WinRTApp::OnWindowClosed(CoreWindow ^ sender, CoreWindowEventArgs ^ arg
SDL_Log("%s\n", __FUNCTION__);
#endif
m_windowClosed = true;
WINRT_LaunchExitUriIfSet();
}
void SDL_WinRTApp::OnAppActivated(CoreApplicationView ^ applicationView, IActivatedEventArgs ^ args)
{
if (args->Kind == Windows::ApplicationModel::Activation::ActivationKind::Protocol)
{
auto protocolArgs = dynamic_cast<Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^>(args);
if (protocolArgs && protocolArgs->Uri)
{
WINRT_ProtocolActivationURI = protocolArgs->Uri->AbsoluteUri;
// Extract and store launchOnExit URI before main URI gets cleared
WINRT_ExtractLaunchOnExitURI(WINRT_ProtocolActivationURI);
}
}
CoreWindow::GetForCurrentThread()->Activate();
}
void SDL_WinRTApp::OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^ args)
{
// Launch exit URI if set before suspending
WINRT_LaunchExitUriIfSet();
// Save app state asynchronously after requesting a deferral. Holding a deferral
// indicates that the application is busy performing suspending operations. Be
// aware that a deferral may not be held indefinitely. After about five seconds,
@@ -740,7 +647,6 @@ void SDL_WinRTApp::OnResuming(Platform::Object ^ sender, Platform::Object ^ args
void SDL_WinRTApp::OnExiting(Platform::Object ^ sender, Platform::Object ^ args)
{
SDL_SendAppEvent(SDL_APP_TERMINATING);
WINRT_LaunchExitUriIfSet();
}
static void WINRT_LogPointerEvent(const char *header, Windows::UI::Core::PointerEventArgs ^ args, Windows::Foundation::Point transformedPoint)
-1
View File
@@ -26,7 +26,6 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo
{
public:
SDL_WinRTApp();
virtual ~SDL_WinRTApp();
// IFrameworkView Methods.
virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView ^ applicationView);
-1
View File
@@ -872,4 +872,3 @@
++'_SDL_DestroyWindowSurface'.'SDL2.dll'.'SDL_DestroyWindowSurface'
# ++'_SDL_GDKGetDefaultUser'.'SDL2.dll'.'SDL_GDKGetDefaultUser'
++'_SDL_GameControllerGetSteamHandle'.'SDL2.dll'.'SDL_GameControllerGetSteamHandle'
# ++'_SDL_WinRTGetProtocolActivationURI'.'SDL2.dll'.'SDL_WinRTGetProtocolActivationURI'
-1
View File
@@ -898,4 +898,3 @@
#define SDL_DestroyWindowSurface SDL_DestroyWindowSurface_REAL
#define SDL_GDKGetDefaultUser SDL_GDKGetDefaultUser_REAL
#define SDL_GameControllerGetSteamHandle SDL_GameControllerGetSteamHandle_REAL
#define SDL_WinRTGetProtocolActivationURI SDL_WinRTGetProtocolActivationURI_REAL
-3
View File
@@ -985,6 +985,3 @@ SDL_DYNAPI_PROC(int,SDL_DestroyWindowSurface,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GDKGetDefaultUser,(XUserHandle *a),(a),return)
#endif
SDL_DYNAPI_PROC(Uint64,SDL_GameControllerGetSteamHandle,(SDL_GameController *a),(a),return)
#if defined(__WINRT__)
SDL_DYNAPI_PROC(char*,SDL_WinRTGetProtocolActivationURI,(void),(),return)
#endif
+4 -4
View File
@@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,33,0,0
PRODUCTVERSION 2,33,0,0
FILEVERSION 2,32,11,0
PRODUCTVERSION 2,32,11,0
FILEFLAGSMASK 0x3fL
FILEFLAGS 0x0L
FILEOS 0x40004L
@@ -23,12 +23,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "SDL\0"
VALUE "FileVersion", "2, 33, 0, 0\0"
VALUE "FileVersion", "2, 32, 11, 0\0"
VALUE "InternalName", "SDL\0"
VALUE "LegalCopyright", "Copyright (C) 2025 Sam Lantinga\0"
VALUE "OriginalFilename", "SDL2.dll\0"
VALUE "ProductName", "Simple DirectMedia Layer\0"
VALUE "ProductVersion", "2, 33, 0, 0\0"
VALUE "ProductVersion", "2, 32, 11, 0\0"
END
END
BLOCK "VarFileInfo"
-42
View File
@@ -29,12 +29,6 @@
#include "software/SDL_render_sw_c.h"
#include "../video/SDL_pixels_c.h"
#if defined(__loongarch__)
#if SDL_VIDEO_OPENGL
#include "SDL_opengl.h"
#endif /* SDL_VIDEO_OPENGL */
#endif
#if defined(__ANDROID__)
#include "../core/android/SDL_android.h"
#endif
@@ -960,34 +954,6 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind
}
#endif /* !SDL_RENDER_DISABLED */
#if defined(__loongarch__)
static SDL_bool SDL_CheckIntegratedGraphics()
{
SDL_Window *window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32,
SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN);
SDL_bool has_lg100_or_lg110 = SDL_FALSE;
if (window) {
SDL_GLContext context = SDL_GL_CreateContext(window);
if (context) {
const GLubyte *(APIENTRY *glGetStringFunc)(GLenum) =
SDL_GL_GetProcAddress("glGetString");
if (glGetStringFunc) {
const char *renderer = (const char*)glGetStringFunc(GL_RENDERER);
if (renderer && (SDL_strstr(renderer, "LG110") ||
SDL_strstr(renderer, "LG100"))) {
has_lg100_or_lg110 = SDL_TRUE;
}
}
SDL_GL_DeleteContext(context);
}
SDL_DestroyWindow(window);
}
return has_lg100_or_lg110;
}
#endif
SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
{
#ifndef SDL_RENDER_DISABLED
@@ -1001,14 +967,6 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags)
Android_ActivityMutex_Lock_Running();
#endif
/* CPU acceleration runs faster than integrated graphics on Loongson at present. */
#if defined(__linux__) && defined(__loongarch__)
if (SDL_CheckIntegratedGraphics()) {
SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0");
flags = SDL_RENDERER_SOFTWARE;
}
#endif
if (!window) {
SDL_InvalidParamError("window");
goto error;
+16 -178
View File
@@ -76,24 +76,6 @@ typedef struct
SDL_Texture *texture;
} PSP_BlendState;
typedef struct
{
SDL_Rect viewport;
SDL_bool viewport_dirty;
SDL_bool viewport_is_set;
SDL_bool cliprect_enabled_dirty;
SDL_bool cliprect_enabled;
SDL_bool cliprect_dirty;
SDL_Rect cliprect;
float draw_offset_x;
float draw_offset_y;
int drawablew;
int drawableh;
} PSP_DrawstateCache;
typedef struct
{
void *frontbuffer; /**< main screen buffer */
@@ -109,7 +91,6 @@ typedef struct
PSP_TextureData *most_recent_target; /**< start of render target LRU double linked list */
PSP_TextureData *least_recent_target; /**< end of the LRU list */
PSP_DrawstateCache drawstate;
SDL_bool vblank_not_reached; /**< whether vblank wasn't reached */
} PSP_RenderData;
@@ -1053,105 +1034,10 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state)
*current = *state;
}
static void ClampCliprectToViewport(SDL_Rect *clip, const SDL_Rect *viewport)
{
int max_x_v, max_y_v, max_x_c, max_y_c;
if (clip->x < 0) {
clip->w += clip->x;
clip->x = 0;
}
if (clip->y < 0) {
clip->h += clip->y;
clip->y = 0;
}
max_x_c = clip->x + clip->w;
max_y_c = clip->y + clip->h;
max_x_v = viewport->x + viewport->w;
max_y_v = viewport->y + viewport->h;
if (max_x_c > max_x_v) {
clip->w -= (max_x_v - max_x_c);
}
if (max_y_c > max_y_v) {
clip->h -= (max_y_v - max_y_c);
}
}
static void SetDrawState(PSP_RenderData *data)
{
if (data->drawstate.viewport_dirty) {
SDL_Rect *viewport = &data->drawstate.viewport;
/* FIXME: Find a genuine way to make viewport work (right now calling these functions here give no effect) */
/*
sceGuOffset(2048 - (480 >> 1) + viewport->x, 2048 - (272 >> 1) + viewport->y);
sceGuViewport(2048, 2048, viewport->w, viewport->h);
*/
data->drawstate.draw_offset_x = viewport->x;
data->drawstate.draw_offset_y = viewport->y;
data->drawstate.viewport_dirty = SDL_FALSE;
}
if (data->drawstate.cliprect_enabled_dirty) {
if (!data->drawstate.cliprect_enabled && !data->drawstate.viewport_is_set) {
sceGuScissor(0, 0, data->drawstate.drawablew, data->drawstate.drawableh);
sceGuEnable(GU_SCISSOR_TEST);
}
data->drawstate.cliprect_enabled_dirty = SDL_FALSE;
}
if ((data->drawstate.cliprect_enabled || data->drawstate.viewport_is_set) && data->drawstate.cliprect_dirty) {
SDL_Rect rect;
SDL_Rect *viewport = &data->drawstate.viewport;
SDL_copyp(&rect, &data->drawstate.cliprect);
if (data->drawstate.viewport_is_set) {
ClampCliprectToViewport(&rect, viewport);
rect.x += viewport->x;
rect.y += viewport->y;
}
sceGuEnable(GU_SCISSOR_TEST);
sceGuScissor(rect.x, rect.y, rect.w, rect.h);
data->drawstate.cliprect_dirty = SDL_FALSE;
}
}
#define PSP_VERTICES_FUNK(FunkName, Type) \
static const Type *FunkName(const PSP_DrawstateCache *drawstate, Uint8 *gpumem, SDL_RenderCommand *cmd, size_t count) \
{ \
size_t i; \
float off_x, off_y; \
Type *verts = (Type *)(gpumem + cmd->data.draw.first); \
\
if (!drawstate->viewport_is_set) { \
return verts; \
} \
\
off_x = drawstate->draw_offset_x; \
off_y = drawstate->draw_offset_y; \
\
for (i = 0; i < count; ++i) { \
verts[i].x += off_x; \
verts[i].y += off_y; \
} \
\
return verts;\
}
PSP_VERTICES_FUNK(PSP_GetVertV, VertV)
PSP_VERTICES_FUNK(PSP_GetVertTV, VertTV)
PSP_VERTICES_FUNK(PSP_GetVertCV, VertCV)
PSP_VERTICES_FUNK(PSP_GetVertTCV, VertTCV)
static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
{
PSP_RenderData *data = (PSP_RenderData *)renderer->driverdata;
Uint8 *gpumem = NULL;
int w = 0, h = 0;
StartDrawing(renderer);
/* note that before the renderer interface change, this would do extrememly small
@@ -1166,21 +1052,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
}
SDL_memcpy(gpumem, vertices, vertsize);
if (!data->boundTarget) {
SDL_GL_GetDrawableSize(renderer->window, &w, &h);
} else {
PSP_TextureData *psp_texture = (PSP_TextureData *)data->boundTarget->driverdata;
w = psp_texture->width;
h = psp_texture->height;
}
if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {
data->drawstate.viewport_dirty = SDL_TRUE; /* if the window dimensions changed, invalidate the current viewport, etc. */
data->drawstate.cliprect_dirty = SDL_TRUE;
data->drawstate.drawablew = w;
data->drawstate.drawableh = h;
}
while (cmd) {
switch (cmd->command) {
case SDL_RENDERCMD_SETDRAWCOLOR:
@@ -1190,42 +1061,22 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_SETVIEWPORT:
{
SDL_Rect *viewport = &data->drawstate.viewport;
if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) {
SDL_copyp(viewport, &cmd->data.viewport.rect);
data->drawstate.viewport_dirty = SDL_TRUE;
data->drawstate.cliprect_dirty = SDL_TRUE;
data->drawstate.viewport_is_set = viewport->x != 0 || viewport->y != 0 || viewport->w != data->drawstate.drawablew || viewport->h != data->drawstate.drawableh;
if (!data->drawstate.cliprect_enabled) {
if (data->drawstate.viewport_is_set) {
SDL_copyp(&data->drawstate.cliprect, viewport);
data->drawstate.cliprect.x = 0;
data->drawstate.cliprect.y = 0;
} else {
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
}
}
}
SDL_Rect *viewport = &cmd->data.viewport.rect;
sceGuOffset(2048 - (viewport->w >> 1), 2048 - (viewport->h >> 1));
sceGuViewport(2048, 2048, viewport->w, viewport->h);
sceGuScissor(viewport->x, viewport->y, viewport->w, viewport->h);
/* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */
break;
}
case SDL_RENDERCMD_SETCLIPRECT:
{
const SDL_Rect *rect = &cmd->data.cliprect.rect;
const SDL_Rect *viewport = &data->drawstate.viewport;
if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) {
data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled;
data->drawstate.cliprect_enabled_dirty = SDL_TRUE;
if (!data->drawstate.cliprect_enabled && data->drawstate.viewport_is_set) {
SDL_copyp(&data->drawstate.cliprect, viewport);
data->drawstate.cliprect.x = 0;
data->drawstate.cliprect.y = 0;
}
}
if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof(*rect)) != 0) {
SDL_copyp(&data->drawstate.cliprect, rect);
data->drawstate.cliprect_dirty = SDL_TRUE;
if (cmd->data.cliprect.enabled) {
sceGuEnable(GU_SCISSOR_TEST);
sceGuScissor(rect->x, rect->y, rect->w, rect->h);
} else {
sceGuDisable(GU_SCISSOR_TEST);
}
break;
}
@@ -1236,7 +1087,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
const Uint8 g = cmd->data.color.g;
const Uint8 b = cmd->data.color.b;
const Uint8 a = cmd->data.color.a;
SetDrawState(data);
sceGuClearColor(GU_RGBA(r, g, b, a));
sceGuClearStencil(a);
sceGuClear(GU_COLOR_BUFFER_BIT | GU_STENCIL_BUFFER_BIT);
@@ -1246,7 +1096,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_DRAW_POINTS:
{
const size_t count = cmd->data.draw.count;
const VertV *verts; /* = (VertV *)(gpumem + cmd->data.draw.first);*/
const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first);
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
@@ -1257,8 +1107,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_FLAT
};
SetDrawState(data);
verts = PSP_GetVertV(&data->drawstate, gpumem, cmd, count);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_POINTS, GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
break;
@@ -1267,7 +1115,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_DRAW_LINES:
{
const size_t count = cmd->data.draw.count;
const VertV *verts; /* = (VertV *)(gpumem + cmd->data.draw.first);*/
const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first);
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
@@ -1278,8 +1126,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_FLAT
};
SetDrawState(data);
verts = PSP_GetVertV(&data->drawstate, gpumem, cmd, count);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_LINE_STRIP, GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
break;
@@ -1288,7 +1134,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_FILL_RECTS:
{
const size_t count = cmd->data.draw.count;
const VertV *verts; /* = (VertV *)(gpumem + cmd->data.draw.first);*/
const VertV *verts = (VertV *)(gpumem + cmd->data.draw.first);
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
const Uint8 b = cmd->data.draw.b;
@@ -1299,8 +1145,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_FLAT
};
SetDrawState(data);
verts = PSP_GetVertV(&data->drawstate, gpumem, cmd, 2 * count);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_SPRITES, GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2 * count, 0, verts);
break;
@@ -1309,7 +1153,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_COPY:
{
const size_t count = cmd->data.draw.count;
const VertTV *verts; /*= (VertTV *)(gpumem + cmd->data.draw.first);*/
const VertTV *verts = (VertTV *)(gpumem + cmd->data.draw.first);
const Uint8 a = cmd->data.draw.a;
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
@@ -1320,8 +1164,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_SMOOTH
};
SetDrawState(data);
verts = PSP_GetVertTV(&data->drawstate, gpumem, cmd, 2 * count);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2 * count, 0, verts);
break;
@@ -1340,8 +1182,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_SMOOTH
};
SetDrawState(data);
verts = PSP_GetVertTV(&data->drawstate, gpumem, cmd, 4);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_TRIANGLE_FAN, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, 0, verts);
break;
@@ -1350,15 +1190,14 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
case SDL_RENDERCMD_GEOMETRY:
{
const size_t count = cmd->data.draw.count;
SetDrawState(data);
if (!cmd->data.draw.texture) {
const VertCV *verts = PSP_GetVertCV(&data->drawstate, gpumem, cmd, count);
const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first);
sceGuDisable(GU_TEXTURE_2D);
/* In GU_SMOOTH mode */
sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
sceGuEnable(GU_TEXTURE_2D);
} else {
const VertTCV *verts; /*= (VertTCV *)(gpumem + cmd->data.draw.first);*/
const VertTCV *verts = (VertTCV *)(gpumem + cmd->data.draw.first);
const Uint8 a = cmd->data.draw.a;
const Uint8 r = cmd->data.draw.r;
const Uint8 g = cmd->data.draw.g;
@@ -1369,7 +1208,6 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
.mode = cmd->data.draw.blend,
.shadeModel = GU_FLAT
};
verts = PSP_GetVertTCV(&data->drawstate, gpumem, cmd, count);
TextureActivate(cmd->data.draw.texture);
PSP_SetBlendState(data, &state);
sceGuDrawArray(GU_TRIANGLES, GU_TEXTURE_32BITF | GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, count, 0, verts);
-1
View File
@@ -399,7 +399,6 @@ struct SDL_VideoDevice
int no_error;
int retained_backing;
int driver_loaded;
int HAS_GL_ARB_color_buffer_float;
char driver_path[256];
void *dll_handle;
} gl_config;
-13
View File
@@ -70,10 +70,6 @@
#include <dlfcn.h>
#endif
#ifndef GL_RGBA_FLOAT_MODE_ARB
#define GL_RGBA_FLOAT_MODE_ARB 0x8820
#endif /* GL_RGBA_FLOAT_MODE_ARB */
/* Available video drivers */
static VideoBootStrap *bootstrap[] = {
#ifdef SDL_VIDEO_DRIVER_COCOA
@@ -4040,15 +4036,6 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value)
*value = _this->gl_config.no_error;
return 0;
}
case SDL_GL_FLOATBUFFERS:
{
if (_this->gl_config.HAS_GL_ARB_color_buffer_float) {
attrib = GL_RGBA_FLOAT_MODE_ARB;
break;
} else {
return 0;
}
}
default:
return SDL_SetError("Unknown OpenGL attribute");
}
+1 -8
View File
@@ -511,10 +511,6 @@ void WIN_GL_InitExtensions(_THIS)
_this->gl_data->HAS_WGL_ARB_create_context_no_error = SDL_TRUE;
}
/* Check for WGL_ARB_pixel_format_float */
_this->gl_data->HAS_WGL_ARB_pixel_format_float =
HasExtension("WGL_ARB_pixel_format_float", extensions);
_this->gl_data->wglMakeCurrent(hdc, NULL);
_this->gl_data->wglDeleteContext(hglrc);
ReleaseDC(hwnd, hdc);
@@ -645,7 +641,7 @@ static int WIN_GL_SetupWindowInternal(_THIS, SDL_Window *window)
*iAttr++ = _this->gl_config.multisamplesamples;
}
if (_this->gl_data->HAS_WGL_ARB_pixel_format_float && _this->gl_config.floatbuffers) {
if (_this->gl_config.floatbuffers) {
*iAttr++ = WGL_PIXEL_TYPE_ARB;
*iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB;
}
@@ -829,9 +825,6 @@ SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window *window)
return NULL;
}
_this->gl_config.HAS_GL_ARB_color_buffer_float =
SDL_GL_ExtensionSupported("GL_ARB_color_buffer_float");
return context;
}
-1
View File
@@ -64,7 +64,6 @@ struct SDL_GLDriverData
SDL_bool HAS_WGL_ARB_context_flush_control;
SDL_bool HAS_WGL_ARB_create_context_robustness;
SDL_bool HAS_WGL_ARB_create_context_no_error;
SDL_bool HAS_WGL_ARB_pixel_format_float;
/* Max version of OpenGL ES context that can be created if the
implementation supports WGL_EXT_create_context_es2_profile.
-3
View File
@@ -67,9 +67,6 @@ static SDL_bool DriverIsProblematic(const char *driver)
*/
"dsp",
/* Jack isn't always configured properly on end user systems */
"jack",
/* OpenBSD sound API. Can be used on Linux, but very rare. */
"sndio",
+33 -83
View File
@@ -88,19 +88,9 @@ int hints_getHint(void *arg)
return TEST_COMPLETED;
}
typedef struct {
char *name;
char *value;
char *oldValue;
} HintCallbackContext;
static void SDLCALL hints_testHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint)
{
HintCallbackContext *context = userdata;
context->name = name ? SDL_strdup(name) : NULL;
context->value = hint ? SDL_strdup(hint) : NULL;
context->oldValue = oldValue ? SDL_strdup(oldValue) : NULL;
*(char **)userdata = hint ? SDL_strdup(hint) : NULL;
}
/**
@@ -112,7 +102,7 @@ int hints_setHint(void *arg)
const char *originalValue;
char *value;
const char *testValue;
HintCallbackContext callback_data;
char *callbackValue;
SDL_bool result;
int i, j;
@@ -162,10 +152,8 @@ int hints_setHint(void *arg)
SDLTest_AssertPass("Call to SDL_GetHint() after saving and restoring hint");
originalValue = SDL_GetHint(testHint);
value = (originalValue == NULL) ? NULL : SDL_strdup(originalValue);
result = SDL_SetHint(testHint, "temp");
SDLTest_AssertCheck(!result, "SDL_SetHint(\"%s\", \"temp\") should return false", testHint);
result = SDL_SetHint(testHint, value);
SDLTest_AssertCheck(!result, "SDL_SetHint(\"%s\", \"%s\" should return false", testHint, value);
SDL_SetHint(testHint, "temp");
SDL_SetHint(testHint, value);
SDL_free(value);
testValue = SDL_GetHint(testHint);
SDLTest_AssertCheck(
@@ -174,26 +162,15 @@ int hints_setHint(void *arg)
testValue);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_DEFAULT)");
result = SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_DEFAULT);
SDLTest_AssertCheck(!result, "SDL_SetHintWithPriority(\"%s\", NULL, SDL_HINT_DEFAULT) should return false", testHint);
SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_DEFAULT);
testValue = SDL_GetHint(testHint);
SDLTest_AssertCheck(
testValue && SDL_strcmp(testValue, "original") == 0,
"testValue = %s, expected \"original\"",
testValue);
SDLTest_AssertPass("Call to SDL_SetHint(\"\", \"data\")");
result = SDL_SetHint("", "data");
SDLTest_AssertCheck(result, "SDL_SetHint(\"\", \"data\") should return true");
testValue = SDL_GetHint("");
SDLTest_AssertCheck(
testValue && SDL_strcmp(testValue, "data") == 0,
"testValue = %s, expected \"data\"",
testValue);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE)");
result = SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(result, "SDL_SetHintWithPriority(\"%s\", \"temp\", SDL_HINT_OVERRIDE) should return true", testHint);
SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
testValue = SDL_GetHint(testHint);
SDLTest_AssertCheck(
testValue && SDL_strcmp(testValue, "temp") == 0,
@@ -201,8 +178,7 @@ int hints_setHint(void *arg)
testValue);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(NULL, SDL_HINT_OVERRIDE)");
result = SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(result, "SDL_SetHintWithPriority(\"%s\", NULL, SDL_HINT_OVERRIDE) should return true", testHint);
SDL_SetHintWithPriority(testHint, NULL, SDL_HINT_OVERRIDE);
testValue = SDL_GetHint(testHint);
SDLTest_AssertCheck(
testValue == NULL,
@@ -218,75 +194,49 @@ int hints_setHint(void *arg)
testValue);
/* Make sure callback functionality works past a reset */
SDL_zero(callback_data);
SDLTest_AssertPass("Call to SDL_AddHintCallback()");
SDL_AddHintCallback(testHint, hints_testHintChanged, &callback_data);
callbackValue = NULL;
SDL_AddHintCallback(testHint, hints_testHintChanged, &callbackValue);
SDLTest_AssertCheck(
callback_data.name && SDL_strcmp(callback_data.name, testHint) == 0,
"callback_data.name = \"%s\", expected \"%s\"",
callback_data.name, testHint);
callbackValue && SDL_strcmp(callbackValue, "original") == 0,
"callbackValue = %s, expected \"original\"",
callbackValue);
SDL_free(callbackValue);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback");
callbackValue = NULL;
SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(
callback_data.value && SDL_strcmp(callback_data.value, "original") == 0,
"callback_data.value = \"%s\", expected \"%s\"",
callback_data.value, "original");
SDL_free(callback_data.name);
SDL_free(callback_data.value);
SDL_free(callback_data.oldValue);
callbackValue && SDL_strcmp(callbackValue, "temp") == 0,
"callbackValue = %s, expected \"temp\"",
callbackValue);
SDL_free(callbackValue);
SDLTest_AssertPass("Call to SDL_ResetHint(), using callback");
SDL_zero(callback_data);
callbackValue = NULL;
SDL_ResetHint(testHint);
SDLTest_AssertCheck(
callback_data.value && SDL_strcmp(callback_data.value, "original") == 0,
callbackValue && SDL_strcmp(callbackValue, "original") == 0,
"callbackValue = %s, expected \"original\"",
callback_data.value);
SDL_free(callback_data.name);
SDL_free(callback_data.value);
SDL_free(callback_data.oldValue);
callbackValue);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback after reset");
SDL_zero(callback_data);
result = SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(result, "SDL_SetHintWithPriority(\"%s\", \"temp\", SDL_HINT_OVERRIDE) should return true", testHint);
callbackValue = NULL;
SDL_SetHintWithPriority(testHint, "temp", SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(
callback_data.value && SDL_strcmp(callback_data.value, "temp") == 0,
callbackValue && SDL_strcmp(callbackValue, "temp") == 0,
"callbackValue = %s, expected \"temp\"",
callback_data.value);
SDL_free(callback_data.name);
SDL_free(callback_data.value);
SDL_free(callback_data.oldValue);
callbackValue);
SDL_free(callbackValue);
SDLTest_AssertPass("Call to SDL_ResetHint(), after clearing callback");
SDL_zero(callback_data);
SDL_DelHintCallback(testHint, hints_testHintChanged, &callback_data);
callbackValue = NULL;
SDL_DelHintCallback(testHint, hints_testHintChanged, &callbackValue);
SDL_ResetHint(testHint);
SDLTest_AssertCheck(
!callback_data.value,
callbackValue == NULL,
"callbackValue = %s, expected \"(null)\"",
callback_data.value);
SDL_free(callback_data.name);
SDL_free(callback_data.value);
SDL_free(callback_data.oldValue);
/* Make sure callback functionality work with hint renamed in sdl3 */
SDLTest_AssertPass("Call to SDL_AddHintCallback()");
SDL_AddHintCallback(SDL_HINT_ALLOW_TOPMOST, hints_testHintChanged, &callback_data);
SDLTest_AssertPass("Call to SDL_SetHintWithPriority(\"temp\", SDL_HINT_OVERRIDE), using callback");
SDL_zero(callback_data);
result = SDL_SetHintWithPriority(SDL_HINT_ALLOW_TOPMOST, "temp", SDL_HINT_OVERRIDE);
SDLTest_AssertCheck(result, "SDL_SetHintWithPriority(\"%s\", \"temp\", SDL_HINT_OVERRIDE) should return true", testHint);
SDLTest_AssertCheck(
callback_data.name && SDL_strcmp(callback_data.name, SDL_HINT_ALLOW_TOPMOST) == 0,
"callback_data.name = \"%s\", expected \"%s\"",
callback_data.name, SDL_HINT_ALLOW_TOPMOST);
SDLTest_AssertCheck(
callback_data.value && SDL_strcmp(callback_data.value, "temp") == 0,
"callback_data.value = \"%s\", expected \"%s\"",
callback_data.value, "temp");
SDL_free(callback_data.name);
SDL_free(callback_data.value);
SDL_free(callback_data.oldValue);
SDL_ResetHint(testHint);
callbackValue);
return TEST_COMPLETED;
}
+6 -279
View File
@@ -12,38 +12,6 @@
/* Helper functions */
/* !
* \brief Private helper to check SDL_FRect equality
*/
static SDL_bool IsFRectEqual(const SDL_FRect *r1, const SDL_FRect *r2) {
static const float MAX_DELTA = 1e-5f;
SDL_FRect delta;
delta.x = r1->x - r2->x;
delta.y = r1->y - r2->y;
delta.w = r1->w - r2->w;
delta.h = r1->h - r2->h;
return -MAX_DELTA <= delta.x && delta.x <= MAX_DELTA
&& -MAX_DELTA <= delta.y && delta.y <= MAX_DELTA
&& -MAX_DELTA <= delta.w && delta.w <= MAX_DELTA
&& -MAX_DELTA <= delta.w && delta.h <= MAX_DELTA;
}
/* !
* \brief Private helper to check SDL_FPoint equality
*/
static SDL_bool IsFPointEqual(const SDL_FPoint *p1, const SDL_FPoint *p2) {
static const float MAX_DELTA = 1e-5f;
SDL_FPoint delta;
delta.x = p1->x - p2->x;
delta.y = p1->y - p2->y;
return -MAX_DELTA <= delta.x && delta.x <= MAX_DELTA
&& -MAX_DELTA <= delta.y && delta.y <= MAX_DELTA;
}
/* Helper functions */
/* !
* \brief Private helper to check SDL_IntersectRectAndLine results
*/
@@ -733,8 +701,8 @@ int rect_testIntersectRectEmpty(void *arg)
*/
int rect_testIntersectRectParam(void *arg)
{
const SDL_Rect rectA = { 0, 0, 32, 32 };
const SDL_Rect rectB = { 0, 0, 32, 32 };
SDL_Rect rectA;
SDL_Rect rectB = { 0 };
SDL_Rect result;
SDL_bool intersection;
@@ -988,8 +956,8 @@ int rect_testHasIntersectionEmpty(void *arg)
*/
int rect_testHasIntersectionParam(void *arg)
{
const SDL_Rect rectA = { 0, 0, 32, 32 };
const SDL_Rect rectB = { 0, 0, 32, 32 };
SDL_Rect rectA;
SDL_Rect rectB = { 0 };
SDL_bool intersection;
/* invalid parameter combinations */
@@ -1524,8 +1492,7 @@ int rect_testUnionRectInside(void *arg)
*/
int rect_testUnionRectParam(void *arg)
{
const SDL_Rect rectA = { 0, 0, 32, 32 };
const SDL_Rect rectB = { 0, 0, 32, 32 };
SDL_Rect rectA, rectB = { 0 };
SDL_Rect result;
/* invalid parameter combinations */
@@ -1731,226 +1698,6 @@ int rect_testFRectEqualsParam(void *arg)
return TEST_COMPLETED;
}
/* !
* \brief Test SDL_HasIntersectionF
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_HasIntersectionF
*/
int rect_testHasIntersectionF(void *arg)
{
const struct {
SDL_FRect r1;
SDL_FRect r2;
SDL_bool expected;
} cases[] = {
{ { 0, 0, 0, 0 }, {0, 0, 0, 0}, SDL_FALSE },
{ { 0, 0, -200, 200 }, {0, 0, -200, 200}, SDL_FALSE },
{ { 0, 0, 10, 10 }, {-5, 5, 10, 2}, SDL_TRUE },
{ { 0, 0, 10, 10 }, {-5, -5, 10, 2}, SDL_FALSE },
{ { 0, 0, 10, 10 }, {-5, -5, 2, 10}, SDL_FALSE },
{ { 0, 0, 10, 10 }, {-5, -5, 5, 5}, SDL_FALSE },
{ { 0, 0, 10, 10 }, {-5, -5, 5.1f, 5.1f}, SDL_TRUE },
{ { 0, 0, 10, 10 }, {-4.99f, -4.99f, 5, 5}, SDL_TRUE },
};
size_t i;
for (i = 0; i < SDL_arraysize(cases); i++) {
SDL_bool result;
SDLTest_AssertPass("About to call SDL_HasIntersectionF(&{ %g, %g, %g, %g }, &{ %g, %g, %g, %g })",
cases[i].r1.x, cases[i].r1.y, cases[i].r1.w, cases[i].r1.h,
cases[i].r2.x, cases[i].r2.y, cases[i].r2.w, cases[i].r2.h
);
result = SDL_HasIntersectionF(&cases[i].r1, &cases[i].r2);
SDLTest_AssertCheck(result == cases[i].expected, "Got %d, expected %d", result, cases[i].expected);
}
return TEST_COMPLETED;
}
/* !
* \brief Test SDL_IntersectFRect
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_IntersectFRect
*/
int rect_testIntersectFRect(void *arg)
{
const struct {
SDL_FRect r1;
SDL_FRect r2;
SDL_bool result;
SDL_FRect intersect;
} cases[] = {
{ { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, SDL_FALSE },
{ { 0, 0, -200, 200 }, { 0, 0, -200, 200 }, SDL_FALSE },
{ { 0, 0, 10, 10 }, { -5, 5, 9.9f, 2 }, SDL_TRUE, { 0, 5, 4.9f, 2 } },
{ { 0, 0, 10, 10 }, { -5, -5, 10, 2 }, SDL_FALSE},
{ { 0, 0, 10, 10 }, { -5, -5, 2, 10 }, SDL_FALSE},
{ { 0, 0, 10, 10 }, { -5, -5, 5, 5 }, SDL_FALSE},
{ { 0, 0, 10, 10 }, { -5, -5, 5.5f, 6 }, SDL_TRUE, { 0, 0, 0.5f, 1 } }
};
size_t i;
for (i = 0; i < SDL_arraysize(cases); i++) {
SDL_bool result;
SDL_FRect intersect;
SDLTest_AssertPass("About to call SDL_IntersectFRect(&{ %g, %g, %g, %g }, &{ %g, %g, %g, %g })",
cases[i].r1.x, cases[i].r1.y, cases[i].r1.w, cases[i].r1.h,
cases[i].r2.x, cases[i].r2.y, cases[i].r2.w, cases[i].r2.h
);
result = SDL_IntersectFRect(&cases[i].r1, &cases[i].r2, &intersect);
SDLTest_AssertCheck(result == cases[i].result, "Got %d, expected %d", result, cases[i].result);
if (cases[i].result) {
SDLTest_AssertCheck(IsFRectEqual(&intersect, &cases[i].intersect),
"Got { %g, %g, %g, %g }, expected { %g, %g, %g, %g }",
intersect.x, intersect.y, intersect.w, intersect.h,
cases[i].intersect.x, cases[i].intersect.y, cases[i].intersect.w, cases[i].intersect.h);
}
}
return TEST_COMPLETED;
}
/* !
* \brief Test SDL_UnionFRect
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_UnionFRect
*/
int rect_testUnionFRect(void *arg)
{
const struct {
SDL_FRect r1;
SDL_FRect r2;
SDL_FRect expected;
} cases[] = {
{ { 0, 0, 10, 10 }, { 19.9f, 20, 10, 10 }, { 0, 0, 29.9f, 30 } },
{ { 0, 0, 0, 0 }, { 20, 20.1f, 10.1f, 10 }, { 20, 20.1f, 10.1f, 10 } },
{ { -200, -4.5f, 450, 33 }, { 20, 20, 10, 10 }, { -200, -4.5f, 450, 34.5f } },
{ { 0, 0, 15, 16.5f }, { 20, 20, 0, 0 }, { 0, 0, 15, 16.5f } }
};
size_t i;
for (i = 0; i < SDL_arraysize(cases); i++) {
SDL_FRect result;
SDLTest_AssertPass("About to call SDL_UnionFRect(&{ %g, %g, %g, %g }, &{ %g, %g, %g, %g })",
cases[i].r1.x, cases[i].r1.y, cases[i].r1.w, cases[i].r1.h,
cases[i].r2.x, cases[i].r2.y, cases[i].r2.w, cases[i].r2.h
);
SDL_UnionFRect(&cases[i].r1, &cases[i].r2, &result);
SDLTest_AssertCheck(IsFRectEqual(&result, &cases[i].expected),
"Got { %g, %g, %g, %g }, expected { %g, %g, %g, %g }",
result.x, result.y, result.w, result.h,
cases[i].expected.x, cases[i].expected.y, cases[i].expected.w, cases[i].expected.h);
}
return TEST_COMPLETED;
}
/* !
* \brief Test SDL_EncloseFPointsUnionFRect
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_EncloseFPoints
*/
int rect_testEncloseFPoints(void *arg)
{
const struct {
SDL_bool with_clip;
SDL_FRect clip;
SDL_bool result;
SDL_FRect enclosing;
} cases[] = {
{ SDL_TRUE, { 0, 0, 10, 10 }, SDL_TRUE, { 0.5f, 0.1f, 6, 8 }},
{ SDL_TRUE, { 1.2f, 1, 10, 10 }, SDL_TRUE, { 1.5f, 1.1f, 5, 7 }},
{ SDL_TRUE, { -10, -10, 3, 3 }, SDL_FALSE },
{ SDL_FALSE, { 0 }, SDL_TRUE, { 0.5, 0.1f, 6, 8 }}
};
const SDL_FPoint points[] = {
{ 0.5f, 0.1f },
{ 5.5f, 7.1f },
{ 1.5f, 1.1f }
};
char points_str[256];
size_t i;
SDL_strlcpy(points_str, "{", sizeof(points_str));
for (i = 0; i < SDL_arraysize(points); i++) {
char point_str[32];
SDL_snprintf(point_str, sizeof(point_str), "{ %g, %g }, ", points[i].x, points[i].y);
SDL_strlcat(points_str, point_str, sizeof(points_str));
}
SDL_strlcat(points_str, "}", sizeof(points_str));
for (i = 0; i < SDL_arraysize(cases); i++) {
char clip_str[64];
SDL_bool result;
SDL_FRect enclosing;
const SDL_FRect* clip_ptr = NULL;
if (cases[i].with_clip) {
SDL_snprintf(clip_str, sizeof(clip_str), "&{ %g, %g, %g, %g }",
cases[i].clip.x, cases[i].clip.y, cases[i].clip.w, cases[i].clip.h);
clip_ptr = &cases[i].clip;
} else {
SDL_strlcpy(clip_str, "NULL", sizeof(clip_str));
}
SDLTest_AssertPass("About to call SDL_EncloseFPoints(&%s, %d, %s)", points_str, (int)SDL_arraysize(points), clip_str);
result = SDL_EncloseFPoints(points, SDL_arraysize(points), clip_ptr, &enclosing);
SDLTest_AssertCheck(result == cases[i].result, "Got %d, expected %d", result, cases[i].result);
if (cases[i].result) {
SDLTest_AssertCheck(IsFRectEqual(&enclosing, &cases[i].enclosing),
"Got { %g, %g, %g, %g }, expected { %g, %g, %g, %g }",
enclosing.x, enclosing.y, enclosing.w, enclosing.h,
cases[i].enclosing.x, cases[i].enclosing.y, cases[i].enclosing.w, cases[i].enclosing.h);
}
}
return TEST_COMPLETED;
}
/* !
* \brief Test SDL_IntersectFRectAndLine
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_IntersectFRectAndLine
*/
int rect_testIntersectFRectAndLine(void *arg)
{
const struct {
SDL_FRect rect;
SDL_FPoint p1;
SDL_FPoint p2;
SDL_bool result;
SDL_FPoint expected1;
SDL_FPoint expected2;
} cases[] = {
{ { 0, 0, 0, 0 }, { -4.8f, -4.8f }, { 5.2f, 5.2f }, SDL_FALSE },
{ { 0, 0, 2, 2 }, { -1, -1 }, { 3.5f, 3.5f }, SDL_TRUE, { 0, 0 }, { 1, 1 } },
{ { -4, -4, 14, 14 }, { 8, 22 }, { 8, 33}, SDL_FALSE }
};
size_t i;
for (i = 0; i < SDL_arraysize(cases); i++) {
SDL_bool result;
SDL_FPoint p1 = cases[i].p1;
SDL_FPoint p2 = cases[i].p2;
SDLTest_AssertPass("About to call SDL_IntersectFRectAndLine(&{%g, %g, %g, %g}, &%g, &%g, &%g, &%g)",
cases[i].rect.x, cases[i].rect.y, cases[i].rect.w, cases[i].rect.h,
p1.x, p1.y, p2.x, p2.y);
result = SDL_IntersectFRectAndLine(&cases[i].rect, &p1.x, &p1.y, &p2.x, &p2.y);
SDLTest_AssertCheck(result == cases[i].result, "Got %d, expected %d", result, cases[i].result);
if (cases[i].result) {
SDLTest_AssertCheck(IsFPointEqual(&p1, &cases[i].expected1),
"Got p1={ %g, %g }, expected p1={ %g, %g }",
p1.x, p1.y,
cases[i].expected1.x, cases[i].expected1.y);
SDLTest_AssertCheck(IsFPointEqual(&p2, &cases[i].expected2),
"Got p2={ %g, %g }, expected p2={ %g, %g }",
p2.x, p2.y,
cases[i].expected2.x, cases[i].expected2.y);
}
}
return TEST_COMPLETED;
}
/* ================= Test References ================== */
/* Rect test cases */
@@ -2089,26 +1836,6 @@ static const SDLTest_TestCaseReference rectTest31 = {
(SDLTest_TestCaseFp)rect_testFRectEqualsParam, "rect_testFRectEqualsParam", "Negative tests against SDL_FRectEquals with invalid parameters", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest32 = {
(SDLTest_TestCaseFp)rect_testHasIntersectionF, "rect_testHasIntersectionF", "Tests SDL_HasIntersectionF", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest33 = {
(SDLTest_TestCaseFp)rect_testIntersectFRect, "rect_testIntersectFRect", "Tests SDL_IntersectFRect", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest34 = {
(SDLTest_TestCaseFp)rect_testUnionFRect, "rect_testUnionFRect", "Tests SDL_UnionFRect", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest35 = {
(SDLTest_TestCaseFp)rect_testEncloseFPoints, "rect_testEncloseFPoints", "Tests SDL_EncloseFPoints", TEST_ENABLED
};
static const SDLTest_TestCaseReference rectTest36 = {
(SDLTest_TestCaseFp)rect_testIntersectFRectAndLine, "rect_testIntersectFRectAndLine", "Tests SDL_IntersectFRectAndLine", TEST_ENABLED
};
/* !
* \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
*
@@ -2118,7 +1845,7 @@ static const SDLTest_TestCaseReference rectTest36 = {
static const SDLTest_TestCaseReference *rectTests[] = {
&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14,
&rectTest15, &rectTest16, &rectTest17, &rectTest18, &rectTest19, &rectTest20, &rectTest21, &rectTest22, &rectTest23, &rectTest24, &rectTest25, &rectTest26, &rectTest27,
&rectTest28, &rectTest29, &rectTest30, &rectTest31, &rectTest32, &rectTest33, &rectTest34, &rectTest35, &rectTest36, NULL
&rectTest28, &rectTest29, &rectTest30, &rectTest31, NULL
};
/* Rect test suite (global) */
+1 -139
View File
@@ -811,136 +811,6 @@ int render_testBlitBlend(void *arg)
return TEST_COMPLETED;
}
static Uint32 read_surface_pixel32(SDL_Surface *surface, int x, int y) {
Uint32 result;
if (x >= surface->w || y >= surface->h) {
SDLTest_AssertCheck(x < surface->w, "x (%d) < surface->w (%d)", x, surface->w);
SDLTest_AssertCheck(y < surface->h, "y (%d) < surface->h (%d)", y, surface->h);
result = 0xdeadbabe;
} else {
SDL_memcpy(&result, (Uint8 *)surface->pixels + surface->pitch * y + surface->format->BytesPerPixel * x, sizeof(Uint32));
}
return result;
}
static int render_testRGBSurfaceNoAlpha(void* arg)
{
SDL_Surface *surface;
SDL_Renderer *software_renderer;
SDL_Surface *surface2;
SDL_Texture *texture2;
int result;
SDL_Rect dest_rect;
SDL_Point point;
Uint32 pixel;
SDLTest_AssertPass("About to call SDL_CreateRGBSurface(0, 128, 128, 32, 0xff0000, 0xff00, 0xff, 0)");
surface = SDL_CreateRGBSurface(0, 128, 128, 32, 0xff0000, 0xff00, 0xff, 0);
SDLTest_AssertCheck(surface != NULL, "Returned surface must be not NULL");
SDLTest_AssertCheck(surface->format->BitsPerPixel == 32, "surface->format->BitsPerPixel should be 32, actual value is %d", surface->format->BitsPerPixel);
SDLTest_AssertCheck(surface->format->BytesPerPixel == 4, "surface->format->BytesPerPixels should be 4, actual value is %d", surface->format->BytesPerPixel);
SDLTest_AssertPass("About to call SDL_CreateSoftwareRenderer(surface)");
software_renderer = SDL_CreateSoftwareRenderer(surface);
SDLTest_AssertCheck(software_renderer != NULL, "Returned renderer must be not NULL");
SDLTest_AssertPass("About to call SDL_CreateRGBSurface(0, 16, 16, 32, 0xff0000, 0xff00, 0xff, 0)");
surface2 = SDL_CreateRGBSurface(0, 16, 16, 32, 0xff0000, 0xff00, 0xff, 0);
SDLTest_AssertCheck(surface2 != NULL, "Returned surface must be not NULL");
SDLTest_AssertPass("About to call SDL_FillRect(surface2, NULL, 0)");
result = SDL_FillRect(surface2, NULL, SDL_MapRGB(surface2->format, 0, 0, 0));
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
SDLTest_AssertPass("About to call SDL_CreateTextureFromSurface(software_renderer, surface2)");
texture2 = SDL_CreateTextureFromSurface(software_renderer, surface2);
SDLTest_AssertCheck(texture2 != NULL, "Returned texture is not NULL");
SDLTest_AssertPass("About to call SDL_SetRenderDrawColor(renderer, 0xaa, 0xbb, 0xcc, 0x0)");
result = SDL_SetRenderDrawColor(software_renderer, 0xaa, 0xbb, 0xcc, 0x0);
SDLTest_AssertPass("About to call SDL_RenderClear(renderer)");
result = SDL_RenderClear(software_renderer);
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
SDLTest_AssertPass("About to call SDL_SetRenderDrawColor(renderer, 0x0, 0x0, 0x0, 0x0)");
result = SDL_SetRenderDrawColor(software_renderer, 0x0, 0x0, 0x0, 0x0);
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
dest_rect.x = 32;
dest_rect.y = 32;
dest_rect.w = surface2->w;
dest_rect.h = surface2->h;
point.x = 0;
point.y = 0;
SDLTest_AssertPass("About to call SDL_RenderCopy(software_renderer, texture, NULL, &{%d, %d, %d, %d})",
dest_rect.x, dest_rect.h, dest_rect.w, dest_rect.h);
result = SDL_RenderCopyEx(software_renderer, texture2, NULL, &dest_rect, 180, &point, SDL_FLIP_NONE);
SDLTest_AssertCheck(result == 0, "Result should be 0, actual value is %d", result);
SDLTest_AssertPass("About to call SDL_RenderPresent(software_renderer)");
SDL_RenderPresent(software_renderer);
pixel = read_surface_pixel32(surface, 0, 0);
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (0, 0) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
pixel = read_surface_pixel32(surface, 15, 15);
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (15, 15) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
pixel = read_surface_pixel32(surface, 16, 16);
SDLTest_AssertCheck(pixel == 0xFF000000u, "Pixel at (16, 16) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xFF000000u, pixel);
pixel = read_surface_pixel32(surface, 31, 31);
SDLTest_AssertCheck(pixel == 0xFF000000u, "Pixel at (31, 31) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xFF000000u, pixel);
pixel = read_surface_pixel32(surface, 32, 32);
SDLTest_AssertCheck(pixel == 0xAABBCCu, "Pixel at (32, 32) should be 0x%08x, actual value is 0x%08" SDL_PRIx32, 0xAABBCCu, pixel);
SDL_DestroyTexture(texture2);
SDL_FreeSurface(surface2);
SDL_DestroyRenderer(software_renderer);
SDL_FreeSurface(surface);
return TEST_COMPLETED;
}
/**
* @brief Tests setting and getting texture scale mode.
*
* \sa
* http://wiki.libsdl.org/SDL2/SDL_SetTextureScaleMode
* http://wiki.libsdl.org/SDL2/SDL_GetTextureScaleMode
*/
int render_testGetSetTextureScaleMode(void *arg)
{
const struct {
const char *name;
SDL_ScaleMode mode;
} modes[] = {
{ "SDL_ScaleModeNearest", SDL_ScaleModeNearest },
{ "SDL_ScaleModeLinear", SDL_ScaleModeLinear },
{ "SDL_ScaleModeBest", SDL_ScaleModeBest }
};
size_t i;
for (i = 0; i < SDL_arraysize(modes); i++) {
SDL_Texture *texture;
int result;
SDL_ScaleMode actual_mode = SDL_ScaleModeNearest;
SDL_ClearError();
SDLTest_AssertPass("About to call SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 16, 16)");
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 16, 16);
SDLTest_AssertCheck(texture != NULL, "SDL_CreateTexture must return a non-NULL texture");
SDLTest_AssertPass("About to call SDL_SetTextureScaleMode(texture, %s)", modes[i].name);
result = SDL_SetTextureScaleMode(texture, modes[i].mode);
SDLTest_AssertCheck(result == 0, "SDL_SetTextureScaleMode must return 0, actual %d", result);
SDLTest_AssertPass("About to call SDL_GetTextureScaleMode(texture)");
result = SDL_GetTextureScaleMode(texture, &actual_mode);
SDLTest_AssertCheck(result == 0, "SDL_SetTextureScaleMode must return 0, actual %d", result);
SDLTest_AssertCheck(actual_mode == modes[i].mode, "SDL_GetTextureScaleMode must return %s (%d), actual=%d",
modes[i].name, modes[i].mode, actual_mode);
}
return TEST_COMPLETED;
}
/**
* @brief Checks to see if functionality is supported. Helper function.
*/
@@ -1291,17 +1161,9 @@ static const SDLTest_TestCaseReference renderTest7 = {
(SDLTest_TestCaseFp)render_testBlitBlend, "render_testBlitBlend", "Tests blitting with blending", TEST_DISABLED
};
static const SDLTest_TestCaseReference renderTest8 = {
(SDLTest_TestCaseFp)render_testGetSetTextureScaleMode, "render_testGetSetTextureScaleMode", "Tests setting/getting texture scale mode", TEST_ENABLED
};
static const SDLTest_TestCaseReference renderTest9 = {
(SDLTest_TestCaseFp)render_testRGBSurfaceNoAlpha, "render_testRGBSurfaceNoAlpha", "Tests RGB surface with no alpha using software renderer", TEST_ENABLED
};
/* Sequence of Render test cases */
static const SDLTest_TestCaseReference *renderTests[] = {
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, &renderTest8, &renderTest9, NULL
&renderTest1, &renderTest2, &renderTest3, &renderTest4, &renderTest5, &renderTest6, &renderTest7, NULL
};
/* Render test suite (global) */
+1 -41
View File
@@ -208,42 +208,6 @@ static int subsystems_dependRefCountWithExtraInit(void)
return TEST_COMPLETED;
}
/**
* \brief Inits and Quits timers subsystem, which cannot be explicitly initialized in SDL3
*
* \sa SDL_InitSubSystem
* \sa SDL_QuitSubSystem
*
*/
static int subsystems_timersSubsystem(void)
{
int result;
/* Ensure that we start with reset subsystems. */
SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0,
"Check result from SDL_WasInit(SDL_INIT_TIMER | SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)");
SDLTest_AssertPass("About to call SDL_WasInit(0)");
result = SDL_WasInit(0);
SDLTest_AssertCheck(result == 0, "SDL_WasInit(0) should return 0, actual 0x%x", result);
SDLTest_AssertPass("About to call SDL_InitSubSystem(SDL_INIT_TIMER)");
result = SDL_InitSubSystem(SDL_INIT_TIMER);
SDLTest_AssertCheck(result == 0, "Must return 0, actually %d", result);
SDLTest_AssertPass("About to call SDL_WasInit(SDL_INIT_TIMER)");
result = SDL_WasInit(SDL_INIT_TIMER);
SDLTest_AssertCheck(result == SDL_INIT_TIMER, "Must return SDL_INIT_TIMER (=%d), actually %d", SDL_INIT_TIMER, result);
SDLTest_AssertPass("About to call SDL_WasInit(0)");
result = SDL_WasInit(0);
SDLTest_AssertCheck(result == SDL_INIT_TIMER, "SDL_WasInit(0) should return SDL_INIT_TIMER, actual 0x%x", result);
SDLTest_AssertPass("About to call SDL_QuitSubSystem(SDL_INIT_TIMER)");
SDL_QuitSubSystem(SDL_INIT_TIMER);
SDLTest_AssertPass("SDL_QuitSubSystem finished");
return TEST_COMPLETED;
}
/* ================= Test References ================== */
/* Subsystems test cases */
@@ -263,13 +227,9 @@ static const SDLTest_TestCaseReference subsystemsTest4 = {
(SDLTest_TestCaseFp)subsystems_dependRefCountWithExtraInit, "subsystems_dependRefCountWithExtraInit", "Check reference count of subsystem dependencies.", TEST_ENABLED
};
static const SDLTest_TestCaseReference subsystemsTest5 = {
(SDLTest_TestCaseFp)subsystems_timersSubsystem, "subsystems_timersSubsystem", "Check timer subsystem, removed in SDL3.", TEST_ENABLED
};
/* Sequence of Events test cases */
static const SDLTest_TestCaseReference *subsystemsTests[] = {
&subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, &subsystemsTest5, NULL
&subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, NULL
};
/* Events test suite (global) */
+1 -57
View File
@@ -798,56 +798,6 @@ int surface_testOverflow(void *arg)
return TEST_COMPLETED;
}
static int surface_testSetGetClipRect(void *args)
{
const struct {
SDL_Rect r;
SDL_bool clipsetval;
SDL_bool cmpval;
} rect_list[] = {
{ { 0, 0, 0, 0}, SDL_FALSE, SDL_TRUE},
{ { 2, 2, 0, 0}, SDL_FALSE, SDL_TRUE},
{ { 2, 2, 5, 1}, SDL_TRUE, SDL_TRUE},
{ { 6, 5, 10, 3}, SDL_TRUE, SDL_FALSE},
{ { 0, 0, 10, 10}, SDL_TRUE, SDL_TRUE},
{ { 0, 0, -10, 10}, SDL_FALSE, SDL_TRUE},
{ { 0, 0, -10, -10}, SDL_FALSE, SDL_TRUE},
{ { -10, -10, 10, 10}, SDL_FALSE, SDL_FALSE},
{ { 10, -10, 10, 10}, SDL_FALSE, SDL_FALSE},
{ { 10, 10, 10, 10}, SDL_TRUE, SDL_FALSE}
};
SDL_Surface *s;
SDL_Rect r;
int i;
SDLTest_AssertPass("About to call SDL_CreateRGBSurface(0, 15, 15, 32, 0, 0, 0, 0)");
s = SDL_CreateRGBSurface(0, 15, 15, 32, 0, 0, 0, 0);
SDLTest_AssertCheck(s != NULL, "SDL_CreateRGBSurface returned non-null surface");
SDL_zero(r);
SDL_GetClipRect(s, &r);
SDLTest_AssertCheck(r.x == 0 && r.y == 0 && r.w == 15 && r.h == 15,
"SDL_GetClipRect of just-created surface. Got {%d, %d, %d, %d}. (Expected {%d, %d, %d, %d})",
r.x, r.y, r.w, r.h, 0, 0, 15, 15);
for (i = 0; i < SDL_arraysize(rect_list); i++) {
SDL_bool b;
const SDL_Rect *r_in = &rect_list[i].r;
SDL_Rect r_out;
SDLTest_AssertPass("About to do SDL_SetClipRect({%d, %d, %d, %d})", r_in->x, r_in->y, r_in->w, r_in->h);
b = SDL_SetClipRect(s, r_in);
SDLTest_AssertCheck(b == rect_list[i].clipsetval, "SDL_SetClipRect returned %d (expected %d)", b, rect_list[i].clipsetval);
SDL_zero(r_out);
SDL_GetClipRect(s, &r_out);
SDLTest_AssertPass("SDL_GetClipRect returned {%d, %d, %d, %d}", r_out.x, r_out.y, r_out.w, r_out.h);
b = r_out.x == r_in->x && r_out.y == r_in->y && r_out.w == r_in->w && r_out.h == r_in->h;
SDLTest_AssertCheck(b == rect_list[i].cmpval, "Current clipping rect is identical to input clipping rect: %d (expected %d)",
b, rect_list[i].cmpval);
}
SDL_FreeSurface(s);
return TEST_COMPLETED;
};
/* ================= Test References ================== */
/* Surface test cases */
@@ -906,17 +856,11 @@ static const SDLTest_TestCaseReference surfaceTestOverflow = {
surface_testOverflow, "surface_testOverflow", "Test overflow detection.", TEST_ENABLED
};
static const SDLTest_TestCaseReference surfaceTestSetGetClipRect = {
surface_testSetGetClipRect, "surface_testSetGetClipRect", "Test SDL_(Set|Get)ClipRect.", TEST_ENABLED
};
/* Sequence of Surface test cases */
static const SDLTest_TestCaseReference *surfaceTests[] = {
&surfaceTest1, &surfaceTest2, &surfaceTest3, &surfaceTest4, &surfaceTest5,
&surfaceTest6, &surfaceTest7, &surfaceTest8, &surfaceTest9, &surfaceTest10,
&surfaceTest11, &surfaceTest12, &surfaceTestOverflow,
&surfaceTestSetGetClipRect,
NULL
&surfaceTest11, &surfaceTest12, &surfaceTestOverflow, NULL
};
/* Surface test suite (global) */
+1 -31
View File
@@ -2251,33 +2251,6 @@ static int video_getWindowSurface(void *arg)
return TEST_COMPLETED;
}
/**
* Tests SDL_SetWindowInputFocus
*/
static int video_setWindowInputFocus(void *arg)
{
int result;
SDL_Window *window;
SDLTest_AssertPass("SDL_SetWindowInputFocus is not supported on dummy and SDL2 wayland driver");
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0 || SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) {
return TEST_SKIPPED;
}
window = _createVideoSuiteTestWindow("video_setWindowInputFocus");
if (!window) {
return TEST_ABORTED;
}
SDLTest_AssertPass("About to call SDL_SetWindowInputFocus(window)");
result = SDL_SetWindowInputFocus(window);
SDLTest_AssertCheck(result == 0, "Result is %d, expected 0", result);
_destroyVideoSuiteTestWindow(window);
return TEST_COMPLETED;
}
/* ================= Test References ================== */
/* Video test cases */
@@ -2365,9 +2338,6 @@ static const SDLTest_TestCaseReference videoTest24 =
static const SDLTest_TestCaseReference videoTest25 = {
(SDLTest_TestCaseFp)video_getWindowSurface, "video_getWindowSurface", "Checks window surface functionality", TEST_ENABLED
};
static const SDLTest_TestCaseReference videoTest26 = {
(SDLTest_TestCaseFp)video_setWindowInputFocus, "video_setWindowInputFocus", "Checks window input focus", TEST_ENABLED
};
/* Sequence of Video test cases */
static const SDLTest_TestCaseReference *videoTests[] = {
@@ -2375,7 +2345,7 @@ static const SDLTest_TestCaseReference *videoTests[] = {
&videoTest7, &videoTest8, &videoTest9, &videoTest10, &videoTest11, &videoTest12,
&videoTest13, &videoTest14, &videoTest15, &videoTest16, &videoTest17,
&videoTest18, &videoTest19, &videoTest20, &videoTest21, &videoTest22,
&videoTest23, &videoTest24, &videoTest25, &videoTest26, NULL
&videoTest23, &videoTest24, &videoTest25, NULL
};
/* Video test suite (global) */