From f9e5abd6e8485c7370e941f3dcccd4b141cf9d8d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 17 Aug 2007 06:58:20 +0000 Subject: [PATCH] More work in progress... --- src/video/SDL_blit.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index 86b26e2ea..3ab73b476 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -121,7 +121,7 @@ SDL_UseAltivecPrefetch() static SDL_BlitFunc SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries) { - int i; + int i, flagcheck; static Uint32 features = 0xffffffff; /* Get the available CPU features */ @@ -157,18 +157,45 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFunc } for (i = 0; entries[i].func; ++i) { + /* Check for matching pixel formats */ if (src_format != entries[i].src_format) { continue; } if (dst_format != entries[i].dst_format) { continue; } - if ((flags & entries[i].flags) != flags) { + + /* Check modulation flags */ + flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR)); + if ((flagcheck & entries[i].flags) != flagcheck) { + continue; + } + + /* Check blend flags */ + flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)); + if ((flagcheck & entries[i].flags) != flagcheck) { + continue; + } + + /* Check colorkey flag */ + flagcheck = (flags & SDL_COPY_COLORKEY); + if ((flagcheck & entries[i].flags) != flagcheck) { + continue; + } + + /* Check scaling flags */ + flagcheck = (flags & SDL_COPY_NEAREST); + if ((flagcheck & entries[i].flags) != flagcheck) { continue; } - if (!(features & entries[i].cpu)) { + + /* Check CPU features */ + flagcheck = entries[i].cpu; + if ((flagcheck & features) != flagcheck) { continue; } + + /* We found the best one! */ return entries[i].func; } return NULL; @@ -232,8 +259,8 @@ SDL_CalculateBlit(SDL_Surface * surface) } /* Choose software blitting function */ - if (surface->flags & SDL_RLEACCELOK) { - if (surface->map->identity + if ((surface->flags & SDL_RLEACCELOK) && !(surface->map->flags & () { + if (surface->map->identity && (surface->map->flags & SDL_COPY_COLORKEY) && (blit_index == 1 || (blit_index == 3 && !surface->format->Amask))) { if (SDL_RLESurface(surface) == 0)