Commit 79f25b0b authored by Sam Lantinga's avatar Sam Lantinga

Moved the colorkey and per-surface alpha into the blit info,

in preparation for support for general color channel modulation.

Removed and consolidated some data in the blit info.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402619
parent 2c7b38b0
...@@ -237,11 +237,6 @@ typedef struct SDL_PixelFormat ...@@ -237,11 +237,6 @@ typedef struct SDL_PixelFormat
Uint32 Gmask; Uint32 Gmask;
Uint32 Bmask; Uint32 Bmask;
Uint32 Amask; Uint32 Amask;
/* RGB color key information */
Uint32 colorkey;
/* Alpha value information (per-surface alpha) */
Uint8 alpha;
} SDL_PixelFormat; } SDL_PixelFormat;
/** /**
......
...@@ -859,7 +859,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -859,7 +859,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
y = dstrect->y; y = dstrect->y;
dstbuf = (Uint8 *) dst->pixels dstbuf = (Uint8 *) dst->pixels
+ y * dst->pitch + x * src->format->BytesPerPixel; + y * dst->pitch + x * src->format->BytesPerPixel;
srcbuf = (Uint8 *) src->map->sw_data->aux_data; srcbuf = (Uint8 *) src->map->data;
{ {
/* skip lines at the top if neccessary */ /* skip lines at the top if neccessary */
...@@ -906,7 +906,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -906,7 +906,7 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect,
} }
alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA
? src->format->alpha : 255; ? (src->map->cmod >> 24) : 255;
/* if left or right edge clipping needed, call clip blit */ /* if left or right edge clipping needed, call clip blit */
if (srcrect->x || srcrect->w != src->w) { if (srcrect->x || srcrect->w != src->w) {
RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha); RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
...@@ -1133,7 +1133,7 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -1133,7 +1133,7 @@ SDL_RLEAlphaBlit(SDL_Surface * src, SDL_Rect * srcrect,
x = dstrect->x; x = dstrect->x;
y = dstrect->y; y = dstrect->y;
dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel; dstbuf = (Uint8 *) dst->pixels + y * dst->pitch + x * df->BytesPerPixel;
srcbuf = (Uint8 *) src->map->sw_data->aux_data + sizeof(RLEDestFormat); srcbuf = (Uint8 *) src->map->data + sizeof(RLEDestFormat);
{ {
/* skip lines at the top if necessary */ /* skip lines at the top if necessary */
...@@ -1628,7 +1628,7 @@ RLEAlphaSurface(SDL_Surface * surface) ...@@ -1628,7 +1628,7 @@ RLEAlphaSurface(SDL_Surface * surface)
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
if (!p) if (!p)
p = rlebuf; p = rlebuf;
surface->map->sw_data->aux_data = p; surface->map->data = p;
} }
return 0; return 0;
...@@ -1715,7 +1715,7 @@ RLEColorkeySurface(SDL_Surface * surface) ...@@ -1715,7 +1715,7 @@ RLEColorkeySurface(SDL_Surface * surface)
skip = run = 0; skip = run = 0;
dst = rlebuf; dst = rlebuf;
rgbmask = ~surface->format->Amask; rgbmask = ~surface->format->Amask;
ckey = surface->format->colorkey & rgbmask; ckey = surface->map->ckey & rgbmask;
lastline = dst; lastline = dst;
getpix = getpixes[bpp - 1]; getpix = getpixes[bpp - 1];
w = surface->w; w = surface->w;
...@@ -1794,7 +1794,7 @@ RLEColorkeySurface(SDL_Surface * surface) ...@@ -1794,7 +1794,7 @@ RLEColorkeySurface(SDL_Surface * surface)
Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
if (!p) if (!p)
p = rlebuf; p = rlebuf;
surface->map->sw_data->aux_data = p; surface->map->data = p;
} }
return (0); return (0);
...@@ -1859,7 +1859,7 @@ UnRLEAlpha(SDL_Surface * surface) ...@@ -1859,7 +1859,7 @@ UnRLEAlpha(SDL_Surface * surface)
Uint8 *srcbuf; Uint8 *srcbuf;
Uint32 *dst; Uint32 *dst;
SDL_PixelFormat *sf = surface->format; SDL_PixelFormat *sf = surface->format;
RLEDestFormat *df = surface->map->sw_data->aux_data; RLEDestFormat *df = surface->map->data;
int (*uncopy_opaque) (Uint32 *, void *, int, int (*uncopy_opaque) (Uint32 *, void *, int,
RLEDestFormat *, SDL_PixelFormat *); RLEDestFormat *, SDL_PixelFormat *);
int (*uncopy_transl) (Uint32 *, void *, int, int (*uncopy_transl) (Uint32 *, void *, int,
...@@ -1948,7 +1948,7 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode) ...@@ -1948,7 +1948,7 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode)
} }
/* fill it with the background colour */ /* fill it with the background colour */
SDL_FillRect(surface, NULL, surface->format->colorkey); SDL_FillRect(surface, NULL, surface->map->ckey);
/* now render the encoded surface */ /* now render the encoded surface */
full.x = full.y = 0; full.x = full.y = 0;
...@@ -1967,9 +1967,9 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode) ...@@ -1967,9 +1967,9 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode)
} }
} }
if (surface->map && surface->map->sw_data->aux_data) { if (surface->map && surface->map->data) {
SDL_free(surface->map->sw_data->aux_data); SDL_free(surface->map->data);
surface->map->sw_data->aux_data = NULL; surface->map->data = NULL;
} }
} }
} }
......
...@@ -77,11 +77,12 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -77,11 +77,12 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect,
info.d_width = dstrect->w; info.d_width = dstrect->w;
info.d_height = dstrect->h; info.d_height = dstrect->h;
info.d_skip = dst->pitch - info.d_width * dst->format->BytesPerPixel; 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.src = src->format;
info.table = src->map->table; info.table = src->map->table;
info.dst = dst->format; info.dst = dst->format;
RunBlit = src->map->sw_data->blit; info.ckey = src->map->ckey;
info.cmod = src->map->cmod;
RunBlit = (SDL_loblit)src->map->data;
/* Run the actual software blit */ /* Run the actual software blit */
RunBlit(&info); RunBlit(&info);
...@@ -166,20 +167,21 @@ SDL_ChooseBlitFunc(SDL_BlitEntry * entries, int count) ...@@ -166,20 +167,21 @@ SDL_ChooseBlitFunc(SDL_BlitEntry * entries, int count)
int int
SDL_CalculateBlit(SDL_Surface * surface) SDL_CalculateBlit(SDL_Surface * surface)
{ {
SDL_loblit blit = NULL;
int blit_index; int blit_index;
/* Clean everything out to start */ /* Clean everything out to start */
if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
SDL_UnRLESurface(surface, 1); SDL_UnRLESurface(surface, 1);
} }
surface->map->sw_blit = NULL; surface->map->blit = NULL;
/* Get the blit function index, based on surface mode */ /* Get the blit function index, based on surface mode */
/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
blit_index = 0; blit_index = 0;
blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0; blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0;
if (surface->flags & SDL_SRCALPHA if (surface->flags & SDL_SRCALPHA
&& (surface->format->alpha != SDL_ALPHA_OPAQUE && ((surface->map->cmod >> 24) != SDL_ALPHA_OPAQUE
|| surface->format->Amask)) { || surface->format->Amask)) {
blit_index |= 2; blit_index |= 2;
} }
...@@ -188,34 +190,28 @@ SDL_CalculateBlit(SDL_Surface * surface) ...@@ -188,34 +190,28 @@ SDL_CalculateBlit(SDL_Surface * surface)
if (surface->map->identity && blit_index == 0) { if (surface->map->identity && blit_index == 0) {
/* Handle overlapping blits on the same surface */ /* Handle overlapping blits on the same surface */
if (surface == surface->map->dst) { if (surface == surface->map->dst) {
surface->map->sw_data->blit = SDL_BlitCopyOverlap; blit = SDL_BlitCopyOverlap;
} else { } else {
surface->map->sw_data->blit = SDL_BlitCopy; blit = SDL_BlitCopy;
} }
} else { } else {
if (surface->format->BitsPerPixel < 8) { if (surface->format->BitsPerPixel < 8) {
surface->map->sw_data->blit = blit = SDL_CalculateBlit0(surface, blit_index);
SDL_CalculateBlit0(surface, blit_index);
} else { } else {
switch (surface->format->BytesPerPixel) { switch (surface->format->BytesPerPixel) {
case 1: case 1:
surface->map->sw_data->blit = blit = SDL_CalculateBlit1(surface, blit_index);
SDL_CalculateBlit1(surface, blit_index);
break; break;
case 2: case 2:
case 3: case 3:
case 4: case 4:
surface->map->sw_data->blit = blit = SDL_CalculateBlitN(surface, blit_index);
SDL_CalculateBlitN(surface, blit_index);
break;
default:
surface->map->sw_data->blit = NULL;
break; break;
} }
} }
} }
/* Make sure we have a blit function */ /* Make sure we have a blit function */
if (surface->map->sw_data->blit == NULL) { if (blit == NULL) {
SDL_InvalidateMap(surface->map); SDL_InvalidateMap(surface->map);
SDL_SetError("Blit combination not supported"); SDL_SetError("Blit combination not supported");
return (-1); return (-1);
...@@ -227,15 +223,16 @@ SDL_CalculateBlit(SDL_Surface * surface) ...@@ -227,15 +223,16 @@ SDL_CalculateBlit(SDL_Surface * surface)
&& (blit_index == 1 && (blit_index == 1
|| (blit_index == 3 && !surface->format->Amask))) { || (blit_index == 3 && !surface->format->Amask))) {
if (SDL_RLESurface(surface) == 0) if (SDL_RLESurface(surface) == 0)
surface->map->sw_blit = SDL_RLEBlit; surface->map->blit = SDL_RLEBlit;
} else if (blit_index == 2 && surface->format->Amask) { } else if (blit_index == 2 && surface->format->Amask) {
if (SDL_RLESurface(surface) == 0) if (SDL_RLESurface(surface) == 0)
surface->map->sw_blit = SDL_RLEAlphaBlit; surface->map->blit = SDL_RLEAlphaBlit;
} }
} }
if (surface->map->sw_blit == NULL) { if (surface->map->blit == NULL) {
surface->map->sw_blit = SDL_SoftBlit; surface->map->blit = SDL_SoftBlit;
surface->map->data = blit;
} }
return (0); return (0);
} }
......
...@@ -45,30 +45,25 @@ typedef struct ...@@ -45,30 +45,25 @@ typedef struct
int d_width; int d_width;
int d_height; int d_height;
int d_skip; int d_skip;
void *aux_data;
SDL_PixelFormat *src; SDL_PixelFormat *src;
Uint8 *table; Uint8 *table;
SDL_PixelFormat *dst; SDL_PixelFormat *dst;
Uint32 ckey, cmod;
} SDL_BlitInfo; } SDL_BlitInfo;
/* The type definition for the low level blit functions */ /* The type definition for the low level blit functions */
typedef void (*SDL_loblit) (SDL_BlitInfo * info); 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 */ /* Blit mapping definition */
typedef struct SDL_BlitMap typedef struct SDL_BlitMap
{ {
SDL_Surface *dst; SDL_Surface *dst;
int identity; int identity;
Uint8 *table; Uint8 *table;
SDL_blit sw_blit; SDL_blit blit;
struct private_swaccel *sw_data; void *data;
Uint32 ckey; /* colorkey */
Uint32 cmod; /* ARGB modulation */
/* the version count matches the destination; mismatch indicates /* the version count matches the destination; mismatch indicates
an invalid mapping */ an invalid mapping */
......
...@@ -200,7 +200,7 @@ BlitBto1Key(SDL_BlitInfo * info) ...@@ -200,7 +200,7 @@ BlitBto1Key(SDL_BlitInfo * info)
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -253,7 +253,7 @@ BlitBto2Key(SDL_BlitInfo * info) ...@@ -253,7 +253,7 @@ BlitBto2Key(SDL_BlitInfo * info)
Uint16 *dstp = (Uint16 *) info->d_pixels; Uint16 *dstp = (Uint16 *) info->d_pixels;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -288,7 +288,7 @@ BlitBto3Key(SDL_BlitInfo * info) ...@@ -288,7 +288,7 @@ BlitBto3Key(SDL_BlitInfo * info)
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -322,7 +322,7 @@ BlitBto4Key(SDL_BlitInfo * info) ...@@ -322,7 +322,7 @@ BlitBto4Key(SDL_BlitInfo * info)
Uint32 *dstp = (Uint32 *) info->d_pixels; Uint32 *dstp = (Uint32 *) info->d_pixels;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -361,7 +361,7 @@ BlitBtoNAlpha(SDL_BlitInfo * info) ...@@ -361,7 +361,7 @@ BlitBtoNAlpha(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int dstbpp; int dstbpp;
int c; int c;
const int A = info->src->alpha; const int A = (info->cmod >> 24);
/* Set up some basic variables */ /* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel; dstbpp = dstfmt->BytesPerPixel;
...@@ -407,8 +407,8 @@ BlitBtoNAlphaKey(SDL_BlitInfo * info) ...@@ -407,8 +407,8 @@ BlitBtoNAlphaKey(SDL_BlitInfo * info)
const SDL_Color *srcpal = srcfmt->palette->colors; const SDL_Color *srcpal = srcfmt->palette->colors;
int dstbpp; int dstbpp;
int c; int c;
const int A = srcfmt->alpha; const int A = (info->cmod >> 24);
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = info->ckey;
/* Set up some basic variables */ /* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel; dstbpp = dstfmt->BytesPerPixel;
......
...@@ -290,7 +290,7 @@ Blit1to1Key(SDL_BlitInfo * info) ...@@ -290,7 +290,7 @@ Blit1to1Key(SDL_BlitInfo * info)
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
if (palmap) { if (palmap) {
while (height--) { while (height--) {
...@@ -337,7 +337,7 @@ Blit1to2Key(SDL_BlitInfo * info) ...@@ -337,7 +337,7 @@ Blit1to2Key(SDL_BlitInfo * info)
Uint16 *dstp = (Uint16 *) info->d_pixels; Uint16 *dstp = (Uint16 *) info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint16 *palmap = (Uint16 *) info->table; Uint16 *palmap = (Uint16 *) info->table;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
/* Set up some basic variables */ /* Set up some basic variables */
dstskip /= 2; dstskip /= 2;
...@@ -369,7 +369,7 @@ Blit1to3Key(SDL_BlitInfo * info) ...@@ -369,7 +369,7 @@ Blit1to3Key(SDL_BlitInfo * info)
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
int o; int o;
while (height--) { while (height--) {
...@@ -402,7 +402,7 @@ Blit1to4Key(SDL_BlitInfo * info) ...@@ -402,7 +402,7 @@ Blit1to4Key(SDL_BlitInfo * info)
Uint32 *dstp = (Uint32 *) info->d_pixels; Uint32 *dstp = (Uint32 *) info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 *palmap = (Uint32 *) info->table; Uint32 *palmap = (Uint32 *) info->table;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
/* Set up some basic variables */ /* Set up some basic variables */
dstskip /= 4; dstskip /= 4;
...@@ -436,7 +436,7 @@ Blit1toNAlpha(SDL_BlitInfo * info) ...@@ -436,7 +436,7 @@ Blit1toNAlpha(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors; const SDL_Color *srcpal = info->src->palette->colors;
int dstbpp; int dstbpp;
const int A = info->src->alpha; const int A = (info->cmod >> 24);
/* Set up some basic variables */ /* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel; dstbpp = dstfmt->BytesPerPixel;
...@@ -477,9 +477,9 @@ Blit1toNAlphaKey(SDL_BlitInfo * info) ...@@ -477,9 +477,9 @@ Blit1toNAlphaKey(SDL_BlitInfo * info)
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = info->src->palette->colors; const SDL_Color *srcpal = info->src->palette->colors;
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = info->ckey;
int dstbpp; int dstbpp;
const int A = srcfmt->alpha; const int A = (info->cmod >> 24);
/* Set up some basic variables */ /* Set up some basic variables */
dstbpp = dstfmt->BytesPerPixel; dstbpp = dstfmt->BytesPerPixel;
......
...@@ -41,7 +41,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info) ...@@ -41,7 +41,7 @@ BlitNto1SurfaceAlpha(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
const unsigned A = srcfmt->alpha; const unsigned A = (info->cmod >> 24);
while (height--) { while (height--) {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
...@@ -152,9 +152,9 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info) ...@@ -152,9 +152,9 @@ BlitNto1SurfaceAlphaKey(SDL_BlitInfo * info)
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = info->ckey;
const int A = srcfmt->alpha; const int A = (info->cmod >> 24);
while (height--) { while (height--) {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
...@@ -261,7 +261,7 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info) ...@@ -261,7 +261,7 @@ BlitRGBtoRGBSurfaceAlphaMMX(SDL_BlitInfo * info)
{ {
SDL_PixelFormat *df = info->dst; SDL_PixelFormat *df = info->dst;
Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask; Uint32 chanmask = df->Rmask | df->Gmask | df->Bmask;
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) { if (alpha == 128 && (df->Rmask | df->Gmask | df->Bmask) == 0x00FFFFFF) {
/* only call a128 version when R,G,B occupy lower bits */ /* only call a128 version when R,G,B occupy lower bits */
...@@ -718,7 +718,6 @@ Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info) ...@@ -718,7 +718,6 @@ Blit32to565PixelAlphaAltivec(SDL_BlitInfo * info)
static void static void
Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha;
int height = info->d_height; int height = info->d_height;
Uint32 *srcp = (Uint32 *) info->s_pixels; Uint32 *srcp = (Uint32 *) info->s_pixels;
int srcskip = info->s_skip >> 2; int srcskip = info->s_skip >> 2;
...@@ -726,10 +725,10 @@ Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) ...@@ -726,10 +725,10 @@ Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info)
int dstskip = info->d_skip >> 2; int dstskip = info->d_skip >> 2;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
unsigned sA = srcfmt->alpha; unsigned sA = (info->cmod >> 24);
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
vector unsigned char mergePermute; vector unsigned char mergePermute;
vector unsigned char vsrcPermute; vector unsigned char vsrcPermute;
vector unsigned char vdstPermute; vector unsigned char vdstPermute;
...@@ -1041,7 +1040,6 @@ static void ...@@ -1041,7 +1040,6 @@ static void
Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
{ {
/* XXX : 6 */ /* XXX : 6 */
unsigned alpha = info->src->alpha;
int height = info->d_height; int height = info->d_height;
Uint32 *srcp = (Uint32 *) info->s_pixels; Uint32 *srcp = (Uint32 *) info->s_pixels;
int srcskip = info->s_skip >> 2; int srcskip = info->s_skip >> 2;
...@@ -1049,7 +1047,7 @@ Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) ...@@ -1049,7 +1047,7 @@ Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
int dstskip = info->d_skip >> 2; int dstskip = info->d_skip >> 2;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
unsigned sA = srcfmt->alpha; unsigned sA = (info->cmod >> 24);
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
vector unsigned char mergePermute; vector unsigned char mergePermute;
vector unsigned char vsrcPermute; vector unsigned char vsrcPermute;
...@@ -1138,7 +1136,7 @@ Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) ...@@ -1138,7 +1136,7 @@ Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info)
static void static void
BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info) BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
int height = info->d_height; int height = info->d_height;
Uint32 *srcp = (Uint32 *) info->s_pixels; Uint32 *srcp = (Uint32 *) info->s_pixels;
int srcskip = info->s_skip >> 2; int srcskip = info->s_skip >> 2;
...@@ -1251,7 +1249,7 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info) ...@@ -1251,7 +1249,7 @@ BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo * info)
static void static void
BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
if (alpha == 128) { if (alpha == 128) {
BlitRGBtoRGBSurfaceAlpha128(info); BlitRGBtoRGBSurfaceAlpha128(info);
} else { } else {
...@@ -1560,7 +1558,7 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask) ...@@ -1560,7 +1558,7 @@ Blit16to16SurfaceAlpha128(SDL_BlitInfo * info, Uint16 mask)
static void static void
Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
if (alpha == 128) { if (alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xf7de); Blit16to16SurfaceAlpha128(info, 0xf7de);
} else { } else {
...@@ -1697,7 +1695,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) ...@@ -1697,7 +1695,7 @@ Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info)
static void static void
Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
if (alpha == 128) { if (alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xfbde); Blit16to16SurfaceAlpha128(info, 0xfbde);
} else { } else {
...@@ -1837,7 +1835,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) ...@@ -1837,7 +1835,7 @@ Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info)
static void static void
Blit565to565SurfaceAlpha(SDL_BlitInfo * info) Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; unsigned alpha = (info->cmod >> 24);
if (alpha == 128) { if (alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xf7de); Blit16to16SurfaceAlpha128(info, 0xf7de);
} else { } else {
...@@ -1876,7 +1874,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info) ...@@ -1876,7 +1874,7 @@ Blit565to565SurfaceAlpha(SDL_BlitInfo * info)
static void static void
Blit555to555SurfaceAlpha(SDL_BlitInfo * info) Blit555to555SurfaceAlpha(SDL_BlitInfo * info)
{ {
unsigned alpha = info->src->alpha; /* downscale alpha to 5 bits */ unsigned alpha = (info->cmod >> 24); /* downscale alpha to 5 bits */
if (alpha == 128) { if (alpha == 128) {
Blit16to16SurfaceAlpha128(info, 0xfbde); Blit16to16SurfaceAlpha128(info, 0xfbde);
} else { } else {
...@@ -2018,7 +2016,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info) ...@@ -2018,7 +2016,7 @@ BlitNtoNSurfaceAlpha(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel;
unsigned sA = srcfmt->alpha; unsigned sA = (info->cmod >> 24);
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
if (sA) { if (sA) {
...@@ -2060,10 +2058,10 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info) ...@@ -2060,10 +2058,10 @@ BlitNtoNSurfaceAlphaKey(SDL_BlitInfo * info)
int dstskip = info->d_skip; int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = info->ckey;
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel;
unsigned sA = srcfmt->alpha; unsigned sA = (info->cmod >> 24);
unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
while (height--) { while (height--) {
......
...@@ -322,8 +322,8 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info) ...@@ -322,8 +322,8 @@ Blit_RGB565_32Altivec(SDL_BlitInfo * info)
vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = (vector unsigned short) vec_splat_u8(-7);
vf800 = vec_sl(vf800, vec_splat_u16(8)); vf800 = vec_sl(vf800, vec_splat_u16(8));
if (dstfmt->Amask && srcfmt->alpha) { if (dstfmt->Amask && (info->cmod >> 24)) {
((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24);
valpha = vec_splat(valpha, 0); valpha = vec_splat(valpha, 0);
} else { } else {
alpha = 0; alpha = 0;
...@@ -470,8 +470,8 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info) ...@@ -470,8 +470,8 @@ Blit_RGB555_32Altivec(SDL_BlitInfo * info)
vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = (vector unsigned short) vec_splat_u8(-7);
vf800 = vec_sl(vf800, vec_splat_u16(8)); vf800 = vec_sl(vf800, vec_splat_u16(8));
if (dstfmt->Amask && srcfmt->alpha) { if (dstfmt->Amask && (info->cmod >> 24)) {
((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24);
valpha = vec_splat(valpha, 0); valpha = vec_splat(valpha, 0);
} else { } else {
alpha = 0; alpha = 0;
...@@ -569,9 +569,9 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info) ...@@ -569,9 +569,9 @@ Blit32to32KeyAltivec(SDL_BlitInfo * info)
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int dstbpp = dstfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel;
int copy_alpha = (srcfmt->Amask && dstfmt->Amask); int copy_alpha = (srcfmt->Amask && dstfmt->Amask);
unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
vector unsigned int valpha; vector unsigned int valpha;
vector unsigned char vpermute; vector unsigned char vpermute;
vector unsigned char vzero; vector unsigned char vzero;
...@@ -687,9 +687,9 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info) ...@@ -687,9 +687,9 @@ ConvertAltivec32to32_noprefetch(SDL_BlitInfo * info)
vector unsigned int vzero = vec_splat_u32(0); vector unsigned int vzero = vec_splat_u32(0);
vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
if (dstfmt->Amask && !srcfmt->Amask) { if (dstfmt->Amask && !srcfmt->Amask) {
if (srcfmt->alpha) { if ((info->cmod >> 24)) {
vector unsigned char valpha; vector unsigned char valpha;
((unsigned char *) &valpha)[0] = srcfmt->alpha; ((unsigned char *) &valpha)[0] = (info->cmod >> 24);
vzero = (vector unsigned int) vec_splat(valpha, 0); vzero = (vector unsigned int) vec_splat(valpha, 0);
} }
} }
...@@ -766,9 +766,9 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info) ...@@ -766,9 +766,9 @@ ConvertAltivec32to32_prefetch(SDL_BlitInfo * info)
vector unsigned int vzero = vec_splat_u32(0); vector unsigned int vzero = vec_splat_u32(0);
vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt);
if (dstfmt->Amask && !srcfmt->Amask) { if (dstfmt->Amask && !srcfmt->Amask) {
if (srcfmt->alpha) { if ((info->cmod >> 24)) {
vector unsigned char valpha; vector unsigned char valpha;
((unsigned char *) &valpha)[0] = srcfmt->alpha; ((unsigned char *) &valpha)[0] = (info->cmod >> 24);
vzero = (vector unsigned int) vec_splat(valpha, 0); vzero = (vector unsigned int) vec_splat(valpha, 0);
} }
} }
...@@ -2039,7 +2039,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info) ...@@ -2039,7 +2039,7 @@ Blit4to4MaskAlpha(SDL_BlitInfo * info)
if (dstfmt->Amask) { if (dstfmt->Amask) {
/* RGB->RGBA, SET_ALPHA */ /* RGB->RGBA, SET_ALPHA */
Uint32 mask = (srcfmt->alpha >> dstfmt->Aloss) << dstfmt->Ashift; Uint32 mask = ((info->cmod >> 24) >> dstfmt->Aloss) << dstfmt->Ashift;
while (height--) { while (height--) {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
...@@ -2087,7 +2087,7 @@ BlitNtoN(SDL_BlitInfo * info) ...@@ -2087,7 +2087,7 @@ BlitNtoN(SDL_BlitInfo * info)
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int dstbpp = dstfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
while (height--) { while (height--) {
/* *INDENT-OFF* */ /* *INDENT-OFF* */
...@@ -2150,7 +2150,7 @@ BlitNto1Key(SDL_BlitInfo * info) ...@@ -2150,7 +2150,7 @@ BlitNto1Key(SDL_BlitInfo * info)
int dstskip = info->d_skip; int dstskip = info->d_skip;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
const Uint8 *palmap = info->table; const Uint8 *palmap = info->table;
Uint32 ckey = srcfmt->colorkey; Uint32 ckey = info->ckey;
Uint32 rgbmask = ~srcfmt->Amask; Uint32 rgbmask = ~srcfmt->Amask;
int srcbpp; int srcbpp;
Uint32 Pixel; Uint32 Pixel;
...@@ -2214,7 +2214,7 @@ Blit2to2Key(SDL_BlitInfo * info) ...@@ -2214,7 +2214,7 @@ Blit2to2Key(SDL_BlitInfo * info)
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint16 *dstp = (Uint16 *) info->d_pixels; Uint16 *dstp = (Uint16 *) info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
Uint32 rgbmask = ~info->src->Amask; Uint32 rgbmask = ~info->src->Amask;
/* Set up some basic variables */ /* Set up some basic variables */
...@@ -2248,12 +2248,12 @@ BlitNtoNKey(SDL_BlitInfo * info) ...@@ -2248,12 +2248,12 @@ BlitNtoNKey(SDL_BlitInfo * info)
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int srcbpp = srcfmt->BytesPerPixel; int srcbpp = srcfmt->BytesPerPixel;
int dstbpp = dstfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel;
unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0;
Uint32 rgbmask = ~srcfmt->Amask; Uint32 rgbmask = ~srcfmt->Amask;
/* Set up some basic variables */ /* Set up some basic variables */
...@@ -2291,7 +2291,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) ...@@ -2291,7 +2291,7 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info)
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->d_pixels;
int dstskip = info->d_skip; int dstskip = info->d_skip;
Uint32 ckey = info->src->colorkey; Uint32 ckey = info->ckey;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
Uint32 rgbmask = ~srcfmt->Amask; Uint32 rgbmask = ~srcfmt->Amask;
...@@ -2332,70 +2332,69 @@ struct blit_table ...@@ -2332,70 +2332,69 @@ struct blit_table
int dstbpp; int dstbpp;
Uint32 dstR, dstG, dstB; Uint32 dstR, dstG, dstB;
Uint32 blit_features; Uint32 blit_features;
void *aux_data;
SDL_loblit blitfunc; SDL_loblit blitfunc;
enum enum
{ NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha; { NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha;
}; };
static const struct blit_table normal_blit_1[] = { static const struct blit_table normal_blit_1[] = {
/* Default for 8-bit RGB source, an invalid combination */ /* Default for 8-bit RGB source, an invalid combination */
{0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0, 0, NULL},
}; };
static const struct blit_table normal_blit_2[] = { static const struct blit_table normal_blit_2[] = {
#if SDL_ALTIVEC_BLITTERS #if SDL_ALTIVEC_BLITTERS
/* has-altivec */ /* has-altivec */
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
2, NULL, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, 2, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
{0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, {0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
2, NULL, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, 2, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
#endif #endif
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00,
0x000000FF, 0x000000FF,
0, NULL, Blit_RGB565_ARGB8888, SET_ALPHA}, 0, Blit_RGB565_ARGB8888, SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00,
0x00FF0000, 0x00FF0000,
0, NULL, Blit_RGB565_ABGR8888, SET_ALPHA}, 0, Blit_RGB565_ABGR8888, SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000,
0x0000FF00, 0x0000FF00,
0, NULL, Blit_RGB565_RGBA8888, SET_ALPHA}, 0, Blit_RGB565_RGBA8888, SET_ALPHA},
{0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000,
0xFF000000, 0xFF000000,
0, NULL, Blit_RGB565_BGRA8888, SET_ALPHA}, 0, Blit_RGB565_BGRA8888, SET_ALPHA},
/* Default for 16-bit RGB source, used if no other blitter matches */ /* Default for 16-bit RGB source, used if no other blitter matches */
{0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0} {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}; };
static const struct blit_table normal_blit_3[] = { static const struct blit_table normal_blit_3[] = {
/* Default for 24-bit RGB source, never optimized */ /* Default for 24-bit RGB source, never optimized */
{0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0} {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}; };
static const struct blit_table normal_blit_4[] = { static const struct blit_table normal_blit_4[] = {
#if SDL_ALTIVEC_BLITTERS #if SDL_ALTIVEC_BLITTERS
/* has-altivec | dont-use-prefetch */ /* has-altivec | dont-use-prefetch */
{0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
6, NULL, ConvertAltivec32to32_noprefetch, 6, ConvertAltivec32to32_noprefetch,
NO_ALPHA | COPY_ALPHA | SET_ALPHA}, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
/* has-altivec */ /* has-altivec */
{0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000,
0x00000000, 0x00000000,
2, NULL, ConvertAltivec32to32_prefetch, 2, ConvertAltivec32to32_prefetch,
NO_ALPHA | COPY_ALPHA | SET_ALPHA}, NO_ALPHA | COPY_ALPHA | SET_ALPHA},
/* has-altivec */ /* has-altivec */
{0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, {0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0,
0x0000001F, 0x0000001F,
2, NULL, Blit_RGB888_RGB565Altivec, NO_ALPHA}, 2, Blit_RGB888_RGB565Altivec, NO_ALPHA},
#endif #endif
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0,
0x0000001F, 0x0000001F,
0, NULL, Blit_RGB888_RGB565, NO_ALPHA}, 0, Blit_RGB888_RGB565, NO_ALPHA},
{0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0,
0x0000001F, 0x0000001F,
0, NULL, Blit_RGB888_RGB555, NO_ALPHA}, 0, Blit_RGB888_RGB555, NO_ALPHA},
/* Default for 32-bit RGB source, used if no other blitter matches */ /* Default for 32-bit RGB source, used if no other blitter matches */
{0, 0, 0, 0, 0, 0, 0, 0, NULL, BlitNtoN, 0} {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0}
}; };
static const struct blit_table *normal_blit[] = { static const struct blit_table *normal_blit[] = {
normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4 normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4
...@@ -2407,7 +2406,6 @@ static const struct blit_table *normal_blit[] = { ...@@ -2407,7 +2406,6 @@ static const struct blit_table *normal_blit[] = {
SDL_loblit SDL_loblit
SDL_CalculateBlitN(SDL_Surface * surface, int blit_index) SDL_CalculateBlitN(SDL_Surface * surface, int blit_index)
{ {
struct private_swaccel *sdata;
SDL_PixelFormat *srcfmt; SDL_PixelFormat *srcfmt;
SDL_PixelFormat *dstfmt; SDL_PixelFormat *dstfmt;
const struct blit_table *table; const struct blit_table *table;
...@@ -2415,7 +2413,6 @@ SDL_CalculateBlitN(SDL_Surface * surface, int blit_index) ...@@ -2415,7 +2413,6 @@ SDL_CalculateBlitN(SDL_Surface * surface, int blit_index)
SDL_loblit blitfun; SDL_loblit blitfun;
/* Set up data for choosing the blit */ /* Set up data for choosing the blit */
sdata = surface->map->sw_data;
srcfmt = surface->format; srcfmt = surface->format;
dstfmt = surface->map->dst->format; dstfmt = surface->map->dst->format;
...@@ -2486,7 +2483,6 @@ SDL_CalculateBlitN(SDL_Surface * surface, int blit_index) ...@@ -2486,7 +2483,6 @@ SDL_CalculateBlitN(SDL_Surface * surface, int blit_index)
table[which].blit_features)) table[which].blit_features))
break; break;
} }
sdata->aux_data = table[which].aux_data;
blitfun = table[which].blitfunc; blitfun = table[which].blitfunc;
if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */ if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
......
...@@ -351,7 +351,6 @@ SDL_AllocFormat(int bpp, ...@@ -351,7 +351,6 @@ SDL_AllocFormat(int bpp,
SDL_OutOfMemory(); SDL_OutOfMemory();
return (NULL); return (NULL);
} }
format->alpha = SDL_ALPHA_OPAQUE;
/* Set up the format */ /* Set up the format */
format->BitsPerPixel = bpp; format->BitsPerPixel = bpp;
...@@ -669,12 +668,12 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical) ...@@ -669,12 +668,12 @@ Map1to1(SDL_Palette * src, SDL_Palette * dst, int *identical)
/* Map from Palette to BitField */ /* Map from Palette to BitField */
static Uint8 * static Uint8 *
Map1toN(SDL_PixelFormat * src, SDL_PixelFormat * dst) Map1toN(SDL_PixelFormat * src, Uint32 cmod, SDL_PixelFormat * dst)
{ {
Uint8 *map; Uint8 *map;
int i; int i;
int bpp; int bpp;
unsigned alpha; unsigned Amod, Rmod, Gmod, Bmod;
SDL_Palette *pal = src->palette; SDL_Palette *pal = src->palette;
bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
...@@ -684,12 +683,18 @@ Map1toN(SDL_PixelFormat * src, SDL_PixelFormat * dst) ...@@ -684,12 +683,18 @@ Map1toN(SDL_PixelFormat * src, SDL_PixelFormat * dst)
return (NULL); return (NULL);
} }
alpha = dst->Amask ? src->alpha : 0; 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 */ /* We memory copy to the pixel map so the endianness is preserved */
for (i = 0; i < pal->ncolors; ++i) { for (i = 0; i < pal->ncolors; ++i) {
ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, Uint8 A = Amod;
pal->colors[i].r, pal->colors[i].g, Uint8 R = (pal->colors[i].r * Rmod) / 255;
pal->colors[i].b, alpha); Uint8 G = (pal->colors[i].g * Gmod) / 255;
Uint8 B = (pal->colors[i].b * Bmod) / 255;
ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
} }
return (map); return (map);
} }
...@@ -720,15 +725,7 @@ SDL_AllocBlitMap(void) ...@@ -720,15 +725,7 @@ SDL_AllocBlitMap(void)
SDL_OutOfMemory(); SDL_OutOfMemory();
return (NULL); return (NULL);
} }
map->cmod = 0xFFFFFFFF;
/* Allocate the software blit data */
map->sw_data =
(struct private_swaccel *) SDL_calloc(1, sizeof(*map->sw_data));
if (map->sw_data == NULL) {
SDL_FreeBlitMap(map);
SDL_OutOfMemory();
return (NULL);
}
/* It's ready to go */ /* It's ready to go */
return (map); return (map);
...@@ -783,7 +780,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) ...@@ -783,7 +780,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst)
default: default:
/* Palette --> BitField */ /* Palette --> BitField */
map->table = Map1toN(srcfmt, dstfmt); map->table = Map1toN(srcfmt, src->map->cmod, dstfmt);
if (map->table == NULL) { if (map->table == NULL) {
return (-1); return (-1);
} }
...@@ -823,9 +820,6 @@ SDL_FreeBlitMap(SDL_BlitMap * map) ...@@ -823,9 +820,6 @@ SDL_FreeBlitMap(SDL_BlitMap * map)
{ {
if (map) { if (map) {
SDL_InvalidateMap(map); SDL_InvalidateMap(map);
if (map->sw_data != NULL) {
SDL_free(map->sw_data);
}
SDL_free(map); SDL_free(map);
} }
} }
......
...@@ -231,7 +231,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key) ...@@ -231,7 +231,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
/* Optimize away operations that don't change anything */ /* Optimize away operations that don't change anything */
if ((flag == (surface->flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK))) && if ((flag == (surface->flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK))) &&
(key == surface->format->colorkey)) { (key == surface->map->ckey)) {
return (0); return (0);
} }
...@@ -242,7 +242,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key) ...@@ -242,7 +242,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
if (flag) { if (flag) {
surface->flags |= SDL_SRCCOLORKEY; surface->flags |= SDL_SRCCOLORKEY;
surface->format->colorkey = key; surface->map->ckey = key;
if (flag & SDL_RLEACCELOK) { if (flag & SDL_RLEACCELOK) {
surface->flags |= SDL_RLEACCELOK; surface->flags |= SDL_RLEACCELOK;
} else { } else {
...@@ -250,7 +250,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key) ...@@ -250,7 +250,7 @@ SDL_SetColorKey(SDL_Surface * surface, Uint32 flag, Uint32 key)
} }
} else { } else {
surface->flags &= ~(SDL_SRCCOLORKEY | SDL_RLEACCELOK); surface->flags &= ~(SDL_SRCCOLORKEY | SDL_RLEACCELOK);
surface->format->colorkey = 0; surface->map->ckey = 0;
} }
SDL_InvalidateMap(surface->map); SDL_InvalidateMap(surface->map);
return (0); return (0);
...@@ -261,7 +261,7 @@ int ...@@ -261,7 +261,7 @@ int
SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value) SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
{ {
Uint32 oldflags = surface->flags; Uint32 oldflags = surface->flags;
Uint32 oldalpha = surface->format->alpha; Uint32 oldalpha = (surface->map->cmod >> 24);
/* Sanity check the flag as it gets passed in */ /* Sanity check the flag as it gets passed in */
if (flag & SDL_SRCALPHA) { if (flag & SDL_SRCALPHA) {
...@@ -285,7 +285,8 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value) ...@@ -285,7 +285,8 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
if (flag) { if (flag) {
surface->flags |= SDL_SRCALPHA; surface->flags |= SDL_SRCALPHA;
surface->format->alpha = value; surface->map->cmod &= 0x00FFFFFF;
surface->map->cmod |= ((Uint32)value << 24);
if (flag & SDL_RLEACCELOK) { if (flag & SDL_RLEACCELOK) {
surface->flags |= SDL_RLEACCELOK; surface->flags |= SDL_RLEACCELOK;
} else { } else {
...@@ -293,7 +294,7 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value) ...@@ -293,7 +294,7 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
} }
} else { } else {
surface->flags &= ~SDL_SRCALPHA; surface->flags &= ~SDL_SRCALPHA;
surface->format->alpha = SDL_ALPHA_OPAQUE; surface->map->cmod |= 0xFF000000;
} }
/* /*
* The representation for software surfaces is independent of * The representation for software surfaces is independent of
...@@ -412,7 +413,7 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -412,7 +413,7 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect,
return (-1); return (-1);
} }
} }
return (src->map->sw_blit(src, srcrect, dst, dstrect)); return (src->map->blit(src, srcrect, dst, dstrect));
} }
...@@ -601,7 +602,7 @@ SDL_ConvertSurface(SDL_Surface * surface, ...@@ -601,7 +602,7 @@ SDL_ConvertSurface(SDL_Surface * surface,
if ((flags & SDL_SRCCOLORKEY) != SDL_SRCCOLORKEY && format->Amask) { if ((flags & SDL_SRCCOLORKEY) != SDL_SRCCOLORKEY && format->Amask) {
surface_flags &= ~SDL_SRCCOLORKEY; surface_flags &= ~SDL_SRCCOLORKEY;
} else { } else {
colorkey = surface->format->colorkey; colorkey = surface->map->ckey;
SDL_SetColorKey(surface, 0, 0); SDL_SetColorKey(surface, 0, 0);
} }
} }
...@@ -610,7 +611,7 @@ SDL_ConvertSurface(SDL_Surface * surface, ...@@ -610,7 +611,7 @@ SDL_ConvertSurface(SDL_Surface * surface,
if (format->Amask) { if (format->Amask) {
surface->flags &= ~SDL_SRCALPHA; surface->flags &= ~SDL_SRCALPHA;
} else { } else {
alpha = surface->format->alpha; alpha = (Uint8)(surface->map->cmod >> 24);
SDL_SetAlpha(surface, 0, 0); SDL_SetAlpha(surface, 0, 0);
} }
} }
......
...@@ -1595,7 +1595,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) ...@@ -1595,7 +1595,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
surface->pitch); surface->pitch);
} }
} else { } else {
Uint8 alpha; Uint32 cmod;
SDL_Rect bounds; SDL_Rect bounds;
SDL_Surface dst; SDL_Surface dst;
...@@ -1648,6 +1648,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) ...@@ -1648,6 +1648,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
} }
/* Copy over the alpha channel */ /* Copy over the alpha channel */
cmod = surface->map->cmod;
if (surface_flags & SDL_SRCALPHA) { if (surface_flags & SDL_SRCALPHA) {
if (fmt->Amask) { if (fmt->Amask) {
surface->flags &= ~SDL_SRCALPHA; surface->flags &= ~SDL_SRCALPHA;
...@@ -1655,7 +1656,6 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) ...@@ -1655,7 +1656,6 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
/* FIXME: Need to make sure the texture has an alpha channel /* FIXME: Need to make sure the texture has an alpha channel
* and copy 'alpha' into the texture alpha channel. * and copy 'alpha' into the texture alpha channel.
*/ */
alpha = surface->format->alpha;
SDL_SetAlpha(surface, 0, 0); SDL_SetAlpha(surface, 0, 0);
} }
} }
...@@ -1673,7 +1673,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) ...@@ -1673,7 +1673,7 @@ SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface)
if (fmt->Amask) { if (fmt->Amask) {
surface->flags |= SDL_SRCALPHA; surface->flags |= SDL_SRCALPHA;
} else { } else {
SDL_SetAlpha(surface, aflags, alpha); SDL_SetAlpha(surface, aflags, (cmod >> 24));
} }
} }
......
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