Commit cf548d0a authored by Sam Lantinga's avatar Sam Lantinga

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

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402629
parent 2e91636d
......@@ -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,7 +608,7 @@ 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");
......@@ -616,7 +616,9 @@ SDL_DisplayFormat(SDL_Surface * surface)
}
/* 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
......
......@@ -38,9 +38,9 @@ BlitBto1(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_pitch;
dstskip = info->dst_skip;
map = info->table;
srcskip += width - (width + 7) / 8;
......@@ -93,9 +93,9 @@ BlitBto2(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = (Uint16 *) info->dst;
dstskip = info->dst_pitch / 2;
dstskip = info->dst_skip / 2;
map = (Uint16 *) info->table;
srcskip += width - (width + 7) / 8;
......@@ -128,9 +128,9 @@ BlitBto3(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_pitch;
dstskip = info->dst_skip;
map = info->table;
srcskip += width - (width + 7) / 8;
......@@ -167,9 +167,9 @@ BlitBto4(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = (Uint32 *) info->dst;
dstskip = info->dst_pitch / 4;
dstskip = info->dst_skip / 4;
map = (Uint32 *) info->table;
srcskip += width - (width + 7) / 8;
......@@ -198,9 +198,9 @@ BlitBto1Key(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint8 *dst = info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
Uint8 *palmap = info->table;
int c;
......@@ -251,9 +251,9 @@ BlitBto2Key(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint16 *dstp = (Uint16 *) info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
Uint8 *palmap = info->table;
int c;
......@@ -286,9 +286,9 @@ BlitBto3Key(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint8 *dst = info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
Uint8 *palmap = info->table;
int c;
......@@ -320,9 +320,9 @@ BlitBto4Key(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint32 *dstp = (Uint32 *) info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
Uint32 ckey = info->colorkey;
Uint8 *palmap = info->table;
int c;
......@@ -355,13 +355,13 @@ BlitBtoNAlpha(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint8 *dst = info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
const SDL_Color *srcpal = info->src->palette->colors;
SDL_PixelFormat *dstfmt = info->dst;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
const SDL_Color *srcpal = info->src_fmt->palette->colors;
SDL_PixelFormat *dstfmt = info->dst_fmt;
int dstbpp;
int c;
const int A = (info->cmod >> 24);
const int A = info->a;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
......@@ -400,15 +400,15 @@ BlitBtoNAlphaKey(SDL_BlitInfo * info)
int height = info->dst_h;
Uint8 *src = info->src;
Uint8 *dst = info->dst;
int srcskip = info->s_skip;
int dstskip = info->dst_pitch;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
int srcskip = info->src_skip;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
const SDL_Color *srcpal = srcfmt->palette->colors;
int dstbpp;
int c;
const int A = (info->cmod >> 24);
Uint32 ckey = info->ckey;
const int A = info->a;
Uint32 ckey = info->colorkey;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
......@@ -440,16 +440,16 @@ BlitBtoNAlphaKey(SDL_BlitInfo * info)
}
}
static SDL_loblit bitmap_blit[] = {
static SDL_BlitFunc bitmap_blit[] = {
NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
};
static SDL_loblit colorkey_blit[] = {
static SDL_BlitFunc colorkey_blit[] = {
NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
};
SDL_loblit
SDL_CalculateBlit0(SDL_Surface * surface, int blit_index)
SDL_BlitFunc
SDL_CalculateBlit0(SDL_Surface * surface)
{
int which;
......@@ -462,17 +462,17 @@ SDL_CalculateBlit0(SDL_Surface * surface, int blit_index)
} else {
which = surface->map->dst->format->BytesPerPixel;
}
switch (blit_index) {
case 0: /* copy */
switch (surface->map->info.flags) {
case 0:
return bitmap_blit[which];
case 1: /* colorkey */
case SDL_COPY_COLORKEY:
return colorkey_blit[which];
case 2: /* alpha */
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? BlitBtoNAlpha : NULL;
case 4: /* alpha + colorkey */
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? BlitBtoNAlphaKey : NULL;
}
return NULL;
......
......@@ -42,9 +42,9 @@ Blit1to1(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_pitch;
dstskip = info->dst_skip;
map = info->table;
while (height--) {
......@@ -93,9 +93,9 @@ Blit1to2(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_pitch;
dstskip = info->dst_skip;
map = (Uint16 *) info->table;
#ifdef USE_DUFFS_LOOP
......@@ -199,9 +199,9 @@ Blit1to3(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = info->dst;
dstskip = info->dst_pitch;
dstskip = info->dst_skip;
map = info->table;
while (height--) {
......@@ -247,9 +247,9 @@ Blit1to4(SDL_BlitInfo * info)
width = info->dst_w;
height = info->dst_h;
src = info->src;
srcskip = info->s_skip;
srcskip = info->src_skip;
dst = (Uint32 *) info->dst;
dstskip = info->dst_pitch / 4;
dstskip = info->dst_skip / 4;
map = (Uint32 *) info->table;
while (height--) {
......@@ -286,11 +286,11 @@ Blit1to1Key(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_pitch;
int dstskip = info->dst_skip;
Uint8 *palmap = info->table;
Uint32 ckey = info->ckey;
Uint32 ckey = info->colorkey;
if (palmap) {
while (height--) {
......@@ -333,11 +333,11 @@ Blit1to2Key(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint16 *dstp = (Uint16 *) info->dst;
int dstskip = info->dst_pitch;
int dstskip = info->dst_skip;
Uint16 *palmap = (Uint16 *) info->table;
Uint32 ckey = info->ckey;
Uint32 ckey = info->colorkey;
/* Set up some basic variables */
dstskip /= 2;
......@@ -365,11 +365,11 @@ Blit1to3Key(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_pitch;
int dstskip = info->dst_skip;
Uint8 *palmap = info->table;
Uint32 ckey = info->ckey;
Uint32 ckey = info->colorkey;
int o;
while (height--) {
......@@ -398,11 +398,11 @@ Blit1to4Key(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint32 *dstp = (Uint32 *) info->dst;
int dstskip = info->dst_pitch;
int dstskip = info->dst_skip;
Uint32 *palmap = (Uint32 *) info->table;
Uint32 ckey = info->ckey;
Uint32 ckey = info->colorkey;
/* Set up some basic variables */
dstskip /= 4;
......@@ -430,13 +430,13 @@ Blit1toNAlpha(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_pitch;
SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors;
int dstskip = info->dst_skip;
SDL_PixelFormat *dstfmt = info->dst_fmt;
const SDL_Color *srcpal = info->src_fmt->palette->colors;
int dstbpp;
const int A = (info->cmod >> 24);
const int A = info->a;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
......@@ -471,15 +471,15 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
int width = info->dst_w;
int height = info->dst_h;
Uint8 *src = info->src;
int srcskip = info->s_skip;
int srcskip = info->src_skip;
Uint8 *dst = info->dst;
int dstskip = info->dst_pitch;
SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors;
Uint32 ckey = info->ckey;
int dstskip = info->dst_skip;
SDL_PixelFormat *srcfmt = info->src_fmt;
SDL_PixelFormat *dstfmt = info->dst_fmt;
const SDL_Color *srcpal = info->src_fmt->palette->colors;
Uint32 ckey = info->colorkey;
int dstbpp;
const int A = (info->cmod >> 24);
const int A = info->a;
/* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel;
......@@ -510,16 +510,16 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
}
}
static SDL_loblit one_blit[] = {
static SDL_BlitFunc one_blit[] = {
NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
};
static SDL_loblit one_blitkey[] = {
static SDL_BlitFunc one_blitkey[] = {
NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
};
SDL_loblit
SDL_CalculateBlit1(SDL_Surface * surface, int blit_index)
SDL_BlitFunc
SDL_CalculateBlit1(SDL_Surface * surface)
{
int which;
SDL_PixelFormat *dstfmt;
......@@ -530,22 +530,21 @@ SDL_CalculateBlit1(SDL_Surface * surface, int blit_index)
} else {
which = dstfmt->BytesPerPixel;
}
switch (blit_index) {
case 0: /* copy */
switch (surface->map->info.flags) {
case 0:
return one_blit[which];
case 1: /* colorkey */
case SDL_COPY_COLORKEY:
return one_blitkey[which];
case 2: /* alpha */
case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
/* 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 */
case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
return which >= 2 ? Blit1toNAlphaKey : NULL;
}
return NULL;
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -5262,7 +5262,7 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
}
}
static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
{ SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
{ SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
{ SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
......
......@@ -95,12 +95,12 @@ SDL_BlitCopy(SDL_BlitInfo * info)
int w, h;
int srcskip, dstskip;
w = info->dst_w * info->dst->BytesPerPixel;
w = info->dst_w * info->dst_fmt->BytesPerPixel;
h = info->dst_h;
src = info->src;
dst = info->dst;
srcskip = w + info->s_skip;
dstskip = w + info->dst_pitch;
srcskip = info->src_pitch;
dstskip = info->dst_pitch;
#ifdef __SSE__
if (SDL_HasSSE() && !((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
......@@ -139,11 +139,11 @@ SDL_BlitCopyOverlap(SDL_BlitInfo * info)
int w, h;
int skip;
w = info->dst_w * info->dst->BytesPerPixel;
w = info->dst_w * info->dst_fmt->BytesPerPixel;
h = info->dst_h;
src = info->src;
dst = info->dst;
skip = w + info->s_skip;
skip = info->src_pitch;
if ((dst < src) || (dst >= (src + h * skip))) {
SDL_BlitCopy(info);
} else {
......
......@@ -668,12 +668,12 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
/* Map from Palette to BitField */
static Uint8 *
Map1toN(SDL_PixelFormat * src, Uint32 cmod, SDL_PixelFormat * dst)
Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
SDL_PixelFormat * dst)
{
Uint8 *map;
int i;
int bpp;
unsigned Amod, Rmod, Gmod, Bmod;
SDL_Palette *pal = src->palette;
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
......@@ -683,17 +683,12 @@ Map1toN(SDL_PixelFormat * src, Uint32 cmod, SDL_PixelFormat * dst)
return (NULL);
}
Amod = (cmod >> 24) & 0xFF;
Rmod = (cmod >> 16) & 0xFF;
Gmod = (cmod >> 8) & 0xFF;
Bmod = (cmod >> 0) & 0xFF;
/* We memory copy to the pixel map so the endianness is preserved */
for (i = 0; i < pal->ncolors; ++i) {
Uint8 A = Amod;
Uint8 R = (pal->colors[i].r * Rmod) / 255;
Uint8 G = (pal->colors[i].g * Gmod) / 255;
Uint8 B = (pal->colors[i].b * Bmod) / 255;
Uint8 R = (Uint8) ((pal->colors[i].r * Rmod) / 255);
Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255);
Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255);
ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
}
return (map);
......@@ -725,7 +720,10 @@ SDL_AllocBlitMap(void)
SDL_OutOfMemory();
return (NULL);
}
map->cmod = 0xFFFFFFFF;
map->info.r = 0xFF;
map->info.g = 0xFF;
map->info.b = 0xFF;
map->info.a = 0xFF;
/* It's ready to go */
return (map);
......@@ -739,9 +737,9 @@ SDL_InvalidateMap(SDL_BlitMap * map)
}
map->dst = NULL;
map->format_version = (unsigned int) -1;
if (map->table) {
SDL_free(map->table);
map->table = NULL;
if (map->info.table) {
SDL_free(map->info.table);
map->info.table = NULL;
}
}
int
......@@ -767,10 +765,10 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
switch (dstfmt->BytesPerPixel) {
case 1:
/* Palette --> Palette */
map->table =
map->info.table =
Map1to1(srcfmt->palette, dstfmt->palette, &map->identity);
if (!map->identity) {
if (map->table == NULL) {
if (map->info.table == NULL) {
return (-1);
}
}
......@@ -780,8 +778,10 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
default:
/* Palette --> BitField */
map->table = Map1toN(srcfmt, src->map->cmod, dstfmt);
if (map->table == NULL) {
map->info.table =
Map1toN(srcfmt, src->map->info.r, src->map->info.g,
src->map->info.b, src->map->info.a, dstfmt);
if (map->info.table == NULL) {
return (-1);
}
break;
......@@ -791,9 +791,9 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
switch (dstfmt->BytesPerPixel) {
case 1:
/* BitField --> Palette */
map->table = MapNto1(srcfmt, dstfmt, &map->identity);
map->info.table = MapNto1(srcfmt, dstfmt, &map->identity);
if (!map->identity) {
if (map->table == NULL) {
if (map->info.table == NULL) {
return (-1);
}
}
......
......@@ -26,7 +26,6 @@
#include "SDL_pixels_c.h"
#include "SDL_rect_c.h"
#include "SDL_yuv_sw_c.h"
#include "SDL_rendercopy.h"
/* SDL surface based renderer implementation */
......@@ -431,81 +430,33 @@ SW_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
}
}
static void
SW_UpdateRenderCopyFunc(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
SDL_DisplayMode *displayMode = &display->current_mode;
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
/* We only need a special copy function for advanced features */
if (texture->modMode
|| (texture->
blendMode & (SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD))
|| texture->scaleMode) {
surface->userdata =
SDL_GetRenderCopyFunc(texture->format, displayMode->format,
texture->modMode, texture->blendMode,
texture->scaleMode);
} else {
surface->userdata = NULL;
}
}
static int
SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
SW_UpdateRenderCopyFunc(renderer, texture);
return 0;
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
texture->b);
}
static int
SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
{
SW_UpdateRenderCopyFunc(renderer, texture);
return 0;
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
return SDL_SetSurfaceAlphaMod(surface, texture->a);
}
static int
SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->blendMode) {
case SDL_TEXTUREBLENDMODE_NONE:
case SDL_TEXTUREBLENDMODE_MASK:
case SDL_TEXTUREBLENDMODE_BLEND:
case SDL_TEXTUREBLENDMODE_ADD:
case SDL_TEXTUREBLENDMODE_MOD:
SW_UpdateRenderCopyFunc(renderer, texture);
return 0;
default:
SDL_Unsupported();
texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
SW_UpdateRenderCopyFunc(renderer, texture);
return -1;
}
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
}
static int
SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
{
switch (texture->scaleMode) {
case SDL_TEXTURESCALEMODE_NONE:
case SDL_TEXTURESCALEMODE_FAST:
SW_UpdateRenderCopyFunc(renderer, texture);
return 0;
case SDL_TEXTURESCALEMODE_SLOW:
case SDL_TEXTURESCALEMODE_BEST:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
SW_UpdateRenderCopyFunc(renderer, texture);
return -1;
default:
SDL_Unsupported();
texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
SW_UpdateRenderCopyFunc(renderer, texture);
return -1;
}
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
return SDL_SetSurfaceBlendMode(surface, texture->scaleMode);
}
static int
......@@ -629,60 +580,18 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
data->surface.pixels, data->surface.pitch);
} else {
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
if (copyfunc) {
SDL_RenderCopyData copydata;
copydata.src =
(Uint8 *) surface->pixels + srcrect->y * surface->pitch +
srcrect->x * surface->format->BytesPerPixel;
copydata.src_w = srcrect->w;
copydata.src_h = srcrect->h;
copydata.src_pitch = surface->pitch;
copydata.dst = (Uint8 *) data->surface.pixels;
copydata.dst_w = dstrect->w;
copydata.dst_h = dstrect->h;
copydata.dst_pitch = data->surface.pitch;
copydata.flags = 0;
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
copydata.r = texture->r;
copydata.g = texture->g;
copydata.b = texture->b;
}
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
copydata.a = texture->a;
}
if (texture->blendMode & SDL_TEXTUREBLENDMODE_MASK) {
copydata.flags |= SDL_RENDERCOPY_MASK;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_BLEND) {
copydata.flags |= SDL_RENDERCOPY_BLEND;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
copydata.flags |= SDL_RENDERCOPY_ADD;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
copydata.flags |= SDL_RENDERCOPY_MOD;
}
if (texture->scaleMode) {
copydata.flags |= SDL_RENDERCOPY_NEAREST;
}
copyfunc(&copydata);
status = 0;
} else {
SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect;
data->surface.w = dstrect->w;
data->surface.h = dstrect->h;
data->surface.clip_rect.w = dstrect->w;
data->surface.clip_rect.h = dstrect->h;
real_dstrect = data->surface.clip_rect;
status =
SDL_LowerBlit(surface, &real_srcrect, &data->surface,
&real_dstrect);
}
SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect;
data->surface.w = dstrect->w;
data->surface.h = dstrect->h;
data->surface.clip_rect.w = dstrect->w;
data->surface.clip_rect.h = dstrect->h;
real_dstrect = data->surface.clip_rect;
status =
SDL_LowerBlit(surface, &real_srcrect, &data->surface,
&real_dstrect);
}
data->renderer->UnlockTexture(data->renderer,
data->texture[data->current_texture]);
......
......@@ -53,9 +53,6 @@ SDL_CreateRGBSurface(Uint32 flags,
SDL_FreeSurface(surface);
return NULL;
}
if (Amask) {
surface->flags |= SDL_SRCALPHA;
}
surface->w = width;
surface->h = height;
surface->pitch = SDL_CalculatePitch(surface);
......@@ -138,6 +135,11 @@ SDL_CreateRGBSurface(Uint32 flags,
}
SDL_FormatChanged(surface);
/* By default surface with an alpha mask are set up for blending */
if (Amask) {
SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
}
/* The surface is ready to go */
surface->refcount = 1;
#ifdef CHECK_LEAKS
......@@ -212,26 +214,29 @@ SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette)
return 0;
}
int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
int
SDL_SetSurfaceRLE(SDL_Surface * surface, int flag)
{
Uint32 flags;
int flags;
if (!surface) {
return -1;
}
flags = surface->map->info.flags;
if (flag) {
surface->flags |= SDL_RLEACCELOK;
surface->map->info.flags |= SDL_COPY_RLE_DESIRED;
} else {
surface->flags &= ~SDL_RLEACCELOK;
surface->map->info.flags &= ~SDL_COPY_RLE_DESIRED;
}
if (surface->flags != flags) {
if (surface->map->info.flags != flags) {
SDL_InvalidateMap(surface->map);
}
return 0;
}
int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
int
SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
{
int flags;
......@@ -253,10 +258,19 @@ int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key)
if (surface->map->info.flags != flags) {
SDL_InvalidateMap(surface->map);
}
/* Compatibility mode */
if (surface->map->info.flags & SDL_COPY_COLORKEY) {
surface->flags |= SDL_SRCCOLORKEY;
} else {
surface->flags &= ~SDL_SRCCOLORKEY;
}
return 0;
}
int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
int
SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
{
int flags;
......@@ -281,7 +295,8 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
}
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 * r, Uint8 * g, Uint8 * b)
int
SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b)
{
if (!surface) {
return -1;
......@@ -299,7 +314,8 @@ int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 * r, Uint8 * g, Uint8 * b
return 0;
}
int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
int
SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha)
{
int flags;
......@@ -321,7 +337,8 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
return 0;
}
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 * alpha)
int
SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha)
{
if (!surface) {
return -1;
......@@ -333,7 +350,8 @@ int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 * alpha)
return 0;
}
int SDL_SetSurfaceBlendMode(SDL_Surface *surface, int blendMode)
int
SDL_SetSurfaceBlendMode(SDL_Surface * surface, int blendMode)
{
int flags, status;
......@@ -343,7 +361,8 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, int blendMode)
status = 0;
flags = surface->map->info.flags;
surface->map->info.flags &= ~(SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD);
surface->map->info.flags &=
~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
switch (blendMode) {
case SDL_TEXTUREBLENDMODE_NONE:
break;
......@@ -368,10 +387,19 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, int blendMode)
if (surface->map->info.flags != flags) {
SDL_InvalidateMap(surface->map);
}
/* Compatibility mode */
if (surface->map->info.flags & SDL_COPY_BLEND) {
surface->flags |= SDL_SRCALPHA;
} else {
surface->flags &= ~SDL_SRCALPHA;
}
return status;
}
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, int *blendMode)
int
SDL_GetSurfaceBlendMode(SDL_Surface * surface, int *blendMode)
{
if (!surface) {
return -1;
......@@ -381,27 +409,30 @@ int SDL_GetSurfaceBlendMode(SDL_Surface *surface, int *blendMode)
return 0;
}
switch(surface->map->info.flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
switch (surface->map->info.
flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
SDL_COPY_MOD)) {
case SDL_COPY_MASK:
*blendMode = SDL_TEXTUREBLENDMODE_MASK:
*blendMode = SDL_TEXTUREBLENDMODE_MASK;
break;
case SDL_COPY_BLEND:
*blendMode = SDL_TEXTUREBLENDMODE_BLEND:
*blendMode = SDL_TEXTUREBLENDMODE_BLEND;
break;
case SDL_COPY_ADD:
*blendMode = SDL_TEXTUREBLENDMODE_ADD:
*blendMode = SDL_TEXTUREBLENDMODE_ADD;
break;
case SDL_COPY_MOD:
*blendMode = SDL_TEXTUREBLENDMODE_MOD:
*blendMode = SDL_TEXTUREBLENDMODE_MOD;
break;
default:
*blendMode = SDL_TEXTUREBLENDMODE_NONE:
*blendMode = SDL_TEXTUREBLENDMODE_NONE;
break;
}
return 0;
}
int SDL_SetSurfaceScaleMode(SDL_Surface *surface, int scaleMode)
int
SDL_SetSurfaceScaleMode(SDL_Surface * surface, int scaleMode)
{
int flags, status;
......@@ -436,7 +467,8 @@ int SDL_SetSurfaceScaleMode(SDL_Surface *surface, int scaleMode)
return status;
}
int SDL_GetSurfaceScaleMode(SDL_Surface *surface, int *scaleMode)
int
SDL_GetSurfaceScaleMode(SDL_Surface * surface, int *scaleMode)
{
if (!surface) {
return -1;
......@@ -446,12 +478,12 @@ int SDL_GetSurfaceScaleMode(SDL_Surface *surface, int *scaleMode)
return 0;
}
switch(surface->map->info.flags & (SDL_COPY_LINEAR)) {
case SDL_COPY_LINEAR:
*scaleMode = SDL_TEXTURESCALEMODE_FAST:
switch (surface->map->info.flags & (SDL_COPY_NEAREST)) {
case SDL_COPY_NEAREST:
*scaleMode = SDL_TEXTURESCALEMODE_FAST;
break;
default:
*scaleMode = SDL_TEXTURESCALEMODE_NONE:
*scaleMode = SDL_TEXTURESCALEMODE_NONE;
break;
}
return 0;
......@@ -706,7 +738,8 @@ SDL_ConvertSurface(SDL_Surface * surface,
if (copy_flags & SDL_COPY_COLORKEY) {
Uint8 keyR, keyG, keyB, keyA;
SDL_GetRGBA(colorkey, surface->format, &keyR, &keyG, &keyB, &keyA);
SDL_GetRGBA(surface->map->info.colorkey, surface->format, &keyR,
&keyG, &keyB, &keyA);
SDL_SetColorKey(convert, 1,
SDL_MapRGBA(convert->format, keyR, keyG, keyB, keyA));
}
......
......@@ -1552,7 +1552,9 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
return 0;
}
} else {
if (surface->format->Amask || !(flags & (SDL_COPY_COLORKEY|SDL_COPY_MASK|SDL_COPY_BLEND))) {
if (surface->format->Amask
|| !(surface->map->info.flags &
(SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) {
bpp = fmt->BitsPerPixel;
Rmask = fmt->Rmask;
Gmask = fmt->Gmask;
......@@ -1602,31 +1604,34 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
dst_fmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
if (dst_fmt) {
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
dst_fmt->palette = SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
dst_fmt->palette =
SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format)));
if (dst_fmt->palette) {
if (fmt->palette) {
fixme
} else {
SDL_DitherColors(dst_fmt->palette->colors, SDL_BITSPERPIXEL(format));
}
}
if (fmt->palette) {
dst_fmt->palette = fmt->palette;
} else {
/* FIXME: Should we try to copy fmt->palette? */
SDL_DitherColors(dst_fmt->palette->colors,
SDL_BITSPERPIXEL(format));
}
}
cvt = SDL_ConvertSurface(surface, fmt, 0);
if (cvt) {
SDL_UpdateTexture(textureID, NULL, cvt->pixels, cvt->pitch);
SDL_FreeSurface(cvt);
dst = SDL_ConvertSurface(surface, dst_fmt, 0);
if (dst) {
SDL_UpdateTexture(textureID, NULL, dst->pixels, dst->pitch);
SDL_FreeSurface(dst);
}
SDL_FreeFormat(fmt);
if (dst_fmt->palette) {
SDL_FreePalette(dst_fmt->palette);
}
SDL_FreeFormat(dst_fmt);
}
if (!dst) {
SDL_DestroyTexture(textureID);
return 0;
}
}
if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) {
SDL_SetTexturePalette(textureID, fmt->palette->colors, 0, fmt->palette->ncolors);
SDL_SetTexturePalette(textureID, fmt->palette->colors, 0,
fmt->palette->ncolors);
}
return textureID;
......
......@@ -25,7 +25,6 @@
#include "../SDL_sysvideo.h"
#include "../SDL_yuv_sw_c.h"
#include "../SDL_renderer_sw.h"
#include "../SDL_rendercopy.h"
/* SDL surface based renderer implementation */
......@@ -160,55 +159,10 @@ SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
} else {
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
SDL_Surface *target = data->screens[data->current_screen];
SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect = *dstrect;
if (copyfunc) {
SDL_RenderCopyData copydata;
copydata.src =
(Uint8 *) surface->pixels + srcrect->y * surface->pitch +
srcrect->x * surface->format->BytesPerPixel;
copydata.src_w = srcrect->w;
copydata.src_h = srcrect->h;
copydata.src_pitch = surface->pitch;
copydata.dst =
(Uint8 *) target->pixels + dstrect->y * target->pitch +
dstrect->x * target->format->BytesPerPixel;
copydata.dst_w = dstrect->w;
copydata.dst_h = dstrect->h;
copydata.dst_pitch = target->pitch;
copydata.flags = 0;
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
copydata.r = texture->r;
copydata.g = texture->g;
copydata.b = texture->b;
}
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
copydata.a = texture->a;
}
if (texture->blendMode & SDL_TEXTUREBLENDMODE_MASK) {
copydata.flags |= SDL_RENDERCOPY_MASK;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_BLEND) {
copydata.flags |= SDL_RENDERCOPY_BLEND;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
copydata.flags |= SDL_RENDERCOPY_ADD;
} else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
copydata.flags |= SDL_RENDERCOPY_MOD;
}
if (texture->scaleMode) {
copydata.flags |= SDL_RENDERCOPY_NEAREST;
}
copyfunc(&copydata);
return 0;
} else {
SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect = *dstrect;
return SDL_LowerBlit(surface, &real_srcrect, target,
&real_dstrect);
}
return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
}
}
......
......@@ -384,7 +384,7 @@ __EOF__
sub output_copyfunctable
{
print FILE <<__EOF__;
static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
__EOF__
for (my $i = 0; $i <= $#src_formats; ++$i) {
my $src = $src_formats[$i];
......
......@@ -253,7 +253,7 @@ void
MoveSprite(SDL_Surface * screen, SDL_Surface * light)
{
SDL_Rect updates[2];
int alpha;
Uint8 alpha;
/* Erase the sprite if it was visible */
if (sprite_visible) {
......@@ -290,10 +290,10 @@ MoveSprite(SDL_Surface * screen, SDL_Surface * light)
}
/* Update transparency (fade in and out) */
alpha = sprite->format->alpha;
if ((alpha + alpha_vel) < 0) {
SDL_GetSurfaceAlphaMod(sprite, &alpha);
if (((int) alpha + alpha_vel) < 0) {
alpha_vel = -alpha_vel;
} else if ((alpha + alpha_vel) > 255) {
} else if (((int) alpha + alpha_vel) > 255) {
alpha_vel = -alpha_vel;
}
SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
......
......@@ -91,9 +91,6 @@ output_surface_details(const char *name, SDL_Surface * surface)
printf(" depth : %d bits per pixel\n",
surface->format->BitsPerPixel);
printf(" pitch : %d\n", (int) surface->pitch);
printf(" alpha : %d\n", (int) surface->format->alpha);
printf(" colorkey : 0x%X\n",
(unsigned int) surface->format->colorkey);
printf(" red bits : 0x%08X mask, %d shift, %d loss\n",
(int) surface->format->Rmask,
......@@ -216,8 +213,10 @@ setup_test(int argc, char **argv)
Uint32 origdstalphaflags = 0;
Uint32 srcalphaflags = 0;
Uint32 dstalphaflags = 0;
int srcalpha = 255;
int dstalpha = 255;
Uint8 origsrcalpha = 255;
Uint8 origdstalpha = 255;
Uint8 srcalpha = 255;
Uint8 dstalpha = 255;
int screenSurface = 0;
int i = 0;
......@@ -313,8 +312,10 @@ setup_test(int argc, char **argv)
(dest->flags & SDL_SRCALPHA) | (dest->flags & SDL_RLEACCEL);
origsrcalphaflags = srcalphaflags;
origdstalphaflags = dstalphaflags;
srcalpha = src->format->alpha;
dstalpha = dest->format->alpha;
SDL_GetSurfaceAlphaMod(src, &srcalpha);
SDL_GetSurfaceAlphaMod(dest, &dstalpha);
origsrcalpha = srcalpha;
origdstalpha = dstalpha;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
......@@ -339,12 +340,10 @@ setup_test(int argc, char **argv)
else if (strcmp(arg, "--dstnorleaccel") == 0)
dstalphaflags &= ~SDL_RLEACCEL;
}
if ((dstalphaflags != origdstalphaflags)
|| (dstalpha != dest->format->alpha))
SDL_SetAlpha(dest, dstalphaflags, (Uint8) dstalpha);
if ((srcalphaflags != origsrcalphaflags)
|| (srcalpha != src->format->alpha))
SDL_SetAlpha(src, srcalphaflags, (Uint8) srcalpha);
if ((dstalphaflags != origdstalphaflags) || (origdstalpha != dstalpha))
SDL_SetAlpha(dest, dstalphaflags, dstalpha);
if ((srcalphaflags != origsrcalphaflags) || (origsrcalpha != srcalpha))
SDL_SetAlpha(src, srcalphaflags, srcalpha);
/* set some sane defaults so we can see if the blit code is broken... */
SDL_FillRect(dest, NULL, SDL_MapRGB(dest->format, 0, 0, 0));
......
......@@ -201,7 +201,7 @@ SDL_GL_LoadTexture(SDL_Surface * surface, GLfloat * texcoord)
/* Save the alpha blending attributes */
saved_flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
saved_alpha = surface->format->alpha;
SDL_GetSurfaceAlphaMod(surface, &saved_alpha);
if ((saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
SDL_SetAlpha(surface, 0, 0);
}
......
......@@ -487,8 +487,6 @@ main(int argc, char **argv)
format.Gloss = 0;
format.Bloss = 0;
format.Aloss = 8;
format.colorkey = 0;
format.alpha = 0;
newsurf = SDL_ConvertSurface(pic, &format, SDL_SWSURFACE);
if (!newsurf) {
......
......@@ -521,8 +521,6 @@ main(int argc, char **argv)
format.Gloss = 0;
format.Bloss = 0;
format.Aloss = 8;
format.colorkey = 0;
format.alpha = 0;
newsurf =
SDL_ConvertSurface(MooseFrame[i], &format, SDL_SWSURFACE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment