Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Okay, still some bugs, but everything builds again...
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 18, 2007
1 parent 61f6c32 commit ec2a2ef
Show file tree
Hide file tree
Showing 23 changed files with 603 additions and 675 deletions.
5 changes: 3 additions & 2 deletions include/SDL_compat.h
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 13 additions & 11 deletions include/SDL_video.h
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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);


Expand All @@ -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);

Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);

/*
Expand Down
10 changes: 6 additions & 4 deletions src/SDL_compat.c
Expand Up @@ -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 *
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions src/video/SDL_RLEaccel.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
50 changes: 35 additions & 15 deletions src/video/SDL_blit.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
19 changes: 12 additions & 7 deletions src/video/SDL_blit.h
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit ec2a2ef

Please sign in to comment.