This commit is contained in:
twinaphex 2016-03-21 04:56:00 +01:00
parent ecba7c4ea3
commit 799048ee56
36 changed files with 10165 additions and 0 deletions

View File

@ -26,6 +26,7 @@ CFLAGS += -Wpointer-arith
CFLAGS += -Wreturn-type
CFLAGS += -Wwrite-strings
CFLAGS += -Wcast-align
CFLAGS += -O0
CCFLAGS += $(CFLAGS)
CCFLAGS += -Werror-implicit-function-declaration
@ -63,6 +64,17 @@ SRCS += surface.cpp
SRCS += SDL_mixer/mixer.cpp
SRCS += SDL_mixer/music.cpp
SRCS += sdl/SDL_error.cpp \
sdl/file/SDL_rwops.cpp \
sdl/video/SDL_blit.cpp \
sdl/video/SDL_blit_0.cpp \
sdl/video/SDL_blit_1.cpp \
sdl/video/SDL_blit_A.cpp \
sdl/video/SDL_blit_N.cpp \
sdl/video/SDL_bmp.cpp \
sdl/video/SDL_pixels.cpp \
sdl/video/SDL_surface.cpp
OBJS = $(filter %.o, $(SRCS:.c=.o) $(SRCS:.cpp=.o))
.SUFFIXES:

220
sdl/SDL_error.c Normal file
View File

@ -0,0 +1,220 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include <stdio.h>
#include "SDL_config.h"
/* Simple error handling in SDL */
#include "SDL_error.h"
#include "SDL_error_c.h"
/* Routine to get the thread-specific error variable */
/* The SDL_arraysize(The ),default (non-thread-safe) global error variable */
static SDL_error SDL_global_error;
#define SDL_GetErrBuf() (&SDL_global_error)
#define SDL_ERRBUFIZE 1024
/* Private functions */
static const char *LRSDL_LookupString(const char *key)
{
/* FIXME: Add code to lookup key in language string hash-table */
return key;
}
/* Public functions */
void LRSDL_SetError (const char *fmt, ...)
{
va_list ap;
SDL_error *error;
/* Copy in the key, mark error as valid */
error = SDL_GetErrBuf();
error->error = 1;
strcpy((char *)error->key, fmt);
va_start(ap, fmt);
error->argc = 0;
while ( *fmt ) {
if ( *fmt++ == '%' ) {
while ( *fmt == '.' || (*fmt >= '0' && *fmt <= '9') ) {
++fmt;
}
switch (*fmt++) {
case 0: /* Malformed format string.. */
--fmt;
break;
case 'c':
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
error->args[error->argc++].value_i =
va_arg(ap, int);
break;
case 'f':
error->args[error->argc++].value_f =
va_arg(ap, double);
break;
case 'p':
error->args[error->argc++].value_ptr =
va_arg(ap, void *);
break;
case 's':
{
int i = error->argc;
const char *str = va_arg(ap, const char *);
if (str == NULL)
str = "(null)";
strcpy((char *)error->args[i].buf, str);
error->argc++;
}
break;
default:
break;
}
if ( error->argc >= ERR_MAX_ARGS ) {
break;
}
}
}
va_end(ap);
/* If we are in debug mode, print out an error message */
#ifdef DEBUG_ERROR
fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
#endif
}
/* This function has a bit more overhead than most error functions
so that it supports internationalization and thread-safe errors.
*/
char *LRSDL_GetErrorMsg(char *errstr, unsigned int maxlen)
{
SDL_error *error;
/* Clear the error string */
*errstr = '\0'; --maxlen;
/* Get the thread-safe error, and print it out */
error = SDL_GetErrBuf();
if ( error->error ) {
const char *fmt;
char *msg = errstr;
int len;
int argi;
fmt = LRSDL_LookupString(error->key);
argi = 0;
while ( *fmt && (maxlen > 0) ) {
if ( *fmt == '%' ) {
char tmp[32], *spot = tmp;
*spot++ = *fmt++;
while ( (*fmt == '.' || (*fmt >= '0' && *fmt <= '9')) && spot < (tmp+SDL_arraysize(tmp)-2) ) {
*spot++ = *fmt++;
}
*spot++ = *fmt++;
*spot++ = '\0';
switch (spot[-2]) {
case '%':
*msg++ = '%';
maxlen -= 1;
break;
case 'c':
case 'i':
case 'd':
case 'u':
case 'o':
case 'x':
case 'X':
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_i);
msg += len;
maxlen -= len;
break;
case 'f':
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_f);
msg += len;
maxlen -= len;
break;
case 'p':
len = SDL_snprintf(msg, maxlen, tmp, error->args[argi++].value_ptr);
msg += len;
maxlen -= len;
break;
case 's':
len = SDL_snprintf(msg, maxlen, tmp, LRSDL_LookupString(error->args[argi++].buf));
msg += len;
maxlen -= len;
break;
}
} else {
*msg++ = *fmt++;
maxlen -= 1;
}
}
*msg = 0; /* NULL terminate the string */
}
return(errstr);
}
/* Available for backwards compatibility */
char *LRSDL_GetError (void)
{
static char errmsg[SDL_ERRBUFIZE];
return((char *)LRSDL_GetErrorMsg(errmsg, SDL_ERRBUFIZE));
}
void LRSDL_ClearError(void)
{
SDL_error *error;
error = SDL_GetErrBuf();
error->error = 0;
}
/* Very common errors go here */
void LRSDL_Error(SDL_errorcode code)
{
switch (code) {
case SDL_ENOMEM:
LRSDL_SetError("Out of memory");
break;
case SDL_EFREAD:
LRSDL_SetError("Error reading from datastream");
break;
case SDL_EFWRITE:
LRSDL_SetError("Error writing to datastream");
break;
case SDL_EFSEEK:
LRSDL_SetError("Error seeking in datastream");
break;
default:
LRSDL_SetError("Unknown SDL error");
break;
}
}

58
sdl/SDL_error_c.h Normal file
View File

@ -0,0 +1,58 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* This file defines a structure that carries language-independent
error messages
*/
#ifndef _SDL_error_c_h
#define _SDL_error_c_h
#define ERR_MAX_STRLEN 128
#define ERR_MAX_ARGS 5
typedef struct SDL_error {
/* This is a numeric value corresponding to the current error */
int error;
/* This is a key used to index into a language hashtable containing
internationalized versions of the SDL error messages. If the key
is not in the hashtable, or no hashtable is available, the key is
used directly as an error message format string.
*/
char key[ERR_MAX_STRLEN];
/* These are the arguments for the error functions */
int argc;
union {
void *value_ptr;
#if 0 /* What is a character anyway? (UNICODE issues) */
unsigned char value_c;
#endif
int value_i;
double value_f;
char buf[ERR_MAX_STRLEN];
} args[ERR_MAX_ARGS];
} SDL_error;
#endif /* _SDL_error_c_h */

307
sdl/file/SDL_rwops.c Normal file
View File

