Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Okay, still some bugs, but everything builds again...

  • Loading branch information
slouken committed Aug 18, 2007
1 parent 61f6c32 commit ec2a2efc9ae9ad5dd9ad4c954015e012dd06efde
@@ -37,8 +37,8 @@ extern "C" {
#endif

#define SDL_SWSURFACE 0x00000000 /* Not used */
//#define SDL_SRCALPHA 0x00010000
//#define SDL_SRCCOLORKEY 0x00020000
#define SDL_SRCALPHA 0x00010000
#define SDL_SRCCOLORKEY 0x00020000
#define SDL_ANYFORMAT 0x00100000
#define SDL_HWPALETTE 0x00200000
#define SDL_DOUBLEBUF 0x00400000
@@ -48,6 +48,7 @@ extern "C" {
#define SDL_OPENGL 0x04000000
#define SDL_HWSURFACE 0x08000001 /* Not used */
#define SDL_ASYNCBLIT 0x08000000 /* Not used */
#define SDL_RLEACCELOK 0x08000000 /* Not used */
#define SDL_HWACCEL 0x08000000 /* Not used */

#define SDL_APPMOUSEFOCUS 0x01
@@ -265,7 +265,7 @@ typedef void *SDL_GLContext;
/* These are the currently supported flags for the SDL_surface */
/* Used internally (read-only) */
#define SDL_PREALLOC 0x00000001 /* Surface uses preallocated memory */
#define SDL_RLEACCEL 0x00000001 /* Surface is RLE encoded */
#define SDL_RLEACCEL 0x00000002 /* Surface is RLE encoded */

/* Evaluates to true if the surface needs to be locked before access */
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
@@ -1407,7 +1407,8 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
* \note If RLE is enabled, colorkey and alpha blending blits are much faster,
* but the surface must be locked before directly accessing the pixels.
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
int flag);

/*
* \fn int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
@@ -1420,7 +1421,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface *surface, int flag);
*
* \return 0 on success, or -1 if the surface is not valid
*/
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
Uint32 flag, Uint32 key);

/**
* \fn int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
@@ -1436,7 +1438,7 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, U
*
* \sa SDL_GetSurfaceColorMod()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
Uint8 r, Uint8 g, Uint8 b);


@@ -1454,7 +1456,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface *surface,
*
* \sa SDL_SetSurfaceColorMod()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
Uint8 * r, Uint8 * g,
Uint8 * b);

@@ -1470,7 +1472,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface *surface,
*
* \sa SDL_GetSurfaceAlphaMod()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
Uint8 alpha);

/**
@@ -1485,7 +1487,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface *surface,
*
* \sa SDL_SetSurfaceAlphaMod()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
Uint8 * alpha);

/**
@@ -1500,7 +1502,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface *surface,
*
* \sa SDL_GetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
int blendMode);

/**
@@ -1515,7 +1517,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface *surface,
*
* \sa SDL_SetSurfaceBlendMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
int *blendMode);

/**
@@ -1532,7 +1534,7 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface *surface,
*
* \sa SDL_GetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface,
int scaleMode);

/**
@@ -1547,7 +1549,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface *surface,
*
* \sa SDL_SetSurfaceScaleMode()
*/
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface *surface,
extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface,
int *scaleMode);

/*
@@ -608,15 +608,17 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
SDL_Surface *
SDL_DisplayFormat(SDL_Surface * surface)
{
Uint32 flags;
SDL_Surface *converted;

if (!SDL_PublicSurface) {
SDL_SetError("No video mode has been set");
return NULL;
}

/* Set the flags appropriate for copying to display surface */
return SDL_ConvertSurface(surface, SDL_PublicSurface->format, SDL_RLEACCELOK);
converted = SDL_ConvertSurface(surface, SDL_PublicSurface->format, 0);
SDL_SetSurfaceRLE(converted, 1);
return converted;
}

SDL_Surface *
@@ -625,7 +627,6 @@ SDL_DisplayFormatAlpha(SDL_Surface * surface)
SDL_PixelFormat *vf;
SDL_PixelFormat *format;
SDL_Surface *converted;
Uint32 flags;
/* default to ARGB8888 */
Uint32 amask = 0xff000000;
Uint32 rmask = 0x00ff0000;
@@ -666,7 +667,8 @@ SDL_DisplayFormatAlpha(SDL_Surface * surface)
break;
}
format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
converted = SDL_ConvertSurface(surface, format, SDL_RLEACCELOK);
converted = SDL_ConvertSurface(surface, format, 0);
SDL_SetSurfaceRLE(converted, 1);
SDL_FreeFormat(format);
return converted;
}
@@ -1821,13 +1821,13 @@ SDL_RLESurface(SDL_Surface * surface)

/* If we don't have colorkey or blending, nothing to do... */
flags = surface->map->info.flags;
if(!(flags & (SDL_COPY_COLORKEY|SDL_COPY_BLEND))) {
if (!(flags & (SDL_COPY_COLORKEY | SDL_COPY_BLEND))) {
return -1;
}

/* Pass on combinations not supported */
if ((flags & SDL_COPY_MODULATE_COLOR) ||
(flags & (SDL_COPY_ADD|SDL_COPY_MOD)) ||
(flags & (SDL_COPY_ADD | SDL_COPY_MOD)) ||
(flags & SDL_COPY_NEAREST)) {
return -1;
}
@@ -1971,7 +1971,8 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode)
}
}
}
surface->map->info.flags &= (SDL_COPY_RLE_COLORKEY|SDL_COPY_RLE_ALPHAKEY);
surface->map->info.flags &=
(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);

if (surface->map->data) {
SDL_free(surface->map->data);
@@ -71,11 +71,15 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect,
(Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
info->src_w = srcrect->w;
info->src_h = srcrect->h;
info->dst = (Uint8 *) dst->pixels +
(Uint16) dstrect->y * dst->pitch +
info->src_skip =
info->src_pitch - info->src_w * info->src_fmt->BytesPerPixel;
info->dst =
(Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch +
(Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
info->dst_w = dstrect->w;
info->dst_h = dstrect->h;
info->dst_skip =
info->dst_pitch - info->dst_w * info->dst_fmt->BytesPerPixel;
RunBlit = (SDL_BlitFunc) src->map->data;

/* Run the actual software blit */
@@ -119,7 +123,8 @@ SDL_UseAltivecPrefetch()
#endif /* __MACOSX__ */

static SDL_BlitFunc
SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
SDL_BlitFuncEntry * entries)
{
int i, flagcheck;
static Uint32 features = 0xffffffff;
@@ -166,13 +171,16 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFunc
}

/* Check modulation flags */
flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR));
flagcheck =
(flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_COLOR));
if ((flagcheck & entries[i].flags) != flagcheck) {
continue;
}

/* Check blend flags */
flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD));
flagcheck =
(flags &
(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
if ((flagcheck & entries[i].flags) != flagcheck) {
continue;
}
@@ -208,8 +216,6 @@ SDL_CalculateBlit(SDL_Surface * surface)
SDL_BlitFunc blit = NULL;
SDL_BlitMap *map = surface->map;
SDL_Surface *dst = map->dst;
Uint32 src_format;
Uint32 dst_format;

/* Clean everything out to start */
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
@@ -222,16 +228,13 @@ SDL_CalculateBlit(SDL_Surface * surface)
map->info.dst_pitch = dst->pitch;

/* See if we can do RLE acceleration */
if (surface->flags & SDL_RLEACCELOK) {
if (surface->map->info.flags & SDL_COPY_RLE_DESIRED) {
if (SDL_RLESurface(surface) == 0) {
return 0;
}
}

/* Choose a standard blit function */
src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);

if (map->identity && !map->info.flags) {
/* Handle overlapping blits on the same surface */
if (surface == dst) {
@@ -240,15 +243,32 @@ SDL_CalculateBlit(SDL_Surface * surface)
blit = SDL_BlitCopy;
}
} else if (surface->format->BitsPerPixel < 8) {
blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable0);
blit = SDL_CalculateBlit0(surface);
} else if (surface->format->BytesPerPixel == 1) {
blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable1);
blit = SDL_CalculateBlit1(surface);
} else if (map->info.flags & SDL_COPY_BLEND) {
blit = SDL_CalculateBlitA(surface);
} else {
blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTableN);
blit = SDL_CalculateBlitN(surface);
}
if (blit == NULL) {
blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_GeneratedBlitFuncTable);
Uint32 src_format =
SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel,
surface->format->Rmask,
surface->format->Gmask,
surface->format->Bmask,
surface->format->Amask);
Uint32 dst_format =
SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel,
dst->format->Rmask, dst->format->Gmask,
dst->format->Bmask,
dst->format->Amask);

blit =
SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
SDL_GeneratedBlitFuncTable);
}
map->data = blit;

/* Make sure we have a blit function */
if (blit == NULL) {
@@ -62,13 +62,16 @@
#define SDL_CPU_ALTIVEC_PREFETCH 0x00000010
#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020

typedef struct {
typedef struct
{
Uint8 *src;
int src_w, src_h;
int src_pitch;
int src_skip;
Uint8 *dst;
int dst_w, dst_h;
int dst_pitch;
int dst_skip;
SDL_PixelFormat *src_fmt;
SDL_PixelFormat *dst_fmt;
Uint8 *table;
@@ -77,9 +80,10 @@ typedef struct {
Uint8 r, g, b, a;
} SDL_BlitInfo;

typedef void (SDLCALL * SDL_BlitFunc)(SDL_BlitInfo *info);
typedef void (SDLCALL * SDL_BlitFunc) (SDL_BlitInfo * info);

typedef struct {
typedef struct
{
Uint32 src_format;
Uint32 dst_format;
int flags;
@@ -104,10 +108,11 @@ typedef struct SDL_BlitMap
/* Functions found in SDL_blit.c */
extern int SDL_CalculateBlit(SDL_Surface * surface);

/* Blit function tables in SDL_blit_*.c */
extern SDL_BlitFuncEntry SDL_BlitFuncTable0[];
extern SDL_BlitFuncEntry SDL_BlitFuncTable1[];
extern SDL_BlitFuncEntry SDL_BlitFuncTableN[];
/* Functions found in SDL_blit_*.c */
extern SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface * surface);
extern SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface * surface);
extern SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface * surface);
extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface);

/*
* Useful macros for blitting routines

0 comments on commit ec2a2ef

Please sign in to comment.