src/video/SDL_surface.c
changeset 2253 6d99edd791bf
parent 2251 292bee385630
child 2257 340942cfda48
     1.1 --- a/src/video/SDL_surface.c	Thu Aug 16 06:40:34 2007 +0000
     1.2 +++ b/src/video/SDL_surface.c	Thu Aug 16 21:43:19 2007 +0000
     1.3 @@ -509,342 +509,6 @@
     1.4      return 0;
     1.5  }
     1.6  
     1.7 -#ifdef __SSE__
     1.8 -/* *INDENT-OFF* */
     1.9 -
    1.10 -#ifdef _MSC_VER
    1.11 -#define SSE_BEGIN \
    1.12 -    __m128 c128; \
    1.13 -	c128.m128_u32[0] = color; \
    1.14 -	c128.m128_u32[1] = color; \
    1.15 -	c128.m128_u32[2] = color; \
    1.16 -	c128.m128_u32[3] = color;
    1.17 -#else
    1.18 -#define SSE_BEGIN \
    1.19 -    DECLARE_ALIGNED(Uint32, cccc[4], 16); \
    1.20 -    cccc[0] = color; \
    1.21 -    cccc[1] = color; \
    1.22 -    cccc[2] = color; \
    1.23 -    cccc[3] = color; \
    1.24 -    __m128 c128 = *(__m128 *)cccc;
    1.25 -#endif
    1.26 -
    1.27 -#define SSE_WORK \
    1.28 -    for (i = n / 64; i--;) { \
    1.29 -        _mm_stream_ps((float *)(p+0), c128); \
    1.30 -        _mm_stream_ps((float *)(p+16), c128); \
    1.31 -        _mm_stream_ps((float *)(p+32), c128); \
    1.32 -        _mm_stream_ps((float *)(p+48), c128); \
    1.33 -        p += 64; \
    1.34 -    }
    1.35 -
    1.36 -#define SSE_END
    1.37 -
    1.38 -#define DEFINE_SSE_FILLRECT(bpp, type) \
    1.39 -static void \
    1.40 -SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
    1.41 -{ \
    1.42 -    SSE_BEGIN; \
    1.43 - \
    1.44 -    while (h--) { \
    1.45 -        int i, n = w * bpp; \
    1.46 -        Uint8 *p = pixels; \
    1.47 - \
    1.48 -        if (n > 15) { \
    1.49 -            int adjust = 16 - ((uintptr_t)p & 15); \
    1.50 -            if (adjust < 16) { \
    1.51 -                n -= adjust; \
    1.52 -                adjust /= bpp; \
    1.53 -                while(adjust--) { \
    1.54 -                    *((type *)p) = (type)color; \
    1.55 -                    p += bpp; \
    1.56 -                } \
    1.57 -            } \
    1.58 -            SSE_WORK; \
    1.59 -        } \
    1.60 -        if (n & 63) { \
    1.61 -            int remainder = (n & 63); \
    1.62 -            remainder /= bpp; \
    1.63 -            while(remainder--) { \
    1.64 -                *((type *)p) = (type)color; \
    1.65 -                p += bpp; \
    1.66 -            } \
    1.67 -        } \
    1.68 -        pixels += pitch; \
    1.69 -    } \
    1.70 - \
    1.71 -    SSE_END; \
    1.72 -}
    1.73 -
    1.74 -DEFINE_SSE_FILLRECT(1, Uint8)
    1.75 -DEFINE_SSE_FILLRECT(2, Uint16)
    1.76 -DEFINE_SSE_FILLRECT(4, Uint32)
    1.77 -
    1.78 -/* *INDENT-ON* */
    1.79 -#endif /* __SSE__ */
    1.80 -
    1.81 -#ifdef __MMX__
    1.82 -/* *INDENT-OFF* */
    1.83 -
    1.84 -#define MMX_BEGIN \
    1.85 -    __m64 c64 = _mm_set_pi32(color, color)
    1.86 -
    1.87 -#define MMX_WORK \
    1.88 -    for (i = n / 64; i--;) { \
    1.89 -        _mm_stream_pi((__m64 *)(p+0), c64); \
    1.90 -        _mm_stream_pi((__m64 *)(p+8), c64); \
    1.91 -        _mm_stream_pi((__m64 *)(p+16), c64); \
    1.92 -        _mm_stream_pi((__m64 *)(p+24), c64); \
    1.93 -        _mm_stream_pi((__m64 *)(p+32), c64); \
    1.94 -        _mm_stream_pi((__m64 *)(p+40), c64); \
    1.95 -        _mm_stream_pi((__m64 *)(p+48), c64); \
    1.96 -        _mm_stream_pi((__m64 *)(p+56), c64); \
    1.97 -        p += 64; \
    1.98 -    }
    1.99 -
   1.100 -#define MMX_END \
   1.101 -    _mm_empty()
   1.102 -
   1.103 -#define DEFINE_MMX_FILLRECT(bpp, type) \
   1.104 -static void \
   1.105 -SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
   1.106 -{ \
   1.107 -    MMX_BEGIN; \
   1.108 - \
   1.109 -    while (h--) { \
   1.110 -        int i, n = w * bpp; \
   1.111 -        Uint8 *p = pixels; \
   1.112 - \
   1.113 -        if (n > 7) { \
   1.114 -            int adjust = 8 - ((uintptr_t)p & 7); \
   1.115 -            if (adjust < 8) { \
   1.116 -                n -= adjust; \
   1.117 -                adjust /= bpp; \
   1.118 -                while(adjust--) { \
   1.119 -                    *((type *)p) = (type)color; \
   1.120 -                    p += bpp; \
   1.121 -                } \
   1.122 -            } \
   1.123 -            MMX_WORK; \
   1.124 -        } \
   1.125 -        if (n & 63) { \
   1.126 -            int remainder = (n & 63); \
   1.127 -            remainder /= bpp; \
   1.128 -            while(remainder--) { \
   1.129 -                *((type *)p) = (type)color; \
   1.130 -                p += bpp; \
   1.131 -            } \
   1.132 -        } \
   1.133 -        pixels += pitch; \
   1.134 -    } \
   1.135 - \
   1.136 -    MMX_END; \
   1.137 -}
   1.138 -
   1.139 -DEFINE_MMX_FILLRECT(1, Uint8)
   1.140 -DEFINE_MMX_FILLRECT(2, Uint16)
   1.141 -DEFINE_MMX_FILLRECT(4, Uint32)
   1.142 -
   1.143 -/* *INDENT-ON* */
   1.144 -#endif /* __MMX__ */
   1.145 -
   1.146 -static void
   1.147 -SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   1.148 -{
   1.149 -    while (h--) {
   1.150 -        int n = w;
   1.151 -        Uint8 *p = pixels;
   1.152 -
   1.153 -        if (n > 3) {
   1.154 -            switch ((uintptr_t) p & 3) {
   1.155 -            case 1:
   1.156 -                *p++ = (Uint8) color;
   1.157 -                --n;
   1.158 -            case 2:
   1.159 -                *p++ = (Uint8) color;
   1.160 -                --n;
   1.161 -            case 3:
   1.162 -                *p++ = (Uint8) color;
   1.163 -                --n;
   1.164 -            }
   1.165 -            SDL_memset4(p, color, (n >> 2));
   1.166 -        }
   1.167 -        if (n & 3) {
   1.168 -            p += (n & ~3);
   1.169 -            switch (n & 3) {
   1.170 -            case 3:
   1.171 -                *p++ = (Uint8) color;
   1.172 -            case 2:
   1.173 -                *p++ = (Uint8) color;
   1.174 -            case 1:
   1.175 -                *p++ = (Uint8) color;
   1.176 -            }
   1.177 -        }
   1.178 -        pixels += pitch;
   1.179 -    }
   1.180 -}
   1.181 -
   1.182 -static void
   1.183 -SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   1.184 -{
   1.185 -    while (h--) {
   1.186 -        int n = w;
   1.187 -        Uint16 *p = (Uint16 *) pixels;
   1.188 -
   1.189 -        if (n > 1) {
   1.190 -            if ((uintptr_t) p & 2) {
   1.191 -                *p++ = (Uint16) color;
   1.192 -                --n;
   1.193 -            }
   1.194 -            SDL_memset4(p, color, (n >> 1));
   1.195 -        }
   1.196 -        if (n & 1) {
   1.197 -            p[n - 1] = (Uint16) color;
   1.198 -        }
   1.199 -        pixels += pitch;
   1.200 -    }
   1.201 -}
   1.202 -
   1.203 -static void
   1.204 -SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   1.205 -{
   1.206 -    Uint8 r = (Uint8) (color & 0xFF);
   1.207 -    Uint8 g = (Uint8) ((color >> 8) & 0xFF);
   1.208 -    Uint8 b = (Uint8) ((color >> 16) & 0xFF);
   1.209 -
   1.210 -    while (h--) {
   1.211 -        int n = w;
   1.212 -        Uint8 *p = pixels;
   1.213 -
   1.214 -        while (n--) {
   1.215 -            *p++ = r;
   1.216 -            *p++ = g;
   1.217 -            *p++ = b;
   1.218 -        }
   1.219 -        pixels += pitch;
   1.220 -    }
   1.221 -}
   1.222 -
   1.223 -static void
   1.224 -SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   1.225 -{
   1.226 -    while (h--) {
   1.227 -        SDL_memset4(pixels, color, w);
   1.228 -        pixels += pitch;
   1.229 -    }
   1.230 -}
   1.231 -
   1.232 -/* 
   1.233 - * This function performs a fast fill of the given rectangle with 'color'
   1.234 - */
   1.235 -int
   1.236 -SDL_FillRect(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color)
   1.237 -{
   1.238 -    Uint8 *pixels;
   1.239 -
   1.240 -    /* This function doesn't work on surfaces < 8 bpp */
   1.241 -    if (dst->format->BitsPerPixel < 8) {
   1.242 -        SDL_SetError("Fill rect on unsupported surface format");
   1.243 -        return (-1);
   1.244 -    }
   1.245 -
   1.246 -    /* If 'dstrect' == NULL, then fill the whole surface */
   1.247 -    if (dstrect) {
   1.248 -        /* Perform clipping */
   1.249 -        if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
   1.250 -            return (0);
   1.251 -        }
   1.252 -    } else {
   1.253 -        dstrect = &dst->clip_rect;
   1.254 -    }
   1.255 -
   1.256 -    /* Perform software fill */
   1.257 -    if (SDL_LockSurface(dst) != 0) {
   1.258 -        return (-1);
   1.259 -    }
   1.260 -
   1.261 -    pixels =
   1.262 -        (Uint8 *) dst->pixels + dstrect->y * dst->pitch +
   1.263 -        dstrect->x * dst->format->BytesPerPixel;
   1.264 -
   1.265 -    switch (dst->format->BytesPerPixel) {
   1.266 -    case 1:
   1.267 -        {
   1.268 -            color |= (color << 8);
   1.269 -            color |= (color << 16);
   1.270 -#ifdef __SSE__
   1.271 -            if (SDL_HasSSE()) {
   1.272 -                SDL_FillRect1SSE(pixels, dst->pitch, color, dstrect->w,
   1.273 -                                 dstrect->h);
   1.274 -                break;
   1.275 -            }
   1.276 -#endif
   1.277 -#ifdef __MMX__
   1.278 -            if (SDL_HasMMX()) {
   1.279 -                SDL_FillRect1MMX(pixels, dst->pitch, color, dstrect->w,
   1.280 -                                 dstrect->h);
   1.281 -                break;
   1.282 -            }
   1.283 -#endif
   1.284 -            SDL_FillRect1(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   1.285 -            break;
   1.286 -        }
   1.287 -
   1.288 -    case 2:
   1.289 -        {
   1.290 -            color |= (color << 16);
   1.291 -#ifdef __SSE__
   1.292 -            if (SDL_HasSSE()) {
   1.293 -                SDL_FillRect2SSE(pixels, dst->pitch, color, dstrect->w,
   1.294 -                                 dstrect->h);
   1.295 -                break;
   1.296 -            }
   1.297 -#endif
   1.298 -#ifdef __MMX__
   1.299 -            if (SDL_HasMMX()) {
   1.300 -                SDL_FillRect2MMX(pixels, dst->pitch, color, dstrect->w,
   1.301 -                                 dstrect->h);
   1.302 -                break;
   1.303 -            }
   1.304 -#endif
   1.305 -            SDL_FillRect2(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   1.306 -            break;
   1.307 -        }
   1.308 -
   1.309 -    case 3:
   1.310 -        /* 24-bit RGB is a slow path, at least for now. */
   1.311 -        {
   1.312 -            SDL_FillRect3(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   1.313 -            break;
   1.314 -        }
   1.315 -
   1.316 -    case 4:
   1.317 -        {
   1.318 -#ifdef __SSE__
   1.319 -            if (SDL_HasSSE()) {
   1.320 -                SDL_FillRect4SSE(pixels, dst->pitch, color, dstrect->w,
   1.321 -                                 dstrect->h);
   1.322 -                break;
   1.323 -            }
   1.324 -#endif
   1.325 -#ifdef __MMX__
   1.326 -            if (SDL_HasMMX()) {
   1.327 -                SDL_FillRect4MMX(pixels, dst->pitch, color, dstrect->w,
   1.328 -                                 dstrect->h);
   1.329 -                break;
   1.330 -            }
   1.331 -#endif
   1.332 -            SDL_FillRect4(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   1.333 -            break;
   1.334 -        }
   1.335 -    }
   1.336 -
   1.337 -    SDL_UnlockSurface(dst);
   1.338 -
   1.339 -    /* We're done! */
   1.340 -    return (0);
   1.341 -}
   1.342 -
   1.343  /*
   1.344   * Lock a surface to directly access the pixels
   1.345   */