@ -0,0 +1,307 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* This file provides a general interface for SDL to read and write
data sources. It can easily be extended to files, memory, etc.
*/
#include "SDL_endian.h"
#include "SDL_rwops.h"
/* Functions to read/write stdio file pointers */
static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
{
if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
return(ftell(context->hidden.stdio.fp));
} else {
LRSDL_Error(SDL_EFSEEK);
return(-1);
}
}
static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{
size_t nread;
nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
if ( nread == 0 && ferror(context->hidden.stdio.fp) ) {
LRSDL_Error(SDL_EFREAD);
}
return(nread);
}
static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
{
size_t nwrote;
nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) {
LRSDL_Error(SDL_EFWRITE);
}
return(nwrote);
}
static int SDLCALL stdio_close(SDL_RWops *context)
{
if ( context ) {
if ( context->hidden.stdio.autoclose ) {
/* WARNING: Check the return value here! */
fclose(context->hidden.stdio.fp);
}
LRSDL_FreeRW(context);
}
return(0);
}
/* Functions to read/write memory pointers */
static int SDLCALL mem_seek(SDL_RWops *context, int offset, int whence)
{
Uint8 *newpos;
switch (whence) {
case RW_SEEK_SET:
newpos = context->hidden.mem.base+offset;
break;
case RW_SEEK_CUR:
newpos = context->hidden.mem.here+offset;
break;
case RW_SEEK_END:
newpos = context->hidden.mem.stop+offset;
break;
default:
LRSDL_SetError("Unknown value for 'whence'");
return(-1);
}
if ( newpos < context->hidden.mem.base ) {
newpos = context->hidden.mem.base;
}
if ( newpos > context->hidden.mem.stop ) {
newpos = context->hidden.mem.stop;
}
context->hidden.mem.here = newpos;
return(context->hidden.mem.here-context->hidden.mem.base);
}
static int SDLCALL mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
{
size_t total_bytes;
size_t mem_available;
total_bytes = (maxnum * size);
if ( (maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != (size_t) size) ) {
return 0;
}
mem_available = (context->hidden.mem.stop - context->hidden.mem.here);
if (total_bytes > mem_available) {
total_bytes = mem_available;
}
SDL_memcpy(ptr, context->hidden.mem.here, total_bytes);
context->hidden.mem.here += total_bytes;
return (total_bytes / size);
}
static int SDLCALL mem_write(SDL_RWops *context, const void *ptr, int size, int num)
{
if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
}
SDL_memcpy(context->hidden.mem.here, ptr, num*size);
context->hidden.mem.here += num*size;
return(num);
}
static int SDLCALL mem_writeconst(SDL_RWops *context, const void *ptr, int size, int num)
{
LRSDL_SetError("Can't write to read-only memory");
return(-1);
}
static int SDLCALL mem_close(SDL_RWops *context)
{
if ( context ) {
LRSDL_FreeRW(context);
}
return(0);
}
/* Functions to create SDL_RWops structures from various data sources */
SDL_RWops *LRSDL_RWFromFile(const char *file, const char *mode)
{
SDL_RWops *rwops = NULL;
FILE *fp = NULL;
(void) fp;
if ( !file || !*file || !mode || !*mode ) {
LRSDL_SetError("SDL_RWFromFile(): No file or no mode specified");
return NULL;
}
fp = fopen(file, mode);
if ( fp == NULL ) {
LRSDL_SetError("Couldn't open %s", file);
} else {
rwops = LRSDL_RWFromFP(fp, 1);
}
return(rwops);
}
SDL_RWops *LRSDL_RWFromFP(FILE *fp, int autoclose)
{
SDL_RWops *rwops = NULL;
rwops = LRSDL_AllocRW();
if ( rwops != NULL ) {
rwops->seek = stdio_seek;
rwops->read = stdio_read;
rwops->write = stdio_write;
rwops->close = stdio_close;
rwops->hidden.stdio.fp = fp;
rwops->hidden.stdio.autoclose = autoclose;
}
return(rwops);
}
SDL_RWops *LRSDL_RWFromMem(void *mem, int size)
{
SDL_RWops *rwops;
rwops = LRSDL_AllocRW();
if ( rwops != NULL ) {
rwops->seek = mem_seek;
rwops->read = mem_read;
rwops->write = mem_write;
rwops->close = mem_close;
rwops->hidden.mem.base = (Uint8 *)mem;
rwops->hidden.mem.here = rwops->hidden.mem.base;
rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
}
return(rwops);
}
SDL_RWops *LRSDL_RWFromConstMem(const void *mem, int size)
{
SDL_RWops *rwops;
rwops = LRSDL_AllocRW();
if ( rwops != NULL ) {
rwops->seek = mem_seek;
rwops->read = mem_read;
rwops->write = mem_writeconst;
rwops->close = mem_close;
rwops->hidden.mem.base = (Uint8 *)mem;
rwops->hidden.mem.here = rwops->hidden.mem.base;
rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
}
return(rwops);
}
SDL_RWops *LRSDL_AllocRW(void)
{
SDL_RWops *area;
area = (SDL_RWops *)SDL_malloc(sizeof *area);
if ( area == NULL ) {
LRSDL_OutOfMemory();
}
return(area);
}
void LRSDL_FreeRW(SDL_RWops *area)
{
SDL_free(area);
}
/* Functions for dynamically reading and writing endian-specific values */
Uint16 LRSDL_ReadLE16 (SDL_RWops *src)
{
Uint16 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapLE16(value));
}
Uint16 LRSDL_ReadBE16 (SDL_RWops *src)
{
Uint16 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapBE16(value));
}
Uint32 LRSDL_ReadLE32 (SDL_RWops *src)
{
Uint32 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapLE32(value));
}
Uint32 LRSDL_ReadBE32 (SDL_RWops *src)
{
Uint32 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapBE32(value));
}
Uint64 LRSDL_ReadLE64 (SDL_RWops *src)
{
Uint64 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapLE64(value));
}
Uint64 LRSDL_ReadBE64 (SDL_RWops *src)
{
Uint64 value;
LRSDL_RWread(src, &value, (sizeof value), 1);
return(SDL_SwapBE64(value));
}
int LRSDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
{
value = SDL_SwapLE16(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}
int LRSDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
{
value = SDL_SwapBE16(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}
int LRSDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
{
value = SDL_SwapLE32(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}
int LRSDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
{
value = SDL_SwapBE32(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}
int LRSDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
{
value = SDL_SwapLE64(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}
int LRSDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
{
value = SDL_SwapBE64(value);
return(LRSDL_RWwrite(dst, &value, (sizeof value), 1));
}

93
sdl/include/SDL.h Normal file
View File

@ -0,0 +1,93 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL.h
* Main include header for the SDL library
*/
#ifndef _SDL_H
#define _SDL_H
#include "SDL_main.h"
#include "SDL_stdinc.h"
#include "SDL_endian.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_video.h"
#include "SDL_version.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/** @file SDL.h
* @note As of version 0.5, SDL is loaded dynamically into the application
*/
/** @name SDL_INIT Flags
* These are the flags which may be passed to SDL_Init() -- you should
* specify the subsystems which you will be using in your application.
*/
/*@{*/
#define SDL_INIT_TIMER 0x00000001
#define SDL_INIT_AUDIO 0x00000010
#define SDL_INIT_VIDEO 0x00000020
#define SDL_INIT_CDROM 0x00000100
#define SDL_INIT_JOYSTICK 0x00000200
#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */
#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */
#define SDL_INIT_EVERYTHING 0x0000FFFF
/*@}*/
/** This function loads the SDL dynamically linked library and initializes
* the subsystems specified by 'flags' (and those satisfying dependencies)
* Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
* signal handlers for some commonly ignored fatal signals (like SIGSEGV)
*/
extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags);
/** This function initializes specific SDL subsystems */
extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
/** This function cleans up specific SDL subsystems */
extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
/** This function returns mask of the specified subsystems which have
* been initialized.
* If 'flags' is 0, it returns a mask of all initialized subsystems.
*/
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
/** This function cleans up all initialized subsystems and unloads the
* dynamically linked library. You should call it upon all exit conditions.
*/
extern DECLSPEC void SDLCALL SDL_Quit(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_H */

View File

@ -0,0 +1,29 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* @file SDL_byteorder.h
* @deprecated Use SDL_endian.h instead
*/
/* DEPRECATED */
#include "SDL_endian.h"

312
sdl/include/SDL_config.h Normal file
View File

@ -0,0 +1,312 @@
/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_h
#define _SDL_config_h
/* This is a set of defines to configure the SDL features */
/* General platform specific identifiers */
#include "SDL_platform.h"
/* C language features */
/* #undef const */
/* #undef inline */
/* #undef volatile */
/* C datatypes */
/* #undef size_t */
/* #undef int8_t */
/* #undef uint8_t */
/* #undef int16_t */
/* #undef uint16_t */
/* #undef int32_t */
/* #undef uint32_t */
/* #undef int64_t */
/* #undef uint64_t */
/* #undef uintptr_t */
#define SDL_HAS_64BIT_TYPE 1
/* Endianness */
//#define SDL_BYTEORDER 1234
/* Comment this if you want to build without any C library requirements */
#define HAVE_LIBC 1
#if HAVE_LIBC
/* Useful headers */
#define HAVE_SYS_TYPES_H 1
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STDLIB_H 1
#define HAVE_STDARG_H 1
#define HAVE_MALLOC_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRING_H 1
#define HAVE_STRINGS_H 1
#ifndef _XBOX1
#define HAVE_ALLOCA_H 1
#define HAVE_INTTYPES_H 1
#endif
#define HAVE_STDINT_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#define HAVE_ICONV_H 1
#define HAVE_SIGNAL_H 1
/* #undef HAVE_ALTIVEC_H */
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
#define HAVE_GETENV 1
#define HAVE_PUTENV 1
#define HAVE_UNSETENV 1
#endif
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_BCOPY 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
/* #undef HAVE_STRLCPY */
/* #undef HAVE_STRLCAT */
#define HAVE_STRDUP 1
/* #undef HAVE__STRREV */
/* #undef HAVE__STRUPR */
/* #undef HAVE__STRLWR */
/* #undef HAVE_INDEX */
/* #undef HAVE_RINDEX */
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
/* #undef HAVE_ITOA */
/* #undef HAVE__LTOA */
/* #undef HAVE__UITOA */
/* #undef HAVE__ULTOA */
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
/* #undef HAVE__I64TOA */
/* #undef HAVE__UI64TOA */
#define HAVE_STRTOLL 1
#define HAVE_STRTOULL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
/* #undef HAVE__STRICMP */
#define HAVE_STRCASECMP 1
/* #undef HAVE__STRNICMP */
#define HAVE_STRNCASECMP 1
#define HAVE_SSCANF 1
#define HAVE_SNPRINTF 1
#define HAVE_VSNPRINTF 1
#define HAVE_ICONV 1
#define HAVE_SIGACTION 1
#define HAVE_SA_SIGACTION 1
#define HAVE_SETJMP 1
#define HAVE_NANOSLEEP 1
/* #undef HAVE_CLOCK_GETTIME */
#define HAVE_GETPAGESIZE 1
#define HAVE_MPROTECT 1
#define HAVE_SEM_TIMEDWAIT 1
#else
/* We may need some replacement for stdarg.h here */
#include <stdarg.h>
#endif /* HAVE_LIBC */
/* Allow disabling of core subsystems */
/* #undef SDL_AUDIO_DISABLED */
/* #undef SDL_CDROM_DISABLED */
/* #undef SDL_CPUINFO_DISABLED */
/* #undef SDL_EVENTS_DISABLED */
/* #undef SDL_FILE_DISABLED */
/* #undef SDL_JOYSTICK_DISABLED */
/* #undef SDL_LOADSO_DISABLED */
/* #undef SDL_THREADS_DISABLED */
/* #undef SDL_TIMERS_DISABLED */
/* #undef SDL_VIDEO_DISABLED */
/* Enable various audio drivers */
#define SDL_AUDIO_DRIVER_ALSA 1
#define SDL_AUDIO_DRIVER_ALSA_DYNAMIC "libasound.so.2"
/* #undef SDL_AUDIO_DRIVER_ARTS */
/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_BAUDIO */
/* #undef SDL_AUDIO_DRIVER_BSD */
/* #undef SDL_AUDIO_DRIVER_COREAUDIO */
/* #undef SDL_AUDIO_DRIVER_DART */
/* #undef SDL_AUDIO_DRIVER_DC */
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* #undef SDL_AUDIO_DRIVER_DMEDIA */
/* #undef SDL_AUDIO_DRIVER_DSOUND */
#define SDL_AUDIO_DRIVER_PULSE 1
#define SDL_AUDIO_DRIVER_PULSE_DYNAMIC "libpulse-simple.so.0"
/* #undef SDL_AUDIO_DRIVER_ESD */
/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */
/* #undef SDL_AUDIO_DRIVER_MINT */
/* #undef SDL_AUDIO_DRIVER_MMEAUDIO */
/* #undef SDL_AUDIO_DRIVER_NAS */
/* #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC */
#define SDL_AUDIO_DRIVER_OSS 1
/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */
/* #undef SDL_AUDIO_DRIVER_PAUD */
/* #undef SDL_AUDIO_DRIVER_QNXNTO */
/* #undef SDL_AUDIO_DRIVER_SNDMGR */
/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */
/* #undef SDL_AUDIO_DRIVER_WAVEOUT */
/* Enable various cdrom drivers */
/* #undef SDL_CDROM_AIX */
/* #undef SDL_CDROM_BEOS */
/* #undef SDL_CDROM_BSDI */
/* #undef SDL_CDROM_DC */
/* #undef SDL_CDROM_DUMMY */
/* #undef SDL_CDROM_FREEBSD */
#define SDL_CDROM_LINUX 1
/* #undef SDL_CDROM_MACOS */
/* #undef SDL_CDROM_MACOSX */
/* #undef SDL_CDROM_MINT */
/* #undef SDL_CDROM_OPENBSD */
/* #undef SDL_CDROM_OS2 */
/* #undef SDL_CDROM_OSF */
/* #undef SDL_CDROM_QNX */
/* #undef SDL_CDROM_WIN32 */
/* Enable various input drivers */
#define SDL_INPUT_LINUXEV 1
/* #undef SDL_INPUT_TSLIB */
/* #undef SDL_JOYSTICK_BEOS */
/* #undef SDL_JOYSTICK_DC */
/* #undef SDL_JOYSTICK_DUMMY */
/* #undef SDL_JOYSTICK_IOKIT */
#define SDL_JOYSTICK_LINUX 1
/* #undef SDL_JOYSTICK_MACOS */
/* #undef SDL_JOYSTICK_MINT */
/* #undef SDL_JOYSTICK_OS2 */
/* #undef SDL_JOYSTICK_RISCOS */
/* #undef SDL_JOYSTICK_WINMM */
/* #undef SDL_JOYSTICK_USBHID */
/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
/* Enable various shared object loading systems */
/* #undef SDL_LOADSO_BEOS */
/* #undef SDL_LOADSO_DLCOMPAT */
#define SDL_LOADSO_DLOPEN 1
/* #undef SDL_LOADSO_DUMMY */
/* #undef SDL_LOADSO_LDG */
/* #undef SDL_LOADSO_MACOS */
/* #undef SDL_LOADSO_OS2 */
/* #undef SDL_LOADSO_WIN32 */
/* Enable various threading systems */
/* #undef SDL_THREAD_BEOS */
/* #undef SDL_THREAD_DC */
/* #undef SDL_THREAD_OS2 */
/* #undef SDL_THREAD_PTH */
#define SDL_THREAD_PTHREAD 1
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */
/* #undef SDL_THREAD_SPROC */
/* #undef SDL_THREAD_WIN32 */
/* Enable various timer systems */
/* #undef SDL_TIMER_BEOS */
/* #undef SDL_TIMER_DC */
/* #undef SDL_TIMER_DUMMY */
/* #undef SDL_TIMER_MACOS */
/* #undef SDL_TIMER_MINT */
/* #undef SDL_TIMER_OS2 */
/* #undef SDL_TIMER_RISCOS */
#define SDL_TIMER_UNIX 1
/* #undef SDL_TIMER_WIN32 */
/* #undef SDL_TIMER_WINCE */
/* Enable various video drivers */
/* #undef SDL_VIDEO_DRIVER_AALIB */
/* #undef SDL_VIDEO_DRIVER_BWINDOW */
/* #undef SDL_VIDEO_DRIVER_CACA */
/* #undef SDL_VIDEO_DRIVER_DC */
/* #undef SDL_VIDEO_DRIVER_DDRAW */
#define SDL_VIDEO_DRIVER_DGA 1
/* #undef SDL_VIDEO_DRIVER_DIRECTFB */
/* #undef SDL_VIDEO_DRIVER_DRAWSPROCKET */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_FBCON 1
/* #undef SDL_VIDEO_DRIVER_GAPI */
/* #undef SDL_VIDEO_DRIVER_GEM */
/* #undef SDL_VIDEO_DRIVER_GGI */
/* #undef SDL_VIDEO_DRIVER_IPOD */
/* #undef SDL_VIDEO_DRIVER_NANOX */
/* #undef SDL_VIDEO_DRIVER_OS2FS */
/* #undef SDL_VIDEO_DRIVER_PHOTON */
/* #undef SDL_VIDEO_DRIVER_PICOGUI */
/* #undef SDL_VIDEO_DRIVER_PS2GS */
/* #undef SDL_VIDEO_DRIVER_PS3 */
/* #undef SDL_VIDEO_DRIVER_QTOPIA */
/* #undef SDL_VIDEO_DRIVER_QUARTZ */
/* #undef SDL_VIDEO_DRIVER_RISCOS */
/* #undef SDL_VIDEO_DRIVER_SVGALIB */
/* #undef SDL_VIDEO_DRIVER_TOOLBOX */
/* #undef SDL_VIDEO_DRIVER_VGL */
/* #undef SDL_VIDEO_DRIVER_WINDIB */
/* #undef SDL_VIDEO_DRIVER_WSCONS */
#define SDL_VIDEO_DRIVER_X11 1
#define SDL_VIDEO_DRIVER_X11_DGAMOUSE 1
#define SDL_VIDEO_DRIVER_X11_DYNAMIC "libX11.so.6"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "libXrandr.so.2"
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "libXrender.so.1"
#define SDL_VIDEO_DRIVER_X11_VIDMODE 1
#define SDL_VIDEO_DRIVER_X11_XINERAMA 1
#define SDL_VIDEO_DRIVER_X11_XME 1
#define SDL_VIDEO_DRIVER_X11_XRANDR 1
#define SDL_VIDEO_DRIVER_X11_XV 1
/* #undef SDL_VIDEO_DRIVER_XBIOS */
/* Enable OpenGL support */
#define SDL_VIDEO_OPENGL 1
#define SDL_VIDEO_OPENGL_GLX 1
/* #undef SDL_VIDEO_OPENGL_WGL */
/* #undef SDL_VIDEO_OPENGL_OSMESA */
/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */
/* Disable screensaver */
#define SDL_VIDEO_DISABLE_SCREENSAVER 1
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
/* #undef SDL_HERMES_BLITTERS */
/* #undef SDL_ALTIVEC_BLITTERS */
#endif /* _SDL_config_h */

View File

@ -0,0 +1,45 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_h
#define _SDL_config_h
#include "SDL_platform.h"
/* Add any platform that doesn't build using the configure system */
#if defined(__DREAMCAST__)
#include "SDL_config_dreamcast.h"
#elif defined(__MACOS__)
#include "SDL_config_macos.h"
#elif defined(__MACOSX__)
#include "SDL_config_macosx.h"
#elif defined(__SYMBIAN32__)
#include "SDL_config_symbian.h" /* must be before win32! */
#elif defined(__WIN32__)
#include "SDL_config_win32.h"
#elif defined(__OS2__)
#include "SDL_config_os2.h"
#else
#include "SDL_config_minimal.h"
#endif /* platform config */
#endif /* _SDL_config_h */

312
sdl/include/SDL_config.h.in Normal file
View File

@ -0,0 +1,312 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_h
#define _SDL_config_h
/* This is a set of defines to configure the SDL features */
/* General platform specific identifiers */
#include "SDL_platform.h"
/* Make sure that this isn't included by Visual C++ */
#ifdef _MSC_VER
#error You should copy include/SDL_config.h.default to include/SDL_config.h
#endif
/* C language features */
#undef const
#undef inline
#undef volatile
/* C datatypes */
#undef size_t
#undef int8_t
#undef uint8_t
#undef int16_t
#undef uint16_t
#undef int32_t
#undef uint32_t
#undef int64_t
#undef uint64_t
#undef uintptr_t
#undef SDL_HAS_64BIT_TYPE
/* Endianness */
#undef SDL_BYTEORDER
/* Comment this if you want to build without any C library requirements */
#undef HAVE_LIBC
#if HAVE_LIBC
/* Useful headers */
#undef HAVE_ALLOCA_H
#undef HAVE_SYS_TYPES_H
#undef HAVE_STDIO_H
#undef STDC_HEADERS
#undef HAVE_STDLIB_H
#undef HAVE_STDARG_H
#undef HAVE_MALLOC_H
#undef HAVE_MEMORY_H
#undef HAVE_STRING_H
#undef HAVE_STRINGS_H
#undef HAVE_INTTYPES_H
#undef HAVE_STDINT_H
#undef HAVE_CTYPE_H
#undef HAVE_MATH_H
#undef HAVE_ICONV_H
#undef HAVE_SIGNAL_H
#undef HAVE_ALTIVEC_H
/* C library functions */
#undef HAVE_MALLOC
#undef HAVE_CALLOC
#undef HAVE_REALLOC
#undef HAVE_FREE
#undef HAVE_ALLOCA
#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */
#undef HAVE_GETENV
#undef HAVE_PUTENV
#undef HAVE_UNSETENV
#endif
#undef HAVE_QSORT
#undef HAVE_ABS
#undef HAVE_BCOPY
#undef HAVE_MEMSET
#undef HAVE_MEMCPY
#undef HAVE_MEMMOVE
#undef HAVE_MEMCMP
#undef HAVE_STRLEN
#undef HAVE_STRLCPY
#undef HAVE_STRLCAT
#undef HAVE_STRDUP
#undef HAVE__STRREV
#undef HAVE__STRUPR
#undef HAVE__STRLWR
#undef HAVE_INDEX
#undef HAVE_RINDEX
#undef HAVE_STRCHR
#undef HAVE_STRRCHR
#undef HAVE_STRSTR
#undef HAVE_ITOA
#undef HAVE__LTOA
#undef HAVE__UITOA
#undef HAVE__ULTOA
#undef HAVE_STRTOL
#undef HAVE_STRTOUL
#undef HAVE__I64TOA
#undef HAVE__UI64TOA
#undef HAVE_STRTOLL
#undef HAVE_STRTOULL
#undef HAVE_STRTOD
#undef HAVE_ATOI
#undef HAVE_ATOF
#undef HAVE_STRCMP
#undef HAVE_STRNCMP
#undef HAVE__STRICMP
#undef HAVE_STRCASECMP
#undef HAVE__STRNICMP
#undef HAVE_STRNCASECMP
#undef HAVE_SSCANF
#undef HAVE_SNPRINTF
#undef HAVE_VSNPRINTF
#undef HAVE_ICONV
#undef HAVE_SIGACTION
#undef HAVE_SA_SIGACTION
#undef HAVE_SETJMP
#undef HAVE_NANOSLEEP
#undef HAVE_CLOCK_GETTIME
#undef HAVE_GETPAGESIZE
#undef HAVE_MPROTECT
#undef HAVE_SEM_TIMEDWAIT
#else
/* We may need some replacement for stdarg.h here */
#include <stdarg.h>
#endif /* HAVE_LIBC */
/* Allow disabling of core subsystems */
#undef SDL_AUDIO_DISABLED
#undef SDL_CDROM_DISABLED
#undef SDL_CPUINFO_DISABLED
#undef SDL_EVENTS_DISABLED
#undef SDL_FILE_DISABLED
#undef SDL_JOYSTICK_DISABLED
#undef SDL_LOADSO_DISABLED
#undef SDL_THREADS_DISABLED
#undef SDL_TIMERS_DISABLED
#undef SDL_VIDEO_DISABLED
/* Enable various audio drivers */
#undef SDL_AUDIO_DRIVER_ALSA
#undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
#undef SDL_AUDIO_DRIVER_ARTS
#undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
#undef SDL_AUDIO_DRIVER_BAUDIO
#undef SDL_AUDIO_DRIVER_BSD
#undef SDL_AUDIO_DRIVER_COREAUDIO
#undef SDL_AUDIO_DRIVER_DART
#undef SDL_AUDIO_DRIVER_DC
#undef SDL_AUDIO_DRIVER_DISK
#undef SDL_AUDIO_DRIVER_DUMMY
#undef SDL_AUDIO_DRIVER_DMEDIA
#undef SDL_AUDIO_DRIVER_DSOUND
#undef SDL_AUDIO_DRIVER_PULSE
#undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
#undef SDL_AUDIO_DRIVER_ESD
#undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
#undef SDL_AUDIO_DRIVER_MINT
#undef SDL_AUDIO_DRIVER_MMEAUDIO
#undef SDL_AUDIO_DRIVER_NAS
#undef SDL_AUDIO_DRIVER_NAS_DYNAMIC
#undef SDL_AUDIO_DRIVER_OSS
#undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
#undef SDL_AUDIO_DRIVER_PAUD
#undef SDL_AUDIO_DRIVER_QNXNTO
#undef SDL_AUDIO_DRIVER_SNDMGR
#undef SDL_AUDIO_DRIVER_SUNAUDIO
#undef SDL_AUDIO_DRIVER_WAVEOUT
/* Enable various cdrom drivers */
#undef SDL_CDROM_AIX
#undef SDL_CDROM_BEOS
#undef SDL_CDROM_BSDI
#undef SDL_CDROM_DC
#undef SDL_CDROM_DUMMY
#undef SDL_CDROM_FREEBSD
#undef SDL_CDROM_LINUX
#undef SDL_CDROM_MACOS
#undef SDL_CDROM_MACOSX
#undef SDL_CDROM_MINT
#undef SDL_CDROM_OPENBSD
#undef SDL_CDROM_OS2
#undef SDL_CDROM_OSF
#undef SDL_CDROM_QNX
#undef SDL_CDROM_WIN32
/* Enable various input drivers */
#undef SDL_INPUT_LINUXEV
#undef SDL_INPUT_TSLIB
#undef SDL_JOYSTICK_BEOS
#undef SDL_JOYSTICK_DC
#undef SDL_JOYSTICK_DUMMY
#undef SDL_JOYSTICK_IOKIT
#undef SDL_JOYSTICK_LINUX
#undef SDL_JOYSTICK_MACOS
#undef SDL_JOYSTICK_MINT
#undef SDL_JOYSTICK_OS2
#undef SDL_JOYSTICK_RISCOS
#undef SDL_JOYSTICK_WINMM
#undef SDL_JOYSTICK_USBHID
#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
/* Enable various shared object loading systems */
#undef SDL_LOADSO_BEOS
#undef SDL_LOADSO_DLCOMPAT
#undef SDL_LOADSO_DLOPEN
#undef SDL_LOADSO_DUMMY
#undef SDL_LOADSO_LDG
#undef SDL_LOADSO_MACOS
#undef SDL_LOADSO_OS2
#undef SDL_LOADSO_WIN32
/* Enable various threading systems */
#undef SDL_THREAD_BEOS
#undef SDL_THREAD_DC
#undef SDL_THREAD_OS2
#undef SDL_THREAD_PTH
#undef SDL_THREAD_PTHREAD
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
#undef SDL_THREAD_SPROC
#undef SDL_THREAD_WIN32
/* Enable various timer systems */
#undef SDL_TIMER_BEOS
#undef SDL_TIMER_DC
#undef SDL_TIMER_DUMMY
#undef SDL_TIMER_MACOS
#undef SDL_TIMER_MINT
#undef SDL_TIMER_OS2
#undef SDL_TIMER_RISCOS
#undef SDL_TIMER_UNIX
#undef SDL_TIMER_WIN32
#undef SDL_TIMER_WINCE
/* Enable various video drivers */
#undef SDL_VIDEO_DRIVER_AALIB
#undef SDL_VIDEO_DRIVER_BWINDOW
#undef SDL_VIDEO_DRIVER_CACA
#undef SDL_VIDEO_DRIVER_DC
#undef SDL_VIDEO_DRIVER_DDRAW
#undef SDL_VIDEO_DRIVER_DGA
#undef SDL_VIDEO_DRIVER_DIRECTFB
#undef SDL_VIDEO_DRIVER_DRAWSPROCKET
#undef SDL_VIDEO_DRIVER_DUMMY
#undef SDL_VIDEO_DRIVER_FBCON
#undef SDL_VIDEO_DRIVER_GAPI
#undef SDL_VIDEO_DRIVER_GEM
#undef SDL_VIDEO_DRIVER_GGI
#undef SDL_VIDEO_DRIVER_IPOD
#undef SDL_VIDEO_DRIVER_NANOX
#undef SDL_VIDEO_DRIVER_OS2FS
#undef SDL_VIDEO_DRIVER_PHOTON
#undef SDL_VIDEO_DRIVER_PICOGUI
#undef SDL_VIDEO_DRIVER_PS2GS
#undef SDL_VIDEO_DRIVER_PS3
#undef SDL_VIDEO_DRIVER_QTOPIA
#undef SDL_VIDEO_DRIVER_QUARTZ
#undef SDL_VIDEO_DRIVER_RISCOS
#undef SDL_VIDEO_DRIVER_SVGALIB
#undef SDL_VIDEO_DRIVER_TOOLBOX
#undef SDL_VIDEO_DRIVER_VGL
#undef SDL_VIDEO_DRIVER_WINDIB
#undef SDL_VIDEO_DRIVER_WSCONS
#undef SDL_VIDEO_DRIVER_X11
#undef SDL_VIDEO_DRIVER_X11_DGAMOUSE
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER
#undef SDL_VIDEO_DRIVER_X11_VIDMODE
#undef SDL_VIDEO_DRIVER_X11_XINERAMA
#undef SDL_VIDEO_DRIVER_X11_XME
#undef SDL_VIDEO_DRIVER_X11_XRANDR
#undef SDL_VIDEO_DRIVER_X11_XV
#undef SDL_VIDEO_DRIVER_XBIOS
/* Enable OpenGL support */
#undef SDL_VIDEO_OPENGL
#undef SDL_VIDEO_OPENGL_GLX
#undef SDL_VIDEO_OPENGL_WGL
#undef SDL_VIDEO_OPENGL_OSMESA
#undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
/* Disable screensaver */
#undef SDL_VIDEO_DISABLE_SCREENSAVER
/* Enable assembly routines */
#undef SDL_ASSEMBLY_ROUTINES
#undef SDL_HERMES_BLITTERS
#undef SDL_ALTIVEC_BLITTERS
#endif /* _SDL_config_h */

View File

@ -0,0 +1,62 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_minimal_h
#define _SDL_config_minimal_h
#include "SDL_platform.h"
/* This is the minimal configuration that can be used to build SDL */
#include <stdarg.h>
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef unsigned int size_t;
typedef unsigned long uintptr_t;
/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */
#define SDL_CDROM_DISABLED 1
/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */
#define SDL_JOYSTICK_DISABLED 1
/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */
#define SDL_LOADSO_DISABLED 1
/* Enable the stub thread support (src/thread/generic/\*.c) */
#define SDL_THREADS_DISABLED 1
/* Enable the stub timer support (src/timer/dummy/\*.c) */
#define SDL_TIMERS_DISABLED 1
/* Enable the dummy video driver (src/video/dummy/\*.c) */
#define SDL_VIDEO_DRIVER_DUMMY 1
#endif /* _SDL_config_minimal_h */

View File

@ -0,0 +1,183 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_config_win32_h
#define _SDL_config_win32_h
#include "SDL_platform.h"
/* This is a set of defines to configure the SDL features */
#if defined(__GNUC__) || defined(__DMC__)
#define HAVE_STDINT_H 1
#elif defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#define _UINTPTR_T_DEFINED
#endif
/* Older Visual C++ headers don't have the Win64-compatible typedefs... */
#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR)))
#define DWORD_PTR DWORD
#endif
#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR)))
#define LONG_PTR LONG
#endif
#else /* !__GNUC__ && !_MSC_VER */
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef signed short int16_t;
typedef unsigned short uint16_t;
typedef signed int int32_t;
typedef unsigned int uint32_t;
typedef signed long long int64_t;
typedef unsigned long long uint64_t;
#ifndef _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED_
typedef unsigned int size_t;
#endif
typedef unsigned int uintptr_t;
#endif /* __GNUC__ || _MSC_VER */
#define SDL_HAS_64BIT_TYPE 1
/* Enabled for SDL 1.2 (binary compatibility) */
#define HAVE_LIBC 1
#ifdef HAVE_LIBC
/* Useful headers */
#define HAVE_STDIO_H 1
#define STDC_HEADERS 1
#define HAVE_STRING_H 1
#define HAVE_CTYPE_H 1
#define HAVE_MATH_H 1
#ifndef _WIN32_WCE
#define HAVE_SIGNAL_H 1
#endif
/* C library functions */
#define HAVE_MALLOC 1
#define HAVE_CALLOC 1
#define HAVE_REALLOC 1
#define HAVE_FREE 1
#define HAVE_ALLOCA 1
#define HAVE_QSORT 1
#define HAVE_ABS 1
#define HAVE_MEMSET 1
#define HAVE_MEMCPY 1
#define HAVE_MEMMOVE 1
#define HAVE_MEMCMP 1
#define HAVE_STRLEN 1
#define HAVE__STRREV 1
#define HAVE__STRUPR 1
#define HAVE__STRLWR 1
#define HAVE_STRCHR 1
#define HAVE_STRRCHR 1
#define HAVE_STRSTR 1
#define HAVE_ITOA 1
#define HAVE__LTOA 1
#define HAVE__ULTOA 1
#define HAVE_STRTOL 1
#define HAVE_STRTOUL 1
#define HAVE_STRTOLL 1
#define HAVE_STRTOD 1
#define HAVE_ATOI 1
#define HAVE_ATOF 1
#define HAVE_STRCMP 1
#define HAVE_STRNCMP 1
#define HAVE__STRICMP 1
#define HAVE__STRNICMP 1
#define HAVE_SSCANF 1
#else
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#endif
/* Enable various audio drivers */
#ifndef _WIN32_WCE
#define SDL_AUDIO_DRIVER_DSOUND 1
#endif
#define SDL_AUDIO_DRIVER_WAVEOUT 1
#define SDL_AUDIO_DRIVER_DISK 1
#define SDL_AUDIO_DRIVER_DUMMY 1
/* Enable various cdrom drivers */
#ifdef _WIN32_WCE
#define SDL_CDROM_DISABLED 1
#else
#define SDL_CDROM_WIN32 1
#endif
/* Enable various input drivers */
#ifdef _WIN32_WCE
#define SDL_JOYSTICK_DISABLED 1
#else
#define SDL_JOYSTICK_WINMM 1
#endif
/* Enable various shared object loading systems */
#define SDL_LOADSO_WIN32 1
/* Enable various threading systems */
#define SDL_THREAD_WIN32 1
/* Enable various timer systems */
#ifdef _WIN32_WCE
#define SDL_TIMER_WINCE 1
#else
#define SDL_TIMER_WIN32 1
#endif
/* Enable various video drivers */
#ifdef _WIN32_WCE
#define SDL_VIDEO_DRIVER_GAPI 1
#endif
#ifndef _WIN32_WCE
#define SDL_VIDEO_DRIVER_DDRAW 1
#endif
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_WINDIB 1
/* Enable OpenGL support */
#ifndef _WIN32_WCE
#define SDL_VIDEO_OPENGL 1
#define SDL_VIDEO_OPENGL_WGL 1
#endif
/* Disable screensaver */
#define SDL_VIDEO_DISABLE_SCREENSAVER 1
/* Enable assembly routines (Win64 doesn't have inline asm) */
#ifndef _WIN64
#define SDL_ASSEMBLY_ROUTINES 1
#endif
#endif /* _SDL_config_win32_h */

22
sdl/include/SDL_copying.h Normal file
View File

@ -0,0 +1,22 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/

202
sdl/include/SDL_endian.h Normal file
View File

@ -0,0 +1,202 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* @file SDL_endian.h
* Functions for reading and writing endian-specific values
*/
#ifndef _SDL_endian_h
#define _SDL_endian_h
#include "SDL_stdinc.h"
/** @name SDL_ENDIANs
* The two types of endianness
*/
/*@{*/
#define SDL_LIL_ENDIAN 1234
#define SDL_BIG_ENDIAN 4321
/*@}*/
#ifdef MSB_FIRST
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#else
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name SDL_Swap Functions
* Use inline functions for compilers that support them, and static
* functions for those that do not. Because these functions become
* static for compilers that do not support inline functions, this
* header should only be included in files that actually use them.
*/
/*@{*/
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
__asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x));
return x;
}
#elif defined(__GNUC__) && defined(__x86_64__)
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
__asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x));
return x;
}
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
int result;
__asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x));
return (Uint16)result;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
static __inline__ Uint16 SDL_Swap16(Uint16 x)
{
__asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc");
return x;
}
#else
static __inline__ Uint16 SDL_Swap16(Uint16 x) {
return SDL_static_cast(Uint16, ((x<<8)|(x>>8)));
}
#endif
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
__asm__("bswap %0" : "=r" (x) : "0" (x));
return x;
}
#elif defined(__GNUC__) && defined(__x86_64__)
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
__asm__("bswapl %0" : "=r" (x) : "0" (x));
return x;
}
#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
Uint32 result;
__asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x));
__asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x));
__asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x));
return result;
}
#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__))
static __inline__ Uint32 SDL_Swap32(Uint32 x)
{
__asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc");
return x;
}
#else
static __inline__ Uint32 SDL_Swap32(Uint32 x) {
return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24)));
}
#endif
#ifdef SDL_HAS_64BIT_TYPE
#if defined(__GNUC__) && defined(__i386__) && \
!(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */)
static __inline__ Uint64 SDL_Swap64(Uint64 x)
{
union {
struct { Uint32 a,b; } s;
Uint64 u;
} v;
v.u = x;
__asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
: "=r" (v.s.a), "=r" (v.s.b)
: "0" (v.s.a), "1" (v.s.b));
return v.u;
}
#elif defined(__GNUC__) && defined(__x86_64__)
static __inline__ Uint64 SDL_Swap64(Uint64 x)
{
__asm__("bswapq %0" : "=r" (x) : "0" (x));
return x;
}
#else
static __inline__ Uint64 SDL_Swap64(Uint64 x)
{
Uint32 hi, lo;
/* Separate into high and low 32-bit values and swap them */
lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x >>= 32;
hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF);
x = SDL_Swap32(lo);
x <<= 32;
x |= SDL_Swap32(hi);
return (x);
}
#endif
#else
/* This is mainly to keep compilers from complaining in SDL code.
* If there is no real 64-bit datatype, then compilers will complain about
* the fake 64-bit datatype that SDL provides when it compiles user code.
*/
#define SDL_Swap64(X) (X)
#endif /* SDL_HAS_64BIT_TYPE */
/*@}*/
/**
* @name SDL_SwapLE and SDL_SwapBE Functions
* Byteswap item from the specified endianness to the native endianness
*/
/*@{*/
#ifdef MSB_FIRST
#define SDL_SwapLE16(X) SDL_Swap16(X)
#define SDL_SwapLE32(X) SDL_Swap32(X)
#define SDL_SwapLE64(X) SDL_Swap64(X)
#define SDL_SwapBE16(X) (X)
#define SDL_SwapBE32(X) (X)
#define SDL_SwapBE64(X) (X)
#else
#define SDL_SwapLE16(X) (X)
#define SDL_SwapLE32(X) (X)
#define SDL_SwapLE64(X) (X)
#define SDL_SwapBE16(X) SDL_Swap16(X)
#define SDL_SwapBE32(X) SDL_Swap32(X)
#define SDL_SwapBE64(X) SDL_Swap64(X)
#endif
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_endian_h */

