src/video/SDL_blit.c
changeset 2267 c785543d1843
parent 2266 e61ad15a205f
child 2328 91e601d9df8b
     1.1 --- a/src/video/SDL_blit.c	Sat Aug 18 01:44:21 2007 +0000
     1.2 +++ b/src/video/SDL_blit.c	Sat Aug 18 05:39:09 2007 +0000
     1.3 @@ -71,11 +71,15 @@
     1.4              (Uint16) srcrect->x * info->src_fmt->BytesPerPixel;
     1.5          info->src_w = srcrect->w;
     1.6          info->src_h = srcrect->h;
     1.7 -        info->dst = (Uint8 *) dst->pixels +
     1.8 -            (Uint16) dstrect->y * dst->pitch +
     1.9 +        info->src_skip =
    1.10 +            info->src_pitch - info->src_w * info->src_fmt->BytesPerPixel;
    1.11 +        info->dst =
    1.12 +            (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch +
    1.13              (Uint16) dstrect->x * info->dst_fmt->BytesPerPixel;
    1.14          info->dst_w = dstrect->w;
    1.15          info->dst_h = dstrect->h;
    1.16 +        info->dst_skip =
    1.17 +            info->dst_pitch - info->dst_w * info->dst_fmt->BytesPerPixel;
    1.18          RunBlit = (SDL_BlitFunc) src->map->data;
    1.19  
    1.20          /* Run the actual software blit */
    1.21 @@ -119,7 +123,8 @@
    1.22  #endif /* __MACOSX__ */
    1.23  
    1.24  static SDL_BlitFunc
    1.25 -SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, SDL_BlitFuncEntry * entries)
    1.26 +SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
    1.27 +                   SDL_BlitFuncEntry * entries)
    1.28  {
    1.29      int i, flagcheck;
    1.30      static Uint32 features = 0xffffffff;
    1.31 @@ -166,13 +171,16 @@
    1.32          }
    1.33  
    1.34          /* Check modulation flags */
    1.35 -        flagcheck = (flags & (SDL_COPY_MODULATE_COLOR|SDL_COPY_MODULATE_COLOR));
    1.36 +        flagcheck =
    1.37 +            (flags & (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_COLOR));
    1.38          if ((flagcheck & entries[i].flags) != flagcheck) {
    1.39              continue;
    1.40          }
    1.41  
    1.42          /* Check blend flags */
    1.43 -        flagcheck = (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD));
    1.44 +        flagcheck =
    1.45 +            (flags &
    1.46 +             (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD));
    1.47          if ((flagcheck & entries[i].flags) != flagcheck) {
    1.48              continue;
    1.49          }
    1.50 @@ -208,8 +216,6 @@
    1.51      SDL_BlitFunc blit = NULL;
    1.52      SDL_BlitMap *map = surface->map;
    1.53      SDL_Surface *dst = map->dst;
    1.54 -    Uint32 src_format;
    1.55 -    Uint32 dst_format;
    1.56  
    1.57      /* Clean everything out to start */
    1.58      if ((surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL) {
    1.59 @@ -222,16 +228,13 @@
    1.60      map->info.dst_pitch = dst->pitch;
    1.61  
    1.62      /* See if we can do RLE acceleration */
    1.63 -    if (surface->flags & SDL_RLEACCELOK) {
    1.64 +    if (surface->map->info.flags & SDL_COPY_RLE_DESIRED) {
    1.65          if (SDL_RLESurface(surface) == 0) {
    1.66              return 0;
    1.67          }
    1.68      }
    1.69  
    1.70      /* Choose a standard blit function */
    1.71 -    src_format = SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, surface->format->Rmask, surface->format->Gmask, surface->format->Bmask, surface->format->Amask);
    1.72 -    dst_format = SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
    1.73 -
    1.74      if (map->identity && !map->info.flags) {
    1.75          /* Handle overlapping blits on the same surface */
    1.76          if (surface == dst) {
    1.77 @@ -240,15 +243,32 @@
    1.78              blit = SDL_BlitCopy;
    1.79          }
    1.80      } else if (surface->format->BitsPerPixel < 8) {
    1.81 -        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable0);
    1.82 +        blit = SDL_CalculateBlit0(surface);
    1.83      } else if (surface->format->BytesPerPixel == 1) {
    1.84 -        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTable1);
    1.85 +        blit = SDL_CalculateBlit1(surface);
    1.86 +    } else if (map->info.flags & SDL_COPY_BLEND) {
    1.87 +        blit = SDL_CalculateBlitA(surface);
    1.88      } else {
    1.89 -        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_BlitFuncTableN);
    1.90 +        blit = SDL_CalculateBlitN(surface);
    1.91      }
    1.92      if (blit == NULL) {
    1.93 -        blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, SDL_GeneratedBlitFuncTable);
    1.94 +        Uint32 src_format =
    1.95 +            SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel,
    1.96 +                                       surface->format->Rmask,
    1.97 +                                       surface->format->Gmask,
    1.98 +                                       surface->format->Bmask,
    1.99 +                                       surface->format->Amask);
   1.100 +        Uint32 dst_format =
   1.101 +            SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel,
   1.102 +                                       dst->format->Rmask, dst->format->Gmask,
   1.103 +                                       dst->format->Bmask,
   1.104 +                                       dst->format->Amask);
   1.105 +
   1.106 +        blit =
   1.107 +            SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags,
   1.108 +                               SDL_GeneratedBlitFuncTable);
   1.109      }
   1.110 +    map->data = blit;
   1.111  
   1.112      /* Make sure we have a blit function */
   1.113      if (blit == NULL) {