src/video/SDL_blit.c
changeset 2266 e61ad15a205f
parent 2265 265bb136af92
child 2267 c785543d1843
     1.1 --- a/src/video/SDL_blit.c	Fri Aug 17 06:58:20 2007 +0000
     1.2 +++ b/src/video/SDL_blit.c	Sat Aug 18 01:44:21 2007 +0000
     1.3 @@ -206,7 +206,8 @@
     1.4  SDL_CalculateBlit(SDL_Surface * surface)
     1.5  {
     1.6      SDL_BlitFunc blit = NULL;
     1.7 -    SDL_Surface *dst = surface->map->dst;
     1.8 +    SDL_BlitMap *map = surface->map;
     1.9 +    SDL_Surface *dst = map->dst;
    1.10      Uint32 src_format;
    1.11      Uint32 dst_format;
    1.12  
    1.13 @@ -214,67 +215,48 @@
    1.14      if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
    1.15          SDL_UnRLESurface(surface, 1);
    1.16      }
    1.17 -    surface->map->blit = NULL;
    1.18 -    surface->map->info.src_fmt = surface->format;
    1.19 -    surface->map->info.src_pitch = surface->pitch;
    1.20 -    surface->map->info.dst_fmt = dst->format;
    1.21 -    surface->map->info.dst_pitch = dst->pitch;
    1.22 +    map->blit = SDL_SoftBlit;
    1.23 +    map->info.src_fmt = surface->format;
    1.24 +    map->info.src_pitch = surface->pitch;
    1.25 +    map->info.dst_fmt = dst->format;
    1.26 +    map->info.dst_pitch = dst->pitch;
    1.27  
    1.28 +    /* See if we can do RLE acceleration */
    1.29 +    if (surface->flags & SDL_RLEACCELOK) {
    1.30 +        if (SDL_RLESurface(surface) == 0) {
    1.31 +            return 0;
    1.32 +        }
    1.33 +    }
    1.34 +
    1.35 +    /* Choose a standard blit function */
    1.36      src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
    1.37      dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
    1.38  
    1.39 -    /* Check for special "identity" case -- copy blit */
    1.40 -    if (surface->map->identity && !surface->map->info.flags) {
    1.41 +    if (map->identity && !map->info.flags) {
    1.42          /* Handle overlapping blits on the same surface */
    1.43          if (surface == dst) {
    1.44              blit = SDL_BlitCopyOverlap;
    1.45          } else {
    1.46              blit = SDL_BlitCopy;
    1.47          }
    1.48 +    } else if (surface->format->BitsPerPixel < 8) {
    1.49 +        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable0);
    1.50 +    } else if (surface->format->BytesPerPixel == 1) {
    1.51 +        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable1);
    1.52      } else {
    1.53 -        if (surface->format->BitsPerPixel < 8) {
    1.54 -            blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable0);
    1.55 -        } else {
    1.56 -            switch (surface->format->BytesPerPixel) {
    1.57 -            case 1:
    1.58 -                blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTable1);
    1.59 -                break;
    1.60 -            case 2:
    1.61 -            case 3:
    1.62 -            case 4:
    1.63 -                blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_BlitFuncTableN);
    1.64 -                break;
    1.65 -            }
    1.66 -        }
    1.67 +        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTableN);
    1.68      }
    1.69      if (blit == NULL) {
    1.70 -        blit = SDL_ChooseBlitFunc(src_format, dst_format, surface->map->info.flags, SDL_GeneratedBlitFuncTable);
    1.71 +        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_GeneratedBlitFuncTable);
    1.72      }
    1.73  
    1.74      /* Make sure we have a blit function */
    1.75      if (blit == NULL) {
    1.76 -        SDL_InvalidateMap(surface->map);
    1.77 +        SDL_InvalidateMap(map);
    1.78          SDL_SetError("Blit combination not supported");
    1.79          return (-1);
    1.80      }
    1.81  
    1.82 -    /* Choose software blitting function */
    1.83 -    if ((surface->flags & SDL_RLEACCELOK) && !(surface->map->flags & () {
    1.84 -        if (surface->map->identity && (surface->map->flags & SDL_COPY_COLORKEY)
    1.85 -            && (blit_index == 1
    1.86 -                || (blit_index == 3 && !surface->format->Amask))) {
    1.87 -            if (SDL_RLESurface(surface) == 0)
    1.88 -                surface->map->blit = SDL_RLEBlit;
    1.89 -        } else if (blit_index == 2 && surface->format->Amask) {
    1.90 -            if (SDL_RLESurface(surface) == 0)
    1.91 -                surface->map->blit = SDL_RLEAlphaBlit;
    1.92 -        }
    1.93 -    }
    1.94 -
    1.95 -    if (surface->map->blit == NULL) {
    1.96 -        surface->map->blit = SDL_SoftBlit;
    1.97 -        surface->map->data = blit;
    1.98 -    }
    1.99      return (0);
   1.100  }
   1.101