72
sdl/include/SDL_error.h Normal file
View File

@ -0,0 +1,72 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* @file SDL_error.h
* Simple error message routines for SDL
*/
#ifndef _SDL_error_h
#define _SDL_error_h
#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Public functions
*/
/*@{*/
extern DECLSPEC void SDLCALL LRSDL_SetError(const char *fmt, ...);
extern DECLSPEC char * SDLCALL LRSDL_GetError(void);
extern DECLSPEC void SDLCALL LRSDL_ClearError(void);
/*@}*/
/**
* @name Private functions
* @internal Private error message function - used internally
*/
/*@{*/
#define LRSDL_OutOfMemory() LRSDL_Error(SDL_ENOMEM)
#define LRSDL_Unsupported() LRSDL_Error(SDL_UNSUPPORTED)
typedef enum {
SDL_ENOMEM,
SDL_EFREAD,
SDL_EFWRITE,
SDL_EFSEEK,
SDL_UNSUPPORTED,
SDL_LASTERROR
} SDL_errorcode;
extern DECLSPEC void SDLCALL LRSDL_Error(SDL_errorcode code);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_error_h */

106
sdl/include/SDL_main.h Normal file
View File

@ -0,0 +1,106 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#ifndef _SDL_main_h
#define _SDL_main_h
#include "SDL_stdinc.h"
/** @file SDL_main.h
* Redefine main() on Win32 and MacOS so that it is called by winmain.c
*/
#if defined(__WIN32__) || \
(defined(__MWERKS__) && !defined(__BEOS__)) || \
defined(__MACOS__) || defined(__MACOSX__) || \
defined(__SYMBIAN32__) || defined(QWS)
#ifdef __cplusplus
#define C_LINKAGE "C"
#else
#define C_LINKAGE
#endif /* __cplusplus */
/** The application's main() function must be called with C linkage,
* and should be declared like this:
* @code
* #ifdef __cplusplus
* extern "C"
* #endif
* int main(int argc, char *argv[])
* {
* }
* @endcode
*/
#define main SDL_main
/** The prototype for the application's main() function */
extern C_LINKAGE int SDL_main(int argc, char *argv[]);
/** @name From the SDL library code -- needed for registering the app on Win32 */
/*@{*/
#ifdef __WIN32__
#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/** This should be called from your WinMain() function, if any */
extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst);
/** This can also be called, but is no longer necessary */
extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst);
/** This can also be called, but is no longer necessary (SDL_Quit calls it) */
extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif
/*@}*/
/** @name From the SDL library code -- needed for registering QuickDraw on MacOS */
/*@{*/
#if defined(__MACOS__)
#include "begin_code.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Forward declaration so we don't need to include QuickDraw.h */
struct QDGlobals;
/** This should be called from your main() function, if any */
extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd);
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif
/*@}*/
#endif /* Need to redefine main()? */
#endif /* _SDL_main_h */

11
sdl/include/SDL_name.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef _SDLname_h_
#define _SDLname_h_
#if defined(__STDC__) || defined(__cplusplus)
#define NeedFunctionPrototypes 1
#endif
#define SDL_NAME(X) SDL_##X
#endif /* _SDLname_h_ */

View File

@ -0,0 +1,70 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_platform.h
* Try to get a standard set of platform defines
*/
#ifndef _SDL_platform_h
#define _SDL_platform_h
#if defined(linux) || defined(__linux) || defined(__linux__)
#undef __LINUX__
#define __LINUX__ 1
#endif
#if defined(__APPLE__)
#undef __MACOSX__
#define __MACOSX__ 1
#elif defined(macintosh)
#undef __MACOS__
#define __MACOS__ 1
#endif
#if defined(__NetBSD__)
#undef __NETBSD__
#define __NETBSD__ 1
#endif
#if defined(__OpenBSD__)
#undef __OPENBSD__
#define __OPENBSD__ 1
#endif
#if defined(__OS2__)
#undef __OS2__
#define __OS2__ 1
#endif
#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE)
#undef __OSF__
#define __OSF__ 1
#endif
#if defined(__QNXNTO__)
#undef __QNXNTO__
#define __QNXNTO__ 1
#endif
#if defined(__SVR4)
#undef __SOLARIS__
#define __SOLARIS__ 1
#endif
#if defined(WIN32) || defined(_WIN32)
#undef __WIN32__
#define __WIN32__ 1
#endif
#endif /* _SDL_platform_h */

155
sdl/include/SDL_rwops.h Normal file
View File

@ -0,0 +1,155 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_rwops.h
* This file provides a general interface for SDL to read and write
* data sources. It can easily be extended to files, memory, etc.
*/
#ifndef _SDL_rwops_h
#define _SDL_rwops_h
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/** This is the read/write operation structure -- very basic */
typedef struct SDL_RWops {
/** Seek to 'offset' relative to whence, one of stdio's whence values:
* SEEK_SET, SEEK_CUR, SEEK_END
* Returns the final offset in the data source.
*/
int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence);
/** Read up to 'maxnum' objects each of size 'size' from the data
* source to the area pointed at by 'ptr'.
* Returns the number of objects read, or -1 if the read failed.
*/
int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
/** Write exactly 'num' objects each of size 'objsize' from the area
* pointed at by 'ptr' to data source.
* Returns 'num', or -1 if the write failed.
*/
int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num);
/** Close and free an allocated SDL_FSops structure */
int (SDLCALL *close)(struct SDL_RWops *context);
Uint32 type;
union {
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
struct {
int append;
void *h;
struct {
void *data;
int size;
int left;
} buffer;
} win32io;
#endif
#ifdef HAVE_STDIO_H
struct {
int autoclose;
FILE *fp;
} stdio;
#endif
struct {
Uint8 *base;
Uint8 *here;
Uint8 *stop;
} mem;
struct {
void *data1;
} unknown;
} hidden;
} SDL_RWops;
/** @name Functions to create SDL_RWops structures from various data sources */
/*@{*/
extern DECLSPEC SDL_RWops * SDLCALL LRSDL_RWFromFile(const char *file, const char *mode);
#ifdef HAVE_STDIO_H
extern DECLSPEC SDL_RWops * SDLCALL LRSDL_RWFromFP(FILE *fp, int autoclose);
#endif
extern DECLSPEC SDL_RWops * SDLCALL LRSDL_RWFromMem(void *mem, int size);
extern DECLSPEC SDL_RWops * SDLCALL LRSDL_RWFromConstMem(const void *mem, int size);
extern DECLSPEC SDL_RWops * SDLCALL LRSDL_AllocRW(void);
extern DECLSPEC void SDLCALL LRSDL_FreeRW(SDL_RWops *area);
/*@}*/
/** @name Seek Reference Points */
/*@{*/
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */
#define RW_SEEK_END 2 /**< Seek relative to the end of data */
/*@}*/
/** @name Macros to easily read and write from an SDL_RWops structure */
/*@{*/
#define LRSDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
#define LRSDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
#define LRSDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
#define LRSDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
#define LRSDL_RWclose(ctx) (ctx)->close(ctx)
/*@}*/
/** @name Read an item of the specified endianness and return in native format */
/*@{*/
extern DECLSPEC Uint16 SDLCALL LRSDL_ReadLE16(SDL_RWops *src);
extern DECLSPEC Uint16 SDLCALL LRSDL_ReadBE16(SDL_RWops *src);
extern DECLSPEC Uint32 SDLCALL LRSDL_ReadLE32(SDL_RWops *src);
extern DECLSPEC Uint32 SDLCALL LRSDL_ReadBE32(SDL_RWops *src);
extern DECLSPEC Uint64 SDLCALL LRSDL_ReadLE64(SDL_RWops *src);
extern DECLSPEC Uint64 SDLCALL LRSDL_ReadBE64(SDL_RWops *src);
/*@}*/
/** @name Write an item of native format to the specified endianness */
/*@{*/
extern DECLSPEC int SDLCALL LRSDL_WriteLE16(SDL_RWops *dst, Uint16 value);
extern DECLSPEC int SDLCALL LRSDL_WriteBE16(SDL_RWops *dst, Uint16 value);
extern DECLSPEC int SDLCALL LRSDL_WriteLE32(SDL_RWops *dst, Uint32 value);
extern DECLSPEC int SDLCALL LRSDL_WriteBE32(SDL_RWops *dst, Uint32 value);
extern DECLSPEC int SDLCALL LRSDL_WriteLE64(SDL_RWops *dst, Uint64 value);
extern DECLSPEC int SDLCALL LRSDL_WriteBE64(SDL_RWops *dst, Uint64 value);
/*@}*/
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_rwops_h */

411
sdl/include/SDL_stdinc.h Normal file
View File

@ -0,0 +1,411 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_stdinc.h
* This is a general header that includes C language support
*/
#ifndef _SDL_stdinc_h
#define _SDL_stdinc_h
#include "SDL_config.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif
#if defined(STDC_HEADERS)
# include <stdlib.h>
# include <stddef.h>
# include <stdarg.h>
#else
# if defined(HAVE_STDLIB_H)
# include <stdlib.h>
# elif defined(HAVE_MALLOC_H)
# include <malloc.h>
# endif
# if defined(HAVE_STDDEF_H)
# include <stddef.h>
# endif
# if defined(HAVE_STDARG_H)
# include <stdarg.h>
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
#endif
#include <stdint.h>
#ifdef HAVE_CTYPE_H
# include <ctype.h>
#endif
/** The number of elements in an array */
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
#define SDL_TABLESIZE(table) SDL_arraysize(table)
/* Use proper C++ casts when compiled as C++ to be compatible with the option
-Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */
#ifdef __cplusplus
#define SDL_reinterpret_cast(type, expression) reinterpret_cast<type>(expression)
#define SDL_static_cast(type, expression) static_cast<type>(expression)
#else
#define SDL_reinterpret_cast(type, expression) ((type)(expression))
#define SDL_static_cast(type, expression) ((type)(expression))
#endif
/** @name Basic data types */
/*@{*/
typedef enum {
SDL_FALSE = 0,
SDL_TRUE = 1
} SDL_bool;
typedef int8_t Sint8;
typedef uint8_t Uint8;
typedef int16_t Sint16;
typedef uint16_t Uint16;
typedef int32_t Sint32;
typedef uint32_t Uint32;
#ifdef SDL_HAS_64BIT_TYPE
typedef int64_t Sint64;
#ifndef SYMBIAN32_GCCE
typedef uint64_t Uint64;
#endif
#else
/* This is really just a hack to prevent the compiler from complaining */
typedef struct {
Uint32 hi;
Uint32 lo;
} Uint64, Sint64;
#endif
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#define SDL_malloc malloc
#define SDL_calloc calloc
#define SDL_realloc realloc
#define SDL_free free
#if defined(HAVE_ALLOCA) && !defined(alloca)
# if defined(__GNUC__)
# define alloca __builtin_alloca
# elif defined(_MSC_VER)
# include <malloc.h>
# define alloca _alloca
# elif defined(__WATCOMC__)
# include <malloc.h>
# elif defined(__BORLANDC__)
# include <malloc.h>
# elif defined(__DMC__)
# include <stdlib.h>
# elif defined(__AIX__)
#pragma alloca
# elif defined(__MRC__)
void *alloca (unsigned);
# else
char *alloca ();
# endif
#endif
#ifdef HAVE_ALLOCA
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
#define SDL_stack_free(data)
#else
#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count))
#define SDL_stack_free(data) SDL_free(data)
#endif
#ifdef HAVE_GETENV
#define SDL_getenv getenv
#else
extern DECLSPEC char * SDLCALL SDL_getenv(const char *name);
#endif
#ifdef HAVE_PUTENV
#define SDL_putenv putenv
#else
extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
#endif
#ifdef HAVE_QSORT
#define SDL_qsort qsort
#else
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size,
int (*compare)(const void *, const void *));
#endif
#ifdef HAVE_ABS
#define SDL_abs abs
#else
#define SDL_abs(X) ((X) < 0 ? -(X) : (X))
#endif
#define SDL_min(x, y) (((x) < (y)) ? (x) : (y))
#define SDL_max(x, y) (((x) > (y)) ? (x) : (y))
#ifdef HAVE_CTYPE_H
#define SDL_isdigit(X) isdigit(X)
#define SDL_isspace(X) isspace(X)
#define SDL_toupper(X) toupper(X)
#define SDL_tolower(X) tolower(X)
#else
#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9'))
#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n'))
#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X))
#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X))
#endif
#define SDL_memset memset
#ifndef SDL_memset4
#define SDL_memset4(dst, val, len) \
do { \
unsigned _count = (len); \
unsigned _n = (_count + 3) / 4; \
Uint32 *_p = SDL_static_cast(Uint32 *, dst); \
Uint32 _val = (val); \
if (len == 0) break; \
switch (_count % 4) { \
case 0: do { *_p++ = _val; \
case 3: *_p++ = _val; \
case 2: *_p++ = _val; \
case 1: *_p++ = _val; \
} while ( --_n ); \
} \
} while(0)
#endif
#define SDL_memcpy memcpy
#ifndef SDL_memcpy4
#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2)
#endif
#ifndef SDL_revcpy
extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len);
#endif
#define SDL_memmove memmove
#define SDL_memcmp memcmp
#define SDL_strlen strlen
#ifdef HAVE_STRLCAT
#define SDL_strlcat strlcat
#else
extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen);
#endif
#ifdef HAVE_STRDUP
#define SDL_strdup strdup
#else
extern DECLSPEC char * SDLCALL SDL_strdup(const char *string);
#endif
#ifdef HAVE__STRREV
#define SDL_strrev _strrev
#else
extern DECLSPEC char * SDLCALL SDL_strrev(char *string);
#endif
#ifdef HAVE__STRUPR
#define SDL_strupr _strupr
#else
extern DECLSPEC char * SDLCALL SDL_strupr(char *string);
#endif
#ifdef HAVE__STRLWR
#define SDL_strlwr _strlwr
#else
extern DECLSPEC char * SDLCALL SDL_strlwr(char *string);
#endif
#ifdef HAVE_STRCHR
#define SDL_strchr strchr
#elif defined(HAVE_INDEX)
#define SDL_strchr index
#else
extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c);
#endif
#ifdef HAVE_STRRCHR
#define SDL_strrchr strrchr
#elif defined(HAVE_RINDEX)
#define SDL_strrchr rindex
#else
extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c);
#endif
#ifdef HAVE_STRSTR
#define SDL_strstr strstr
#else
extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle);
#endif
#ifdef HAVE_ITOA
#define SDL_itoa itoa
#else
#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix)
#endif
#ifdef HAVE__LTOA
#define SDL_ltoa _ltoa
#else
extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix);
#endif
#ifdef HAVE__UITOA
#define SDL_uitoa _uitoa
#else
#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix)
#endif
#ifdef HAVE__ULTOA
#define SDL_ultoa _ultoa
#else
extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix);
#endif
#ifdef HAVE_STRTOL
#define SDL_strtol strtol
#else
extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base);
#endif
#ifdef HAVE_STRTOUL
#define SDL_strtoul strtoul
#else
extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base);
#endif
#ifdef SDL_HAS_64BIT_TYPE
#ifdef HAVE__I64TOA
#define SDL_lltoa _i64toa
#else
extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix);
#endif
#ifdef HAVE__UI64TOA
#define SDL_ulltoa _ui64toa
#else
extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix);
#endif
#ifdef HAVE_STRTOLL
#define SDL_strtoll strtoll
#else
extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base);
#endif
#ifdef HAVE_STRTOULL
#define SDL_strtoull strtoull
#else
extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base);
#endif
#endif /* SDL_HAS_64BIT_TYPE */
#ifdef HAVE_STRTOD
#define SDL_strtod strtod
#else
extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp);
#endif
#ifdef HAVE_ATOI
#define SDL_atoi atoi
#else
#define SDL_atoi(X) SDL_strtol(X, NULL, 0)
#endif
#ifdef HAVE_ATOF
#define SDL_atof atof
#else
#define SDL_atof(X) SDL_strtod(X, NULL)
#endif
#ifdef HAVE_STRCMP
#define SDL_strcmp strcmp
#else
extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2);
#endif
#ifdef HAVE_STRNCMP
#define SDL_strncmp strncmp
#else
extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen);
#endif
#ifdef HAVE_STRCASECMP
#define SDL_strcasecmp strcasecmp
#elif defined(HAVE__STRICMP)
#define SDL_strcasecmp _stricmp
#else
extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
#endif
#ifdef HAVE_STRNCASECMP
#define SDL_strncasecmp strncasecmp
#elif defined(HAVE__STRNICMP)
#define SDL_strncasecmp _strnicmp
#else
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen);
#endif
#ifdef HAVE_SSCANF
#define SDL_sscanf sscanf
#else
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...);
#endif
#if defined(HAVE_SNPRINTF) && !defined(_WIN32)
#define SDL_snprintf snprintf
#elif defined(HAVE_SNPRINTF) && defined(_WIN32)
#define SDL_snprintf _snprintf
#else
extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);
#endif
#ifdef HAVE_VSNPRINTF
#define SDL_vsnprintf vsnprintf
#else
extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap);
#endif
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_stdinc_h */

28
sdl/include/SDL_types.h Normal file
View File

@ -0,0 +1,28 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_types.h
* @deprecated Use SDL_stdinc.h instead.
*/
/* DEPRECATED */
#include "SDL_stdinc.h"

91
sdl/include/SDL_version.h Normal file
View File

