Mercurial > sdl-ios-xcode
changeset 2257:340942cfda48
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 17 Aug 2007 00:54:53 +0000 |
parents | e893d24ad8db |
children | 771bd3389e3a |
files | include/SDL_pixels.h src/video/SDL_RLEaccel.c src/video/SDL_blit.c src/video/SDL_blit.h src/video/SDL_blit_0.c src/video/SDL_blit_1.c src/video/SDL_blit_A.c src/video/SDL_blit_N.c src/video/SDL_pixels.c src/video/SDL_surface.c src/video/SDL_video.c |
diffstat | 11 files changed, 122 insertions(+), 146 deletions(-) [+] |
line wrap: on
line diff
--- a/include/SDL_pixels.h Thu Aug 16 22:56:18 2007 +0000 +++ b/include/SDL_pixels.h Fri Aug 17 00:54:53 2007 +0000 @@ -237,11 +237,6 @@ Uint32 Gmask; Uint32 Bmask; Uint32 Amask; - - /* RGB color key information */ - Uint32 colorkey; - /* Alpha value information (per-surface alpha) */ - Uint8 alpha; } SDL_PixelFormat; /**
--- a/src/video/SDL_RLEaccel.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_RLEaccel.c Fri Aug 17 00:54:53 2007 +0000 @@ -859,7 +859,7 @@ y = dstrect->y; dstbuf = (Uint8 *) dst->pixels + 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 */ @@ -906,7 +906,7 @@ } 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 (srcrect->x || srcrect->w != src->w) { RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha); @@ -1133,7 +1133,7 @@ x = dstrect->x; y = dstrect->y; 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 */ @@ -1628,7 +1628,7 @@ Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if (!p) p = rlebuf; - surface->map->sw_data->aux_data = p; + surface->map->data = p; } return 0; @@ -1715,7 +1715,7 @@ skip = run = 0; dst = rlebuf; rgbmask = ~surface->format->Amask; - ckey = surface->format->colorkey & rgbmask; + ckey = surface->map->ckey & rgbmask; lastline = dst; getpix = getpixes[bpp - 1]; w = surface->w; @@ -1794,7 +1794,7 @@ Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); if (!p) p = rlebuf; - surface->map->sw_data->aux_data = p; + surface->map->data = p; } return (0); @@ -1859,7 +1859,7 @@ Uint8 *srcbuf; Uint32 *dst; SDL_PixelFormat *sf = surface->format; - RLEDestFormat *df = surface->map->sw_data->aux_data; + RLEDestFormat *df = surface->map->data; int (*uncopy_opaque) (Uint32 *, void *, int, RLEDestFormat *, SDL_PixelFormat *); int (*uncopy_transl) (Uint32 *, void *, int, @@ -1948,7 +1948,7 @@ } /* 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 */ full.x = full.y = 0; @@ -1967,9 +1967,9 @@ } } - if (surface->map && surface->map->sw_data->aux_data) { - SDL_free(surface->map->sw_data->aux_data); - surface->map->sw_data->aux_data = NULL; + if (surface->map && surface->map->data) { + SDL_free(surface->map->data); + surface->map->data = NULL; } } }
--- a/src/video/SDL_blit.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit.c Fri Aug 17 00:54:53 2007 +0000 @@ -77,11 +77,12 @@ info.d_width = dstrect->w; info.d_height = dstrect->h; info.d_skip = dst->pitch - info.d_width * dst->format->BytesPerPixel; - info.aux_data = src->map->sw_data->aux_data; info.src = src->format; info.table = src->map->table; info.dst = dst->format; - RunBlit = src->map->sw_data->blit; + info.ckey = src->map->ckey; + info.cmod = src->map->cmod; + RunBlit = (SDL_loblit)src->map->data; /* Run the actual software blit */ RunBlit(&info); @@ -166,20 +167,21 @@ int SDL_CalculateBlit(SDL_Surface * surface) { + SDL_loblit blit = NULL; int blit_index; /* Clean everything out to start */ if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) { SDL_UnRLESurface(surface, 1); } - surface->map->sw_blit = NULL; + surface->map->blit = NULL; /* Get the blit function index, based on surface mode */ /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ blit_index = 0; blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0; if (surface->flags & SDL_SRCALPHA - && (surface->format->alpha != SDL_ALPHA_OPAQUE + && ((surface->map->cmod >> 24) != SDL_ALPHA_OPAQUE || surface->format->Amask)) { blit_index |= 2; } @@ -188,34 +190,28 @@ if (surface->map->identity && blit_index == 0) { /* Handle overlapping blits on the same surface */ if (surface == surface->map->dst) { - surface->map->sw_data->blit = SDL_BlitCopyOverlap; + blit = SDL_BlitCopyOverlap; } else { - surface->map->sw_data->blit = SDL_BlitCopy; + blit = SDL_BlitCopy; } } else { if (surface->format->BitsPerPixel < 8) { - surface->map->sw_data->blit = - SDL_CalculateBlit0(surface, blit_index); + blit = SDL_CalculateBlit0(surface, blit_index); } else { switch (surface->format->BytesPerPixel) { case 1: - surface->map->sw_data->blit = - SDL_CalculateBlit1(surface, blit_index); + blit = SDL_CalculateBlit1(surface, blit_index); break; case 2: case 3: case 4: - surface->map->sw_data->blit = - SDL_CalculateBlitN(surface, blit_index); - break; - default: - surface->map->sw_data->blit = NULL; + blit = SDL_CalculateBlitN(surface, blit_index); break; } } } /* Make sure we have a blit function */ - if (surface->map->sw_data->blit == NULL) { + if (blit == NULL) { SDL_InvalidateMap(surface->map); SDL_SetError("Blit combination not supported"); return (-1); @@ -227,15 +223,16 @@ && (blit_index == 1 || (blit_index == 3 && !surface->format->Amask))) { if (SDL_RLESurface(surface) == 0) - surface->map->sw_blit = SDL_RLEBlit; + surface->map->blit = SDL_RLEBlit; } else if (blit_index == 2 && surface->format->Amask) { if (SDL_RLESurface(surface) == 0) - surface->map->sw_blit = SDL_RLEAlphaBlit; + surface->map->blit = SDL_RLEAlphaBlit; } } - if (surface->map->sw_blit == NULL) { - surface->map->sw_blit = SDL_SoftBlit; + if (surface->map->blit == NULL) { + surface->map->blit = SDL_SoftBlit; + surface->map->data = blit; } return (0); }
--- a/src/video/SDL_blit.h Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit.h Fri Aug 17 00:54:53 2007 +0000 @@ -45,30 +45,25 @@ int d_width; int d_height; int d_skip; - void *aux_data; SDL_PixelFormat *src; Uint8 *table; SDL_PixelFormat *dst; + Uint32 ckey, cmod; } SDL_BlitInfo; /* The type definition for the low level blit functions */ typedef void (*SDL_loblit) (SDL_BlitInfo * info); -/* This is the private info structure for software accelerated blits */ -struct private_swaccel -{ - SDL_loblit blit; - void *aux_data; -}; - /* Blit mapping definition */ typedef struct SDL_BlitMap { SDL_Surface *dst; int identity; Uint8 *table; - SDL_blit sw_blit; - struct private_swaccel *sw_data; + SDL_blit blit; + void *data; + Uint32 ckey; /* colorkey */ + Uint32 cmod; /* ARGB modulation */ /* the version count matches the destination; mismatch indicates an invalid mapping */
--- a/src/video/SDL_blit_0.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit_0.c Fri Aug 17 00:54:53 2007 +0000 @@ -200,7 +200,7 @@ Uint8 *dst = info->d_pixels; int srcskip = info->s_skip; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; Uint8 *palmap = info->table; int c; @@ -253,7 +253,7 @@ Uint16 *dstp = (Uint16 *) info->d_pixels; int srcskip = info->s_skip; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; Uint8 *palmap = info->table; int c; @@ -288,7 +288,7 @@ Uint8 *dst = info->d_pixels; int srcskip = info->s_skip; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; Uint8 *palmap = info->table; int c; @@ -322,7 +322,7 @@ Uint32 *dstp = (Uint32 *) info->d_pixels; int srcskip = info->s_skip; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; Uint8 *palmap = info->table; int c; @@ -361,7 +361,7 @@ SDL_PixelFormat *dstfmt = info->dst; int dstbpp; int c; - const int A = info->src->alpha; + const int A = (info->cmod >> 24); /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; @@ -407,8 +407,8 @@ const SDL_Color *srcpal = srcfmt->palette->colors; int dstbpp; int c; - const int A = srcfmt->alpha; - Uint32 ckey = srcfmt->colorkey; + const int A = (info->cmod >> 24); + Uint32 ckey = info->ckey; /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel;
--- a/src/video/SDL_blit_1.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit_1.c Fri Aug 17 00:54:53 2007 +0000 @@ -290,7 +290,7 @@ Uint8 *dst = info->d_pixels; int dstskip = info->d_skip; Uint8 *palmap = info->table; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; if (palmap) { while (height--) { @@ -337,7 +337,7 @@ Uint16 *dstp = (Uint16 *) info->d_pixels; int dstskip = info->d_skip; Uint16 *palmap = (Uint16 *) info->table; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; /* Set up some basic variables */ dstskip /= 2; @@ -369,7 +369,7 @@ Uint8 *dst = info->d_pixels; int dstskip = info->d_skip; Uint8 *palmap = info->table; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; int o; while (height--) { @@ -402,7 +402,7 @@ Uint32 *dstp = (Uint32 *) info->d_pixels; int dstskip = info->d_skip; Uint32 *palmap = (Uint32 *) info->table; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; /* Set up some basic variables */ dstskip /= 4; @@ -436,7 +436,7 @@ SDL_PixelFormat *dstfmt = info->dst; const SDL_Color *srcpal = info->src->palette->colors; int dstbpp; - const int A = info->src->alpha; + const int A = (info->cmod >> 24); /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; @@ -477,9 +477,9 @@ SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; const SDL_Color *srcpal = info->src->palette->colors; - Uint32 ckey = srcfmt->colorkey; + Uint32 ckey = info->ckey; int dstbpp; - const int A = srcfmt->alpha; + const int A = (info->cmod >> 24); /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel;
--- a/src/video/SDL_blit_A.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit_A.c Fri Aug 17 00:54:53 2007 +0000 @@ -41,7 +41,7 @@ SDL_PixelFormat *dstfmt = info->dst; int srcbpp = srcfmt->BytesPerPixel; - const unsigned A = srcfmt->alpha; + const unsigned A = (info->cmod >> 24); while (height--) { /* *INDENT-OFF* */ @@ -152,9 +152,9 @@ SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; 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--) { /* *INDENT-OFF* */ @@ -261,7 +261,7 @@ { SDL_PixelFormat *df = info->dst; 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) { /* only call a128 version when R,G,B occupy lower bits */ @@ -718,7 +718,6 @@ static void Blit32to32SurfaceAlphaKeyAltivec(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; int height = info->d_height; Uint32 *srcp = (Uint32 *) info->s_pixels; int srcskip = info->s_skip >> 2; @@ -726,10 +725,10 @@ int dstskip = info->d_skip >> 2; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; - unsigned sA = srcfmt->alpha; + unsigned sA = (info->cmod >> 24); unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; vector unsigned char mergePermute; vector unsigned char vsrcPermute; vector unsigned char vdstPermute; @@ -1041,7 +1040,6 @@ Blit32to32SurfaceAlphaAltivec(SDL_BlitInfo * info) { /* XXX : 6 */ - unsigned alpha = info->src->alpha; int height = info->d_height; Uint32 *srcp = (Uint32 *) info->s_pixels; int srcskip = info->s_skip >> 2; @@ -1049,7 +1047,7 @@ int dstskip = info->d_skip >> 2; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; - unsigned sA = srcfmt->alpha; + unsigned sA = (info->cmod >> 24); unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; vector unsigned char mergePermute; vector unsigned char vsrcPermute; @@ -1138,7 +1136,7 @@ static void BlitRGBtoRGBSurfaceAlphaAltivec(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; + unsigned alpha = (info->cmod >> 24); int height = info->d_height; Uint32 *srcp = (Uint32 *) info->s_pixels; int srcskip = info->s_skip >> 2; @@ -1251,7 +1249,7 @@ static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; + unsigned alpha = (info->cmod >> 24); if (alpha == 128) { BlitRGBtoRGBSurfaceAlpha128(info); } else { @@ -1560,7 +1558,7 @@ static void Blit565to565SurfaceAlphaMMX(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; + unsigned alpha = (info->cmod >> 24); if (alpha == 128) { Blit16to16SurfaceAlpha128(info, 0xf7de); } else { @@ -1697,7 +1695,7 @@ static void Blit555to555SurfaceAlphaMMX(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; + unsigned alpha = (info->cmod >> 24); if (alpha == 128) { Blit16to16SurfaceAlpha128(info, 0xfbde); } else { @@ -1837,7 +1835,7 @@ static void Blit565to565SurfaceAlpha(SDL_BlitInfo * info) { - unsigned alpha = info->src->alpha; + unsigned alpha = (info->cmod >> 24); if (alpha == 128) { Blit16to16SurfaceAlpha128(info, 0xf7de); } else { @@ -1876,7 +1874,7 @@ static void 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) { Blit16to16SurfaceAlpha128(info, 0xfbde); } else { @@ -2018,7 +2016,7 @@ SDL_PixelFormat *dstfmt = info->dst; int srcbpp = srcfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel; - unsigned sA = srcfmt->alpha; + unsigned sA = (info->cmod >> 24); unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; if (sA) { @@ -2060,10 +2058,10 @@ int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; - Uint32 ckey = srcfmt->colorkey; + Uint32 ckey = info->ckey; int srcbpp = srcfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel; - unsigned sA = srcfmt->alpha; + unsigned sA = (info->cmod >> 24); unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0; while (height--) {
--- a/src/video/SDL_blit_N.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_blit_N.c Fri Aug 17 00:54:53 2007 +0000 @@ -322,8 +322,8 @@ vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); - if (dstfmt->Amask && srcfmt->alpha) { - ((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; + if (dstfmt->Amask && (info->cmod >> 24)) { + ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24); valpha = vec_splat(valpha, 0); } else { alpha = 0; @@ -470,8 +470,8 @@ vf800 = (vector unsigned short) vec_splat_u8(-7); vf800 = vec_sl(vf800, vec_splat_u16(8)); - if (dstfmt->Amask && srcfmt->alpha) { - ((unsigned char *) &valpha)[0] = alpha = srcfmt->alpha; + if (dstfmt->Amask && (info->cmod >> 24)) { + ((unsigned char *) &valpha)[0] = alpha = (info->cmod >> 24); valpha = vec_splat(valpha, 0); } else { alpha = 0; @@ -569,9 +569,9 @@ SDL_PixelFormat *dstfmt = info->dst; int dstbpp = dstfmt->BytesPerPixel; 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 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; vector unsigned int valpha; vector unsigned char vpermute; vector unsigned char vzero; @@ -687,9 +687,9 @@ vector unsigned int vzero = vec_splat_u32(0); vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); if (dstfmt->Amask && !srcfmt->Amask) { - if (srcfmt->alpha) { + if ((info->cmod >> 24)) { 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); } } @@ -766,9 +766,9 @@ vector unsigned int vzero = vec_splat_u32(0); vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); if (dstfmt->Amask && !srcfmt->Amask) { - if (srcfmt->alpha) { + if ((info->cmod >> 24)) { 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); } } @@ -2039,7 +2039,7 @@ if (dstfmt->Amask) { /* RGB->RGBA, SET_ALPHA */ - Uint32 mask = (srcfmt->alpha >> dstfmt->Aloss) << dstfmt->Ashift; + Uint32 mask = ((info->cmod >> 24) >> dstfmt->Aloss) << dstfmt->Ashift; while (height--) { /* *INDENT-OFF* */ @@ -2087,7 +2087,7 @@ int srcbpp = srcfmt->BytesPerPixel; SDL_PixelFormat *dstfmt = info->dst; int dstbpp = dstfmt->BytesPerPixel; - unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; + unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0; while (height--) { /* *INDENT-OFF* */ @@ -2150,7 +2150,7 @@ int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; const Uint8 *palmap = info->table; - Uint32 ckey = srcfmt->colorkey; + Uint32 ckey = info->ckey; Uint32 rgbmask = ~srcfmt->Amask; int srcbpp; Uint32 Pixel; @@ -2214,7 +2214,7 @@ int srcskip = info->s_skip; Uint16 *dstp = (Uint16 *) info->d_pixels; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; Uint32 rgbmask = ~info->src->Amask; /* Set up some basic variables */ @@ -2248,12 +2248,12 @@ int srcskip = info->s_skip; Uint8 *dst = info->d_pixels; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; int srcbpp = srcfmt->BytesPerPixel; int dstbpp = dstfmt->BytesPerPixel; - unsigned alpha = dstfmt->Amask ? srcfmt->alpha : 0; + unsigned alpha = dstfmt->Amask ? (info->cmod >> 24) : 0; Uint32 rgbmask = ~srcfmt->Amask; /* Set up some basic variables */ @@ -2291,7 +2291,7 @@ int srcskip = info->s_skip; Uint8 *dst = info->d_pixels; int dstskip = info->d_skip; - Uint32 ckey = info->src->colorkey; + Uint32 ckey = info->ckey; SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *dstfmt = info->dst; Uint32 rgbmask = ~srcfmt->Amask; @@ -2332,70 +2332,69 @@ int dstbpp; Uint32 dstR, dstG, dstB; Uint32 blit_features; - void *aux_data; SDL_loblit blitfunc; enum { NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha; }; static const struct blit_table normal_blit_1[] = { /* 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[] = { #if SDL_ALTIVEC_BLITTERS /* has-altivec */ {0x0000F800, 0x000007E0, 0x0000001F, 4, 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, 0x00000000, - 2, NULL, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, + 2, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, #endif {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0, NULL, Blit_RGB565_ARGB8888, SET_ALPHA}, + 0, Blit_RGB565_ARGB8888, SET_ALPHA}, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, - 0, NULL, Blit_RGB565_ABGR8888, SET_ALPHA}, + 0, Blit_RGB565_ABGR8888, SET_ALPHA}, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, - 0, NULL, Blit_RGB565_RGBA8888, SET_ALPHA}, + 0, Blit_RGB565_RGBA8888, SET_ALPHA}, {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 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 */ - {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[] = { /* 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[] = { #if SDL_ALTIVEC_BLITTERS /* has-altivec | dont-use-prefetch */ {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, - 6, NULL, ConvertAltivec32to32_noprefetch, + 6, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, /* has-altivec */ {0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, - 2, NULL, ConvertAltivec32to32_prefetch, + 2, ConvertAltivec32to32_prefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, /* has-altivec */ {0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, - 2, NULL, Blit_RGB888_RGB565Altivec, NO_ALPHA}, + 2, Blit_RGB888_RGB565Altivec, NO_ALPHA}, #endif {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F, - 0, NULL, Blit_RGB888_RGB565, NO_ALPHA}, + 0, Blit_RGB888_RGB565, NO_ALPHA}, {0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 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 */ - {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[] = { normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4 @@ -2407,7 +2406,6 @@ SDL_loblit SDL_CalculateBlitN(SDL_Surface * surface, int blit_index) { - struct private_swaccel *sdata; SDL_PixelFormat *srcfmt; SDL_PixelFormat *dstfmt; const struct blit_table *table; @@ -2415,7 +2413,6 @@ SDL_loblit blitfun; /* Set up data for choosing the blit */ - sdata = surface->map->sw_data; srcfmt = surface->format; dstfmt = surface->map->dst->format; @@ -2486,7 +2483,6 @@ table[which].blit_features)) break; } - sdata->aux_data = table[which].aux_data; blitfun = table[which].blitfunc; if (blitfun == BlitNtoN) { /* default C fallback catch-all. Slow! */
--- a/src/video/SDL_pixels.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_pixels.c Fri Aug 17 00:54:53 2007 +0000 @@ -351,7 +351,6 @@ SDL_OutOfMemory(); return (NULL); } - format->alpha = SDL_ALPHA_OPAQUE; /* Set up the format */ format->BitsPerPixel = bpp; @@ -669,12 +668,12 @@ /* Map from Palette to BitField */ static Uint8 * -Map1toN(SDL_PixelFormat * src, SDL_PixelFormat * dst) +Map1toN(SDL_PixelFormat * src, Uint32 cmod, SDL_PixelFormat * dst) { Uint8 *map; int i; int bpp; - unsigned alpha; + unsigned Amod, Rmod, Gmod, Bmod; SDL_Palette *pal = src->palette; bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); @@ -684,12 +683,18 @@ 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 */ for (i = 0; i < pal->ncolors; ++i) { - ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, - pal->colors[i].r, pal->colors[i].g, - pal->colors[i].b, alpha); + 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; + ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A); } return (map); } @@ -720,15 +725,7 @@ SDL_OutOfMemory(); return (NULL); } - - /* 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); - } + map->cmod = 0xFFFFFFFF; /* It's ready to go */ return (map); @@ -783,7 +780,7 @@ default: /* Palette --> BitField */ - map->table = Map1toN(srcfmt, dstfmt); + map->table = Map1toN(srcfmt, src->map->cmod, dstfmt); if (map->table == NULL) { return (-1); } @@ -823,9 +820,6 @@ { if (map) { SDL_InvalidateMap(map); - if (map->sw_data != NULL) { - SDL_free(map->sw_data); - } SDL_free(map); } }
--- a/src/video/SDL_surface.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_surface.c Fri Aug 17 00:54:53 2007 +0000 @@ -231,7 +231,7 @@ /* Optimize away operations that don't change anything */ if ((flag == (surface->flags & (SDL_SRCCOLORKEY | SDL_RLEACCELOK))) && - (key == surface->format->colorkey)) { + (key == surface->map->ckey)) { return (0); } @@ -242,7 +242,7 @@ if (flag) { surface->flags |= SDL_SRCCOLORKEY; - surface->format->colorkey = key; + surface->map->ckey = key; if (flag & SDL_RLEACCELOK) { surface->flags |= SDL_RLEACCELOK; } else { @@ -250,7 +250,7 @@ } } else { surface->flags &= ~(SDL_SRCCOLORKEY | SDL_RLEACCELOK); - surface->format->colorkey = 0; + surface->map->ckey = 0; } SDL_InvalidateMap(surface->map); return (0); @@ -261,7 +261,7 @@ SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value) { Uint32 oldflags = surface->flags; - Uint32 oldalpha = surface->format->alpha; + Uint32 oldalpha = (surface->map->cmod >> 24); /* Sanity check the flag as it gets passed in */ if (flag & SDL_SRCALPHA) { @@ -285,7 +285,8 @@ if (flag) { surface->flags |= SDL_SRCALPHA; - surface->format->alpha = value; + surface->map->cmod &= 0x00FFFFFF; + surface->map->cmod |= ((Uint32)value << 24); if (flag & SDL_RLEACCELOK) { surface->flags |= SDL_RLEACCELOK; } else { @@ -293,7 +294,7 @@ } } else { surface->flags &= ~SDL_SRCALPHA; - surface->format->alpha = SDL_ALPHA_OPAQUE; + surface->map->cmod |= 0xFF000000; } /* * The representation for software surfaces is independent of @@ -412,7 +413,7 @@ return (-1); } } - return (src->map->sw_blit(src, srcrect, dst, dstrect)); + return (src->map->blit(src, srcrect, dst, dstrect)); } @@ -601,7 +602,7 @@ if ((flags & SDL_SRCCOLORKEY) != SDL_SRCCOLORKEY && format->Amask) { surface_flags &= ~SDL_SRCCOLORKEY; } else { - colorkey = surface->format->colorkey; + colorkey = surface->map->ckey; SDL_SetColorKey(surface, 0, 0); } } @@ -610,7 +611,7 @@ if (format->Amask) { surface->flags &= ~SDL_SRCALPHA; } else { - alpha = surface->format->alpha; + alpha = (Uint8)(surface->map->cmod >> 24); SDL_SetAlpha(surface, 0, 0); } }
--- a/src/video/SDL_video.c Thu Aug 16 22:56:18 2007 +0000 +++ b/src/video/SDL_video.c Fri Aug 17 00:54:53 2007 +0000 @@ -1595,7 +1595,7 @@ surface->pitch); } } else { - Uint8 alpha; + Uint32 cmod; SDL_Rect bounds; SDL_Surface dst; @@ -1648,6 +1648,7 @@ } /* Copy over the alpha channel */ + cmod = surface->map->cmod; if (surface_flags & SDL_SRCALPHA) { if (fmt->Amask) { surface->flags &= ~SDL_SRCALPHA; @@ -1655,7 +1656,6 @@ /* FIXME: Need to make sure the texture has an alpha channel * and copy 'alpha' into the texture alpha channel. */ - alpha = surface->format->alpha; SDL_SetAlpha(surface, 0, 0); } } @@ -1673,7 +1673,7 @@ if (fmt->Amask) { surface->flags |= SDL_SRCALPHA; } else { - SDL_SetAlpha(surface, aflags, alpha); + SDL_SetAlpha(surface, aflags, (cmod >> 24)); } }