-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
94 changed files
with
2,321 additions
and
598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
@@ -47,6 +47,7 @@ | |
#include "SDL_loadso.h" | ||
#include "SDL_log.h" | ||
#include "SDL_messagebox.h" | ||
#include "SDL_metal.h" | ||
#include "SDL_mutex.h" | ||
#include "SDL_power.h" | ||
#include "SDL_render.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
@@ -162,12 +162,29 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); | |
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") | ||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") | ||
#elif defined(__GNUC__) && defined(__arm__) | ||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) | ||
#if 0 /* defined(__LINUX__) || defined(__ANDROID__) */ | ||
/* Information from: | ||
https://chromium.googlesource.com/chromium/chromium/+/trunk/base/atomicops_internals_arm_gcc.h#19 | ||
The Linux kernel provides a helper function which provides the right code for a memory barrier, | ||
hard-coded at address 0xffff0fa0 | ||
*/ | ||
typedef void (*SDL_KernelMemoryBarrierFunc)(); | ||
#define SDL_MemoryBarrierRelease() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() | ||
#define SDL_MemoryBarrierAcquire() ((SDL_KernelMemoryBarrierFunc)0xffff0fa0)() | ||
#elif 0 /* defined(__QNXNTO__) */ | ||
#include <sys/cpuinline.h> | ||
|
||
#define SDL_MemoryBarrierRelease() __cpu_membarrier() | ||
#define SDL_MemoryBarrierAcquire() __cpu_membarrier() | ||
#else | ||
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) | ||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") | ||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") | ||
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) | ||
#ifdef __thumb__ | ||
/* The mcr instruction isn't available in thumb mode, use real functions */ | ||
#define SDL_MEMORY_BARRIER_USES_FUNCTION | ||
#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction() | ||
#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction() | ||
#else | ||
|
@@ -177,6 +194,7 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void); | |
#else | ||
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("" : : : "memory") | ||
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("" : : : "memory") | ||
#endif /* __LINUX__ || __ANDROID__ */ | ||
#endif /* __GNUC__ && __arm__ */ | ||
#else | ||
#if (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5120)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
@@ -420,23 +420,56 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, | |
/* @} *//* Pause audio functions */ | ||
|
||
/** | ||
* This function loads a WAVE from the data source, automatically freeing | ||
* that source if \c freesrc is non-zero. For example, to load a WAVE file, | ||
* you could do: | ||
* \brief Load the audio data of a WAVE file into memory | ||
* | ||
* Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len | ||
* to be valid pointers. The entire data portion of the file is then loaded | ||
* into memory and decoded if necessary. | ||
* | ||
* If \c freesrc is non-zero, the data source gets automatically closed and | ||
* freed before the function returns. | ||
* | ||
* Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), | ||
* IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and | ||
* µ-law (8 bits). Other formats are currently unsupported and cause an error. | ||
* | ||
* If this function succeeds, the pointer returned by it is equal to \c spec | ||
* and the pointer to the audio data allocated by the function is written to | ||
* \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec | ||
* members \c freq, \c channels, and \c format are set to the values of the | ||
* audio data in the buffer. The \c samples member is set to a sane default and | ||
* all others are set to zero. | ||
* | ||
* It's necessary to use SDL_FreeWAV() to free the audio data returned in | ||
* \c audio_buf when it is no longer used. | ||
* | ||
* Because of the underspecification of the Waveform format, there are many | ||
* problematic files in the wild that cause issues with strict decoders. To | ||
* provide compatibility with these files, this decoder is lenient in regards | ||
* to the truncation of the file, the fact chunk, and the size of the RIFF | ||
* chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, | ||
* and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the | ||
* loading process. | ||
* | ||
* Any file that is invalid (due to truncation, corruption, or wrong values in | ||
* the headers), too big, or unsupported causes an error. Additionally, any | ||
* critical I/O error from the data source will terminate the loading process | ||
* with an error. The function returns NULL on error and in all cases (with the | ||
* exception of \c src being NULL), an appropriate error message will be set. | ||
* | ||
* It is required that the data source supports seeking. | ||
* | ||
* Example: | ||
* \code | ||
* SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); | ||
* \endcode | ||
* | ||
* If this function succeeds, it returns the given SDL_AudioSpec, | ||
* filled with the audio data format of the wave data, and sets | ||
* \c *audio_buf to a malloc()'d buffer containing the audio data, | ||
* and sets \c *audio_len to the length of that audio buffer, in bytes. | ||
* You need to free the audio buffer with SDL_FreeWAV() when you are | ||
* done with it. | ||
* | ||
* This function returns NULL and sets the SDL error message if the | ||
* wave file cannot be opened, uses an unknown data format, or is | ||
* corrupt. Currently raw and MS-ADPCM WAVE files are supported. | ||
* \param src The data source with the WAVE data | ||
* \param freesrc A integer value that makes the function close the data source if non-zero | ||
* \param spec A pointer filled with the audio format of the audio data | ||
* \param audio_buf A pointer filled with the audio data allocated by the function | ||
* \param audio_len A pointer filled with the length of the audio data buffer in bytes | ||
* \return NULL on error, or non-NULL on success. | ||
*/ | ||
extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, | ||
int freesrc, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
@@ -101,6 +101,15 @@ SDL_MostSignificantBitIndex32(Uint32 x) | |
#endif | ||
} | ||
|
||
SDL_FORCE_INLINE SDL_bool | ||
SDL_HasExactlyOneBitSet32(Uint32 x) | ||
{ | ||
if (x && !(x & (x - 1))) { | ||
return SDL_TRUE; | ||
} | ||
return SDL_FALSE; | ||
} | ||
|
||
/* Ends C function definitions when using C++ */ | ||
#ifdef __cplusplus | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
@@ -50,6 +50,9 @@ typedef enum | |
SDL_BLENDMODE_MOD = 0x00000004, /**< color modulate | ||
dstRGB = srcRGB * dstRGB | ||
dstA = dstA */ | ||
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply | ||
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) | ||
dstA = (srcA * dstA) + (dstA * (1-srcA)) */ | ||
SDL_BLENDMODE_INVALID = 0x7FFFFFFF | ||
|
||
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */ | ||
|
@@ -90,12 +93,12 @@ typedef enum | |
/** | ||
* \brief Create a custom blend mode, which may or may not be supported by a given renderer | ||
* | ||
* \param srcColorFactor | ||
* \param dstColorFactor | ||
* \param colorOperation | ||
* \param srcAlphaFactor | ||
* \param dstAlphaFactor | ||
* \param alphaOperation | ||
* \param srcColorFactor source color factor | ||
* \param dstColorFactor destination color factor | ||
* \param colorOperation color operation | ||
* \param srcAlphaFactor source alpha factor | ||
* \param dstAlphaFactor destination alpha factor | ||
* \param alphaOperation alpha operation | ||
* | ||
* The result of the blend mode operation will be: | ||
* dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
Simple DirectMedia Layer | ||
Copyright (C) 1997-2018 Sam Lantinga <[email protected]> | ||
Copyright (C) 1997-2020 Sam Lantinga <[email protected]> | ||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
|
Oops, something went wrong.