src/video/SDL_blit_N.c
changeset 7372 f90f720b9e56
parent 7364 e21bd6987b86
child 7373 5e6efd29b461
     1.1 --- a/src/video/SDL_blit_N.c	Sun Jul 07 10:15:10 2013 -0700
     1.2 +++ b/src/video/SDL_blit_N.c	Sun Jul 07 10:31:01 2013 -0700
     1.3 @@ -993,6 +993,116 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +/* Special optimized blit for RGB 10-10-10 --> RGB 3-3-2 */
     1.8 +#define RGB101010_RGB332(dst, src) { \
     1.9 +    dst = (Uint8)((((src)&0x38000000)>>22)| \
    1.10 +                  (((src)&0x000E0000)>>15)| \
    1.11 +                  (((src)&0x00000300)>>8)); \
    1.12 +}
    1.13 +static void
    1.14 +Blit_RGB101010_index8(SDL_BlitInfo * info)
    1.15 +{
    1.16 +#ifndef USE_DUFFS_LOOP
    1.17 +    int c;
    1.18 +#endif
    1.19 +    int width, height;
    1.20 +    Uint32 *src;
    1.21 +    const Uint8 *map;
    1.22 +    Uint8 *dst;
    1.23 +    int srcskip, dstskip;
    1.24 +
    1.25 +    /* Set up some basic variables */
    1.26 +    width = info->dst_w;
    1.27 +    height = info->dst_h;
    1.28 +    src = (Uint32 *) info->src;
    1.29 +    srcskip = info->src_skip / 4;
    1.30 +    dst = info->dst;
    1.31 +    dstskip = info->dst_skip;
    1.32 +    map = info->table;
    1.33 +
    1.34 +    if (map == NULL) {
    1.35 +        while (height--) {
    1.36 +#ifdef USE_DUFFS_LOOP
    1.37 +            /* *INDENT-OFF* */
    1.38 +            DUFFS_LOOP(
    1.39 +                RGB101010_RGB332(*dst++, *src);
    1.40 +            , width);
    1.41 +            /* *INDENT-ON* */
    1.42 +#else
    1.43 +            for (c = width / 4; c; --c) {
    1.44 +                /* Pack RGB into 8bit pixel */
    1.45 +                ++src;
    1.46 +                RGB101010_RGB332(*dst++, *src);
    1.47 +                ++src;
    1.48 +                RGB101010_RGB332(*dst++, *src);
    1.49 +                ++src;
    1.50 +                RGB101010_RGB332(*dst++, *src);
    1.51 +                ++src;
    1.52 +            }
    1.53 +            switch (width & 3) {
    1.54 +            case 3:
    1.55 +                RGB101010_RGB332(*dst++, *src);
    1.56 +                ++src;
    1.57 +            case 2:
    1.58 +                RGB101010_RGB332(*dst++, *src);
    1.59 +                ++src;
    1.60 +            case 1:
    1.61 +                RGB101010_RGB332(*dst++, *src);
    1.62 +                ++src;
    1.63 +            }
    1.64 +#endif /* USE_DUFFS_LOOP */
    1.65 +            src += srcskip;
    1.66 +            dst += dstskip;
    1.67 +        }
    1.68 +    } else {
    1.69 +        int Pixel;
    1.70 +
    1.71 +        while (height--) {
    1.72 +#ifdef USE_DUFFS_LOOP
    1.73 +            /* *INDENT-OFF* */
    1.74 +            DUFFS_LOOP(
    1.75 +                RGB101010_RGB332(Pixel, *src);
    1.76 +                *dst++ = map[Pixel];
    1.77 +                ++src;
    1.78 +            , width);
    1.79 +            /* *INDENT-ON* */
    1.80 +#else
    1.81 +            for (c = width / 4; c; --c) {
    1.82 +                /* Pack RGB into 8bit pixel */
    1.83 +                RGB101010_RGB332(Pixel, *src);
    1.84 +                *dst++ = map[Pixel];
    1.85 +                ++src;
    1.86 +                RGB101010_RGB332(Pixel, *src);
    1.87 +                *dst++ = map[Pixel];
    1.88 +                ++src;
    1.89 +                RGB101010_RGB332(Pixel, *src);
    1.90 +                *dst++ = map[Pixel];
    1.91 +                ++src;
    1.92 +                RGB101010_RGB332(Pixel, *src);
    1.93 +                *dst++ = map[Pixel];
    1.94 +                ++src;
    1.95 +            }
    1.96 +            switch (width & 3) {
    1.97 +            case 3:
    1.98 +                RGB101010_RGB332(Pixel, *src);
    1.99 +                *dst++ = map[Pixel];
   1.100 +                ++src;
   1.101 +            case 2:
   1.102 +                RGB101010_RGB332(Pixel, *src);
   1.103 +                *dst++ = map[Pixel];
   1.104 +                ++src;
   1.105 +            case 1:
   1.106 +                RGB101010_RGB332(Pixel, *src);
   1.107 +                *dst++ = map[Pixel];
   1.108 +                ++src;
   1.109 +            }
   1.110 +#endif /* USE_DUFFS_LOOP */
   1.111 +            src += srcskip;
   1.112 +            dst += dstskip;
   1.113 +        }
   1.114 +    }
   1.115 +}
   1.116 +
   1.117  /* Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 */
   1.118  #define RGB888_RGB555(dst, src) { \
   1.119      *(Uint16 *)(dst) = (Uint16)((((*src)&0x00F80000)>>9)| \
   1.120 @@ -1860,85 +1970,6 @@
   1.121      Blit_RGB565_32(info, RGB565_BGRA8888_LUT);
   1.122  }
   1.123  
   1.124 -/* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
   1.125 -#ifndef RGB888_RGB332
   1.126 -#define RGB888_RGB332(dst, src) { \
   1.127 -    dst = (((src)&0x00E00000)>>16)| \
   1.128 -          (((src)&0x0000E000)>>11)| \
   1.129 -          (((src)&0x000000C0)>>6); \
   1.130 -}
   1.131 -#endif
   1.132 -static void
   1.133 -Blit_RGB888_index8_map(SDL_BlitInfo * info)
   1.134 -{
   1.135 -#ifndef USE_DUFFS_LOOP
   1.136 -    int c;
   1.137 -#endif
   1.138 -    int Pixel;
   1.139 -    int width, height;
   1.140 -    Uint32 *src;
   1.141 -    const Uint8 *map;
   1.142 -    Uint8 *dst;
   1.143 -    int srcskip, dstskip;
   1.144 -
   1.145 -    /* Set up some basic variables */
   1.146 -    width = info->dst_w;
   1.147 -    height = info->dst_h;
   1.148 -    src = (Uint32 *) info->src;
   1.149 -    srcskip = info->src_skip / 4;
   1.150 -    dst = info->dst;
   1.151 -    dstskip = info->dst_skip;
   1.152 -    map = info->table;
   1.153 -
   1.154 -#ifdef USE_DUFFS_LOOP
   1.155 -    while (height--) {
   1.156 -        /* *INDENT-OFF* */
   1.157 -        DUFFS_LOOP(
   1.158 -            RGB888_RGB332(Pixel, *src);
   1.159 -            *dst++ = map[Pixel];
   1.160 -            ++src;
   1.161 -        , width);
   1.162 -        /* *INDENT-ON* */
   1.163 -        src += srcskip;
   1.164 -        dst += dstskip;
   1.165 -    }
   1.166 -#else
   1.167 -    while (height--) {
   1.168 -        for (c = width / 4; c; --c) {
   1.169 -            /* Pack RGB into 8bit pixel */
   1.170 -            RGB888_RGB332(Pixel, *src);
   1.171 -            *dst++ = map[Pixel];
   1.172 -            ++src;
   1.173 -            RGB888_RGB332(Pixel, *src);
   1.174 -            *dst++ = map[Pixel];
   1.175 -            ++src;
   1.176 -            RGB888_RGB332(Pixel, *src);
   1.177 -            *dst++ = map[Pixel];
   1.178 -            ++src;
   1.179 -            RGB888_RGB332(Pixel, *src);
   1.180 -            *dst++ = map[Pixel];
   1.181 -            ++src;
   1.182 -        }
   1.183 -        switch (width & 3) {
   1.184 -        case 3:
   1.185 -            RGB888_RGB332(Pixel, *src);
   1.186 -            *dst++ = map[Pixel];
   1.187 -            ++src;
   1.188 -        case 2:
   1.189 -            RGB888_RGB332(Pixel, *src);
   1.190 -            *dst++ = map[Pixel];
   1.191 -            ++src;
   1.192 -        case 1:
   1.193 -            RGB888_RGB332(Pixel, *src);
   1.194 -            *dst++ = map[Pixel];
   1.195 -            ++src;
   1.196 -        }
   1.197 -        src += srcskip;
   1.198 -        dst += dstskip;
   1.199 -    }
   1.200 -#endif /* USE_DUFFS_LOOP */
   1.201 -}
   1.202 -
   1.203  static void
   1.204  BlitNto1(SDL_BlitInfo * info)
   1.205  {
   1.206 @@ -2440,11 +2471,12 @@
   1.207                  (srcfmt->Rmask == 0x00FF0000) &&
   1.208                  (srcfmt->Gmask == 0x0000FF00) &&
   1.209                  (srcfmt->Bmask == 0x000000FF)) {
   1.210 -                if (surface->map->info.table) {
   1.211 -                    blitfun = Blit_RGB888_index8_map;
   1.212 -                } else {
   1.213 -                    blitfun = Blit_RGB888_index8;
   1.214 -                }
   1.215 +                blitfun = Blit_RGB888_index8;
   1.216 +            } else if ((srcfmt->BytesPerPixel == 4) &&
   1.217 +                (srcfmt->Rmask == 0x3FF00000) &&
   1.218 +                (srcfmt->Gmask == 0x000FFC00) &&
   1.219 +                (srcfmt->Bmask == 0x000003FF)) {
   1.220 +                blitfun = Blit_RGB101010_index8;
   1.221              } else {
   1.222                  blitfun = BlitNto1;
   1.223              }