Commit 94de1268 authored by Sam Lantinga's avatar Sam Lantinga

More work in progress, still doesn't compile...

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402625
parent 422ec364
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
#include "SDL_blit.h" #include "SDL_blit.h"
#include "SDL_blit_auto.h"
#include "SDL_blit_copy.h" #include "SDL_blit_copy.h"
#include "SDL_RLEaccel_c.h" #include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h" #include "SDL_pixels_c.h"
...@@ -61,19 +62,20 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect, ...@@ -61,19 +62,20 @@ 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_BlitFunc RunBlit;
SDL_BlitInfo *info = &src->map->info; SDL_BlitInfo *info = &src->map->info;
/* Set up the blit information */ /* Set up the blit information */
info->src = (Uint8 *) src->pixels + info->src = (Uint8 *) src->pixels +
(Uint16) srcrect->y * src->pitch + (Uint16) srcrect->y * src->pitch +
(Uint16) srcrect->x * info->src_fmt->BytesPerPixel; (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
info.src_w = srcrect->w; info->src_w = srcrect->w;
info.src_h = srcrect->h; info->src_h = srcrect->h;
info.dst = (Uint8 *) dst->pixels + info->dst = (Uint8 *) dst->pixels +
(Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->y * dst->pitch +
(Uint16) dstrect->x * info->dst_fmt->BytesPerPixel; (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
info.dst_w = dstrect->w; info->dst_w = dstrect->w;
info.dst_h = dstrect->h; info->dst_h = dstrect->h;
RunBlit = (SDL_BlitFunc) src->map->data; RunBlit = (SDL_BlitFunc) src->map->data;
/* Run the actual software blit */ /* Run the actual software blit */
...@@ -117,7 +119,7 @@ SDL_UseAltivecPrefetch() ...@@ -117,7 +119,7 @@ SDL_UseAltivecPrefetch()
#endif /* __MACOSX__ */ #endif /* __MACOSX__ */
static SDL_BlitFunc static SDL_BlitFunc
SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntry * entries) SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
{ {
int i; int i;
static Uint32 features = 0xffffffff; static Uint32 features = 0xffffffff;
...@@ -154,7 +156,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntr ...@@ -154,7 +156,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitEntr
} }
} }
for (i = 0; entries[i].blit; ++i) { for (i = 0; entries[i].func; ++i) {
if (src_format != entries[i].src_format) { if (src_format != entries[i].src_format) {
continue; continue;
} }
...@@ -177,44 +179,43 @@ int ...@@ -177,44 +179,43 @@ int
SDL_CalculateBlit(SDL_Surface * surface) SDL_CalculateBlit(SDL_Surface * surface)
{ {
SDL_BlitFunc blit = NULL; SDL_BlitFunc blit = NULL;
int blit_index; SDL_Surface *dst = surface->map->dst;
Uint32 src_format;
Uint32 dst_format;
/* 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->blit = NULL; surface->map->blit = NULL;
surface->map->info.src_fmt = surface->format;
surface->map->info.src_pitch = surface->pitch;
surface->map->info.dst_fmt = dst->format;
surface->map->info.dst_pitch = dst->pitch;
/* Get the blit function index, based on surface mode */ src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
blit_index = 0;
blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY)) << 0;
if (surface->flags & SDL_SRCALPHA
&& ((surface->map->cmod >> 24) != SDL_ALPHA_OPAQUE
|| surface->format->Amask)) {
blit_index |= 2;
}
/* Check for special "identity" case -- copy blit */ /* Check for special "identity" case -- copy blit */
if (surface->map->identity && blit_index == 0) { if (surface->map->identity && !surface->map->info.flags) {
/* Handle overlapping blits on the same surface */ /* Handle overlapping blits on the same surface */
if (surface == surface->map->dst) { if (surface == dst) {
blit = SDL_BlitCopyOverlap; blit = SDL_BlitCopyOverlap;
} else { } else {
blit = SDL_BlitCopy; blit = SDL_BlitCopy;
} }
} else { } else {
if (surface->format->BitsPerPixel < 8) { if (surface->format->BitsPerPixel < 8) {
blit = SDL_CalculateBlit0(surface, blit_index); blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable0);
} else { } else {
switch (surface->format->BytesPerPixel) { switch (surface->format->BytesPerPixel) {
case 1: case 1:
blit = SDL_CalculateBlit1(surface, blit_index); blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable1);
break; break;
case 2: case 2:
case 3: case 3:
case 4: case 4:
blit = SDL_CalculateBlitN(surface, blit_index); blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTableN);
break; break;
} }
} }
......
...@@ -101,6 +101,11 @@ typedef struct SDL_BlitMap ...@@ -101,6 +101,11 @@ typedef struct SDL_BlitMap
/* 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);
/* Blit function tables in SDL_blit_*.c */
extern SDL_BlitFuncEntry SDL_BlitFuncTable0[];
extern SDL_BlitFuncEntry SDL_BlitFuncTable1[];
extern SDL_BlitFuncEntry SDL_BlitFuncTableN[];
/* /*
* Useful macros for blitting routines * Useful macros for blitting routines
*/ */
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
/* *INDENT-OFF* */ /* *INDENT-OFF* */
extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable; extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[];
/* *INDENT-ON* */ /* *INDENT-ON* */
......
...@@ -123,7 +123,7 @@ __EOF__ ...@@ -123,7 +123,7 @@ __EOF__
sub output_copydefs sub output_copydefs
{ {
print FILE <<__EOF__; print FILE <<__EOF__;
extern SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable; extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[];
__EOF__ __EOF__
} }
...@@ -275,7 +275,7 @@ sub output_copyfunc ...@@ -275,7 +275,7 @@ sub output_copyfunc
my $blend = shift; my $blend = shift;
my $scale = shift; my $scale = shift;
output_copyfuncname("void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
print FILE <<__EOF__; print FILE <<__EOF__;
{ {
const int flags = info->flags; const int flags = info->flags;
...@@ -384,7 +384,7 @@ __EOF__ ...@@ -384,7 +384,7 @@ __EOF__
sub output_copyfunctable sub output_copyfunctable
{ {
print FILE <<__EOF__; print FILE <<__EOF__;
static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = { static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
__EOF__ __EOF__
for (my $i = 0; $i <= $#src_formats; ++$i) { for (my $i = 0; $i <= $#src_formats; ++$i) {
my $src = $src_formats[$i]; my $src = $src_formats[$i];
...@@ -436,8 +436,6 @@ __EOF__ ...@@ -436,8 +436,6 @@ __EOF__
{ 0, 0, 0, 0, NULL } { 0, 0, 0, 0, NULL }
}; };
SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
__EOF__ __EOF__
} }
...@@ -469,10 +467,10 @@ close_file("SDL_blit_auto.h"); ...@@ -469,10 +467,10 @@ close_file("SDL_blit_auto.h");
open_file("SDL_blit_auto.c"); open_file("SDL_blit_auto.c");
output_copyinc(); output_copyinc();
output_copyfunctable();
for (my $i = 0; $i <= $#src_formats; ++$i) { for (my $i = 0; $i <= $#src_formats; ++$i) {
for (my $j = 0; $j <= $#dst_formats; ++$j) { for (my $j = 0; $j <= $#dst_formats; ++$j) {
output_copyfunc_c($src_formats[$i], $dst_formats[$j]); output_copyfunc_c($src_formats[$i], $dst_formats[$j]);
} }
} }
output_copyfunctable();
close_file("SDL_blit_auto.c"); close_file("SDL_blit_auto.c");
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