Commit 422ec364 authored by Sam Lantinga's avatar Sam Lantinga

Work in progress: merging new texture features into SDL blit system

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402624
parent 3f37bb54
...@@ -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->map->cmod >> 24) : 255; ? src->map->info.a : 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);
...@@ -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->map->ckey & rgbmask; ckey = surface->map->info.colorkey & rgbmask;
lastline = dst; lastline = dst;
getpix = getpixes[bpp - 1]; getpix = getpixes[bpp - 1];
w = surface->w; w = surface->w;
...@@ -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->map->ckey); SDL_FillRect(surface, NULL, surface->map->info.colorkey);
/* now render the encoded surface */ /* now render the encoded surface */
full.x = full.y = 0; full.x = full.y = 0;
......
...@@ -61,31 +61,23 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -61,31 +61,23 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect,
/* Set up source and destination buffer pointers, and BLIT! */ /* Set up source and destination buffer pointers, and BLIT! */
if (okay && srcrect->w && srcrect->h) { if (okay && srcrect->w && srcrect->h) {
SDL_BlitInfo info; SDL_BlitInfo *info = &src->map->info;
SDL_loblit RunBlit;
/* Set up the blit information */ /* Set up the blit information */
info.s_pixels = (Uint8 *) src->pixels + info->src = (Uint8 *) src->pixels +
(Uint16) srcrect->y * src->pitch + (Uint16) srcrect->y * src->pitch +
(Uint16) srcrect->x * src->format->BytesPerPixel; (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
info.s_width = srcrect->w; info.src_w = srcrect->w;
info.s_height = srcrect->h; info.src_h = srcrect->h;
info.s_skip = src->pitch - info.s_width * src->format->BytesPerPixel; info.dst = (Uint8 *) dst->pixels +
info.d_pixels = (Uint8 *) dst->pixels +
(Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->y * dst->pitch +
(Uint16) dstrect->x * dst->format->BytesPerPixel; (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
info.d_width = dstrect->w; info.dst_w = dstrect->w;
info.d_height = dstrect->h; info.dst_h = dstrect->h;
info.d_skip = dst->pitch - info.d_width * dst->format->BytesPerPixel; RunBlit = (SDL_BlitFunc) src->map->data;
info.src = src->format;
info.table = src->map->table;
info.dst = dst->format;
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);
} }
/* We need to unlock the surfaces if they're locked */ /* We need to unlock the surfaces if they're locked */
...@@ -124,50 +116,67 @@ SDL_UseAltivecPrefetch() ...@@ -124,50 +116,67 @@ SDL_UseAltivecPrefetch()
} }
#endif /* __MACOSX__ */ #endif /* __MACOSX__ */
static SDL_loblit static SDL_BlitFunc
SDL_ChooseBlitFunc(SDL_BlitEntry * entries, int count) SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntry * entries)
{ {
int i; int i;
static Uint32 features = 0xffffffff; static Uint32 features = 0xffffffff;
/* Get the available CPU features */
if (features == 0xffffffff) { if (features == 0xffffffff) {
const char *override = SDL_getenv("SDL_BLIT_FEATURES"); const char *override = SDL_getenv("SDL_BLIT_CPU_FEATURES");
features = SDL_BLIT_ANY; features = SDL_CPU_ANY;
/* Allow an override for testing .. */ /* Allow an override for testing .. */
if (override) { if (override) {
SDL_sscanf(override, "%u", &features); SDL_sscanf(override, "%u", &features);
} else { } else {
if (SDL_HasMMX()) { if (SDL_HasMMX()) {
features |= SDL_BLIT_MMX; features |= SDL_CPU_MMX;
}
if (SDL_Has3DNow()) {
features |= SDL_CPU_3DNOW;
} }
if (SDL_HasSSE()) { if (SDL_HasSSE()) {
features |= SDL_BLIT_SSE; features |= SDL_CPU_SSE;
}
if (SDL_HasSSE2()) {
features |= SDL_CPU_SSE2;
} }
if (SDL_HasAltiVec()) { if (SDL_HasAltiVec()) {
if (SDL_UseAltivecPrefetch()) { if (SDL_UseAltivecPrefetch()) {
features |= SDL_BLIT_ALTIVEC_PREFETCH; features |= SDL_CPU_ALTIVEC_PREFETCH;
} else { } else {
features |= SDL_BLIT_ALTIVEC_NOPREFETCH; features |= SDL_CPU_ALTIVEC_NOPREFETCH;
} }
} }
} }
} }
for (i = count; i > 0; --i) { for (i = 0; entries[i].blit; ++i) {
if (features & entries[i].features) { if (src_format != entries[i].src_format) {
return entries[i].blit; continue;
}
if (dst_format != entries[i].dst_format) {
continue;
}
if ((flags & entries[i].flags) != flags) {
continue;
} }
if (!(features & entries[i].cpu)) {
continue;
}
return entries[i].func;
} }
return entries[0].blit; return NULL;
} }
/* Figure out which of many blit routines to set up on a surface */ /* Figure out which of many blit routines to set up on a surface */
int int
SDL_CalculateBlit(SDL_Surface * surface) SDL_CalculateBlit(SDL_Surface * surface)
{ {
SDL_loblit blit = NULL; SDL_BlitFunc blit = NULL;
int blit_index; int blit_index;
/* Clean everything out to start */ /* Clean everything out to start */
...@@ -210,6 +219,10 @@ SDL_CalculateBlit(SDL_Surface * surface) ...@@ -210,6 +219,10 @@ SDL_CalculateBlit(SDL_Surface * surface)
} }
} }
} }
if (blit == NULL) {
blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_GeneratedBlitFuncTable);
}
/* Make sure we have a blit function */ /* Make sure we have a blit function */
if (blit == NULL) { if (blit == NULL) {
SDL_InvalidateMap(surface->map); SDL_InvalidateMap(surface->map);
......
...@@ -33,67 +33,74 @@ ...@@ -33,67 +33,74 @@
#ifdef __SSE__ #ifdef __SSE__
#include <xmmintrin.h> #include <xmmintrin.h>
#endif #endif
#ifdef __SSE2__
#include <emmintrin.h>
#endif
#include "SDL_cpuinfo.h" #include "SDL_cpuinfo.h"
#include "SDL_endian.h" #include "SDL_endian.h"
/* The structure passed to the low level blit functions */ /* SDL blit copy flags */
typedef struct #define SDL_COPY_MODULATE_COLOR 0x0001
{ #define SDL_COPY_MODULATE_ALPHA 0x0002
Uint8 *s_pixels; #define SDL_COPY_MASK 0x0010
int s_width; #define SDL_COPY_BLEND 0x0020
int s_height; #define SDL_COPY_ADD 0x0040
int s_skip; #define SDL_COPY_MOD 0x0080
Uint8 *d_pixels; #define SDL_COPY_COLORKEY 0x0100
int d_width; #define SDL_COPY_NEAREST 0x0200
int d_height;
int d_skip; /* SDL blit CPU flags */
SDL_PixelFormat *src; #define SDL_CPU_ANY 0x0000
#define SDL_CPU_MMX 0x0001
#define SDL_CPU_3DNOW 0x0002
#define SDL_CPU_SSE 0x0004
#define SDL_CPU_SSE2 0x0008
#define SDL_CPU_ALTIVEC_PREFETCH 0x0010
#define SDL_CPU_ALTIVEC_NOPREFETCH 0x0020
typedef struct {
Uint8 *src;
int src_w, src_h;
int src_pitch;
Uint8 *dst;
int dst_w, dst_h;
int dst_pitch;
SDL_PixelFormat *src_fmt;
SDL_PixelFormat *dst_fmt;
Uint8 *table; Uint8 *table;
SDL_PixelFormat *dst; int flags;
Uint32 ckey, cmod; Uint32 colorkey;
Uint8 r, g, b, a;
} SDL_BlitInfo; } SDL_BlitInfo;
/* The type definition for the low level blit functions */ typedef void (SDLCALL * SDL_BlitFunc)(SDL_BlitInfo *info);
typedef void (*SDL_loblit) (SDL_BlitInfo * info);
typedef struct {
Uint32 src_format;
Uint32 dst_format;
int flags;
int cpu;
SDL_BlitFunc func;
} SDL_BlitFuncEntry;
/* 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;
SDL_blit blit; SDL_blit blit;
void *data; void *data;
Uint32 ckey; /* colorkey */ SDL_BlitInfo info;
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 */
unsigned int format_version; unsigned int format_version;
} SDL_BlitMap; } SDL_BlitMap;
#define SDL_BLIT_ANY 0x00000000
#define SDL_BLIT_MMX 0x00000001
#define SDL_BLIT_SSE 0x00000002
#define SDL_BLIT_ALTIVEC_PREFETCH 0x00000004
#define SDL_BLIT_ALTIVEC_NOPREFETCH 0x00000008
typedef struct SDL_BlitEntry
{
Uint32 features;
SDL_loblit blit;
} SDL_BlitEntry;
/* Functions found in SDL_blit.c */ /* Functions found in SDL_blit.c */
extern int SDL_CalculateBlit(SDL_Surface * surface); extern int SDL_CalculateBlit(SDL_Surface * surface);
/* Functions found in SDL_blit_{0,1,N,A}.c */
extern SDL_loblit SDL_CalculateBlit0(SDL_Surface * surface, int complex);
extern SDL_loblit SDL_CalculateBlit1(SDL_Surface * surface, int complex);
extern SDL_loblit SDL_CalculateBlitN(SDL_Surface * surface, int complex);
extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface * surface, int complex);
/* /*
* Useful macros for blitting routines * Useful macros for blitting routines
*/ */
......
...@@ -35,12 +35,12 @@ BlitBto1(SDL_BlitInfo * info) ...@@ -35,12 +35,12 @@ BlitBto1(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = info->d_pixels; dst = info->dst;
dstskip = info->d_skip; dstskip = info->dst_pitch;
map = info->table; map = info->table;
srcskip += width - (width + 7) / 8; srcskip += width - (width + 7) / 8;
...@@ -90,12 +90,12 @@ BlitBto2(SDL_BlitInfo * info) ...@@ -90,12 +90,12 @@ BlitBto2(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = (Uint16 *) info->d_pixels; dst = (Uint16 *) info->dst;
dstskip = info->d_skip / 2; dstskip = info->dst_pitch / 2;
map = (Uint16 *) info->table; map = (Uint16 *) info->table;
srcskip += width - (width + 7) / 8; srcskip += width - (width + 7) / 8;
...@@ -125,12 +125,12 @@ BlitBto3(SDL_BlitInfo * info) ...@@ -125,12 +125,12 @@ BlitBto3(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = info->d_pixels; dst = info->dst;
dstskip = info->d_skip; dstskip = info->dst_pitch;
map = info->table; map = info->table;
srcskip += width - (width + 7) / 8; srcskip += width - (width + 7) / 8;
...@@ -164,12 +164,12 @@ BlitBto4(SDL_BlitInfo * info) ...@@ -164,12 +164,12 @@ BlitBto4(SDL_BlitInfo * info)
int c; int c;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = (Uint32 *) info->d_pixels; dst = (Uint32 *) info->dst;
dstskip = info->d_skip / 4; dstskip = info->dst_pitch / 4;
map = (Uint32 *) info->table; map = (Uint32 *) info->table;
srcskip += width - (width + 7) / 8; srcskip += width - (width + 7) / 8;
...@@ -194,12 +194,12 @@ BlitBto4(SDL_BlitInfo * info) ...@@ -194,12 +194,12 @@ BlitBto4(SDL_BlitInfo * info)
static void static void
BlitBto1Key(SDL_BlitInfo * info) BlitBto1Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -247,12 +247,12 @@ BlitBto1Key(SDL_BlitInfo * info) ...@@ -247,12 +247,12 @@ BlitBto1Key(SDL_BlitInfo * info)
static void static void
BlitBto2Key(SDL_BlitInfo * info) BlitBto2Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint16 *dstp = (Uint16 *) info->d_pixels; Uint16 *dstp = (Uint16 *) info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -282,12 +282,12 @@ BlitBto2Key(SDL_BlitInfo * info) ...@@ -282,12 +282,12 @@ BlitBto2Key(SDL_BlitInfo * info)
static void static void
BlitBto3Key(SDL_BlitInfo * info) BlitBto3Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -316,12 +316,12 @@ BlitBto3Key(SDL_BlitInfo * info) ...@@ -316,12 +316,12 @@ BlitBto3Key(SDL_BlitInfo * info)
static void static void
BlitBto4Key(SDL_BlitInfo * info) BlitBto4Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint32 *dstp = (Uint32 *) info->d_pixels; Uint32 *dstp = (Uint32 *) info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
int c; int c;
...@@ -351,12 +351,12 @@ BlitBto4Key(SDL_BlitInfo * info) ...@@ -351,12 +351,12 @@ BlitBto4Key(SDL_BlitInfo * info)
static void static void
BlitBtoNAlpha(SDL_BlitInfo * info) BlitBtoNAlpha(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
const SDL_Color *srcpal = info->src->palette->colors; const SDL_Color *srcpal = info->src->palette->colors;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
int dstbpp; int dstbpp;
...@@ -396,12 +396,12 @@ BlitBtoNAlpha(SDL_BlitInfo * info) ...@@ -396,12 +396,12 @@ BlitBtoNAlpha(SDL_BlitInfo * info)
static void static void
BlitBtoNAlphaKey(SDL_BlitInfo * info) BlitBtoNAlphaKey(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int srcskip = info->s_skip; int srcskip = info->s_skip;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
SDL_PixelFormat *srcfmt = info->src; SDL_PixelFormat *srcfmt = info->src;
SDL_PixelFormat *dstfmt = info->dst; SDL_PixelFormat *dstfmt = info->dst;
const SDL_Color *srcpal = srcfmt->palette->colors; const SDL_Color *srcpal = srcfmt->palette->colors;
......
...@@ -39,12 +39,12 @@ Blit1to1(SDL_BlitInfo * info) ...@@ -39,12 +39,12 @@ Blit1to1(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = info->d_pixels; dst = info->dst;
dstskip = info->d_skip; dstskip = info->dst_pitch;
map = info->table; map = info->table;
while (height--) { while (height--) {
...@@ -90,12 +90,12 @@ Blit1to2(SDL_BlitInfo * info) ...@@ -90,12 +90,12 @@ Blit1to2(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = info->d_pixels; dst = info->dst;
dstskip = info->d_skip; dstskip = info->dst_pitch;
map = (Uint16 *) info->table; map = (Uint16 *) info->table;
#ifdef USE_DUFFS_LOOP #ifdef USE_DUFFS_LOOP
...@@ -196,12 +196,12 @@ Blit1to3(SDL_BlitInfo * info) ...@@ -196,12 +196,12 @@ Blit1to3(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = info->d_pixels; dst = info->dst;
dstskip = info->d_skip; dstskip = info->dst_pitch;
map = info->table; map = info->table;
while (height--) { while (height--) {
...@@ -244,12 +244,12 @@ Blit1to4(SDL_BlitInfo * info) ...@@ -244,12 +244,12 @@ Blit1to4(SDL_BlitInfo * info)
int srcskip, dstskip; int srcskip, dstskip;
/* Set up some basic variables */ /* Set up some basic variables */
width = info->d_width; width = info->dst_w;
height = info->d_height; height = info->dst_h;
src = info->s_pixels; src = info->src;
srcskip = info->s_skip; srcskip = info->s_skip;
dst = (Uint32 *) info->d_pixels; dst = (Uint32 *) info->dst;
dstskip = info->d_skip / 4; dstskip = info->dst_pitch / 4;
map = (Uint32 *) info->table; map = (Uint32 *) info->table;
while (height--) { while (height--) {
...@@ -283,12 +283,12 @@ Blit1to4(SDL_BlitInfo * info) ...@@ -283,12 +283,12 @@ Blit1to4(SDL_BlitInfo * info)
static void static void
Blit1to1Key(SDL_BlitInfo * info) Blit1to1Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
...@@ -330,12 +330,12 @@ Blit1to1Key(SDL_BlitInfo * info) ...@@ -330,12 +330,12 @@ Blit1to1Key(SDL_BlitInfo * info)
static void static void
Blit1to2Key(SDL_BlitInfo * info) Blit1to2Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint16 *dstp = (Uint16 *) info->d_pixels; Uint16 *dstp = (Uint16 *) info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint16 *palmap = (Uint16 *) info->table; Uint16 *palmap = (Uint16 *) info->table;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
...@@ -362,12 +362,12 @@ Blit1to2Key(SDL_BlitInfo * info) ...@@ -362,12 +362,12 @@ Blit1to2Key(SDL_BlitInfo * info)
static void static void
Blit1to3Key(SDL_BlitInfo * info) Blit1to3Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint8 *palmap = info->table; Uint8 *palmap = info->table;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
int o; int o;
...@@ -395,12 +395,12 @@ Blit1to3Key(SDL_BlitInfo * info) ...@@ -395,12 +395,12 @@ Blit1to3Key(SDL_BlitInfo * info)
static void static void
Blit1to4Key(SDL_BlitInfo * info) Blit1to4Key(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint32 *dstp = (Uint32 *) info->d_pixels; Uint32 *dstp = (Uint32 *) info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
Uint32 *palmap = (Uint32 *) info->table; Uint32 *palmap = (Uint32 *) info->table;
Uint32 ckey = info->ckey; Uint32 ckey = info->ckey;
...@@ -427,12 +427,12 @@ Blit1to4Key(SDL_BlitInfo * info) ...@@ -427,12 +427,12 @@ Blit1to4Key(SDL_BlitInfo * info)
static void static void
Blit1toNAlpha(SDL_BlitInfo * info) Blit1toNAlpha(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
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;
...@@ -468,12 +468,12 @@ Blit1toNAlpha(SDL_BlitInfo * info) ...@@ -468,12 +468,12 @@ Blit1toNAlpha(SDL_BlitInfo * info)
static void static void
Blit1toNAlphaKey(SDL_BlitInfo * info) Blit1toNAlphaKey(SDL_BlitInfo * info)
{ {
int width = info->d_width; int width = info->dst_w;
int height = info->d_height; int height = info->dst_h;
Uint8 *src = info->s_pixels; Uint8 *src = info->src;
int srcskip = info->s_skip; int srcskip = info->s_skip;
Uint8 *dst = info->d_pixels; Uint8 *dst = info->dst;
int dstskip = info->d_skip; int dstskip = info->dst_pitch;
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;
......
This diff is collapsed.
This diff is collapsed.
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* *INDENT-OFF* */
extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable;
/* *INDENT-ON* */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -95,12 +95,12 @@ SDL_BlitCopy(SDL_BlitInfo * info) ...@@ -95,12 +95,12 @@ SDL_BlitCopy(SDL_BlitInfo * info)
int w, h; int w, h;
int srcskip, dstskip; int srcskip, dstskip;
w = info->d_width * info->dst->BytesPerPixel; w = info->dst_w * info->dst->BytesPerPixel;
h = info->d_height; h = info->dst_h;
src = info->s_pixels; src = info->src;
dst = info->d_pixels; dst = info->dst;
srcskip = w + info->s_skip; srcskip = w + info->s_skip;
dstskip = w + info->d_skip; dstskip = w + info->dst_pitch;
#ifdef __SSE__ #ifdef __SSE__
if (SDL_HasSSE() && !((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) { if (SDL_HasSSE() && !((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) {
...@@ -139,10 +139,10 @@ SDL_BlitCopyOverlap(SDL_BlitInfo * info) ...@@ -139,10 +139,10 @@ SDL_BlitCopyOverlap(SDL_BlitInfo * info)
int w, h; int w, h;
int skip; int skip;
w = info->d_width * info->dst->BytesPerPixel; w = info->dst_w * info->dst->BytesPerPixel;
h = info->d_height; h = info->dst_h;
src = info->s_pixels; src = info->src;
dst = info->d_pixels; dst = info->dst;
skip = w + info->s_skip; skip = w + info->s_skip;
if ((dst < src) || (dst >= (src + h * skip))) { if ((dst < src) || (dst >= (src + h * skip))) {
SDL_BlitCopy(info); SDL_BlitCopy(info);
......
/* DO NOT EDIT! This file is generated by sdlgenblit.pl */
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
/* *INDENT-OFF* */
#define SDL_RENDERCOPY_MODULATE_COLOR 0x0001
#define SDL_RENDERCOPY_MODULATE_ALPHA 0x0002
#define SDL_RENDERCOPY_MASK 0x0010
#define SDL_RENDERCOPY_BLEND 0x0020
#define SDL_RENDERCOPY_ADD 0x0040
#define SDL_RENDERCOPY_MOD 0x0080
#define SDL_RENDERCOPY_NEAREST 0x0100
typedef struct {
Uint8 *src;
int src_w, src_h;
int src_pitch;
Uint8 *dst;
int dst_w, dst_h;
int dst_pitch;
void *aux_data;
int flags;
Uint8 r, g, b, a;
} SDL_RenderCopyData;
typedef int (SDLCALL * SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data);
extern int SDLCALL SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data);
/* *INDENT-ON* */
/* vi: set ts=4 sw=4 expandtab: */
...@@ -667,7 +667,8 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, ...@@ -667,7 +667,8 @@ SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
if (texture->scaleMode) { if (texture->scaleMode) {
copydata.flags |= SDL_RENDERCOPY_NEAREST; copydata.flags |= SDL_RENDERCOPY_NEAREST;
} }
status = copyfunc(&copydata); copyfunc(&copydata);
status = 0;
} else { } else {
SDL_Rect real_srcrect = *srcrect; SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect; SDL_Rect real_dstrect;
......
...@@ -200,7 +200,8 @@ SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, ...@@ -200,7 +200,8 @@ SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
if (texture->scaleMode) { if (texture->scaleMode) {
copydata.flags |= SDL_RENDERCOPY_NEAREST; copydata.flags |= SDL_RENDERCOPY_NEAREST;
} }
return copyfunc(&copydata); copyfunc(&copydata);
return 0;
} else { } else {
SDL_Rect real_srcrect = *srcrect; SDL_Rect real_srcrect = *srcrect;
SDL_Rect real_dstrect = *dstrect; SDL_Rect real_dstrect = *dstrect;
......
This diff is collapsed.
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