WinRT: merged with latest, official, SDL 2.x sources
This commit is contained in:
commit
6a01cdf7f3
17 changed files with 169 additions and 107 deletions
|
@ -32,7 +32,7 @@ import java.lang.*;
|
||||||
public class SDLActivity extends Activity {
|
public class SDLActivity extends Activity {
|
||||||
|
|
||||||
// Keep track of the paused state
|
// Keep track of the paused state
|
||||||
public static boolean mIsPaused;
|
public static boolean mIsPaused = false;
|
||||||
|
|
||||||
// Main components
|
// Main components
|
||||||
private static SDLActivity mSingleton;
|
private static SDLActivity mSingleton;
|
||||||
|
@ -71,9 +71,6 @@ public class SDLActivity extends Activity {
|
||||||
// So we can call stuff from static callbacks
|
// So we can call stuff from static callbacks
|
||||||
mSingleton = this;
|
mSingleton = this;
|
||||||
|
|
||||||
// Keep track of the paused state
|
|
||||||
mIsPaused = false;
|
|
||||||
|
|
||||||
// Set up the surface
|
// Set up the surface
|
||||||
mSurface = new SDLSurface(getApplication());
|
mSurface = new SDLSurface(getApplication());
|
||||||
|
|
||||||
|
|
|
@ -551,7 +551,7 @@ macro(CheckPTHREAD)
|
||||||
if(PTHREADS)
|
if(PTHREADS)
|
||||||
if(LINUX)
|
if(LINUX)
|
||||||
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
set(PTHREAD_CFLAGS "-D_REENTRANT")
|
||||||
set(PTHREAD_LDFLAGS "-lpthread")
|
set(PTHREAD_LDFLAGS "-pthread")
|
||||||
elseif(BSDI)
|
elseif(BSDI)
|
||||||
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
set(PTHREAD_CFLAGS "-D_REENTRANT -D_THREAD_SAFE")
|
||||||
set(PTHREAD_LDFLAGS "")
|
set(PTHREAD_LDFLAGS "")
|
||||||
|
@ -607,6 +607,7 @@ macro(CheckPTHREAD)
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
return 0;
|
||||||
}" HAVE_RECURSIVE_MUTEXES)
|
}" HAVE_RECURSIVE_MUTEXES)
|
||||||
if(HAVE_RECURSIVE_MUTEXES)
|
if(HAVE_RECURSIVE_MUTEXES)
|
||||||
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
|
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1)
|
||||||
|
@ -616,6 +617,7 @@ macro(CheckPTHREAD)
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
pthread_mutexattr_t attr;
|
pthread_mutexattr_t attr;
|
||||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||||
|
return 0;
|
||||||
}" HAVE_RECURSIVE_MUTEXES_NP)
|
}" HAVE_RECURSIVE_MUTEXES_NP)
|
||||||
if(HAVE_RECURSIVE_MUTEXES_NP)
|
if(HAVE_RECURSIVE_MUTEXES_NP)
|
||||||
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
|
set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1)
|
||||||
|
@ -624,7 +626,8 @@ macro(CheckPTHREAD)
|
||||||
|
|
||||||
if(PTHREADS_SEM)
|
if(PTHREADS_SEM)
|
||||||
check_c_source_compiles("#include <pthread.h>
|
check_c_source_compiles("#include <pthread.h>
|
||||||
#include <semaphore.h>" HAVE_PTHREADS_SEM)
|
#include <semaphore.h>
|
||||||
|
int main(int argc, char **argv) { return 0; }" HAVE_PTHREADS_SEM)
|
||||||
if(HAVE_PTHREADS_SEM)
|
if(HAVE_PTHREADS_SEM)
|
||||||
check_c_source_compiles("
|
check_c_source_compiles("
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
|
@ -124,11 +124,11 @@ typedef enum
|
||||||
/**
|
/**
|
||||||
* \brief Fields shared by every event
|
* \brief Fields shared by every event
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_GenericEvent
|
typedef struct SDL_CommonEvent
|
||||||
{
|
{
|
||||||
Uint32 type;
|
Uint32 type;
|
||||||
Uint32 timestamp;
|
Uint32 timestamp;
|
||||||
} SDL_GenericEvent;
|
} SDL_CommonEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Window state change event data (event.window.*)
|
* \brief Window state change event data (event.window.*)
|
||||||
|
@ -464,7 +464,7 @@ typedef struct SDL_SysWMEvent
|
||||||
typedef union SDL_Event
|
typedef union SDL_Event
|
||||||
{
|
{
|
||||||
Uint32 type; /**< Event type, shared with all events */
|
Uint32 type; /**< Event type, shared with all events */
|
||||||
SDL_GenericEvent generic; /**< Generic event data */
|
SDL_CommonEvent common; /**< Common event data */
|
||||||
SDL_WindowEvent window; /**< Window event data */
|
SDL_WindowEvent window; /**< Window event data */
|
||||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||||
|
|
|
@ -47,18 +47,18 @@ typedef struct SDL_Cursor SDL_Cursor; /* Implementation dependent */
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SDL_SYSTEM_CURSOR_ARROW, // Arrow
|
SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */
|
||||||
SDL_SYSTEM_CURSOR_IBEAM, // I-beam
|
SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */
|
||||||
SDL_SYSTEM_CURSOR_WAIT, // Wait
|
SDL_SYSTEM_CURSOR_WAIT, /**< Wait */
|
||||||
SDL_SYSTEM_CURSOR_CROSSHAIR, // Crosshair
|
SDL_SYSTEM_CURSOR_CROSSHAIR, /**< Crosshair */
|
||||||
SDL_SYSTEM_CURSOR_WAITARROW, // Small wait cursor (or Wait if not available)
|
SDL_SYSTEM_CURSOR_WAITARROW, /**< Small wait cursor (or Wait if not available) */
|
||||||
SDL_SYSTEM_CURSOR_SIZENWSE, // Double arrow pointing northwest and southeast
|
SDL_SYSTEM_CURSOR_SIZENWSE, /**< Double arrow pointing northwest and southeast */
|
||||||
SDL_SYSTEM_CURSOR_SIZENESW, // Double arrow pointing northeast and southwest
|
SDL_SYSTEM_CURSOR_SIZENESW, /**< Double arrow pointing northeast and southwest */
|
||||||
SDL_SYSTEM_CURSOR_SIZEWE, // Double arrow pointing west and east
|
SDL_SYSTEM_CURSOR_SIZEWE, /**< Double arrow pointing west and east */
|
||||||
SDL_SYSTEM_CURSOR_SIZENS, // Double arrow pointing north and south
|
SDL_SYSTEM_CURSOR_SIZENS, /**< Double arrow pointing north and south */
|
||||||
SDL_SYSTEM_CURSOR_SIZEALL, // Four pointed arrow pointing north, south, east, and west
|
SDL_SYSTEM_CURSOR_SIZEALL, /**< Four pointed arrow pointing north, south, east, and west */
|
||||||
SDL_SYSTEM_CURSOR_NO, // Slashed circle or crossbones
|
SDL_SYSTEM_CURSOR_NO, /**< Slashed circle or crossbones */
|
||||||
SDL_SYSTEM_CURSOR_HAND, // Hand
|
SDL_SYSTEM_CURSOR_HAND, /**< Hand */
|
||||||
SDL_NUM_SYSTEM_CURSORS
|
SDL_NUM_SYSTEM_CURSORS
|
||||||
} SDL_SystemCursor;
|
} SDL_SystemCursor;
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ typedef struct SDL_RWops
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
void *data1;
|
void *data1;
|
||||||
int data2;
|
void *data2;
|
||||||
} unknown;
|
} unknown;
|
||||||
} hidden;
|
} hidden;
|
||||||
|
|
||||||
|
|
|
@ -100,9 +100,11 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
|
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
|
||||||
#define SDL_static_cast(type, expression) static_cast<type>(expression)
|
#define SDL_static_cast(type, expression) static_cast<type>(expression)
|
||||||
|
#define SDL_const_cast(type, expression) const_cast<type>(expression)
|
||||||
#else
|
#else
|
||||||
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
|
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
|
||||||
#define SDL_static_cast(type, expression) ((type)(expression))
|
#define SDL_static_cast(type, expression) ((type)(expression))
|
||||||
|
#define SDL_const_cast(type, expression) ((type)(expression))
|
||||||
#endif
|
#endif
|
||||||
/*@}*//*Cast operators*/
|
/*@}*//*Cast operators*/
|
||||||
|
|
||||||
|
@ -509,49 +511,25 @@ SDL_FORCE_INLINE char *SDL_strlwr_inline(char *str) { return _strlwr(str); }
|
||||||
|
|
||||||
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
|
extern DECLSPEC char *SDLCALL SDL_strchr(const char *str, int c);
|
||||||
#ifdef HAVE_STRCHR
|
#ifdef HAVE_STRCHR
|
||||||
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) {
|
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,strchr(str, c)); }
|
||||||
#ifdef __cplusplus
|
|
||||||
return const_cast<char*>(strchr(str, c));
|
|
||||||
#else
|
|
||||||
return (char*)strchr(str, c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define SDL_strchr SDL_strchr_inline
|
#define SDL_strchr SDL_strchr_inline
|
||||||
#elif defined(HAVE_INDEX) /* !!! FIXME: is there anywhere that has this but not strchr? */
|
#elif defined(HAVE_INDEX) /* !!! FIXME: is there anywhere that has this but not strchr? */
|
||||||
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return index(str, c); }
|
SDL_FORCE_INLINE char *SDL_strchr_inline(const char *str, int c) { return SDL_const_cast(char*,index(str, c)); }
|
||||||
#define SDL_strchr SDL_strchr_inline
|
#define SDL_strchr SDL_strchr_inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
extern DECLSPEC char *SDLCALL SDL_strrchr(const char *str, int c);
|
||||||
#ifdef HAVE_STRRCHR
|
#ifdef HAVE_STRRCHR
|
||||||
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
|
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,strrchr(str, c)); }
|
||||||
#ifdef __cplusplus
|
|
||||||
return const_cast<char*>(strrchr(str, c));
|
|
||||||
#else
|
|
||||||
return (char*)strrchr(str, c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define SDL_strrchr SDL_strrchr_inline
|
#define SDL_strrchr SDL_strrchr_inline
|
||||||
#elif defined(HAVE_RINDEX) /* !!! FIXME: is there anywhere that has this but not strrchr? */
|
#elif defined(HAVE_RINDEX) /* !!! FIXME: is there anywhere that has this but not strrchr? */
|
||||||
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) {
|
SDL_FORCE_INLINE char *SDL_strrchr_inline(const char *str, int c) { return SDL_const_cast(char*,rindex(str, c)); }
|
||||||
#ifdef __cplusplus
|
|
||||||
return const_cast<char*>(rindex(str, c));
|
|
||||||
#else
|
|
||||||
return (char*)rindex(str, c);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define SDL_strrchr SDL_strrchr_inline
|
#define SDL_strrchr SDL_strrchr_inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
extern DECLSPEC char *SDLCALL SDL_strstr(const char *haystack, const char *needle);
|
||||||
#ifdef HAVE_STRSTR
|
#ifdef HAVE_STRSTR
|
||||||
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) {
|
SDL_FORCE_INLINE char *SDL_strstr_inline(const char *haystack, const char *needle) { return SDL_const_cast(char*,strstr(haystack, needle)); }
|
||||||
#ifdef __cplusplus
|
|
||||||
return const_cast<char*>(strstr(haystack, needle));
|
|
||||||
#else
|
|
||||||
return (char*)strstr(haystack, needle);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define SDL_strstr SDL_strstr_inline
|
#define SDL_strstr SDL_strstr_inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -132,12 +132,6 @@ SDL_StartEventLoop(void)
|
||||||
FIXME: Does this introduce any other bugs with events at startup?
|
FIXME: Does this introduce any other bugs with events at startup?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* No filter to start with, process most event types */
|
|
||||||
SDL_EventOK = NULL;
|
|
||||||
SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
|
|
||||||
SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
|
|
||||||
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
|
|
||||||
|
|
||||||
/* Create the lock and set ourselves active */
|
/* Create the lock and set ourselves active */
|
||||||
#if !SDL_THREADS_DISABLED
|
#if !SDL_THREADS_DISABLED
|
||||||
if (!SDL_EventQ.lock) {
|
if (!SDL_EventQ.lock) {
|
||||||
|
@ -147,6 +141,13 @@ SDL_StartEventLoop(void)
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
#endif /* !SDL_THREADS_DISABLED */
|
#endif /* !SDL_THREADS_DISABLED */
|
||||||
|
|
||||||
|
/* No filter to start with, process most event types */
|
||||||
|
SDL_EventOK = NULL;
|
||||||
|
SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE);
|
||||||
|
SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE);
|
||||||
|
SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
|
||||||
|
|
||||||
SDL_EventQ.active = 1;
|
SDL_EventQ.active = 1;
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -373,7 +374,7 @@ int
|
||||||
SDL_PushEvent(SDL_Event * event)
|
SDL_PushEvent(SDL_Event * event)
|
||||||
{
|
{
|
||||||
SDL_EventWatcher *curr;
|
SDL_EventWatcher *curr;
|
||||||
event->generic.timestamp = SDL_GetTicks();
|
event->common.timestamp = SDL_GetTicks();
|
||||||
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
|
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -635,8 +635,9 @@ SDL_AllocRW(void)
|
||||||
area = (SDL_RWops *) SDL_malloc(sizeof *area);
|
area = (SDL_RWops *) SDL_malloc(sizeof *area);
|
||||||
if (area == NULL) {
|
if (area == NULL) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
}
|
} else {
|
||||||
area->type = SDL_RWOPS_UNKNOWN;
|
area->type = SDL_RWOPS_UNKNOWN;
|
||||||
|
}
|
||||||
return (area);
|
return (area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,18 @@ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event)
|
||||||
{
|
{
|
||||||
if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) // simple axis to axis, send it through
|
if ( controllerlist->mapping.raxes[event->jaxis.axis] >= 0 ) // simple axis to axis, send it through
|
||||||
{
|
{
|
||||||
SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.raxes[event->jaxis.axis], event->jaxis.value );
|
SDL_GameControllerAxis axis = controllerlist->mapping.raxes[event->jaxis.axis];
|
||||||
|
Sint16 value = event->jaxis.value;
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||||
|
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||||
|
/* Shift it to be 0 - 32767. */
|
||||||
|
value = value / 2 + 16384;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SDL_PrivateGameControllerAxis( controllerlist, axis, value );
|
||||||
}
|
}
|
||||||
else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) // simlate an axis as a button
|
else if ( controllerlist->mapping.raxesasbutton[event->jaxis.axis] >= 0 ) // simlate an axis as a button
|
||||||
{
|
{
|
||||||
|
@ -187,7 +198,7 @@ int SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event)
|
||||||
}
|
}
|
||||||
else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) // an button pretending to be an axis
|
else if ( controllerlist->mapping.rbuttonasaxis[event->jbutton.button] >= 0 ) // an button pretending to be an axis
|
||||||
{
|
{
|
||||||
SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32768 : 0 );
|
SDL_PrivateGameControllerAxis( controllerlist, controllerlist->mapping.rbuttonasaxis[event->jbutton.button], event->jbutton.state > 0 ? 32767 : 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1304,10 +1304,10 @@ RenderDrawLinesWithRects(SDL_Renderer * renderer,
|
||||||
frect->h = renderer->scale.y;
|
frect->h = renderer->scale.y;
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: We can't use a rect for this line... */
|
/* FIXME: We can't use a rect for this line... */
|
||||||
frects[0].x = points[i].x * renderer->scale.x;
|
fpoints[0].x = points[i].x * renderer->scale.x;
|
||||||
frects[0].y = points[i].y * renderer->scale.y;
|
fpoints[0].y = points[i].y * renderer->scale.y;
|
||||||
frects[1].x = points[i+1].x * renderer->scale.x;
|
fpoints[1].x = points[i+1].x * renderer->scale.x;
|
||||||
frects[1].y = points[i+1].y * renderer->scale.y;
|
fpoints[1].y = points[i+1].y * renderer->scale.y;
|
||||||
status += renderer->RenderDrawLines(renderer, fpoints, 2);
|
status += renderer->RenderDrawLines(renderer, fpoints, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1564,8 +1564,7 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) {
|
||||||
GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
|
GLES2_TextureData *texturedata = (GLES2_TextureData *)texture->driverdata;
|
||||||
GLES2_ActivateRenderer(renderer);
|
GLES2_ActivateRenderer(renderer);
|
||||||
|
|
||||||
data->glActiveTexture(GL_TEXTURE0);
|
data->glBindTexture(texturedata->texture_type, 0);
|
||||||
data->glDisable(texturedata->texture_type);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -260,6 +260,12 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
SDL_RWread(src, &palette->colors[i].g, 1, 1);
|
SDL_RWread(src, &palette->colors[i].g, 1, 1);
|
||||||
SDL_RWread(src, &palette->colors[i].r, 1, 1);
|
SDL_RWread(src, &palette->colors[i].r, 1, 1);
|
||||||
SDL_RWread(src, &palette->colors[i].a, 1, 1);
|
SDL_RWread(src, &palette->colors[i].a, 1, 1);
|
||||||
|
|
||||||
|
/* According to Microsoft documentation, the fourth element
|
||||||
|
is reserved and must be zero, so we shouldn't treat it as
|
||||||
|
alpha.
|
||||||
|
*/
|
||||||
|
palette->colors[i].a = SDL_ALPHA_OPAQUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,13 @@ SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B)
|
||||||
{
|
{
|
||||||
int Amin, Amax, Bmin, Bmax;
|
int Amin, Amax, Bmin, Bmax;
|
||||||
|
|
||||||
if (!A || !B) {
|
if (!A) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("A");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!B) {
|
||||||
|
SDL_InvalidParamError("B");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,13 +76,25 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||||
{
|
{
|
||||||
int Amin, Amax, Bmin, Bmax;
|
int Amin, Amax, Bmin, Bmax;
|
||||||
|
|
||||||
if (!A || !B || !result) {
|
if (!A) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("A");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!B) {
|
||||||
|
SDL_InvalidParamError("B");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
SDL_InvalidParamError("result");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special cases for empty rects */
|
/* Special cases for empty rects */
|
||||||
if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
|
if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) {
|
||||||
|
result->w = 0;
|
||||||
|
result->h = 0;
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +130,18 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
|
||||||
{
|
{
|
||||||
int Amin, Amax, Bmin, Bmax;
|
int Amin, Amax, Bmin, Bmax;
|
||||||
|
|
||||||
if (!A || !B || !result) {
|
if (!A) {
|
||||||
|
SDL_InvalidParamError("A");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!B) {
|
||||||
|
SDL_InvalidParamError("B");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
SDL_InvalidParamError("result");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,12 +199,12 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip,
|
||||||
int x, y, i;
|
int x, y, i;
|
||||||
|
|
||||||
if (!points) {
|
if (!points) {
|
||||||
/* TODO error message */
|
SDL_InvalidParamError("points");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count < 1) {
|
if (count < 1) {
|
||||||
/* TODO error message */
|
SDL_InvalidParamError("count");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,8 +326,28 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2,
|
||||||
int recty2;
|
int recty2;
|
||||||
int outcode1, outcode2;
|
int outcode1, outcode2;
|
||||||
|
|
||||||
if (!rect || !X1 || !Y1 || !X2 || !Y2) {
|
if (!rect) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("rect");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!X1) {
|
||||||
|
SDL_InvalidParamError("X1");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Y1) {
|
||||||
|
SDL_InvalidParamError("Y1");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!X2) {
|
||||||
|
SDL_InvalidParamError("X2");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Y2) {
|
||||||
|
SDL_InvalidParamError("Y2");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,18 +466,28 @@ SDL_GetSpanEnclosingRect(int width, int height,
|
||||||
int span_y1, span_y2;
|
int span_y1, span_y2;
|
||||||
int rect_y1, rect_y2;
|
int rect_y1, rect_y2;
|
||||||
|
|
||||||
if (width < 1 || height < 1) {
|
if (width < 1) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("width");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rects || !span) {
|
if (height < 1) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("height");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rects) {
|
||||||
|
SDL_InvalidParamError("rects");
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!span) {
|
||||||
|
SDL_InvalidParamError("span");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numrects < 1) {
|
if (numrects < 1) {
|
||||||
// TODO error message
|
SDL_InvalidParamError("numrects");
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,14 @@ X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y)
|
||||||
unsigned int width_bytes = ((surface->w + 7) & ~7) / 8;
|
unsigned int width_bytes = ((surface->w + 7) & ~7) / 8;
|
||||||
|
|
||||||
data_bits = SDL_calloc(1, surface->h * width_bytes);
|
data_bits = SDL_calloc(1, surface->h * width_bytes);
|
||||||
|
if (!data_bits) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
mask_bits = SDL_calloc(1, surface->h * width_bytes);
|
mask_bits = SDL_calloc(1, surface->h * width_bytes);
|
||||||
if (!data_bits || !mask_bits) {
|
if (!mask_bits) {
|
||||||
|
SDL_free(data_bits);
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,29 +524,17 @@ decode_edid (const uchar *edid)
|
||||||
|
|
||||||
decode_check_sum (edid, info);
|
decode_check_sum (edid, info);
|
||||||
|
|
||||||
if (!decode_header (edid))
|
if (!decode_header (edid) ||
|
||||||
return NULL;
|
!decode_vendor_and_product_identification (edid, info) ||
|
||||||
|
!decode_edid_version (edid, info) ||
|
||||||
if (!decode_vendor_and_product_identification (edid, info))
|
!decode_display_parameters (edid, info) ||
|
||||||
return NULL;
|
!decode_color_characteristics (edid, info) ||
|
||||||
|
!decode_established_timings (edid, info) ||
|
||||||
if (!decode_edid_version (edid, info))
|
!decode_standard_timings (edid, info) ||
|
||||||
return NULL;
|
!decode_descriptors (edid, info)) {
|
||||||
|
free(info);
|
||||||
if (!decode_display_parameters (edid, info))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!decode_color_characteristics (edid, info))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!decode_established_timings (edid, info))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!decode_standard_timings (edid, info))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (!decode_descriptors (edid, info))
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -614,8 +614,11 @@ int rect_testIntersectRectEmpty (void *arg)
|
||||||
SDL_Rect rectB;
|
SDL_Rect rectB;
|
||||||
SDL_Rect result;
|
SDL_Rect result;
|
||||||
SDL_bool intersection;
|
SDL_bool intersection;
|
||||||
|
SDL_bool empty;
|
||||||
|
|
||||||
// Rect A empty
|
// Rect A empty
|
||||||
|
result.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
result.h = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
@ -627,8 +630,12 @@ int rect_testIntersectRectEmpty (void *arg)
|
||||||
rectB = refRectB;
|
rectB = refRectB;
|
||||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||||
|
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||||
|
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||||
|
|
||||||
// Rect B empty
|
// Rect B empty
|
||||||
|
result.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
result.h = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
@ -640,8 +647,12 @@ int rect_testIntersectRectEmpty (void *arg)
|
||||||
rectB = refRectB;
|
rectB = refRectB;
|
||||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||||
|
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||||
|
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||||
|
|
||||||
// Rect A and B empty
|
// Rect A and B empty
|
||||||
|
result.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
result.h = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.x = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.y = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
refRectA.w = SDLTest_RandomIntegerInRange(1, 100);
|
||||||
|
@ -655,6 +666,8 @@ int rect_testIntersectRectEmpty (void *arg)
|
||||||
rectB = refRectB;
|
rectB = refRectB;
|
||||||
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
intersection = SDL_IntersectRect(&rectA, &rectB, &result);
|
||||||
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
_validateIntersectRectResults(intersection, SDL_FALSE, &rectA, &rectB, &refRectA, &refRectB, (SDL_Rect *)NULL, (SDL_Rect *)NULL);
|
||||||
|
empty = (SDL_bool)SDL_RectEmpty(&result);
|
||||||
|
SDLTest_AssertCheck(empty == SDL_TRUE, "Validate result is empty Rect; got: %s", (empty == SDL_TRUE) ? "SDL_TRUE" : "SDL_FALSE");
|
||||||
|
|
||||||
return TEST_COMPLETED;
|
return TEST_COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Visual Studio 2008 doesn't have stdint.h */
|
/* Visual Studio 2008 doesn't have stdint.h */
|
||||||
#if defined(_MSC_VER) && _MSC_VER <= 1500
|
#if defined(_MSC_VER) && _MSC_VER <= 1500
|
||||||
|
@ -1522,7 +1523,7 @@ video_getSetWindowData(void *arg)
|
||||||
returnValue = TEST_ABORTED;
|
returnValue = TEST_ABORTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
userdata = (char *)strdup(referenceUserdata);
|
userdata = SDL_strdup(referenceUserdata);
|
||||||
if (userdata == NULL) {
|
if (userdata == NULL) {
|
||||||
returnValue = TEST_ABORTED;
|
returnValue = TEST_ABORTED;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue