More work in progress...
authorSam Lantinga <slouken@libsdl.org>
Fri, 17 Aug 2007 06:58:20 +0000
changeset 2265265bb136af92
parent 2264 f7f80b822c1f
child 2266 e61ad15a205f
More work in progress...
src/video/SDL_blit.c
     1.1 --- a/src/video/SDL_blit.c	Fri Aug 17 06:41:20 2007 +0000
     1.2 +++ b/src/video/SDL_blit.c	Fri Aug 17 06:58:20 2007 +0000
     1.3 @@ -121,7 +121,7 @@
     1.4  static SDL_BlitFunc
     1.5  SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
     1.6  {
     1.7 -    int i;
     1.8 +    int i, flagcheck;
     1.9      static Uint32 features = 0xffffffff;
    1.10  
    1.11      /* Get the available CPU features */
    1.12 @@ -157,18 +157,45 @@
    1.13      }
    1.14  
    1.15      for (i = 0; entries[i].func; ++i) {
    1.16 +        /* Check for matching pixel formats */
    1.17          if (src_format != entries[i].src_format) {
    1.18              continue;
    1.19          }
    1.20          if (dst_format != entries[i].dst_format) {
    1.21              continue;
    1.22          }
    1.23 -        if ((flags & entries[i].flags) != flags) {
    1.24 +
    1.25 +        /* Check modulation flags */
    1.26 +        flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR));
    1.27 +        if ((flagcheck & entries[i].flags) != flagcheck) {
    1.28              continue;
    1.29          }
    1.30 -        if (!(features & entries[i].cpu)) {
    1.31 +
    1.32 +        /* Check blend flags */
    1.33 +        flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD));
    1.34 +        if ((flagcheck & entries[i].flags) != flagcheck) {
    1.35              continue;
    1.36          }
    1.37 +
    1.38 +        /* Check colorkey flag */
    1.39 +        flagcheck = (flags & SDL_COPY_COLORKEY);
    1.40 +        if ((flagcheck & entries[i].flags) != flagcheck) {
    1.41 +            continue;
    1.42 +        }
    1.43 +
    1.44 +        /* Check scaling flags */
    1.45 +        flagcheck = (flags & SDL_COPY_NEAREST);
    1.46 +        if ((flagcheck & entries[i].flags) != flagcheck) {
    1.47 +            continue;
    1.48 +        }
    1.49 +
    1.50 +        /* Check CPU features */
    1.51 +        flagcheck = entries[i].cpu;
    1.52 +        if ((flagcheck & features) != flagcheck) {
    1.53 +            continue;
    1.54 +        }
    1.55 +
    1.56 +        /* We found the best one! */
    1.57          return entries[i].func;
    1.58      }
    1.59      return NULL;
    1.60 @@ -232,8 +259,8 @@
    1.61      }
    1.62  
    1.63      /* Choose software blitting function */
    1.64 -    if (surface->flags & SDL_RLEACCELOK) {
    1.65 -        if (surface->map->identity
    1.66 +    if ((surface->flags & SDL_RLEACCELOK) && !(surface->map->flags & () {
    1.67 +        if (surface->map->identity && (surface->map->flags & SDL_COPY_COLORKEY)
    1.68              && (blit_index == 1
    1.69                  || (blit_index == 3 && !surface->format->Amask))) {
    1.70              if (SDL_RLESurface(surface) == 0)