@ -0,0 +1,91 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_version.h
* This header defines the current SDL version
*/
#ifndef _SDL_version_h
#define _SDL_version_h
#include "SDL_stdinc.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/** @name Version Number
* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/
/*@{*/
#define SDL_MAJOR_VERSION 1
#define SDL_MINOR_VERSION 2
#define SDL_PATCHLEVEL 15
/*@}*/
typedef struct SDL_version {
Uint8 major;
Uint8 minor;
Uint8 patch;
} SDL_version;
/**
* This macro can be used to fill a version structure with the compile-time
* version of the SDL library.
*/
#define SDL_VERSION(X) \
{ \
(X)->major = SDL_MAJOR_VERSION; \
(X)->minor = SDL_MINOR_VERSION; \
(X)->patch = SDL_PATCHLEVEL; \
}
/** This macro turns the version numbers into a numeric value:
* (1,2,3) -> (1203)
* This assumes that there will never be more than 100 patchlevels
*/
#define SDL_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z))
/** This is the version number macro for the current SDL version */
#define SDL_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
/** This macro will evaluate to true if compiled with SDL at least X.Y.Z */
#define SDL_VERSION_ATLEAST(X, Y, Z) \
(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
/** This function gets the version of the dynamically linked SDL library.
* it should NOT be used to fill a version structure, instead you should
* use the SDL_Version() macro.
*/
extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_version_h */

605
sdl/include/SDL_video.h Normal file
View File

@ -0,0 +1,605 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
/** @file SDL_video.h
* Header file for access to the SDL raw framebuffer window
*/
#ifndef _SDL_video_h
#define _SDL_video_h
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
/** @name Transparency definitions
* These define alpha as the opacity of a surface
*/
/*@{*/
#define SDL_ALPHA_OPAQUE 255
#define SDL_ALPHA_TRANSPARENT 0
/*@}*/
/** @name Useful data types */
/*@{*/
typedef struct SDL_Rect {
Sint16 x, y;
Uint16 w, h;
} SDL_Rect;
typedef struct SDL_Color {
Uint8 r;
Uint8 g;
Uint8 b;
Uint8 unused;
} SDL_Color;
#define SDL_Colour SDL_Color
typedef struct SDL_Palette {
int ncolors;
SDL_Color *colors;
} SDL_Palette;
/*@}*/
/** Everything in the pixel format structure is read-only */
typedef struct SDL_PixelFormat {
SDL_Palette *palette;
Uint8 BitsPerPixel;
Uint8 BytesPerPixel;
Uint8 Rloss;
Uint8 Gloss;
Uint8 Bloss;
Uint8 Aloss;
Uint8 Rshift;
Uint8 Gshift;
Uint8 Bshift;
Uint8 Ashift;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
Uint32 Amask;
/** RGB color key information */
Uint32 colorkey;
/** Alpha value information (per-surface alpha) */
Uint8 alpha;
} SDL_PixelFormat;
/** This structure should be treated as read-only, except for 'pixels',
* which, if not NULL, contains the raw pixel data for the surface.
*/
typedef struct SDL_Surface {
Uint32 flags; /**< Read-only */
SDL_PixelFormat *format; /**< Read-only */
int w, h; /**< Read-only */
Uint16 pitch; /**< Read-only */
void *pixels; /**< Read-write */
int offset; /**< Private */
/** Hardware-specific surface info */
struct private_hwdata *hwdata;
/** clipping information */
SDL_Rect clip_rect; /**< Read-only */
Uint32 unused1; /**< for binary compatibility */
/** Allow recursive locks */
Uint32 locked; /**< Private */
/** info for fast blit mapping to other surfaces */
struct SDL_BlitMap *map; /**< Private */
/** format version, bumped at every change to invalidate blit maps */
unsigned int format_version; /**< Private */
/** Reference count -- used when freeing surface */
int refcount; /**< Read-mostly */
} SDL_Surface;
/** @name SDL_Surface Flags
* These are the currently supported flags for the SDL_surface
*/
/*@{*/
/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
/*@{*/
#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */
#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */
#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */
/*@}*/
/** Available for SDL_SetVideoMode() */
/*@{*/
#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */
#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */
#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */
#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */
#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */
#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */
#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */
/*@}*/
/** Used internally (read-only) */
/*@{*/
#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */
#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */
#define SDL_RLEACCELOK 0x00002000 /**< Private flag */
#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */
#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */
#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */
/*@}*/
/*@}*/
/** Evaluates to true if the surface needs to be locked before access */
#define SDL_MUSTLOCK(surface) \
(surface->offset || \
((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
/** typedef for private surface blitting functions */
typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
struct SDL_Surface *dst, SDL_Rect *dstrect);
/** Useful for determining the video hardware capabilities */
typedef struct SDL_VideoInfo {
Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */
Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */
Uint32 UnusedBits1 :6;
Uint32 UnusedBits2 :1;
Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */
Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */
Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_fill :1; /**< Flag: Accelerated color fill */
Uint32 UnusedBits3 :16;
Uint32 video_mem; /**< The total amount of video memory (in K) */
SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */
int current_w; /**< Value: The current video mode width */
int current_h; /**< Value: The current video mode height */
} SDL_VideoInfo;
/** @name Overlay Formats
* The most common video overlay formats.
* For an explanation of these pixel formats, see:
* http://www.webartz.com/fourcc/indexyuv.htm
*
* For information on the relationship between color spaces, see:
* http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
*/
/*@{*/
#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */
#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */
#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */
#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */
#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */
/*@}*/
/** The YUV hardware video overlay */
typedef struct SDL_Overlay {
Uint32 format; /**< Read-only */
int w, h; /**< Read-only */
int planes; /**< Read-only */
Uint16 *pitches; /**< Read-only */
Uint8 **pixels; /**< Read-write */
/** @name Hardware-specific surface info */
/*@{*/
struct private_yuvhwfuncs *hwfuncs;
struct private_yuvhwdata *hwdata;
/*@{*/
/** @name Special flags */
/*@{*/
Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */
Uint32 UnusedBits :31;
/*@}*/
} SDL_Overlay;
/** @name flags for SDL_SetPalette() */
/*@{*/
#define SDL_LOGPAL 0x01
#define SDL_PHYSPAL 0x02
/*@}*/
/* Function prototypes */
/** @name SDL_Update Functions
* These functions should not be called while 'screen' is locked.
*/
/*@{*/
/**
* Makes sure the given list of rectangles is updated on the given screen.
*/
extern DECLSPEC void SDLCALL LRSDL_UpdateRects
(SDL_Surface *screen, int numrects, SDL_Rect *rects);
/**
* If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
* screen.
*/
extern DECLSPEC void SDLCALL LRSDL_UpdateRect
(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
/*@}*/
/**
* On hardware that supports double-buffering, this function sets up a flip
* and returns. The hardware will wait for vertical retrace, and then swap
* video buffers before the next video surface blit or lock will return.
* On hardware that doesn not support double-buffering, this is equivalent
* to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
* The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
* setting the video mode for this function to perform hardware flipping.
* This function returns 0 if successful, or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL LRSDL_Flip(SDL_Surface *screen);
/**
* Set the gamma correction for each of the color channels.
* The gamma values range (approximately) between 0.1 and 10.0
*
* If this function isn't supported directly by the hardware, it will
* be emulated using gamma ramps, if available. If successful, this
* function returns 0, otherwise it returns -1.
*/
extern DECLSPEC int SDLCALL LRSDL_SetGamma(float red, float green, float blue);
/**
* Sets a portion of the colormap for the given 8-bit surface. If 'surface'
* is not a palettized surface, this function does nothing, returning 0.
* If all of the colors were set as passed to SDL_SetColors(), it will
* return 1. If not all the color entries were set exactly as given,
* it will return 0, and you should look at the surface palette to
* determine the actual color palette.
*
* When 'surface' is the surface associated with the current display, the
* display colormap will be updated with the requested colors. If
* SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
* will always return 1, and the palette is guaranteed to be set the way
* you desire, even if the window colormap has to be warped or run under
* emulation.
*/
extern DECLSPEC int SDLCALL LRSDL_SetColors(SDL_Surface *surface,
SDL_Color *colors, int firstcolor, int ncolors);
/**
* Sets a portion of the colormap for a given 8-bit surface.
* 'flags' is one or both of:
* SDL_LOGPAL -- set logical palette, which controls how blits are mapped
* to/from the surface,
* SDL_PHYSPAL -- set physical palette, which controls how pixels look on
* the screen
* Only screens have physical palettes. Separate change of physical/logical
* palettes is only possible if the screen has SDL_HWPALETTE set.
*
* The return value is 1 if all colours could be set as requested, and 0
* otherwise.
*
* SDL_SetColors() is equivalent to calling this function with
* flags = (SDL_LOGPAL|SDL_PHYSPAL).
*/
extern DECLSPEC int SDLCALL LRSDL_SetPalette(SDL_Surface *surface, int flags,
SDL_Color *colors, int firstcolor,
int ncolors);
/**
* Maps an RGB triple to an opaque pixel value for a given pixel format
*/
extern DECLSPEC Uint32 SDLCALL LRSDL_MapRGB
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b);
/**
* Maps an RGBA quadruple to a pixel value for a given pixel format
*/
extern DECLSPEC Uint32 SDLCALL LRSDL_MapRGBA
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a);
/**
* Maps a pixel value into the RGB components for a given pixel format
*/
extern DECLSPEC void SDLCALL LRSDL_GetRGB(Uint32 pixel,
const SDL_PixelFormat * const fmt,
Uint8 *r, Uint8 *g, Uint8 *b);
/**
* Maps a pixel value into the RGBA components for a given pixel format
*/
extern DECLSPEC void SDLCALL LRSDL_GetRGBA(Uint32 pixel,
const SDL_PixelFormat * const fmt,
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
/** @sa SDL_CreateRGBSurface */
#define LRSDL_AllocSurface LRSDL_CreateRGBSurface
/**
* Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
* If the depth is greater than 8 bits, the pixel format is set using the
* flags '[RGB]mask'.
* If the function runs out of memory, it will return NULL.
*
* The 'flags' tell what kind of surface to create.
* SDL_SWSURFACE means that the surface should be created in system memory.
* SDL_HWSURFACE means that the surface should be created in video memory,
* with the same format as the display surface. This is useful for surfaces
* that will not change much, to take advantage of hardware acceleration
* when being blitted to the display surface.
* SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
* this surface, but you must always lock it before accessing the pixels.
* SDL will wait for current blits to finish before returning from the lock.
* SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
* If the hardware supports acceleration of colorkey blits between
* two surfaces in video memory, SDL will try to place the surface in
* video memory. If this isn't possible or if there is no hardware
* acceleration available, the surface will be placed in system memory.
* SDL_SRCALPHA means that the surface will be used for alpha blits and
* if the hardware supports hardware acceleration of alpha blits between
* two surfaces in video memory, to place the surface in video memory
* if possible, otherwise it will be placed in system memory.
* If the surface is created in video memory, blits will be _much_ faster,
* but the surface format must be identical to the video surface format,
* and the only way to access the pixels member of the surface is to use
* the SDL_LockSurface() and SDL_UnlockSurface() calls.
* If the requested surface actually resides in video memory, SDL_HWSURFACE
* will be set in the flags member of the returned surface. If for some
* reason the surface could not be placed in video memory, it will not have
* the SDL_HWSURFACE flag set, and will be created in system memory instead.
*/
extern DECLSPEC SDL_Surface * SDLCALL LRSDL_CreateRGBSurface
(Uint32 flags, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/** @sa SDL_CreateRGBSurface */
extern DECLSPEC SDL_Surface * SDLCALL LRSDL_CreateRGBSurfaceFrom(void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern DECLSPEC void SDLCALL LRSDL_FreeSurface(SDL_Surface *surface);
/**
* SDL_LockSurface() sets up a surface for directly accessing the pixels.
* Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
* to and read from 'surface->pixels', using the pixel format stored in
* 'surface->format'. Once you are done accessing the surface, you should
* use SDL_UnlockSurface() to release it.
*
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
* to 0, then you can read and write to the surface at any time, and the
* pixel format of the surface will not change. In particular, if the
* SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
* will not need to lock the display surface before accessing it.
*
* No operating system or library calls should be made between lock/unlock
* pairs, as critical system locks may be held during this time.
*
* SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
*/
extern DECLSPEC int SDLCALL LRSDL_LockSurface(SDL_Surface *surface);
extern DECLSPEC void SDLCALL LRSDL_UnlockSurface(SDL_Surface *surface);
/**
* Load a surface from a seekable SDL data source (memory or file.)
* If 'freesrc' is non-zero, the source will be closed after being read.
* Returns the new surface, or NULL if there was an error.
* The new surface should be freed with SDL_FreeSurface().
*/
extern DECLSPEC SDL_Surface * SDLCALL LRSDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
/** Convenience macro -- load a surface from a file */
#define LRSDL_LoadBMP(file) LRSDL_LoadBMP_RW(LRSDL_RWFromFile(file, "rb"), 1)
/**
* Save a surface to a seekable SDL data source (memory or file.)
* If 'freedst' is non-zero, the source will be closed after being written.
* Returns 0 if successful or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL LRSDL_SaveBMP_RW
(SDL_Surface *surface, SDL_RWops *dst, int freedst);
/** Convenience macro -- save a surface to a file */
#define LRSDL_SaveBMP(surface, file) \
LRSDL_SaveBMP_RW(surface, LRSDL_RWFromFile(file, "wb"), 1)
/**
* Sets the color key (transparent pixel) in a blittable surface.
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
* 'key' will be the transparent pixel in the source image of a blit.
* SDL_RLEACCEL requests RLE acceleration for the surface if present,
* and removes RLE acceleration if absent.
* If 'flag' is 0, this function clears any current color key.
* This function returns 0, or -1 if there was an error.
*/
extern DECLSPEC int SDLCALL LRSDL_SetColorKey
(SDL_Surface *surface, Uint32 flag, Uint32 key);
/**
* This function sets the alpha value for the entire surface, as opposed to
* using the alpha component of each pixel. This value measures the range
* of transparency of the surface, 0 being completely transparent to 255
* being completely opaque. An 'alpha' value of 255 causes blits to be
* opaque, the source pixels copied to the destination (the default). Note
* that per-surface alpha can be combined with colorkey transparency.
*
* If 'flag' is 0, alpha blending is disabled for the surface.
* If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
* OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
* surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
*
* The 'alpha' parameter is ignored for surfaces that have an alpha channel.
*/
extern DECLSPEC int SDLCALL LRSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
/**
* Sets the clipping rectangle for the destination surface in a blit.
*
* If the clip rectangle is NULL, clipping will be disabled.
* If the clip rectangle doesn't intersect the surface, the function will
* return SDL_FALSE and blits will be completely clipped. Otherwise the
* function returns SDL_TRUE and blits to the surface will be clipped to
* the intersection of the surface area and the clipping rectangle.
*
* Note that blits are automatically clipped to the edges of the source
* and destination surfaces.
*/
extern DECLSPEC SDL_bool SDLCALL LRSDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect);
/**
* This performs a fast blit from the source surface to the destination
* surface. It assumes that the source and destination rectangles are
* the same size. If either 'srcrect' or 'dstrect' are NULL, the entire
* surface (src or dst) is copied. The final blit rectangles are saved
* in 'srcrect' and 'dstrect' after all clipping is performed.
* If the blit is successful, it returns 0, otherwise it returns -1.
*
* The blit function should not be called on a locked surface.
*
* The blit semantics for surfaces with and without alpha and colorkey
* are defined as follows:
*
* RGBA->RGB:
* SDL_SRCALPHA set:
* alpha-blend (using alpha-channel).
* SDL_SRCCOLORKEY ignored.
* SDL_SRCALPHA not set:
* copy RGB.
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source colour key, ignoring alpha in the
* comparison.
*
* RGB->RGBA:
* SDL_SRCALPHA set:
* alpha-blend (using the source per-surface alpha value);
* set destination alpha to opaque.
* SDL_SRCALPHA not set:
* copy RGB, set destination alpha to source per-surface alpha value.
* both:
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* source colour key.
*
* RGBA->RGBA:
* SDL_SRCALPHA set:
* alpha-blend (using the source alpha channel) the RGB values;
* leave destination alpha untouched. [Note: is this correct?]
* SDL_SRCCOLORKEY ignored.
* SDL_SRCALPHA not set:
* copy all of RGBA to the destination.
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source colour key, ignoring alpha in the
* comparison.
*
* RGB->RGB:
* SDL_SRCALPHA set:
* alpha-blend (using the source per-surface alpha value).
* SDL_SRCALPHA not set:
* copy RGB.
* both:
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* source colour key.
*
* If either of the surfaces were in video memory, and the blit returns -2,
* the video memory was lost, so it should be reloaded with artwork and
* re-blitted:
* @code
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
* while ( SDL_LockSurface(image) < 0 )
* Sleep(10);
* -- Write image pixels to image->pixels --
* SDL_UnlockSurface(image);
* }
* @endcode
*
* This happens under DirectX 5.0 when the system switches away from your
* fullscreen application. The lock will also fail until you have access
* to the video memory again.
*
* You should call SDL_BlitSurface() unless you know exactly how SDL
* blitting works internally and how to use the other blit functions.
*/
/** This is the public blit function, SDL_BlitSurface(), and it performs
* rectangle validation and clipping before passing it to SDL_LowerBlit()
*/
extern DECLSPEC int SDLCALL LRSDL_UpperBlit
(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
/** This is a semi-private blit function and it performs low-level surface
* blitting only.
*/
extern DECLSPEC int SDLCALL LRSDL_LowerBlit
(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect);
/**
* This function performs a fast fill of the given rectangle with 'color'
* The given rectangle is clipped to the destination surface clip area
* and the final fill rectangle is saved in the passed in pointer.
* If 'dstrect' is NULL, the whole surface will be filled with 'color'
* The color should be a pixel of the format used by the surface, and
* can be generated by the SDL_MapRGB() function.
* This function returns 0 on success, or -1 on error.
*/
extern DECLSPEC int SDLCALL LRSDL_FillRect
(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
/**
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer, suitable for fast
* blitting onto the display surface. It calls SDL_ConvertSurface()
*
* If you want to take advantage of hardware colorkey or alpha blit
* acceleration, you should set the colorkey and alpha value before
* calling this function.
*
* If the conversion fails or runs out of memory, it returns NULL
*/
extern DECLSPEC SDL_Surface * SDLCALL LRSDL_DisplayFormat(SDL_Surface *surface);
/**
* This function takes a surface and copies it to a new surface of the
* pixel format and colors of the video framebuffer (if possible),
* suitable for fast alpha blitting onto the display surface.
* The new surface will always have an alpha channel.
*
* If you want to take advantage of hardware colorkey or alpha blit
* acceleration, you should set the colorkey and alpha value before
* calling this function.
*
* If the conversion fails or runs out of memory, it returns NULL
*/
extern DECLSPEC SDL_Surface * SDLCALL LRSDL_DisplayFormatAlpha(SDL_Surface *surface);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"
#endif /* _SDL_video_h */

87
sdl/include/begin_code.h Normal file
View File

@ -0,0 +1,87 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* @file begin_code.h
* This file sets things up for C dynamic library function definitions,
* static inlined functions, and structures aligned at 4-byte alignment.
* If you don't like ugly C preprocessor code, don't look at this file. :)
*/
/**
* @file begin_code.h
* This shouldn't be nested -- included it around code only.
*/
#ifdef _begin_code_h
#error Nested inclusion of begin_code.h
#endif
#define _begin_code_h
#ifndef DECLSPEC
# define DECLSPEC
#endif
/**
* @def SDLCALL
* By default SDL uses the C calling convention
*/
#ifndef SDLCALL
# define SDLCALL
#endif /* SDLCALL */
/**
* @file begin_code.h
* Force structure packing at 4 byte alignment.
* This is necessary if the header is included in code which has structure
* packing set to an alternate value, say for loading structures from disk.
* The packing is reset to the previous value in close_code.h
*/
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
#ifdef _MSC_VER
#pragma warning(disable: 4103)
#endif
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
#ifdef _M_X64
/* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */
#pragma pack(push,8)
#else
#pragma pack(push,4)
#endif
#elif (defined(__MWERKS__) && defined(__MACOS__))
#pragma options align=mac68k4byte
#pragma enumsalwaysint on
#endif /* Compiler needs structure packing set */
/**
* @def SDL_INLINE_OKAY
* Set up compiler-specific options for inlining functions
*/
#ifndef SDL_INLINE_OKAY
#define SDL_INLINE_OKAY
#ifdef _MSC_VER
#define __inline__ _inline
#else
#define __inline__ inline
#endif
#endif

46
sdl/include/close_code.h Normal file
View File

@ -0,0 +1,46 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/
/**
* @file close_code.h
* This file reverses the effects of begin_code.h and should be included
* after you finish any function and structure declarations in your headers
*/
#undef _begin_code_h
/**
* @file close_code.h
* Reset structure packing at previous byte alignment
*/
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
#ifdef __BORLANDC__
#pragma nopackwarning
#endif
#if (defined(__MWERKS__) && defined(__MACOS__))
#pragma options align=reset
#pragma enumsalwaysint reset
#else
#pragma pack(pop)
#endif
#endif /* Compiler needs structure packing set */

946
sdl/include/doxyfile Normal file
View File

@ -0,0 +1,946 @@
# Doxyfile 1.2.16
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
#---------------------------------------------------------------------------
# General configuration options
#---------------------------------------------------------------------------
# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
# by quotes) that should identify the project.
PROJECT_NAME = SDL
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.2.15
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
OUTPUT_DIRECTORY = docs
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Brazilian, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch,
# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Korean,
# Norwegian, Polish, Portuguese, Romanian, Russian, Slovak, Slovene,
# Spanish, Swedish and Ukrainian.
OUTPUT_LANGUAGE = English
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
EXTRACT_ALL = NO
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
EXTRACT_PRIVATE = NO
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
EXTRACT_STATIC = NO
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
EXTRACT_LOCAL_CLASSES = NO
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_MEMBERS = NO
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these class will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
HIDE_UNDOC_CLASSES = NO
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
BRIEF_MEMBER_DESC = YES
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
REPEAT_BRIEF = YES
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
ALWAYS_DETAILED_SEC = NO
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited
# members of a class in the documentation of that class as if those members were
# ordinary class members. Constructors, destructors and assignment operators of
# the base classes will not be shown.
INLINE_INHERITED_MEMB = NO
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
FULL_PATH_NAMES = NO
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. It is allowed to use relative paths in the argument list.
STRIP_FROM_PATH =
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
INTERNAL_DOCS = NO
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
STRIP_CODE_COMMENTS = YES
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower case letters. If set to YES upper case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# users are adviced to set this option to NO.
CASE_SENSE_NAMES = YES
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful is your file systems
# doesn't support long names like on DOS, Mac, or CD-ROM.
SHORT_NAMES = NO
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
HIDE_SCOPE_NAMES = NO
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
VERBATIM_HEADERS = YES
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put list of the files that are included by a file in the documentation
# of that file.
SHOW_INCLUDE_FILES = YES
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like the Qt-style comments (thus requiring an
# explict @brief command for a brief description.
JAVADOC_AUTOBRIEF = NO
# If the DETAILS_AT_TOP tag is set to YES then Doxygen
# will output the detailed description near the top, like JavaDoc.
# If set to NO, the detailed description appears after the member
# documentation.
DETAILS_AT_TOP = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# reimplements.
INHERIT_DOCS = YES
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
INLINE_INFO = YES
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
SORT_MEMBER_DOCS = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
DISTRIBUTE_GROUP_DOC = NO
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
TAB_SIZE = 4
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
GENERATE_TESTLIST = YES
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
GENERATE_BUGLIST = YES
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
ALIASES =
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
ENABLED_SECTIONS =
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or define consist of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and defines in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
MAX_INITIALIZER_LINES = 30
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
# only. Doxygen will then generate output that is more tailored for C.
# For instance some of the names that are used will be different. The list
# of all members will be omitted, etc.
OPTIMIZE_OUTPUT_FOR_C = YES
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources
# only. Doxygen will then generate output that is more tailored for Java.
# For instance namespaces will be presented as packages, qualified scopes
# will look different, etc.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
SHOW_USED_FILES = YES
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
WARNINGS = YES
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
WARN_IF_UNDOCUMENTED = YES
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text.
WARN_FORMAT = "$file:$line: $text"
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
INPUT = include
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
# *.h++ *.idl *.odl
FILE_PATTERNS = *.h
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
RECURSIVE = NO
# The EXCLUDE tag can be used to specify files and/or directories that should
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
EXCLUDE =
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories
# that are symbolic links (a Unix filesystem feature) are excluded from the input.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories.
EXCLUDE_PATTERNS =
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
EXAMPLE_PATH =
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
EXAMPLE_RECURSIVE = NO
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output.
INPUT_FILTER =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse.
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
SOURCE_BROWSER = NO
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
INLINE_SOURCES = NO
# If the REFERENCED_BY_RELATION tag is set to YES (the default)
# then for each documented function all documented
# functions referencing it will be listed.
REFERENCED_BY_RELATION = YES
# If the REFERENCES_RELATION tag is set to YES (the default)
# then for each documented function all documented entities
# called/used by that function will be listed.
REFERENCES_RELATION = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
COLS_IN_ALPHA_INDEX = 5
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
GENERATE_HTML = YES
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
HTML_OUTPUT = html
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
HTML_FILE_EXTENSION = .html
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header.
HTML_HEADER =
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
HTML_FOOTER =
# The HTML_STYLESHEET tag can be used to specify a user defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet
HTML_STYLESHEET =
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
# of the generated HTML documentation.
GENERATE_HTMLHELP = NO
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
GENERATE_CHI = NO
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
BINARY_TOC = NO
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the Html help documentation and to the tree view.
TOC_EXPAND = NO
# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
# top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it.
DISABLE_INDEX = NO
# This tag can be used to set the number of enum values (range [1..20])
# that doxygen will group on one line in the generated HTML documentation.
ENUM_VALUES_PER_LINE = 4
# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
# generated containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript and frames is required (for instance Mozilla, Netscape 4.0+,
# or Internet explorer 4.0+). Note that for large projects the tree generation
# can take a very long time. In such cases it is better to disable this feature.
# Windows users are probably better off using the HTML help feature.
GENERATE_TREEVIEW = NO
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
GENERATE_LATEX = NO
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be invoked. If left blank `latex' will be used as the default command name.
LATEX_CMD_NAME = latex
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
MAKEINDEX_CMD_NAME = makeindex
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_LATEX = NO
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, a4wide, letter, legal and
# executive. If left blank a4wide will be used.
PAPER_TYPE = a4wide
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
EXTRA_PACKAGES =
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
LATEX_HEADER =
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
PDF_HYPERLINKS = NO
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
USE_PDFLATEX = NO
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
LATEX_BATCHMODE = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimised for Word 97 and may not look very pretty with
# other RTF readers or editors.
GENERATE_RTF = YES
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
RTF_OUTPUT = rtf
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
COMPACT_RTF = NO
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
RTF_HYPERLINKS = NO
# Load stylesheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assigments. You only have to provide
# replacements, missing definitions are set to their default value.
RTF_STYLESHEET_FILE =
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
GENERATE_MAN = YES
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
MAN_OUTPUT = man
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
MAN_EXTENSION = .3
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
MAN_LINKS = YES
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
GENERATE_XML = NO
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
ENABLE_PREPROCESSING = YES
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
MACRO_EXPANSION = YES
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_PREDEFINED tags.
EXPAND_ONLY_PREDEF = YES
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# in the INCLUDE_PATH (see below) will be search if a #include is found.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
INCLUDE_FILE_PATTERNS =
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed.
PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 SDLCALL= SNDDECLSPEC=
# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition.
EXPAND_AS_DEFINED =
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all function-like macros that are alone
# on a line and do not end with a semicolon. Such function macros are typically
# used for boiler-plate code, and will confuse the parser if not removed.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to external references
#---------------------------------------------------------------------------
# The TAGFILES tag can be used to specify one or more tagfiles.
TAGFILES =
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
GENERATE_TAGFILE =
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
ALLEXTERNALS = NO
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in Html, RTF and LaTeX) for classes with base or
# super classes. Setting the tag to NO turns the diagrams off. Note that this
# option is superceded by the HAVE_DOT option below. This is only a fallback. It is
# recommended to install and use dot, since it yields more powerful graphs.
CLASS_DIAGRAMS = NO
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
HAVE_DOT = NO
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# the CLASS_DIAGRAMS tag to NO.
CLASS_GRAPH = NO
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
COLLABORATION_GRAPH = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
TEMPLATE_RELATIONS = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
INCLUDE_GRAPH = NO
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
INCLUDED_BY_GRAPH = YES
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will graphical hierarchy of all classes instead of a textual one.
GRAPHICAL_HIERARCHY = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are png, jpg, or gif
# If left blank png will be used.
DOT_IMAGE_FORMAT = png
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found on the path.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
DOTFILE_DIRS =
# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_WIDTH = 1024
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
# this value, doxygen will try to truncate the graph, so that it fits within
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_HEIGHT = 1024
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
GENERATE_LEGEND = YES
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermedate dot files that are used to generate
# the various graphs.
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::addtions related to the search engine
#---------------------------------------------------------------------------
# The SEARCHENGINE tag specifies whether or not a search engine should be
# used. If set to NO the values of all tags below this one will be ignored.
SEARCHENGINE = NO
# The CGI_NAME tag should be the name of the CGI script that
# starts the search engine (doxysearch) with the correct parameters.
# A script with this name will be generated by doxygen.
CGI_NAME = search.cgi
# The CGI_URL tag should be the absolute URL to the directory where the
# cgi binaries are located. See the documentation of your http daemon for
# details.
CGI_URL =
# The DOC_URL tag should be the absolute URL to the directory where the
# documentation is located. If left blank the absolute path to the
# documentation, with file:// prepended to it, will be used.
DOC_URL =
# The DOC_ABSPATH tag should be the absolute path to the directory where the
# documentation is located. If left blank the directory on the local machine
# will be used.
DOC_ABSPATH =
# The BIN_ABSPATH tag must point to the directory where the doxysearch binary
# is installed.
BIN_ABSPATH = /usr/local/bin/
# The EXT_DOC_PATHS tag can be used to specify one or more paths to
# documentation generated for other projects. This allows doxysearch to search
# the documentation for these projects as well.
EXT_DOC_PATHS =

180
sdl/video/SDL_blit.c Normal file
View File

@ -0,0 +1,180 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
/* The general purpose software blit routine */
static int LRSDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
/* Set up source and destination buffer pointers, and BLIT! */
if (srcrect->w && srcrect->h )
{
SDL_BlitInfo info;
SDL_loblit RunBlit;
/* Set up the blit information */
info.s_pixels = (Uint8 *)src->pixels +
(Uint16)srcrect->y*src->pitch +
(Uint16)srcrect->x*src->format->BytesPerPixel;
info.s_width = srcrect->w;
info.s_height = srcrect->h;
info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel;
info.d_pixels = (Uint8 *)dst->pixels +
(Uint16)dstrect->y*dst->pitch +
(Uint16)dstrect->x*dst->format->BytesPerPixel;
info.d_width = dstrect->w;
info.d_height = dstrect->h;
info.d_skip=dst->pitch-info.d_width*dst->format->BytesPerPixel;
info.aux_data = src->map->sw_data->aux_data;
info.src = src->format;
info.table = src->map->table;
info.dst = dst->format;
RunBlit = src->map->sw_data->blit;
/* Run the actual software blit */
RunBlit(&info);
}
return 0;
}
static void LRSDL_BlitCopy(SDL_BlitInfo *info)
{
Uint8 *src, *dst;
int w, h;
int srcskip, dstskip;
w = info->d_width*info->dst->BytesPerPixel;
h = info->d_height;
src = info->s_pixels;
dst = info->d_pixels;
srcskip = w+info->s_skip;
dstskip = w+info->d_skip;
while ( h-- ) {
SDL_memcpy(dst, src, w);
src += srcskip;
dst += dstskip;
}
}
static void LRSDL_BlitCopyOverlap(SDL_BlitInfo *info)
{
Uint8 *src, *dst;
int w, h;
int srcskip, dstskip;
w = info->d_width*info->dst->BytesPerPixel;
h = info->d_height;
src = info->s_pixels;
dst = info->d_pixels;
srcskip = w+info->s_skip;
dstskip = w+info->d_skip;
if ( dst < src )
{
while ( h-- )
{
memmove(dst, src, w);
src += srcskip;
dst += dstskip;
}
}
else
{
src += ((h-1) * srcskip);
dst += ((h-1) * dstskip);
while ( h-- )
{
memmove(dst, src, w);
src -= srcskip;
dst -= dstskip;
}
}
}
/* Figure out which of many blit routines to set up on a surface */
int LRSDL_CalculateBlit(SDL_Surface *surface)
{
int blit_index;
/* Clean everything out to start */
surface->map->sw_blit = NULL;
/* Figure out if an accelerated hardware blit is possible */
surface->flags &= ~SDL_HWACCEL;
/* Get the blit function index, based on surface mode */
/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
blit_index = 0;
blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0;
if ( surface->flags & SDL_SRCALPHA
&& (surface->format->alpha != SDL_ALPHA_OPAQUE
|| surface->format->Amask) ) {
blit_index |= 2;
}
/* Check for special "identity" case -- copy blit */
if ( surface->map->identity && blit_index == 0 ) {
surface->map->sw_data->blit = LRSDL_BlitCopy;
/* Handle overlapping blits on the same surface */
if ( surface == surface->map->dst ) {
surface->map->sw_data->blit = LRSDL_BlitCopyOverlap;
}
} else {
if ( surface->format->BitsPerPixel < 8 ) {
surface->map->sw_data->blit =
LRSDL_CalculateBlit0(surface, blit_index);
} else {
switch ( surface->format->BytesPerPixel ) {
case 1:
surface->map->sw_data->blit =
LRSDL_CalculateBlit1(surface, blit_index);
break;
case 2:
case 3:
case 4:
surface->map->sw_data->blit =
LRSDL_CalculateBlitN(surface, blit_index);
break;
default:
surface->map->sw_data->blit = NULL;
break;
}
}
}
/* Make sure we have a blit function */
if ( surface->map->sw_data->blit == NULL ) {
LRSDL_InvalidateMap(surface->map);
LRSDL_SetError("Blit combination not supported");
return(-1);
}
surface->map->sw_blit = LRSDL_SoftBlit;
return(0);
}

424
sdl/video/SDL_blit.h Normal file
View File

@ -0,0 +1,424 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_blit_h
#define _SDL_blit_h
#include "SDL_endian.h"
/* The structure passed to the low level blit functions */
typedef struct {
Uint8 *s_pixels;
int s_width;
int s_height;
int s_skip;
Uint8 *d_pixels;
int d_width;
int d_height;
int d_skip;
void *aux_data;
SDL_PixelFormat *src;
Uint8 *table;
SDL_PixelFormat *dst;
} SDL_BlitInfo;
/* The type definition for the low level blit functions */
typedef void (*SDL_loblit)(SDL_BlitInfo *info);
/* This is the private info structure for software accelerated blits */
struct private_swaccel {
SDL_loblit blit;
void *aux_data;
};
/* Blit mapping definition */
typedef struct SDL_BlitMap {
SDL_Surface *dst;
int identity;
Uint8 *table;
SDL_blit hw_blit;
SDL_blit sw_blit;
struct private_hwaccel *hw_data;
struct private_swaccel *sw_data;
/* the version count matches the destination; mismatch indicates
an invalid mapping */
unsigned int format_version;
} SDL_BlitMap;
/* Functions found in SDL_blit.c */
extern int LRSDL_CalculateBlit(SDL_Surface *surface);
/* Functions found in SDL_blit_{0,1,N,A}.c */
extern SDL_loblit LRSDL_CalculateBlit0(SDL_Surface *surface, int complex);
extern SDL_loblit LRSDL_CalculateBlit1(SDL_Surface *surface, int complex);
extern SDL_loblit LRSDL_CalculateBlitN(SDL_Surface *surface, int complex);
extern SDL_loblit LRSDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
/*
* Useful macros for blitting routines
*/
#define FORMAT_EQUAL(A, B) \
((A)->BitsPerPixel == (B)->BitsPerPixel \
&& ((A)->Rmask == (B)->Rmask) && ((A)->Amask == (B)->Amask))
/* Load pixel of the specified format from a buffer and get its R-G-B values */
/* FIXME: rescale values to 0..255 here? */
#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \
{ \
r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); \
g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); \
b = (((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); \
}
#define RGB_FROM_RGB565(Pixel, r, g, b) \
{ \
r = (((Pixel&0xF800)>>11)<<3); \
g = (((Pixel&0x07E0)>>5)<<2); \
b = ((Pixel&0x001F)<<3); \
}
#define RGB_FROM_RGB555(Pixel, r, g, b) \
{ \
r = (((Pixel&0x7C00)>>10)<<3); \
g = (((Pixel&0x03E0)>>5)<<3); \
b = ((Pixel&0x001F)<<3); \
}
#define RGB_FROM_RGB888(Pixel, r, g, b) \
{ \
r = ((Pixel&0xFF0000)>>16); \
g = ((Pixel&0xFF00)>>8); \
b = (Pixel&0xFF); \
}
#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \
do { \
switch (bpp) { \
case 2: \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)(buf); \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
Pixel = 0; /* appease gcc */ \
break; \
} \
} while(0)
#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \
do { \
switch (bpp) { \
case 2: \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: { \
Uint8 *B = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
} else { \
Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
} \
} \
break; \
\
case 4: \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
Pixel = 0; /* prevent gcc from complaining */ \
break; \
} \
RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \
} while(0)
/* Assemble R-G-B values into a specified pixel format and store them */
#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \
{ \
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift); \
}
#define RGB565_FROM_RGB(Pixel, r, g, b) \
{ \
Pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3); \
}
#define RGB555_FROM_RGB(Pixel, r, g, b) \
{ \
Pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3); \
}
#define RGB888_FROM_RGB(Pixel, r, g, b) \
{ \
Pixel = (r<<16)|(g<<8)|b; \
}
#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \
{ \
switch (bpp) { \
case 2: { \
Uint16 Pixel; \
\
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
case 3: { \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
*((buf)+fmt->Rshift/8) = r; \
*((buf)+fmt->Gshift/8) = g; \
*((buf)+fmt->Bshift/8) = b; \
} else { \
*((buf)+2-fmt->Rshift/8) = r; \
*((buf)+2-fmt->Gshift/8) = g; \
*((buf)+2-fmt->Bshift/8) = b; \
} \
} \
break; \
\
case 4: { \
Uint32 Pixel; \
\
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \
}
#define ASSEMBLE_RGB_AMASK(buf, bpp, fmt, r, g, b, Amask) \
{ \
switch (bpp) { \
case 2: { \
Uint16 *bufp; \
Uint16 Pixel; \
\
bufp = (Uint16 *)buf; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
\
case 3: { \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
*((buf)+fmt->Rshift/8) = r; \
*((buf)+fmt->Gshift/8) = g; \
*((buf)+fmt->Bshift/8) = b; \
} else { \
*((buf)+2-fmt->Rshift/8) = r; \
*((buf)+2-fmt->Gshift/8) = g; \
*((buf)+2-fmt->Bshift/8) = b; \
} \
} \
break; \
\
case 4: { \
Uint32 *bufp; \
Uint32 Pixel; \
\
bufp = (Uint32 *)buf; \
PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \
*bufp = Pixel | (*bufp & Amask); \
} \
break; \
} \
}
/* FIXME: Should we rescale alpha into 0..255 here? */
#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \
{ \
r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
a = ((Pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
}
#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \
{ \
r = (Pixel&fmt->Rmask)>>fmt->Rshift; \
g = (Pixel&fmt->Gmask)>>fmt->Gshift; \
b = (Pixel&fmt->Bmask)>>fmt->Bshift; \
a = (Pixel&fmt->Amask)>>fmt->Ashift; \
}
#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \
{ \
r = (Pixel>>24); \
g = ((Pixel>>16)&0xFF); \
b = ((Pixel>>8)&0xFF); \
a = (Pixel&0xFF); \
}
#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \
{ \
r = ((Pixel>>16)&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = (Pixel&0xFF); \
a = (Pixel>>24); \
}
#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \
{ \
r = (Pixel&0xFF); \
g = ((Pixel>>8)&0xFF); \
b = ((Pixel>>16)&0xFF); \
a = (Pixel>>24); \
}
#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \
do { \
switch (bpp) { \
case 2: \
Pixel = *((Uint16 *)(buf)); \
break; \
\
case 3: {/* FIXME: broken code (no alpha) */ \
Uint8 *b = (Uint8 *)buf; \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
Pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
} else { \
Pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
} \
} \
break; \
\
case 4: \
Pixel = *((Uint32 *)(buf)); \
break; \
\
default: \
Pixel = 0; /* stop gcc complaints */ \
break; \
} \
RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \
Pixel &= ~fmt->Amask; \
} while(0)
/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \
{ \
Pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
((g>>fmt->Gloss)<<fmt->Gshift)| \
((b>>fmt->Bloss)<<fmt->Bshift)| \
((a>>fmt->Aloss)<<fmt->Ashift); \
}
#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
{ \
switch (bpp) { \
case 2: { \
Uint16 Pixel; \
\
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint16 *)(buf)) = Pixel; \
} \
break; \
\
case 3: { /* FIXME: broken code (no alpha) */ \
if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { \
*((buf)+fmt->Rshift/8) = r; \
*((buf)+fmt->Gshift/8) = g; \
*((buf)+fmt->Bshift/8) = b; \
} else { \
*((buf)+2-fmt->Rshift/8) = r; \
*((buf)+2-fmt->Gshift/8) = g; \
*((buf)+2-fmt->Bshift/8) = b; \
} \
} \
break; \
\
case 4: { \
Uint32 Pixel; \
\
PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \
*((Uint32 *)(buf)) = Pixel; \
} \
break; \
} \
}
/* Blend the RGB values of two Pixels based on a source alpha value */
#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
do { \
dR = (((sR-dR)*(A)+255)>>8)+dR; \
dG = (((sG-dG)*(A)+255)>>8)+dG; \
dB = (((sB-dB)*(A)+255)>>8)+dB; \
} while(0)
/* Don't use Duff's device to unroll loops */
#define DUFFS_LOOP_DOUBLE2(pixel_copy_increment, \
double_pixel_copy_increment, width) \
{ int n = width; \
if( n & 1 ) { \
pixel_copy_increment; \
n--; \
} \
n=n>>1; \
for(; n > 0; --n) { \
double_pixel_copy_increment; \
} \
}
/* Don't use Duff's device to unroll loops */
#define DUFFS_LOOP_QUATRO2(pixel_copy_increment, \
double_pixel_copy_increment, \
quatro_pixel_copy_increment, width) \
{ int n = width; \
if(n & 1) { \
pixel_copy_increment; \
n--; \
} \
if(n & 2) { \
double_pixel_copy_increment; \
n -= 2; \
} \
n=n>>2; \
for(; n > 0; --n) { \
quatro_pixel_copy_increment; \
} \
}
/* Don't use Duff's device to unroll loops */
#define DUFFS_LOOP(pixel_copy_increment, width) \
{ int n; \
for ( n=width; n > 0; --n ) { \
pixel_copy_increment; \
} \
}
#define DUFFS_LOOP8(pixel_copy_increment, width) \
DUFFS_LOOP(pixel_copy_increment, width)
#define DUFFS_LOOP4(pixel_copy_increment, width) \
DUFFS_LOOP(pixel_copy_increment, width)
/* Prevent Visual C++ 6.0 from printing out stupid warnings */
#if defined(_MSC_VER) && (_MSC_VER >= 600)
#pragma warning(disable: 4550)
#endif
#endif /* _SDL_blit_h */

471
sdl/video/SDL_blit_0.c Normal file
View File

@ -0,0 +1,471 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_video.h"
#include "SDL_blit.h"
/* Functions to blit from bitmaps to other surfaces */
static void BlitBto1(SDL_BlitInfo *info)
{
int c;
int width, height;
Uint8 *src, *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = info->d_pixels;
dstskip = info->d_skip;
map = info->table;
srcskip += width-(width+7)/8;
if ( map ) {
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
*dst = map[bit];
}
dst++;
byte <<= 1;
}
src += srcskip;
dst += dstskip;
}
} else {
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
*dst = bit;
}
dst++;
byte <<= 1;
}
src += srcskip;
dst += dstskip;
}
}
}
static void BlitBto2(SDL_BlitInfo *info)
{
int c;
int width, height;
Uint8 *src;
Uint16 *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = (Uint16 *)info->d_pixels;
dstskip = info->d_skip/2;
map = (Uint16 *)info->table;
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
*dst = map[bit];
}
byte <<= 1;
dst++;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitBto3(SDL_BlitInfo *info)
{
int c, o;
int width, height;
Uint8 *src, *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = info->d_pixels;
dstskip = info->d_skip;
map = info->table;
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
o = bit * 4;
dst[0] = map[o++];
dst[1] = map[o++];
dst[2] = map[o++];
}
byte <<= 1;
dst += 3;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitBto4(SDL_BlitInfo *info)
{
int width, height;
Uint8 *src;
Uint32 *map, *dst;
int srcskip, dstskip;
int c;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = (Uint32 *)info->d_pixels;
dstskip = info->d_skip/4;
map = (Uint32 *)info->table;
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
*dst = map[bit];
}
byte <<= 1;
dst++;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitBto1Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey;
Uint8 *palmap = info->table;
int c;
/* Set up some basic variables */
srcskip += width-(width+7)/8;
if ( palmap ) {
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
*dst = palmap[bit];
}
dst++;
byte <<= 1;
}
src += srcskip;
dst += dstskip;
}
} else {
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
*dst = bit;
}
dst++;
byte <<= 1;
}
src += srcskip;
dst += dstskip;
}
}
}
static void BlitBto2Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey;
Uint8 *palmap = info->table;
int c;
/* Set up some basic variables */
srcskip += width-(width+7)/8;
dstskip /= 2;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
*dstp=((Uint16 *)palmap)[bit];
}
byte <<= 1;
dstp++;
}
src += srcskip;
dstp += dstskip;
}
}
static void BlitBto3Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey;
Uint8 *palmap = info->table;
int c;
/* Set up some basic variables */
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
SDL_memcpy(dst, &palmap[bit*4], 3);
}
byte <<= 1;
dst += 3;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitBto4Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey;
Uint8 *palmap = info->table;
int c;
/* Set up some basic variables */
srcskip += width-(width+7)/8;
dstskip /= 4;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
*dstp=((Uint32 *)palmap)[bit];
}
byte <<= 1;
dstp++;
}
src += srcskip;
dstp += dstskip;
}
}
static void BlitBtoNAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
const SDL_Color *srcpal = info->src->palette->colors;
SDL_PixelFormat *dstfmt = info->dst;
int dstbpp;
int c;
const int A = info->src->alpha;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( 1 ) {
Uint32 pixel;
unsigned sR, sG, sB;
unsigned dR, dG, dB;
sR = srcpal[bit].r;
sG = srcpal[bit].g;
sB = srcpal[bit].b;
DISEMBLE_RGB(dst, dstbpp, dstfmt,
pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
}
byte <<= 1;
dst += dstbpp;
}
src += srcskip;
dst += dstskip;
}
}
static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip;
int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = srcfmt->palette->colors;
int dstbpp;
int c;
const int A = srcfmt->alpha;
Uint32 ckey = srcfmt->colorkey;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
srcskip += width-(width+7)/8;
while ( height-- ) {
Uint8 byte = 0, bit;
for ( c=0; c<width; ++c ) {
if ( (c&7) == 0 ) {
byte = *src++;
}
bit = (byte&0x80)>>7;
if ( bit != ckey ) {
int sR, sG, sB;
int dR, dG, dB;
Uint32 pixel;
sR = srcpal[bit].r;
sG = srcpal[bit].g;
sB = srcpal[bit].b;
DISEMBLE_RGB(dst, dstbpp, dstfmt,
pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
}
byte <<= 1;
dst += dstbpp;
}
src += srcskip;
dst += dstskip;
}
}
static SDL_loblit bitmap_blit[] = {
NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
};
static SDL_loblit colorkey_blit[] = {
NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
};
SDL_loblit LRSDL_CalculateBlit0(SDL_Surface *surface, int blit_index)
{
int which;
if ( surface->format->BitsPerPixel != 1 ) {
/* We don't support sub 8-bit packed pixel modes */
return NULL;
}
if ( surface->map->dst->format->BitsPerPixel < 8 ) {
which = 0;
} else {
which = surface->map->dst->format->BytesPerPixel;
}
switch(blit_index) {
case 0: /* copy */
return bitmap_blit[which];
case 1: /* colorkey */
return colorkey_blit[which];
case 2: /* alpha */
return which >= 2 ? BlitBtoNAlpha : NULL;
case 4: /* alpha + colorkey */
return which >= 2 ? BlitBtoNAlphaKey : NULL;
}
return NULL;
}

474
sdl/video/SDL_blit_1.c Normal file
View File

@ -0,0 +1,474 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_video.h"
#include "SDL_blit.h"
#include "SDL_sysvideo.h"
#include "SDL_endian.h"
/* Functions to blit from 8-bit surfaces to other surfaces */
static void Blit1to1(SDL_BlitInfo *info)
{
int c;
int width, height;
Uint8 *src, *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = info->d_pixels;
dstskip = info->d_skip;
map = info->table;
while ( height-- ) {
for ( c=width; c; --c ) {
*dst = map[*src];
dst++;
src++;
}
src += srcskip;
dst += dstskip;
}
}
#ifdef MSB_FIRST
#define HI 0
#define LO 1
#else
#define HI 1
#define LO 0
#endif
static void Blit1to2(SDL_BlitInfo *info)
{
int c;
int width, height;
Uint8 *src, *dst;
Uint16 *map;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = info->d_pixels;
dstskip = info->d_skip;
map = (Uint16 *)info->table;
/* Memory align at 4-byte boundary, if necessary */
if ( (long)dst & 0x03 ) {
/* Don't do anything if width is 0 */
if ( width == 0 ) {
return;
}
--width;
while ( height-- ) {
/* Perform copy alignment */
*(Uint16 *)dst = map[*src++];
dst += 2;
/* Copy in 4 pixel chunks */
for ( c=width/4; c; --c ) {
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
*(Uint16 *)dst = map[*src++];
dst += 2;
case 2:
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
break;
case 1:
*(Uint16 *)dst = map[*src++];
dst += 2;
break;
}
src += srcskip;
dst += dstskip;
}
} else {
while ( height-- ) {
/* Copy in 4 pixel chunks */
for ( c=width/4; c; --c ) {
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
}
/* Get any leftovers */
switch (width & 3) {
case 3:
*(Uint16 *)dst = map[*src++];
dst += 2;
case 2:
*(Uint32 *)dst =
(map[src[HI]]<<16)|(map[src[LO]]);
src += 2;
dst += 4;
break;
case 1:
*(Uint16 *)dst = map[*src++];
dst += 2;
break;
}
src += srcskip;
dst += dstskip;
}
}
}
static void Blit1to3(SDL_BlitInfo *info)
{
int c;
int o;
int width, height;
Uint8 *src, *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = info->d_pixels;
dstskip = info->d_skip;
map = info->table;
while ( height-- ) {
for ( c=width; c; --c ) {
o = *src * 4;
dst[0] = map[o++];
dst[1] = map[o++];
dst[2] = map[o++];
src++;
dst += 3;
}
src += srcskip;
dst += dstskip;
}
}
static void Blit1to4(SDL_BlitInfo *info)
{
int c;
int width, height;
Uint8 *src;
Uint32 *map, *dst;
int srcskip, dstskip;
/* Set up some basic variables */
width = info->d_width;
height = info->d_height;
src = info->s_pixels;
srcskip = info->s_skip;
dst = (Uint32 *)info->d_pixels;
dstskip = info->d_skip/4;
map = (Uint32 *)info->table;
while ( height-- ) {
for ( c=width/4; c; --c ) {
*dst++ = map[*src++];
*dst++ = map[*src++];
*dst++ = map[*src++];
*dst++ = map[*src++];
}
switch ( width & 3 ) {
case 3:
*dst++ = map[*src++];
case 2:
*dst++ = map[*src++];
case 1:
*dst++ = map[*src++];
}
src += srcskip;
dst += dstskip;
}
}
static void Blit1to1Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
Uint8 *palmap = info->table;
Uint32 ckey = info->src->colorkey;
if ( palmap ) {
while ( height-- ) {
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = palmap[*src];
}
dst++;
src++;
},
width);
src += srcskip;
dst += dstskip;
}
} else {
while ( height-- ) {
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dst = *src;
}
dst++;
src++;
},
width);
src += srcskip;
dst += dstskip;
}
}
}
static void Blit1to2Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip;
Uint16 *palmap = (Uint16 *)info->table;
Uint32 ckey = info->src->colorkey;
/* Set up some basic variables */
dstskip /= 2;
while ( height-- ) {
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp=palmap[*src];
}
src++;
dstp++;
},
width);
src += srcskip;
dstp += dstskip;
}
}
static void Blit1to3Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
Uint8 *palmap = info->table;
Uint32 ckey = info->src->colorkey;
int o;
while ( height-- ) {
DUFFS_LOOP(
{
if ( *src != ckey ) {
o = *src * 4;
dst[0] = palmap[o++];
dst[1] = palmap[o++];
dst[2] = palmap[o++];
}
src++;
dst += 3;
},
width);
src += srcskip;
dst += dstskip;
}
}
static void Blit1to4Key(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip;
Uint32 *palmap = (Uint32 *)info->table;
Uint32 ckey = info->src->colorkey;
/* Set up some basic variables */
dstskip /= 4;
while ( height-- ) {
DUFFS_LOOP(
{
if ( *src != ckey ) {
*dstp = palmap[*src];
}
src++;
dstp++;
},
width);
src += srcskip;
dstp += dstskip;
}
}
static void Blit1toNAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors;
int dstbpp;
const int A = info->src->alpha;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
while ( height-- ) {
int sR, sG, sB;
int dR, dG, dB;
DUFFS_LOOP4(
{
Uint32 pixel;
sR = srcpal[*src].r;
sG = srcpal[*src].g;
sB = srcpal[*src].b;
DISEMBLE_RGB(dst, dstbpp, dstfmt,
pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
src++;
dst += dstbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
static void Blit1toNAlphaKey(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors;
Uint32 ckey = srcfmt->colorkey;
int dstbpp;
const int A = srcfmt->alpha;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
while ( height-- ) {
int sR, sG, sB;
int dR, dG, dB;
DUFFS_LOOP(
{
if ( *src != ckey ) {
Uint32 pixel;
sR = srcpal[*src].r;
sG = srcpal[*src].g;
sB = srcpal[*src].b;
DISEMBLE_RGB(dst, dstbpp, dstfmt,
pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
}
src++;
dst += dstbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
static SDL_loblit one_blit[] = {
NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
};
static SDL_loblit one_blitkey[] = {
NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
};
SDL_loblit LRSDL_CalculateBlit1(SDL_Surface *surface, int blit_index)
{
int which;
SDL_PixelFormat *dstfmt;
dstfmt = surface->map->dst->format;
if ( dstfmt->BitsPerPixel < 8 ) {
which = 0;
} else {
which = dstfmt->BytesPerPixel;
}
switch(blit_index) {
case 0: /* copy */
return one_blit[which];
case 1: /* colorkey */
return one_blitkey[which];
case 2: /* alpha */
/* Supporting 8bpp->8bpp alpha is doable but requires lots of
tables which consume space and takes time to precompute,
so is better left to the user */
return which >= 2 ? Blit1toNAlpha : NULL;
case 3: /* alpha + colorkey */
return which >= 2 ? Blit1toNAlphaKey : NULL;
}
return NULL;
}

820
sdl/video/SDL_blit_A.c Normal file
View File

@ -0,0 +1,820 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_video.h"
#include "SDL_blit.h"
/* Functions to perform alpha blended blitting */
/* N->1 blending with per-surface alpha */
static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
Uint8 *palmap = info->table;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel;
const unsigned A = srcfmt->alpha;
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
dR &= 0xff;
dG &= 0xff;
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|
((dG>>5)<<(2))|
((dB>>6)<<(0));
} else {
*dst = palmap[((dR>>5)<<(3+2))|
((dG>>5)<<(2)) |
((dB>>6)<<(0))];
}
dst++;
src += srcbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
/* N->1 blending with pixel alpha */
static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
Uint8 *palmap = info->table;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel;
/* FIXME: fix alpha bit field expansion here too? */
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned sA;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA);
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
dR &= 0xff;
dG &= 0xff;
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|
((dG>>5)<<(2))|
((dB>>6)<<(0));
} else {
*dst = palmap[((dR>>5)<<(3+2))|
((dG>>5)<<(2)) |
((dB>>6)<<(0)) ];
}
dst++;
src += srcbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
/* colorkeyed N->1 blending with per-surface alpha */
static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
Uint8 *palmap = info->table;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel;
Uint32 ckey = srcfmt->colorkey;
const int A = srcfmt->alpha;
while ( height-- ) {
DUFFS_LOOP(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
if ( Pixel != ckey ) {
dR = dstfmt->palette->colors[*dst].r;
dG = dstfmt->palette->colors[*dst].g;
dB = dstfmt->palette->colors[*dst].b;
ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
dR &= 0xff;
dG &= 0xff;
dB &= 0xff;
/* Pack RGB into 8bit pixel */
if ( palmap == NULL ) {
*dst =((dR>>5)<<(3+2))|
((dG>>5)<<(2)) |
((dB>>6)<<(0));
} else {
*dst = palmap[((dR>>5)<<(3+2))|
((dG>>5)<<(2)) |
((dB>>6)<<(0)) ];
}
}
dst++;
src += srcbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
/* fast RGB888->(A)RGB888 blending with surface alpha=128 special case */
static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
*dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)
+ (s & d & 0x00010101)) | 0xff000000;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
/* fast RGB888->(A)RGB888 blending with surface alpha */
static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
{
unsigned alpha = info->src->alpha;
if(alpha == 128) {
BlitRGBtoRGBSurfaceAlpha128(info);
} else {
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
Uint32 s;
Uint32 d;
Uint32 s1;
Uint32 d1;
while(height--) {
DUFFS_LOOP_DOUBLE2({
/* One Pixel Blend */
s = *srcp;
d = *dstp;
s1 = s & 0xff00ff;
d1 = d & 0xff00ff;
d1 = (d1 + ((s1 - d1) * alpha >> 8))
& 0xff00ff;
s &= 0xff00;
d &= 0xff00;
d = (d + ((s - d) * alpha >> 8)) & 0xff00;
*dstp = d1 | d | 0xff000000;
++srcp;
++dstp;
},{
/* Two Pixels Blend */
s = *srcp;
d = *dstp;
s1 = s & 0xff00ff;
d1 = d & 0xff00ff;
d1 += (s1 - d1) * alpha >> 8;
d1 &= 0xff00ff;
s = ((s & 0xff00) >> 8) |
((srcp[1] & 0xff00) << 8);
d = ((d & 0xff00) >> 8) |
((dstp[1] & 0xff00) << 8);
d += (s - d) * alpha >> 8;
d &= 0x00ff00ff;
*dstp++ = d1 | ((d << 8) & 0xff00) | 0xff000000;
++srcp;
s1 = *srcp;
d1 = *dstp;
s1 &= 0xff00ff;
d1 &= 0xff00ff;
d1 += (s1 - d1) * alpha >> 8;
d1 &= 0xff00ff;
*dstp = d1 | ((d >> 8) & 0xff00) | 0xff000000;
++srcp;
++dstp;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast ARGB888->(A)RGB888 blending with pixel alpha */
static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint32 *dstp = (Uint32 *)info->d_pixels;
int dstskip = info->d_skip >> 2;
while(height--) {
DUFFS_LOOP4({
Uint32 dalpha;
Uint32 d;
Uint32 s1;
Uint32 d1;
Uint32 s = *srcp;
Uint32 alpha = s >> 24;
/* FIXME: Here we special-case opaque alpha since the
compositioning used (>>8 instead of /255) doesn't handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
if(alpha) {
if(alpha == SDL_ALPHA_OPAQUE) {
*dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
} else {
/*
* take out the middle component (green), and process
* the other two in parallel. One multiply less.
*/
d = *dstp;
dalpha = d & 0xff000000;
s1 = s & 0xff00ff;
d1 = d & 0xff00ff;
d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
s &= 0xff00;
d &= 0xff00;
d = (d + ((s - d) * alpha >> 8)) & 0xff00;
*dstp = d1 | d | dalpha;
}
}
++srcp;
++dstp;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
/* 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel */
/* blend a single 16 bit pixel at 50% */
#define BLEND16_50(d, s, mask) \
((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff)))
/* blend two 16 bit pixels at 50% */
#define BLEND2x16_50(d, s, mask) \
(((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) \
+ (s & d & (~(mask | mask << 16))))
static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask)
{
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
while(height--) {
if(((uintptr_t)srcp ^ (uintptr_t)dstp) & 2) {
/*
* Source and destination not aligned, pipeline it.
* This is mostly a win for big blits but no loss for
* small ones
*/
Uint32 prev_sw;
int w = width;
/* handle odd destination */
if((uintptr_t)dstp & 2) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
dstp++;
srcp++;
w--;
}
srcp++; /* srcp is now 32-bit aligned */
/* bootstrap pipeline with first halfword */
prev_sw = ((Uint32 *)srcp)[-1];
while(w > 1) {
Uint32 sw, dw, s;
sw = *(Uint32 *)srcp;
dw = *(Uint32 *)dstp;
#ifdef MSB_FIRST
s = (prev_sw << 16) + (sw >> 16);
#else
s = (prev_sw >> 16) + (sw << 16);
#endif
prev_sw = sw;
*(Uint32 *)dstp = BLEND2x16_50(dw, s, mask);
dstp += 2;
srcp += 2;
w -= 2;
}
/* final pixel if any */
if(w) {
Uint16 d = *dstp, s;
#ifdef MSB_FIRST
s = (Uint16)prev_sw;
#else
s = (Uint16)(prev_sw >> 16);
#endif
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
}
srcp += srcskip - 1;
dstp += dstskip;
} else {
/* source and destination are aligned */
int w = width;
/* first odd pixel? */
if((uintptr_t)srcp & 2) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
w--;
}
/* srcp and dstp are now 32-bit aligned */
while(w > 1) {
Uint32 sw = *(Uint32 *)srcp;
Uint32 dw = *(Uint32 *)dstp;
*(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask);
srcp += 2;
dstp += 2;
w -= 2;
}
/* last odd pixel? */
if(w) {
Uint16 d = *dstp, s = *srcp;
*dstp = BLEND16_50(d, s, mask);
srcp++;
dstp++;
}
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast RGB565->RGB565 blending with surface alpha */
static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
{
unsigned alpha = info->src->alpha;
if(alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xf7de);
} else {
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
alpha >>= 3; /* downscale alpha to 5 bits */
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to
* the high 16 bits, and process all three RGB
* components at the same time.
*/
s = (s | s << 16) & 0x07e0f81f;
d = (d | d << 16) & 0x07e0f81f;
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
*dstp++ = (Uint16)(d | d >> 16);
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast RGB555->RGB555 blending with surface alpha */
static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
{
unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */
if(alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xfbde);
} else {
int width = info->d_width;
int height = info->d_height;
Uint16 *srcp = (Uint16 *)info->s_pixels;
int srcskip = info->s_skip >> 1;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
alpha >>= 3; /* downscale alpha to 5 bits */
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp++;
Uint32 d = *dstp;
/*
* shift out the middle component (green) to
* the high 16 bits, and process all three RGB
* components at the same time.
*/
s = (s | s << 16) & 0x03e07c1f;
d = (d | d << 16) & 0x03e07c1f;
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
*dstp++ = (Uint16)(d | d >> 16);
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
}
/* fast ARGB8888->RGB565 blending with pixel alpha */
static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
while(height--) {
DUFFS_LOOP4({
Uint32 s = *srcp;
unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
/* FIXME: Here we special-case opaque alpha since the
compositioning used (>>8 instead of /255) doesn't handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
if(alpha) {
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
*dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f));
} else {
Uint32 d = *dstp;
/*
* convert source and destination to G0RAB65565
* and blend all components at the same time
*/
s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
+ (s >> 3 & 0x1f);
d = (d | d << 16) & 0x07e0f81f;
d += (s - d) * alpha >> 5;
d &= 0x07e0f81f;
*dstp = (Uint16)(d | d >> 16);
}
}
srcp++;
dstp++;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
/* fast ARGB8888->RGB555 blending with pixel alpha */
static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint32 *srcp = (Uint32 *)info->s_pixels;
int srcskip = info->s_skip >> 2;
Uint16 *dstp = (Uint16 *)info->d_pixels;
int dstskip = info->d_skip >> 1;
while(height--) {
DUFFS_LOOP4({
unsigned alpha;
Uint32 s = *srcp;
alpha = s >> 27; /* downscale alpha to 5 bits */
/* FIXME: Here we special-case opaque alpha since the
compositioning used (>>8 instead of /255) doesn't handle
it correctly. Also special-case alpha=0 for speed?
Benchmark this! */
if(alpha) {
if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
*dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f));
} else {
Uint32 d = *dstp;
/*
* convert source and destination to G0RAB65565
* and blend all components at the same time
*/
s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
+ (s >> 3 & 0x1f);
d = (d | d << 16) & 0x03e07c1f;
d += (s - d) * alpha >> 5;
d &= 0x03e07c1f;
*dstp = (Uint16)(d | d >> 16);
}
}
srcp++;
dstp++;
}, width);
srcp += srcskip;
dstp += dstskip;
}
}
/* General (slow) N->N blending with per-surface alpha */
static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel;
unsigned sA = srcfmt->alpha;
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
if(sA) {
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
src += srcbpp;
dst += dstbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
}
/* General (slow) colorkeyed N->N blending with per-surface alpha */
static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
Uint32 ckey = srcfmt->colorkey;
int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel;
unsigned sA = srcfmt->alpha;
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel);
if(sA && Pixel != ckey) {
RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB);
DISEMBLE_RGB(dst, dstbpp, dstfmt, Pixel, dR, dG, dB);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
src += srcbpp;
dst += dstbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
/* General (slow) N->N blending with pixel alpha */
static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
{
int width = info->d_width;
int height = info->d_height;
Uint8 *src = info->s_pixels;
int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcbpp;
int dstbpp;
/* Set up some basic variables */
srcbpp = srcfmt->BytesPerPixel;
dstbpp = dstfmt->BytesPerPixel;
/* FIXME: for 8bpp source alpha, this doesn't get opaque values
quite right. for <8bpp source alpha, it gets them very wrong
(check all macros!)
It is unclear whether there is a good general solution that doesn't
need a branch (or a divide). */
while ( height-- ) {
DUFFS_LOOP4(
{
Uint32 Pixel;
unsigned sR;
unsigned sG;
unsigned sB;
unsigned dR;
unsigned dG;
unsigned dB;
unsigned sA;
unsigned dA;
DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA);
if(sA) {
DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA);
ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
}
src += srcbpp;
dst += dstbpp;
},
width);
src += srcskip;
dst += dstskip;
}
}
SDL_loblit LRSDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
{
SDL_PixelFormat *sf = surface->format;
SDL_PixelFormat *df = surface->map->dst->format;
if(sf->Amask == 0) {
if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
if(df->BytesPerPixel == 1)
return BlitNto1SurfaceAlphaKey;
else
return BlitNtoNSurfaceAlphaKey;
} else {
/* Per-surface alpha blits */
switch(df->BytesPerPixel) {
case 1:
return BlitNto1SurfaceAlpha;
case 2:
if(surface->map->identity) {
if(df->Gmask == 0x7e0)
{
return Blit565to565SurfaceAlpha;
}
else if(df->Gmask == 0x3e0)
{
return Blit555to555SurfaceAlpha;
}
}
return BlitNtoNSurfaceAlpha;
case 4:
if(sf->Rmask == df->Rmask
&& sf->Gmask == df->Gmask
&& sf->Bmask == df->Bmask
&& sf->BytesPerPixel == 4)
{
if((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff)
{
return BlitRGBtoRGBSurfaceAlpha;
}
}
return BlitNtoNSurfaceAlpha;
case 3:
default:
return BlitNtoNSurfaceAlpha;
}
}
} else {
/* Per-pixel alpha blits */
switch(df->BytesPerPixel) {
case 1:
return BlitNto1PixelAlpha;
case 2:
if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
&& sf->Gmask == 0xff00
&& ((sf->Rmask == 0xff && df->Rmask == 0x1f)
|| (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
if(df->Gmask == 0x7e0)
return BlitARGBto565PixelAlpha;
else if(df->Gmask == 0x3e0)
return BlitARGBto555PixelAlpha;
}
return BlitNtoNPixelAlpha;
case 4:
if(sf->Rmask == df->Rmask
&& sf->Gmask == df->Gmask
&& sf->Bmask == df->Bmask
&& sf->BytesPerPixel == 4)
{
if(sf->Amask == 0xff000000)
{
return BlitRGBtoRGBPixelAlpha;
}
}
return BlitNtoNPixelAlpha;
case 3:
default:
return BlitNtoNPixelAlpha;
}
}
}

1494
sdl/video/SDL_blit_N.c Normal file

File diff suppressed because it is too large Load Diff

548
sdl/video/SDL_bmp.c Normal file
View File

@ -0,0 +1,548 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/*
Code to load and save surfaces in Windows BMP format.
Why support BMP format? Well, it's a native format for Windows, and
most image processing programs can read and write it. It would be nice
to be able to have at least one image format that we can natively load
and save, and since PNG is so complex that it would bloat the library,
BMP is a good alternative.
This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.
*/
#include "SDL_video.h"
#include "SDL_endian.h"
/* Compression encodings for BMP files */
#ifndef BI_RGB
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
#define BI_BITFIELDS 3
#endif
SDL_Surface * LRSDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
{
SDL_bool was_error;
long fp_offset = 0;
int bmpPitch;
int i, pad;
SDL_Surface *surface;
Uint32 Rmask;
Uint32 Gmask;
Uint32 Bmask;
SDL_Palette *palette;
Uint8 *bits;
Uint8 *top, *end;
SDL_bool topDown;
int ExpandBMP;
/* The Win32 BMP file header (14 bytes) */
char magic[2];
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
/* The Win32 BITMAPINFOHEADER struct (40 bytes) */
Uint32 biSize;
Sint32 biWidth;
Sint32 biHeight;
Uint16 biPlanes;
Uint16 biBitCount;
Uint32 biCompression;
Uint32 biSizeImage;
Sint32 biXPelsPerMeter;
Sint32 biYPelsPerMeter;
Uint32 biClrUsed;
Uint32 biClrImportant;
/* Make sure we are passed a valid data source */
surface = NULL;
was_error = SDL_FALSE;
if ( src == NULL ) {
was_error = SDL_TRUE;
goto done;
}
/* Read in the BMP file header */
fp_offset = LRSDL_RWtell(src);
LRSDL_ClearError();
if ( LRSDL_RWread(src, magic, 1, 2) != 2 ) {
LRSDL_Error(SDL_EFREAD);
was_error = SDL_TRUE;
goto done;
}
if ( SDL_strncmp(magic, "BM", 2) != 0 ) {
LRSDL_SetError("File is not a Windows BMP file");
was_error = SDL_TRUE;
goto done;
}
bfSize = LRSDL_ReadLE32(src);
bfReserved1 = LRSDL_ReadLE16(src);
bfReserved2 = LRSDL_ReadLE16(src);
bfOffBits = LRSDL_ReadLE32(src);
/* Read the Win32 BITMAPINFOHEADER */
biSize = LRSDL_ReadLE32(src);
if ( biSize == 12 ) {
biWidth = (Uint32)LRSDL_ReadLE16(src);
biHeight = (Uint32)LRSDL_ReadLE16(src);
biPlanes = LRSDL_ReadLE16(src);
biBitCount = LRSDL_ReadLE16(src);
biCompression = BI_RGB;
biSizeImage = 0;
biXPelsPerMeter = 0;
biYPelsPerMeter = 0;
biClrUsed = 0;
biClrImportant = 0;
} else {
biWidth = LRSDL_ReadLE32(src);
biHeight = LRSDL_ReadLE32(src);
biPlanes = LRSDL_ReadLE16(src);
biBitCount = LRSDL_ReadLE16(src);
biCompression = LRSDL_ReadLE32(src);
biSizeImage = LRSDL_ReadLE32(src);
biXPelsPerMeter = LRSDL_ReadLE32(src);
biYPelsPerMeter = LRSDL_ReadLE32(src);
biClrUsed = LRSDL_ReadLE32(src);
biClrImportant = LRSDL_ReadLE32(src);
}
/* stop some compiler warnings. */
(void) bfSize;
(void) bfReserved1;
(void) bfReserved2;
(void) biPlanes;
(void) biSizeImage;
(void) biXPelsPerMeter;
(void) biYPelsPerMeter;
(void) biClrImportant;
if (biHeight < 0) {
topDown = SDL_TRUE;
biHeight = -biHeight;
} else {
topDown = SDL_FALSE;
}
/* Check for read error */
if ( SDL_strcmp(LRSDL_GetError(), "") != 0 ) {
was_error = SDL_TRUE;
goto done;
}
/* Expand 1 and 4 bit bitmaps to 8 bits per pixel */
switch (biBitCount) {
case 1:
case 4:
ExpandBMP = biBitCount;
biBitCount = 8;
break;
default:
ExpandBMP = 0;
break;
}
/* We don't support any BMP compression right now */
Rmask = Gmask = Bmask = 0;
switch (biCompression) {
case BI_RGB:
/* If there are no masks, use the defaults */
if ( bfOffBits == (14+biSize) ) {
/* Default values for the BMP format */
switch (biBitCount) {
case 15:
case 16:
Rmask = 0x7C00;
Gmask = 0x03E0;
Bmask = 0x001F;
break;
case 24:
#ifdef MSB_FIRST
Rmask = 0x000000FF;
Gmask = 0x0000FF00;
Bmask = 0x00FF0000;
break;
#endif
case 32:
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
break;
default:
break;
}
break;
}
/* Fall through -- read the RGB masks */
case BI_BITFIELDS:
switch (biBitCount) {
case 15:
case 16:
case 32:
Rmask = LRSDL_ReadLE32(src);
Gmask = LRSDL_ReadLE32(src);
Bmask = LRSDL_ReadLE32(src);
break;
default:
break;
}
break;
default:
LRSDL_SetError("Compressed BMP files not supported");
was_error = SDL_TRUE;
goto done;
}
/* Create a compatible surface, note that the colors are RGB ordered */
surface = LRSDL_CreateRGBSurface(SDL_SWSURFACE,
biWidth, biHeight, biBitCount, Rmask, Gmask, Bmask, 0);
if ( surface == NULL ) {
was_error = SDL_TRUE;
goto done;
}
/* Load the palette, if any */
palette = (surface->format)->palette;
if ( palette ) {
if ( biClrUsed == 0 ) {
biClrUsed = 1 << biBitCount;
}
if ( biSize == 12 ) {
for ( i = 0; i < (int)biClrUsed; ++i ) {
LRSDL_RWread(src, &palette->colors[i].b, 1, 1);
LRSDL_RWread(src, &palette->colors[i].g, 1, 1);
LRSDL_RWread(src, &palette->colors[i].r, 1, 1);
palette->colors[i].unused = 0;
}
} else {
for ( i = 0; i < (int)biClrUsed; ++i ) {
LRSDL_RWread(src, &palette->colors[i].b, 1, 1);
LRSDL_RWread(src, &palette->colors[i].g, 1, 1);
LRSDL_RWread(src, &palette->colors[i].r, 1, 1);
LRSDL_RWread(src, &palette->colors[i].unused, 1, 1);
}
}
palette->ncolors = biClrUsed;
}
/* Read the surface pixels. Note that the bmp image is upside down */
if ( LRSDL_RWseek(src, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
LRSDL_Error(SDL_EFSEEK);
was_error = SDL_TRUE;
goto done;
}
top = (Uint8 *)surface->pixels;
end = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
switch (ExpandBMP) {
case 1:
bmpPitch = (biWidth + 7) >> 3;
pad = (((bmpPitch)%4) ? (4-((bmpPitch)%4)) : 0);
break;
case 4:
bmpPitch = (biWidth + 1) >> 1;
pad = (((bmpPitch)%4) ? (4-((bmpPitch)%4)) : 0);
break;
default:
pad = ((surface->pitch%4) ?
(4-(surface->pitch%4)) : 0);
break;
}
if ( topDown ) {
bits = top;
} else {
bits = end - surface->pitch;
}
while ( bits >= top && bits < end ) {
switch (ExpandBMP) {
case 1:
case 4: {
Uint8 pixel = 0;
int shift = (8-ExpandBMP);
for ( i=0; i<surface->w; ++i ) {
if ( i%(8/ExpandBMP) == 0 ) {
if ( !LRSDL_RWread(src, &pixel, 1, 1) ) {
LRSDL_SetError(
"Error reading from BMP");
was_error = SDL_TRUE;
goto done;
}
}
*(bits+i) = (pixel>>shift);
pixel <<= ExpandBMP;
} }
break;
default:
if ( LRSDL_RWread(src, bits, 1, surface->pitch)
!= surface->pitch ) {
LRSDL_Error(SDL_EFREAD);
was_error = SDL_TRUE;
goto done;
}
#ifdef MSB_FIRST
/* Byte-swap the pixels if needed. Note that the 24bpp
case has already been taken care of above. */
switch(biBitCount) {
case 15:
case 16: {
Uint16 *pix = (Uint16 *)bits;
for(i = 0; i < surface->w; i++)
pix[i] = SDL_Swap16(pix[i]);
break;
}
case 32: {
Uint32 *pix = (Uint32 *)bits;
for(i = 0; i < surface->w; i++)
pix[i] = SDL_Swap32(pix[i]);
break;
}
}
#endif
break;
}
/* Skip padding bytes, ugh */
if ( pad ) {
Uint8 padbyte;
for ( i=0; i<pad; ++i ) {
LRSDL_RWread(src, &padbyte, 1, 1);
}
}
if ( topDown ) {
bits += surface->pitch;
} else {
bits -= surface->pitch;
}
}
done:
if ( was_error ) {
if ( src ) {
LRSDL_RWseek(src, fp_offset, RW_SEEK_SET);
}
if ( surface ) {
LRSDL_FreeSurface(surface);
}
surface = NULL;
}
if ( freesrc && src ) {
LRSDL_RWclose(src);
}
return(surface);
}
int LRSDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
{
long fp_offset;
int i, pad;
SDL_Surface *surface;
Uint8 *bits;
/* The Win32 BMP file header (14 bytes) */
char magic[2] = { 'B', 'M' };
Uint32 bfSize;
Uint16 bfReserved1;
Uint16 bfReserved2;
Uint32 bfOffBits;
/* The Win32 BITMAPINFOHEADER struct (40 bytes) */
Uint32 biSize;
Sint32 biWidth;
Sint32 biHeight;
Uint16 biPlanes;
Uint16 biBitCount;
Uint32 biCompression;
Uint32 biSizeImage;
Sint32 biXPelsPerMeter;
Sint32 biYPelsPerMeter;
Uint32 biClrUsed;
Uint32 biClrImportant;
/* Make sure we have somewhere to save */
surface = NULL;
if ( dst ) {
if ( saveme->format->palette ) {
if ( saveme->format->BitsPerPixel == 8 ) {
surface = saveme;
} else {
LRSDL_SetError("%d bpp BMP files not supported",
saveme->format->BitsPerPixel);
}
}
else if ( (saveme->format->BitsPerPixel == 24) &&
#ifdef MSB_FIRST
(saveme->format->Rmask == 0x000000FF) &&
(saveme->format->Gmask == 0x0000FF00) &&
(saveme->format->Bmask == 0x00FF0000)
#else
(saveme->format->Rmask == 0x00FF0000) &&
(saveme->format->Gmask == 0x0000FF00) &&
(saveme->format->Bmask == 0x000000FF)
#endif
) {
surface = saveme;
} else {
SDL_Rect bounds;
/* Convert to 24 bits per pixel */
surface = LRSDL_CreateRGBSurface(SDL_SWSURFACE,
saveme->w, saveme->h, 24,
#ifdef MSB_FIRST
0x000000FF, 0x0000FF00, 0x00FF0000,
#else
0x00FF0000, 0x0000FF00, 0x000000FF,
#endif
0);
if ( surface != NULL ) {
bounds.x = 0;
bounds.y = 0;
bounds.w = saveme->w;
bounds.h = saveme->h;
if ( LRSDL_LowerBlit(saveme, &bounds, surface,
&bounds) < 0 ) {
LRSDL_FreeSurface(surface);
LRSDL_SetError(
"Couldn't convert image to 24 bpp");
surface = NULL;
}
}
}
}
if ( surface )
{
const int bw = surface->w*surface->format->BytesPerPixel;
/* Set the BMP file header values */
bfSize = 0; /* We'll write this when we're done */
bfReserved1 = 0;
bfReserved2 = 0;
bfOffBits = 0; /* We'll write this when we're done */
/* Write the BMP file header values */
fp_offset = LRSDL_RWtell(dst);
LRSDL_ClearError();
LRSDL_RWwrite(dst, magic, 2, 1);
LRSDL_WriteLE32(dst, bfSize);
LRSDL_WriteLE16(dst, bfReserved1);
LRSDL_WriteLE16(dst, bfReserved2);
LRSDL_WriteLE32(dst, bfOffBits);
/* Set the BMP info values */
biSize = 40;
biWidth = surface->w;
biHeight = surface->h;
biPlanes = 1;
biBitCount = surface->format->BitsPerPixel;
biCompression = BI_RGB;
biSizeImage = surface->h*surface->pitch;
biXPelsPerMeter = 0;
biYPelsPerMeter = 0;
if ( surface->format->palette ) {
biClrUsed = surface->format->palette->ncolors;
} else {
biClrUsed = 0;
}
biClrImportant = 0;
/* Write the BMP info values */
LRSDL_WriteLE32(dst, biSize);
LRSDL_WriteLE32(dst, biWidth);
LRSDL_WriteLE32(dst, biHeight);
LRSDL_WriteLE16(dst, biPlanes);
LRSDL_WriteLE16(dst, biBitCount);
LRSDL_WriteLE32(dst, biCompression);
LRSDL_WriteLE32(dst, biSizeImage);
LRSDL_WriteLE32(dst, biXPelsPerMeter);
LRSDL_WriteLE32(dst, biYPelsPerMeter);
LRSDL_WriteLE32(dst, biClrUsed);
LRSDL_WriteLE32(dst, biClrImportant);
/* Write the palette (in BGR color order) */
if ( surface->format->palette ) {
SDL_Color *colors;
int ncolors;
colors = surface->format->palette->colors;
ncolors = surface->format->palette->ncolors;
for ( i=0; i<ncolors; ++i ) {
LRSDL_RWwrite(dst, &colors[i].b, 1, 1);
LRSDL_RWwrite(dst, &colors[i].g, 1, 1);
LRSDL_RWwrite(dst, &colors[i].r, 1, 1);
LRSDL_RWwrite(dst, &colors[i].unused, 1, 1);
}
}
/* Write the bitmap offset */
bfOffBits = LRSDL_RWtell(dst)-fp_offset;
if ( LRSDL_RWseek(dst, fp_offset+10, RW_SEEK_SET) < 0 ) {
LRSDL_Error(SDL_EFSEEK);
}
LRSDL_WriteLE32(dst, bfOffBits);
if ( LRSDL_RWseek(dst, fp_offset+bfOffBits, RW_SEEK_SET) < 0 ) {
LRSDL_Error(SDL_EFSEEK);
}
/* Write the bitmap image upside down */
bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
pad = ((bw%4) ? (4-(bw%4)) : 0);
while ( bits > (Uint8 *)surface->pixels ) {
bits -= surface->pitch;
if ( LRSDL_RWwrite(dst, bits, 1, bw) != bw) {
LRSDL_Error(SDL_EFWRITE);
break;
}
if ( pad ) {
const Uint8 padbyte = 0;
for ( i=0; i<pad; ++i ) {
LRSDL_RWwrite(dst, &padbyte, 1, 1);
}
}
}
/* Write the BMP file size */
bfSize = LRSDL_RWtell(dst)-fp_offset;
if ( LRSDL_RWseek(dst, fp_offset+2, RW_SEEK_SET) < 0 ) {
LRSDL_Error(SDL_EFSEEK);
}
LRSDL_WriteLE32(dst, bfSize);
if ( LRSDL_RWseek(dst, fp_offset+bfSize, RW_SEEK_SET) < 0 ) {
LRSDL_Error(SDL_EFSEEK);
}
if ( surface != saveme ) {
LRSDL_FreeSurface(surface);
}
}
if ( freedst && dst ) {
LRSDL_RWclose(dst);
}
return((SDL_strcmp(LRSDL_GetError(), "") == 0) ? 0 : -1);
}

600
sdl/video/SDL_pixels.c Normal file
View File

@ -0,0 +1,600 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* General (mostly internal) pixel/color manipulation routines for SDL */
#include "SDL_endian.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
/* Helper functions */
/*
* Allocate a pixel format structure and fill it according to the given info.
*/
SDL_PixelFormat *LRSDL_AllocFormat(int bpp,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
SDL_PixelFormat *format;
Uint32 mask;
/* Allocate an empty pixel format structure */
format = (SDL_PixelFormat*)SDL_malloc(sizeof(*format));
if ( format == NULL ) {
LRSDL_OutOfMemory();
return(NULL);
}
SDL_memset(format, 0, sizeof(*format));
format->alpha = SDL_ALPHA_OPAQUE;
/* Set up the format */
format->BitsPerPixel = bpp;
format->BytesPerPixel = (bpp+7)/8;
if ( Rmask || Bmask || Gmask ) { /* Packed pixels with custom mask */
format->palette = NULL;
format->Rshift = 0;
format->Rloss = 8;
if ( Rmask ) {
for ( mask = Rmask; !(mask&0x01); mask >>= 1 )
++format->Rshift;
for ( ; (mask&0x01); mask >>= 1 )
--format->Rloss;
}
format->Gshift = 0;
format->Gloss = 8;
if ( Gmask ) {
for ( mask = Gmask; !(mask&0x01); mask >>= 1 )
++format->Gshift;
for ( ; (mask&0x01); mask >>= 1 )
--format->Gloss;
}
format->Bshift = 0;
format->Bloss = 8;
if ( Bmask ) {
for ( mask = Bmask; !(mask&0x01); mask >>= 1 )
++format->Bshift;
for ( ; (mask&0x01); mask >>= 1 )
--format->Bloss;
}
format->Ashift = 0;
format->Aloss = 8;
if ( Amask ) {
for ( mask = Amask; !(mask&0x01); mask >>= 1 )
++format->Ashift;
for ( ; (mask&0x01); mask >>= 1 )
--format->Aloss;
}
format->Rmask = Rmask;
format->Gmask = Gmask;
format->Bmask = Bmask;
format->Amask = Amask;
} else if ( bpp > 8 ) { /* Packed pixels with standard mask */
/* R-G-B */
if ( bpp > 24 )
bpp = 24;
format->Rloss = 8-(bpp/3);
format->Gloss = 8-(bpp/3)-(bpp%3);
format->Bloss = 8-(bpp/3);
format->Rshift = ((bpp/3)+(bpp%3))+(bpp/3);
format->Gshift = (bpp/3);
format->Bshift = 0;
format->Rmask = ((0xFF>>format->Rloss)<<format->Rshift);
format->Gmask = ((0xFF>>format->Gloss)<<format->Gshift);
format->Bmask = ((0xFF>>format->Bloss)<<format->Bshift);
} else {
/* Palettized formats have no mask info */
format->Rloss = 8;
format->Gloss = 8;
format->Bloss = 8;
format->Aloss = 8;
format->Rshift = 0;
format->Gshift = 0;
format->Bshift = 0;
format->Ashift = 0;
format->Rmask = 0;
format->Gmask = 0;
format->Bmask = 0;
format->Amask = 0;
}
if ( bpp <= 8 ) { /* Palettized mode */
int ncolors = 1<<bpp;
format->palette = (SDL_Palette *)SDL_malloc(sizeof(SDL_Palette));
if ( format->palette == NULL ) {
LRSDL_FreeFormat(format);
LRSDL_OutOfMemory();
return(NULL);
}
(format->palette)->ncolors = ncolors;
(format->palette)->colors = (SDL_Color *)SDL_malloc(
(format->palette)->ncolors*sizeof(SDL_Color));
if ( (format->palette)->colors == NULL ) {
LRSDL_FreeFormat(format);
LRSDL_OutOfMemory();
return(NULL);
}
if ( Rmask || Bmask || Gmask ) {
/* create palette according to masks */
int i;
int Rm=0,Gm=0,Bm=0;
int Rw=0,Gw=0,Bw=0;
if(Rmask)
{
Rw=8-format->Rloss;
for(i=format->Rloss;i>0;i-=Rw)
Rm|=1<<i;
}
if(Gmask)
{
Gw=8-format->Gloss;
for(i=format->Gloss;i>0;i-=Gw)
Gm|=1<<i;
}
if(Bmask)
{
Bw=8-format->Bloss;
for(i=format->Bloss;i>0;i-=Bw)
Bm|=1<<i;
}
#ifdef ENABLE_PALETTE_ALPHA
if(Amask)
{
Aw=8-format->Aloss;
for(i=format->Aloss;i>0;i-=Aw)
Am|=1<<i;
}
#endif
for(i=0; i < ncolors; ++i) {
int r,g,b;
r=(i&Rmask)>>format->Rshift;
r=(r<<format->Rloss)|((r*Rm)>>Rw);
format->palette->colors[i].r=r;
g=(i&Gmask)>>format->Gshift;
g=(g<<format->Gloss)|((g*Gm)>>Gw);
format->palette->colors[i].g=g;
b=(i&Bmask)>>format->Bshift;
b=(b<<format->Bloss)|((b*Bm)>>Bw);
format->palette->colors[i].b=b;
#ifdef ENABLE_PALETTE_ALPHA
a=(i&Amask)>>format->Ashift;
a=(a<<format->Aloss)|((a*Am)>>Aw);
format->palette->colors[i].unused=a;
#else
format->palette->colors[i].unused=0;
#endif
}
} else if ( ncolors == 2 ) {
/* Create a black and white bitmap palette */
format->palette->colors[0].r = 0xFF;
format->palette->colors[0].g = 0xFF;
format->palette->colors[0].b = 0xFF;
format->palette->colors[1].r = 0x00;
format->palette->colors[1].g = 0x00;
format->palette->colors[1].b = 0x00;
} else {
/* Create an empty palette */
SDL_memset((format->palette)->colors, 0,
(format->palette)->ncolors*sizeof(SDL_Color));
}
}
return(format);
}
SDL_PixelFormat *LRSDL_ReallocFormat(SDL_Surface *surface, int bpp,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
if ( surface->format ) {
LRSDL_FreeFormat(surface->format);
LRSDL_FormatChanged(surface);
}
surface->format = LRSDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
return surface->format;
}
/*
* Change any previous mappings from/to the new surface format
*/
void LRSDL_FormatChanged(SDL_Surface *surface)
{
static int format_version = 0;
++format_version;
if ( format_version < 0 ) { /* It wrapped... */
format_version = 1;
}
surface->format_version = format_version;
LRSDL_InvalidateMap(surface->map);
}
/*
* Free a previously allocated format structure
*/
void LRSDL_FreeFormat(SDL_PixelFormat *format)
{
if ( format ) {
if ( format->palette ) {
if ( format->palette->colors ) {
SDL_free(format->palette->colors);
}
SDL_free(format->palette);
}
SDL_free(format);
}
}
/*
* Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors
*/
void LRSDL_DitherColors(SDL_Color *colors, int bpp)
{
int i;
if(bpp != 8)
return; /* only 8bpp supported right now */
for(i = 0; i < 256; i++) {
int r, g, b;
/* map each bit field to the full [0, 255] interval,
so 0 is mapped to (0, 0, 0) and 255 to (255, 255, 255) */
r = i & 0xe0;
r |= r >> 3 | r >> 6;
colors[i].r = r;
g = (i << 3) & 0xe0;
g |= g >> 3 | g >> 6;
colors[i].g = g;
b = i & 0x3;
b |= b << 2;
b |= b << 4;
colors[i].b = b;
}
}
/*
* Calculate the pad-aligned scanline width of a surface
*/
Uint16 LRSDL_CalculatePitch(SDL_Surface *surface)
{
Uint16 pitch;
/* Surface should be 4-byte aligned for speed */
pitch = surface->w*surface->format->BytesPerPixel;
switch (surface->format->BitsPerPixel) {
case 1:
pitch = (pitch+7)/8;
break;
case 4:
pitch = (pitch+1)/2;
break;
default:
break;
}
pitch = (pitch + 3) & ~3; /* 4-byte aligning */
return(pitch);
}
/*
* Match an RGB value to a particular palette index
*/
Uint8 LRSDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b)
{
/* Do colorspace distance matching */
unsigned int smallest;
unsigned int distance;
int rd, gd, bd;
int i;
Uint8 pixel=0;
smallest = ~0;
for ( i=0; i<pal->ncolors; ++i ) {
rd = pal->colors[i].r - r;
gd = pal->colors[i].g - g;
bd = pal->colors[i].b - b;
distance = (rd*rd)+(gd*gd)+(bd*bd);
if ( distance < smallest ) {
pixel = i;
if ( distance == 0 ) { /* Perfect match! */
break;
}
smallest = distance;
}
}
return(pixel);
}
/* Find the opaque pixel value corresponding to an RGB triple */
Uint32 LRSDL_MapRGB
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b)
{
if ( format->palette == NULL ) {
return (r >> format->Rloss) << format->Rshift
| (g >> format->Gloss) << format->Gshift
| (b >> format->Bloss) << format->Bshift
| format->Amask;
} else {
return LRSDL_FindColor(format->palette, r, g, b);
}
}
/* Find the pixel value corresponding to an RGBA quadruple */
Uint32 LRSDL_MapRGBA
(const SDL_PixelFormat * const format,
const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a)
{
if ( format->palette == NULL ) {
return (r >> format->Rloss) << format->Rshift
| (g >> format->Gloss) << format->Gshift
| (b >> format->Bloss) << format->Bshift
| ((a >> format->Aloss) << format->Ashift & format->Amask);
} else {
return LRSDL_FindColor(format->palette, r, g, b);
}
}
void LRSDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * const fmt,
Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
{
if ( fmt->palette == NULL ) {
/*
* This makes sure that the result is mapped to the
* interval [0..255], and the maximum value for each
* component is 255. This is important to make sure
* that white is indeed reported as (255, 255, 255),
* and that opaque alpha is 255.
* This only works for RGB bit fields at least 4 bit
* wide, which is almost always the case.
*/
unsigned v;
v = (pixel & fmt->Rmask) >> fmt->Rshift;
*r = (v << fmt->Rloss) + (v >> (8 - (fmt->Rloss << 1)));
v = (pixel & fmt->Gmask) >> fmt->Gshift;
*g = (v << fmt->Gloss) + (v >> (8 - (fmt->Gloss << 1)));
v = (pixel & fmt->Bmask) >> fmt->Bshift;
*b = (v << fmt->Bloss) + (v >> (8 - (fmt->Bloss << 1)));
if(fmt->Amask) {
v = (pixel & fmt->Amask) >> fmt->Ashift;
*a = (v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)));
} else {
*a = SDL_ALPHA_OPAQUE;
}
} else {
*r = fmt->palette->colors[pixel].r;
*g = fmt->palette->colors[pixel].g;
*b = fmt->palette->colors[pixel].b;
*a = SDL_ALPHA_OPAQUE;
}
}
void LRSDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * const fmt,
Uint8 *r,Uint8 *g,Uint8 *b)
{
if ( fmt->palette == NULL ) {
/* the note for SDL_GetRGBA above applies here too */
unsigned v;
v = (pixel & fmt->Rmask) >> fmt->Rshift;
*r = (v << fmt->Rloss) + (v >> (8 - (fmt->Rloss << 1)));
v = (pixel & fmt->Gmask) >> fmt->Gshift;
*g = (v << fmt->Gloss) + (v >> (8 - (fmt->Gloss << 1)));
v = (pixel & fmt->Bmask) >> fmt->Bshift;
*b = (v << fmt->Bloss) + (v >> (8 - (fmt->Bloss << 1)));
} else {
*r = fmt->palette->colors[pixel].r;
*g = fmt->palette->colors[pixel].g;
*b = fmt->palette->colors[pixel].b;
}
}
/* Apply gamma to a set of colors - this is easy. :) */
void LRSDL_ApplyGamma(Uint16 *gamma, SDL_Color *colors, SDL_Color *output,
int ncolors)
{
int i;
for ( i=0; i<ncolors; ++i ) {
output[i].r = gamma[0*256 + colors[i].r] >> 8;
output[i].g = gamma[1*256 + colors[i].g] >> 8;
output[i].b = gamma[2*256 + colors[i].b] >> 8;
}
}
/* Map from Palette to Palette */
static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
{
Uint8 *map;
int i;
if ( identical ) {
if ( src->ncolors <= dst->ncolors ) {
/* If an identical palette, no need to map */
if ( SDL_memcmp(src->colors, dst->colors, src->ncolors*
sizeof(SDL_Color)) == 0 ) {
*identical = 1;
return(NULL);
}
}
*identical = 0;
}
map = (Uint8 *)SDL_malloc(src->ncolors);
if ( map == NULL ) {
LRSDL_OutOfMemory();
return(NULL);
}
for ( i=0; i<src->ncolors; ++i ) {
map[i] = LRSDL_FindColor(dst,
src->colors[i].r, src->colors[i].g, src->colors[i].b);
}
return(map);
}
/* Map from Palette to BitField */
static Uint8 *Map1toN(SDL_PixelFormat *src, SDL_PixelFormat *dst)
{
Uint8 *map;
int i;
int bpp;
unsigned alpha;
SDL_Palette *pal = src->palette;
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
map = (Uint8 *)SDL_malloc(pal->ncolors*bpp);
if ( map == NULL ) {
LRSDL_OutOfMemory();
return(NULL);
}
alpha = dst->Amask ? src->alpha : 0;
/* We memory copy to the pixel map so the endianness is preserved */
for ( i=0; i<pal->ncolors; ++i ) {
ASSEMBLE_RGBA(&map[i*bpp], dst->BytesPerPixel, dst,
pal->colors[i].r, pal->colors[i].g,
pal->colors[i].b, alpha);
}
return(map);
}
/* Map from BitField to Dithered-Palette to Palette */
static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_PixelFormat *dst, int *identical)
{
/* Generate a 256 color dither palette */
SDL_Palette dithered;
SDL_Color colors[256];
SDL_Palette *pal = dst->palette;
/* SDL_DitherColors does not initialize the 'unused' component of colors,
but Map1to1 compares it against pal, so we should initialize it. */
SDL_memset(colors, 0, sizeof(colors));
dithered.ncolors = 256;
LRSDL_DitherColors(colors, 8);
dithered.colors = colors;
return(Map1to1(&dithered, pal, identical));
}
SDL_BlitMap *LRSDL_AllocBlitMap(void)
{
SDL_BlitMap *map;
/* Allocate the empty map */
map = (SDL_BlitMap *)SDL_malloc(sizeof(*map));
if ( map == NULL ) {
LRSDL_OutOfMemory();
return(NULL);
}
SDL_memset(map, 0, sizeof(*map));
/* Allocate the software blit data */
map->sw_data = (struct private_swaccel *)SDL_malloc(sizeof(*map->sw_data));
if ( map->sw_data == NULL ) {
LRSDL_FreeBlitMap(map);
LRSDL_OutOfMemory();
return(NULL);
}
SDL_memset(map->sw_data, 0, sizeof(*map->sw_data));
/* It's ready to go */
return(map);
}
void LRSDL_InvalidateMap(SDL_BlitMap *map)
{
if ( ! map ) {
return;
}
map->dst = NULL;
map->format_version = (unsigned int)-1;
if ( map->table ) {
SDL_free(map->table);
map->table = NULL;
}
}
int LRSDL_MapSurface (SDL_Surface *src, SDL_Surface *dst)
{
SDL_PixelFormat *srcfmt;
SDL_PixelFormat *dstfmt;
SDL_BlitMap *map;
/* Clear out any previous mapping */
map = src->map;
LRSDL_InvalidateMap(map);
/* Figure out what kind of mapping we're doing */
map->identity = 0;
srcfmt = src->format;
dstfmt = dst->format;
switch (srcfmt->BytesPerPixel) {
case 1:
switch (dstfmt->BytesPerPixel) {
case 1:
/* Palette --> Palette */
map->table = Map1to1(srcfmt->palette,
dstfmt->palette, &map->identity);
if ( ! map->identity ) {
if ( map->table == NULL ) {
return(-1);
}
}
if (srcfmt->BitsPerPixel!=dstfmt->BitsPerPixel)
map->identity = 0;
break;
default:
/* Palette --> BitField */
map->table = Map1toN(srcfmt, dstfmt);
if ( map->table == NULL ) {
return(-1);
}
break;
}
break;
default:
switch (dstfmt->BytesPerPixel) {
case 1:
/* BitField --> Palette */
map->table = MapNto1(srcfmt, dstfmt, &map->identity);
if ( ! map->identity ) {
if ( map->table == NULL ) {
return(-1);
}
}
map->identity = 0; /* Don't optimize to copy */
break;
default:
/* BitField --> BitField */
if ( FORMAT_EQUAL(srcfmt, dstfmt) )
map->identity = 1;
break;
}
break;
}
map->dst = dst;
map->format_version = dst->format_version;
/* Choose your blitters wisely */
return(LRSDL_CalculateBlit(src));
}
void LRSDL_FreeBlitMap(SDL_BlitMap *map)
{
if ( map ) {
LRSDL_InvalidateMap(map);
if ( map->sw_data != NULL ) {
SDL_free(map->sw_data);
}
SDL_free(map);
}
}

46
sdl/video/SDL_pixels_c.h Normal file
View File

@ -0,0 +1,46 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* Useful functions and variables from SDL_pixel.c */
#include "SDL_blit.h"
/* Pixel format functions */
extern SDL_PixelFormat *LRSDL_AllocFormat(int bpp,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern SDL_PixelFormat *LRSDL_ReallocFormat(SDL_Surface *surface, int bpp,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
extern void LRSDL_FormatChanged(SDL_Surface *surface);
extern void LRSDL_FreeFormat(SDL_PixelFormat *format);
/* Blit mapping functions */
extern SDL_BlitMap *LRSDL_AllocBlitMap(void);
extern void LRSDL_InvalidateMap(SDL_BlitMap *map);
extern int LRSDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
extern void LRSDL_FreeBlitMap(SDL_BlitMap *map);
/* Miscellaneous functions */
extern Uint16 LRSDL_CalculatePitch(SDL_Surface *surface);
extern void LRSDL_DitherColors(SDL_Color *colors, int bpp);
extern Uint8 LRSDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
extern void LRSDL_ApplyGamma(Uint16 *gamma, SDL_Color *colors, SDL_Color *output, int ncolors);

548
sdl/video/SDL_surface.c Normal file
View File

@ -0,0 +1,548 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_blit.h"
#include "SDL_pixels_c.h"
/* Public routines */
/*
* Create an empty RGB surface of the appropriate depth
*/
SDL_Surface * LRSDL_CreateRGBSurface (Uint32 flags,
int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
SDL_Surface *surface;
/* Make sure the size requested doesn't overflow our datatypes */
/* Next time I write a library like SDL, I'll use int for size. :) */
if ( width >= 16384 || height >= 65536 ) {
LRSDL_SetError("Width or height is too large");
return(NULL);
}
flags &= ~SDL_HWSURFACE;
/* Allocate the surface */
surface = (SDL_Surface *)SDL_malloc(sizeof(*surface));
if (!surface)
{
LRSDL_OutOfMemory();
return(NULL);
}
surface->flags = SDL_SWSURFACE;
surface->format = LRSDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
if (!surface->format)
{
SDL_free(surface);
return(NULL);
}
if (Amask)
surface->flags |= SDL_SRCALPHA;
surface->w = width;
surface->h = height;
surface->pitch = LRSDL_CalculatePitch(surface);
surface->pixels = NULL;
surface->offset = 0;
surface->hwdata = NULL;
surface->locked = 0;
surface->map = NULL;
surface->unused1 = 0;
LRSDL_SetClipRect(surface, NULL);
LRSDL_FormatChanged(surface);
/* Get the pixels */
if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE))
{
if ( surface->w && surface->h )
{
surface->pixels = SDL_malloc(surface->h*surface->pitch);
if (!surface->pixels)
{
LRSDL_FreeSurface(surface);
LRSDL_OutOfMemory();
return(NULL);
}
/* This is important for bitmaps */
SDL_memset(surface->pixels, 0, surface->h*surface->pitch);
}
}
/* Allocate an empty mapping */
surface->map = LRSDL_AllocBlitMap();
if (!surface->map)
{
LRSDL_FreeSurface(surface);
return(NULL);
}
/* The surface is ready to go */
surface->refcount = 1;
return(surface);
}
/*
* Create an RGB surface from an existing memory buffer
*/
SDL_Surface * LRSDL_CreateRGBSurfaceFrom (void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
{
SDL_Surface *surface;
surface = LRSDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
Rmask, Gmask, Bmask, Amask);
if (surface)
{
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
surface->h = height;
surface->pitch = pitch;
LRSDL_SetClipRect(surface, NULL);
}
return(surface);
}
/*
* Set the color key in a blittable surface
*/
int LRSDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key)
{
/* Sanity check the flag as it gets passed in */
if ( flag & SDL_SRCCOLORKEY ) {
if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
flag = (SDL_SRCCOLORKEY | SDL_RLEACCELOK);
} else {
flag = SDL_SRCCOLORKEY;
}
} else {
flag = 0;
}
/* Optimize away operations that don't change anything */
if ( (flag == (surface->flags & (SDL_SRCCOLORKEY|SDL_RLEACCELOK))) &&
(key == surface->format->colorkey) ) {
return(0);
}
if ( flag ) {
surface->flags |= SDL_SRCCOLORKEY;
surface->format->colorkey = key;
if ( flag & SDL_RLEACCELOK ) {
surface->flags |= SDL_RLEACCELOK;
} else {
surface->flags &= ~SDL_RLEACCELOK;
}
} else {
surface->flags &= ~(SDL_SRCCOLORKEY|SDL_RLEACCELOK);
surface->format->colorkey = 0;
}
LRSDL_InvalidateMap(surface->map);
return(0);
}
/* This function sets the alpha channel of a surface */
int LRSDL_SetAlpha (SDL_Surface *surface, Uint32 flag, Uint8 value)
{
Uint32 oldflags = surface->flags;
Uint32 oldalpha = surface->format->alpha;
/* Sanity check the flag as it gets passed in */
if ( flag & SDL_SRCALPHA ) {
if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
flag = (SDL_SRCALPHA | SDL_RLEACCELOK);
} else {
flag = SDL_SRCALPHA;
}
} else {
flag = 0;
}
/* Optimize away operations that don't change anything */
if ( (flag == (surface->flags & (SDL_SRCALPHA|SDL_RLEACCELOK))) &&
(!flag || value == oldalpha) ) {
return(0);
}
if ( flag ) {
surface->flags |= SDL_SRCALPHA;
surface->format->alpha = value;
if ( flag & SDL_RLEACCELOK ) {
surface->flags |= SDL_RLEACCELOK;
} else {
surface->flags &= ~SDL_RLEACCELOK;
}
} else {
surface->flags &= ~SDL_SRCALPHA;
surface->format->alpha = SDL_ALPHA_OPAQUE;
}
/*
* The representation for software surfaces is independent of
* per-surface alpha, so no need to invalidate the blit mapping
* if just the alpha value was changed. (If either is 255, we still
* need to invalidate.)
*/
if(oldflags != surface->flags || (((oldalpha + 1) ^ (value + 1)) & 0x100))
LRSDL_InvalidateMap(surface->map);
return(0);
}
int LRSDL_SetAlphaChannel(SDL_Surface *surface, Uint8 value)
{
int row, col;
int offset;
Uint8 *buf;
if ( (surface->format->Amask != 0xFF000000) &&
(surface->format->Amask != 0x000000FF) ) {
LRSDL_SetError("Unsupported surface alpha mask format");
return -1;
}
#ifdef MSB_FIRST
if ( surface->format->Amask == 0xFF000000 )
offset = 0;
else
offset = 3;
#else
if ( surface->format->Amask == 0xFF000000 )
offset = 3;
else
offset = 0;
#endif
row = surface->h;
while (row--) {
col = surface->w;
buf = (Uint8 *)surface->pixels + row * surface->pitch + offset;
while(col--) {
*buf = value;
buf += 4;
}
}
return 0;
}
/*
* A function to calculate the intersection of two rectangles:
* return true if the rectangles intersect, false otherwise
*/
static __inline__
SDL_bool LRSDL_IntersectRect(const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *intersection)
{
int Amin, Amax, Bmin, Bmax;
/* Horizontal intersection */
Amin = A->x;
Amax = Amin + A->w;
Bmin = B->x;
Bmax = Bmin + B->w;
if(Bmin > Amin)
Amin = Bmin;
intersection->x = Amin;
if(Bmax < Amax)
Amax = Bmax;
intersection->w = Amax - Amin > 0 ? Amax - Amin : 0;
/* Vertical intersection */
Amin = A->y;
Amax = Amin + A->h;
Bmin = B->y;
Bmax = Bmin + B->h;
if(Bmin > Amin)
Amin = Bmin;
intersection->y = Amin;
if(Bmax < Amax)
Amax = Bmax;
intersection->h = Amax - Amin > 0 ? Amax - Amin : 0;
return (SDL_bool)(intersection->w && intersection->h);
}
/*
* Set the clipping rectangle for a blittable surface
*/
SDL_bool LRSDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect)
{
SDL_Rect full_rect;
/* Don't do anything if there's no surface to act on */
if ( ! surface ) {
return SDL_FALSE;
}
/* Set up the full surface rectangle */
full_rect.x = 0;
full_rect.y = 0;
full_rect.w = surface->w;
full_rect.h = surface->h;
/* Set the clipping rectangle */
if ( ! rect ) {
surface->clip_rect = full_rect;
return (SDL_bool)1;
}
return LRSDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
}
/*
* Set up a blit between two surfaces -- split into three parts:
* The upper part, SDL_UpperBlit(), performs clipping and rectangle
* verification. The lower part is a pointer to a low level
* accelerated blitting function.
*
* These parts are separated out and each used internally by this
* library in the optimimum places. They are exported so that if
* you know exactly what you are doing, you can optimize your code
* by calling the one(s) you need.
*/
int LRSDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
/* Check to make sure the blit mapping is valid */
if ( (src->map->dst != dst) ||
(src->map->dst->format_version != src->map->format_version) ) {
if ( LRSDL_MapSurface(src, dst) < 0 ) {
return(-1);
}
}
return(src->map->sw_blit(src, srcrect, dst, dstrect));
}
int LRSDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
SDL_Surface *dst, SDL_Rect *dstrect)
{
SDL_Rect fulldst;
int srcx, srcy, w, h;
/* If the destination rectangle is NULL, use the entire dest surface */
if (!dstrect)
{
fulldst.x = fulldst.y = 0;
dstrect = &fulldst;
}
/* clip the source rectangle to the source surface */
if(srcrect) {
int maxw, maxh;
srcx = srcrect->x;
w = srcrect->w;
if(srcx < 0) {
w += srcx;
dstrect->x -= srcx;
srcx = 0;
}
maxw = src->w - srcx;
if(maxw < w)
w = maxw;
srcy = srcrect->y;
h = srcrect->h;
if(srcy < 0) {
h += srcy;
dstrect->y -= srcy;
srcy = 0;
}
maxh = src->h - srcy;
if(maxh < h)
h = maxh;
}
else
{
srcx = srcy = 0;
w = src->w;
h = src->h;
}
/* clip the destination rectangle against the clip rectangle */
{
SDL_Rect *clip = &dst->clip_rect;
int dx, dy;
dx = clip->x - dstrect->x;
if(dx > 0) {
w -= dx;
dstrect->x += dx;
srcx += dx;
}
dx = dstrect->x + w - clip->x - clip->w;
if(dx > 0)
w -= dx;
dy = clip->y - dstrect->y;
if(dy > 0) {
h -= dy;
dstrect->y += dy;
srcy += dy;
}
dy = dstrect->y + h - clip->y - clip->h;
if(dy > 0)
h -= dy;
}
if(w > 0 && h > 0) {
SDL_Rect sr;
sr.x = srcx;
sr.y = srcy;
sr.w = dstrect->w = w;
sr.h = dstrect->h = h;
return LRSDL_LowerBlit(src, &sr, dst, dstrect);
}
dstrect->w = dstrect->h = 0;
return 0;
}
/*
* This function performs a fast fill of the given rectangle with 'color'
*/
int LRSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
{
int x, y;
Uint8 *row;
if ( dstrect )
{
/* Perform clipping */
if ( !LRSDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) )
return(0);
}
else
{
/* If 'dstrect' == NULL, then fill the whole surface */
dstrect = &dst->clip_rect;
}
row = (Uint8 *)dst->pixels+dstrect->y*dst->pitch+
dstrect->x*dst->format->BytesPerPixel;
if ( dst->format->palette || (color == 0) ) {
x = dstrect->w*dst->format->BytesPerPixel;
if ( !color && !((uintptr_t)row&3) && !(x&3) && !(dst->pitch&3) ) {
int n = x >> 2;
for ( y=dstrect->h; y; --y ) {
SDL_memset4(row, 0, n);
row += dst->pitch;
}
} else {
{
for(y = dstrect->h; y; y--) {
SDL_memset(row, color, x);
row += dst->pitch;
}
}
}
} else {
switch (dst->format->BytesPerPixel) {
case 2:
for ( y=dstrect->h; y; --y ) {
Uint16 *pixels = (Uint16 *)row;
Uint16 c = (Uint16)color;
Uint32 cc = (Uint32)c << 16 | c;
int n = dstrect->w;
if((uintptr_t)pixels & 3) {
*pixels++ = c;
n--;
}
if(n >> 1)
SDL_memset4(pixels, cc, n >> 1);
if(n & 1)
pixels[n - 1] = c;
row += dst->pitch;
}
break;
case 3:
#ifdef MSB_FIRST
color <<= 8;
#endif
for ( y=dstrect->h; y; --y ) {
Uint8 *pixels = row;
for ( x=dstrect->w; x; --x ) {
SDL_memcpy(pixels, &color, 3);
pixels += 3;
}
row += dst->pitch;
}
break;
case 4:
for(y = dstrect->h; y; --y) {
SDL_memset4(row, color, dstrect->w);
row += dst->pitch;
}
break;
}
}
/* We're done! */
return(0);
}
/*
* Lock a surface to directly access the pixels
*/
int LRSDL_LockSurface (SDL_Surface *surface)
{
return(0);
}
/*
* Unlock a previously locked surface
*/
void LRSDL_UnlockSurface (SDL_Surface *surface)
{
surface->pixels = (Uint8 *)surface->pixels - surface->offset;
}
/*
* Free a surface created by the above function.
*/
void LRSDL_FreeSurface (SDL_Surface *surface)
{
/* Free anything that's not NULL, and not the screen surface */
if (!surface)
return;
if ( --surface->refcount > 0 )
return;
if (surface->format)
{
LRSDL_FreeFormat(surface->format);
surface->format = NULL;
}
if (surface->map)
{
LRSDL_FreeBlitMap(surface->map);
surface->map = NULL;
}
if ( surface->pixels &&
((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
SDL_free(surface->pixels);
}
SDL_free(surface);
}

75
sdl/video/SDL_sysvideo.h Normal file
View File

@ -0,0 +1,75 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifndef _SDL_sysvideo_h
#define _SDL_sysvideo_h
/* This file prototypes the video driver implementation.
This is designed to be easily converted to C++ in the future.
*/
/* The SDL video driver */
typedef struct SDL_VideoDevice SDL_VideoDevice;
/* Define the SDL video driver structure */
#define _THIS SDL_VideoDevice *_this
#ifndef _STATUS
#define _STATUS SDL_status *status
#endif
struct SDL_VideoDevice {
/* * * */
/* The name of this video driver */
const char *name;
int (*SetColors)(_THIS, int firstcolor, int ncolors,
SDL_Color *colors);
/* This pointer should exist in the native video subsystem and should
point to an appropriate update function for the current video mode
*/
void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
/* * * */
/* Data common to all drivers */
SDL_Surface *screen;
SDL_Surface *shadow;
SDL_Surface *visible;
SDL_Palette *physpal; /* physical palette, if != logical palette */
SDL_Color *gammacols; /* gamma-corrected colours, or NULL */
int offset_x;
int offset_y;
/* Driver information flags */
int handles_any_size; /* Driver handles any size video mode */
/* * * */
/* Data private to this driver */
struct SDL_PrivateVideoData *hidden;
/* * * */
/* The function used to dispose of this structure */
void (*free)(_THIS);
};
#undef _THIS
#endif /* _SDL_sysvideo_h */