Added stubs for software implementations of blending fills and line drawing
authorSam Lantinga <slouken@libsdl.org>
Sat, 20 Dec 2008 13:14:28 +0000
changeset 288832e8bbba1e94
parent 2887 f8c0c5ef6d54
child 2889 67f84eb26ea1
Added stubs for software implementations of blending fills and line drawing
include/SDL_surface.h
src/video/SDL_blendline.c
src/video/SDL_blendrect.c
src/video/SDL_drawline.c
src/video/SDL_fill.c
src/video/SDL_fillrect.c
src/video/SDL_renderer_sw.c
src/video/dummy/SDL_nullrender.c
src/video/x11/SDL_x11render.c
     1.1 --- a/include/SDL_surface.h	Sat Dec 20 12:32:53 2008 +0000
     1.2 +++ b/include/SDL_surface.h	Sat Dec 20 13:14:28 2008 +0000
     1.3 @@ -366,6 +366,23 @@
     1.4      (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
     1.5  
     1.6  /*
     1.7 + * This function draws a line with 'color'
     1.8 + * The color should be a pixel of the format used by the surface, and 
     1.9 + * can be generated by the SDL_MapRGB() function.
    1.10 + * This function returns 0 on success, or -1 on error.
    1.11 + */
    1.12 +extern DECLSPEC int SDLCALL SDL_DrawLine
    1.13 +    (SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color);
    1.14 +
    1.15 +/*
    1.16 + * This function blends an RGBA value along a line
    1.17 + * This function returns 0 on success, or -1 on error.
    1.18 + */
    1.19 +extern DECLSPEC int SDLCALL SDL_BlendLine
    1.20 +    (SDL_Surface * dst, int x1, int y1, int x2, int y2, int blendMode,
    1.21 +     Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    1.22 +
    1.23 +/*
    1.24   * This function performs a fast fill of the given rectangle with 'color'
    1.25   * The given rectangle is clipped to the destination surface clip area
    1.26   * and the final fill rectangle is saved in the passed in pointer.
    1.27 @@ -378,6 +395,17 @@
    1.28      (SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color);
    1.29  
    1.30  /*
    1.31 + * This function blends an RGBA value into the given rectangle.
    1.32 + * The given rectangle is clipped to the destination surface clip area
    1.33 + * and the final fill rectangle is saved in the passed in pointer.
    1.34 + * If 'dstrect' is NULL, the whole surface will be filled with 'color'
    1.35 + * This function returns 0 on success, or -1 on error.
    1.36 + */
    1.37 +extern DECLSPEC int SDLCALL SDL_BlendRect
    1.38 +    (SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r, Uint8 g,
    1.39 +     Uint8 b, Uint8 a);
    1.40 +
    1.41 +/*
    1.42   * This performs a fast blit from the source surface to the destination
    1.43   * surface.  It assumes that the source and destination rectangles are
    1.44   * the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/SDL_blendline.c	Sat Dec 20 13:14:28 2008 +0000
     2.3 @@ -0,0 +1,49 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2009 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +#include "SDL_video.h"
    2.28 +#include "SDL_blit.h"
    2.29 +
    2.30 +
    2.31 +int
    2.32 +SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    2.33 +              int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    2.34 +{
    2.35 +    /* This function doesn't work on surfaces < 8 bpp */
    2.36 +    if (dst->format->BitsPerPixel < 8) {
    2.37 +        SDL_SetError("SDL_BlendLine(): Unsupported surface format");
    2.38 +        return (-1);
    2.39 +    }
    2.40 +
    2.41 +    /* Perform clipping */
    2.42 +    /* FIXME
    2.43 +       if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
    2.44 +       return (0);
    2.45 +       }
    2.46 +     */
    2.47 +
    2.48 +    SDL_Unsupported();
    2.49 +    return -1;
    2.50 +}
    2.51 +
    2.52 +/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/SDL_blendrect.c	Sat Dec 20 13:14:28 2008 +0000
     3.3 @@ -0,0 +1,52 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2009 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +#include "SDL_config.h"
    3.26 +
    3.27 +#include "SDL_video.h"
    3.28 +#include "SDL_blit.h"
    3.29 +
    3.30 +
    3.31 +int
    3.32 +SDL_BlendRect(SDL_Surface * dst, SDL_Rect * dstrect, int blendMode, Uint8 r,
    3.33 +              Uint8 g, Uint8 b, Uint8 a)
    3.34 +{
    3.35 +    /* This function doesn't work on surfaces < 8 bpp */
    3.36 +    if (dst->format->BitsPerPixel < 8) {
    3.37 +        SDL_SetError("SDL_BlendRect(): Unsupported surface format");
    3.38 +        return (-1);
    3.39 +    }
    3.40 +
    3.41 +    /* If 'dstrect' == NULL, then fill the whole surface */
    3.42 +    if (dstrect) {
    3.43 +        /* Perform clipping */
    3.44 +        if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
    3.45 +            return (0);
    3.46 +        }
    3.47 +    } else {
    3.48 +        dstrect = &dst->clip_rect;
    3.49 +    }
    3.50 +
    3.51 +    SDL_Unsupported();
    3.52 +    return -1;
    3.53 +}
    3.54 +
    3.55 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/SDL_drawline.c	Sat Dec 20 13:14:28 2008 +0000
     4.3 @@ -0,0 +1,48 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2009 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#include "SDL_video.h"
    4.28 +#include "SDL_blit.h"
    4.29 +
    4.30 +
    4.31 +int
    4.32 +SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
    4.33 +{
    4.34 +    /* This function doesn't work on surfaces < 8 bpp */
    4.35 +    if (dst->format->BitsPerPixel < 8) {
    4.36 +        SDL_SetError("SDL_DrawLine(): Unsupported surface format");
    4.37 +        return (-1);
    4.38 +    }
    4.39 +
    4.40 +    /* Perform clipping */
    4.41 +    /* FIXME
    4.42 +       if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
    4.43 +       return (0);
    4.44 +       }
    4.45 +     */
    4.46 +
    4.47 +    SDL_Unsupported();
    4.48 +    return -1;
    4.49 +}
    4.50 +
    4.51 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/SDL_fill.c	Sat Dec 20 12:32:53 2008 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,365 +0,0 @@
     5.4 -/*
     5.5 -    SDL - Simple DirectMedia Layer
     5.6 -    Copyright (C) 1997-2009 Sam Lantinga
     5.7 -
     5.8 -    This library is free software; you can redistribute it and/or
     5.9 -    modify it under the terms of the GNU Lesser General Public
    5.10 -    License as published by the Free Software Foundation; either
    5.11 -    version 2.1 of the License, or (at your option) any later version.
    5.12 -
    5.13 -    This library is distributed in the hope that it will be useful,
    5.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 -    Lesser General Public License for more details.
    5.17 -
    5.18 -    You should have received a copy of the GNU Lesser General Public
    5.19 -    License along with this library; if not, write to the Free Software
    5.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 -
    5.22 -    Sam Lantinga
    5.23 -    slouken@libsdl.org
    5.24 -*/
    5.25 -#include "SDL_config.h"
    5.26 -
    5.27 -#include "SDL_video.h"
    5.28 -#include "SDL_blit.h"
    5.29 -
    5.30 -
    5.31 -#ifdef __SSE__
    5.32 -/* *INDENT-OFF* */
    5.33 -
    5.34 -#ifdef _MSC_VER
    5.35 -#define SSE_BEGIN \
    5.36 -    __m128 c128; \
    5.37 -    c128.m128_u32[0] = color; \
    5.38 -    c128.m128_u32[1] = color; \
    5.39 -    c128.m128_u32[2] = color; \
    5.40 -    c128.m128_u32[3] = color;
    5.41 -#else
    5.42 -#define SSE_BEGIN \
    5.43 -    DECLARE_ALIGNED(Uint32, cccc[4], 16); \
    5.44 -    cccc[0] = color; \
    5.45 -    cccc[1] = color; \
    5.46 -    cccc[2] = color; \
    5.47 -    cccc[3] = color; \
    5.48 -    __m128 c128 = *(__m128 *)cccc;
    5.49 -#endif
    5.50 -
    5.51 -#define SSE_WORK \
    5.52 -    for (i = n / 64; i--;) { \
    5.53 -        _mm_stream_ps((float *)(p+0), c128); \
    5.54 -        _mm_stream_ps((float *)(p+16), c128); \
    5.55 -        _mm_stream_ps((float *)(p+32), c128); \
    5.56 -        _mm_stream_ps((float *)(p+48), c128); \
    5.57 -        p += 64; \
    5.58 -    }
    5.59 -
    5.60 -#define SSE_END
    5.61 -
    5.62 -#define DEFINE_SSE_FILLRECT(bpp, type) \
    5.63 -static void \
    5.64 -SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
    5.65 -{ \
    5.66 -    SSE_BEGIN; \
    5.67 - \
    5.68 -    while (h--) { \
    5.69 -        int i, n = w * bpp; \
    5.70 -        Uint8 *p = pixels; \
    5.71 - \
    5.72 -        if (n > 15) { \
    5.73 -            int adjust = 16 - ((uintptr_t)p & 15); \
    5.74 -            if (adjust < 16) { \
    5.75 -                n -= adjust; \
    5.76 -                adjust /= bpp; \
    5.77 -                while (adjust--) { \
    5.78 -                    *((type *)p) = (type)color; \
    5.79 -                    p += bpp; \
    5.80 -                } \
    5.81 -            } \
    5.82 -            SSE_WORK; \
    5.83 -        } \
    5.84 -        if (n & 63) { \
    5.85 -            int remainder = (n & 63); \
    5.86 -            remainder /= bpp; \
    5.87 -            while (remainder--) { \
    5.88 -                *((type *)p) = (type)color; \
    5.89 -                p += bpp; \
    5.90 -            } \
    5.91 -        } \
    5.92 -        pixels += pitch; \
    5.93 -    } \
    5.94 - \
    5.95 -    SSE_END; \
    5.96 -}
    5.97 -
    5.98 -DEFINE_SSE_FILLRECT(1, Uint8)
    5.99 -DEFINE_SSE_FILLRECT(2, Uint16)
   5.100 -DEFINE_SSE_FILLRECT(4, Uint32)
   5.101 -
   5.102 -/* *INDENT-ON* */
   5.103 -#endif /* __SSE__ */
   5.104 -
   5.105 -#ifdef __MMX__
   5.106 -/* *INDENT-OFF* */
   5.107 -
   5.108 -#define MMX_BEGIN \
   5.109 -    __m64 c64 = _mm_set_pi32(color, color)
   5.110 -
   5.111 -#define MMX_WORK \
   5.112 -    for (i = n / 64; i--;) { \
   5.113 -        _mm_stream_pi((__m64 *)(p+0), c64); \
   5.114 -        _mm_stream_pi((__m64 *)(p+8), c64); \
   5.115 -        _mm_stream_pi((__m64 *)(p+16), c64); \
   5.116 -        _mm_stream_pi((__m64 *)(p+24), c64); \
   5.117 -        _mm_stream_pi((__m64 *)(p+32), c64); \
   5.118 -        _mm_stream_pi((__m64 *)(p+40), c64); \
   5.119 -        _mm_stream_pi((__m64 *)(p+48), c64); \
   5.120 -        _mm_stream_pi((__m64 *)(p+56), c64); \
   5.121 -        p += 64; \
   5.122 -    }
   5.123 -
   5.124 -#define MMX_END \
   5.125 -    _mm_empty()
   5.126 -
   5.127 -#define DEFINE_MMX_FILLRECT(bpp, type) \
   5.128 -static void \
   5.129 -SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
   5.130 -{ \
   5.131 -    MMX_BEGIN; \
   5.132 - \
   5.133 -    while (h--) { \
   5.134 -        int i, n = w * bpp; \
   5.135 -        Uint8 *p = pixels; \
   5.136 - \
   5.137 -        if (n > 7) { \
   5.138 -            int adjust = 8 - ((uintptr_t)p & 7); \
   5.139 -            if (adjust < 8) { \
   5.140 -                n -= adjust; \
   5.141 -                adjust /= bpp; \
   5.142 -                while (adjust--) { \
   5.143 -                    *((type *)p) = (type)color; \
   5.144 -                    p += bpp; \
   5.145 -                } \
   5.146 -            } \
   5.147 -            MMX_WORK; \
   5.148 -        } \
   5.149 -        if (n & 63) { \
   5.150 -            int remainder = (n & 63); \
   5.151 -            remainder /= bpp; \
   5.152 -            while (remainder--) { \
   5.153 -                *((type *)p) = (type)color; \
   5.154 -                p += bpp; \
   5.155 -            } \
   5.156 -        } \
   5.157 -        pixels += pitch; \
   5.158 -    } \
   5.159 - \
   5.160 -    MMX_END; \
   5.161 -}
   5.162 -
   5.163 -DEFINE_MMX_FILLRECT(1, Uint8)
   5.164 -DEFINE_MMX_FILLRECT(2, Uint16)
   5.165 -DEFINE_MMX_FILLRECT(4, Uint32)
   5.166 -
   5.167 -/* *INDENT-ON* */
   5.168 -#endif /* __MMX__ */
   5.169 -
   5.170 -static void
   5.171 -SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   5.172 -{
   5.173 -    while (h--) {
   5.174 -        int n = w;
   5.175 -        Uint8 *p = pixels;
   5.176 -
   5.177 -        if (n > 3) {
   5.178 -            switch ((uintptr_t) p & 3) {
   5.179 -            case 1:
   5.180 -                *p++ = (Uint8) color;
   5.181 -                --n;
   5.182 -            case 2:
   5.183 -                *p++ = (Uint8) color;
   5.184 -                --n;
   5.185 -            case 3:
   5.186 -                *p++ = (Uint8) color;
   5.187 -                --n;
   5.188 -            }
   5.189 -            SDL_memset4(p, color, (n >> 2));
   5.190 -        }
   5.191 -        if (n & 3) {
   5.192 -            p += (n & ~3);
   5.193 -            switch (n & 3) {
   5.194 -            case 3:
   5.195 -                *p++ = (Uint8) color;
   5.196 -            case 2:
   5.197 -                *p++ = (Uint8) color;
   5.198 -            case 1:
   5.199 -                *p++ = (Uint8) color;
   5.200 -            }
   5.201 -        }
   5.202 -        pixels += pitch;
   5.203 -    }
   5.204 -}
   5.205 -
   5.206 -static void
   5.207 -SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   5.208 -{
   5.209 -    while (h--) {
   5.210 -        int n = w;
   5.211 -        Uint16 *p = (Uint16 *) pixels;
   5.212 -
   5.213 -        if (n > 1) {
   5.214 -            if ((uintptr_t) p & 2) {
   5.215 -                *p++ = (Uint16) color;
   5.216 -                --n;
   5.217 -            }
   5.218 -            SDL_memset4(p, color, (n >> 1));
   5.219 -        }
   5.220 -        if (n & 1) {
   5.221 -            p[n - 1] = (Uint16) color;
   5.222 -        }
   5.223 -        pixels += pitch;
   5.224 -    }
   5.225 -}
   5.226 -
   5.227 -static void
   5.228 -SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   5.229 -{
   5.230 -    Uint8 r = (Uint8) ((color >> 16) & 0xFF);
   5.231 -    Uint8 g = (Uint8) ((color >> 8) & 0xFF);
   5.232 -    Uint8 b = (Uint8) (color & 0xFF);
   5.233 -
   5.234 -    while (h--) {
   5.235 -        int n = w;
   5.236 -        Uint8 *p = pixels;
   5.237 -
   5.238 -        while (n--) {
   5.239 -            *p++ = r;
   5.240 -            *p++ = g;
   5.241 -            *p++ = b;
   5.242 -        }
   5.243 -        pixels += pitch;
   5.244 -    }
   5.245 -}
   5.246 -
   5.247 -static void
   5.248 -SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   5.249 -{
   5.250 -    while (h--) {
   5.251 -        SDL_memset4(pixels, color, w);
   5.252 -        pixels += pitch;
   5.253 -    }
   5.254 -}
   5.255 -
   5.256 -/* 
   5.257 - * This function performs a fast fill of the given rectangle with 'color'
   5.258 - */
   5.259 -int
   5.260 -SDL_FillRect(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color)
   5.261 -{
   5.262 -    Uint8 *pixels;
   5.263 -
   5.264 -    /* This function doesn't work on surfaces < 8 bpp */
   5.265 -    if (dst->format->BitsPerPixel < 8) {
   5.266 -        SDL_SetError("SDL_FillRect(): Unsupported surface format");
   5.267 -        return (-1);
   5.268 -    }
   5.269 -
   5.270 -    /* If 'dstrect' == NULL, then fill the whole surface */
   5.271 -    if (dstrect) {
   5.272 -        /* Perform clipping */
   5.273 -        if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
   5.274 -            return (0);
   5.275 -        }
   5.276 -    } else {
   5.277 -        dstrect = &dst->clip_rect;
   5.278 -    }
   5.279 -
   5.280 -    /* Perform software fill */
   5.281 -    if (!dst->pixels) {
   5.282 -        SDL_SetError("SDL_FillRect(): You must lock the surface");
   5.283 -        return (-1);
   5.284 -    }
   5.285 -
   5.286 -    pixels =
   5.287 -        (Uint8 *) dst->pixels + dstrect->y * dst->pitch +
   5.288 -        dstrect->x * dst->format->BytesPerPixel;
   5.289 -
   5.290 -    switch (dst->format->BytesPerPixel) {
   5.291 -    case 1:
   5.292 -        {
   5.293 -            color |= (color << 8);
   5.294 -            color |= (color << 16);
   5.295 -#ifdef __SSE__
   5.296 -            if (SDL_HasSSE()) {
   5.297 -                SDL_FillRect1SSE(pixels, dst->pitch, color, dstrect->w,
   5.298 -                                 dstrect->h);
   5.299 -                break;
   5.300 -            }
   5.301 -#endif
   5.302 -#ifdef __MMX__
   5.303 -            if (SDL_HasMMX()) {
   5.304 -                SDL_FillRect1MMX(pixels, dst->pitch, color, dstrect->w,
   5.305 -                                 dstrect->h);
   5.306 -                break;
   5.307 -            }
   5.308 -#endif
   5.309 -            SDL_FillRect1(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   5.310 -            break;
   5.311 -        }
   5.312 -
   5.313 -    case 2:
   5.314 -        {
   5.315 -            color |= (color << 16);
   5.316 -#ifdef __SSE__
   5.317 -            if (SDL_HasSSE()) {
   5.318 -                SDL_FillRect2SSE(pixels, dst->pitch, color, dstrect->w,
   5.319 -                                 dstrect->h);
   5.320 -                break;
   5.321 -            }
   5.322 -#endif
   5.323 -#ifdef __MMX__
   5.324 -            if (SDL_HasMMX()) {
   5.325 -                SDL_FillRect2MMX(pixels, dst->pitch, color, dstrect->w,
   5.326 -                                 dstrect->h);
   5.327 -                break;
   5.328 -            }
   5.329 -#endif
   5.330 -            SDL_FillRect2(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   5.331 -            break;
   5.332 -        }
   5.333 -
   5.334 -    case 3:
   5.335 -        /* 24-bit RGB is a slow path, at least for now. */
   5.336 -        {
   5.337 -            SDL_FillRect3(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   5.338 -            break;
   5.339 -        }
   5.340 -
   5.341 -    case 4:
   5.342 -        {
   5.343 -#ifdef __SSE__
   5.344 -            if (SDL_HasSSE()) {
   5.345 -                SDL_FillRect4SSE(pixels, dst->pitch, color, dstrect->w,
   5.346 -                                 dstrect->h);
   5.347 -                break;
   5.348 -            }
   5.349 -#endif
   5.350 -#ifdef __MMX__
   5.351 -            if (SDL_HasMMX()) {
   5.352 -                SDL_FillRect4MMX(pixels, dst->pitch, color, dstrect->w,
   5.353 -                                 dstrect->h);
   5.354 -                break;
   5.355 -            }
   5.356 -#endif
   5.357 -            SDL_FillRect4(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   5.358 -            break;
   5.359 -        }
   5.360 -    }
   5.361 -
   5.362 -    SDL_UnlockSurface(dst);
   5.363 -
   5.364 -    /* We're done! */
   5.365 -    return (0);
   5.366 -}
   5.367 -
   5.368 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/SDL_fillrect.c	Sat Dec 20 13:14:28 2008 +0000
     6.3 @@ -0,0 +1,365 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997-2009 Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Lesser General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2.1 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Lesser General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Lesser General Public
    6.19 +    License along with this library; if not, write to the Free Software
    6.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 +
    6.22 +    Sam Lantinga
    6.23 +    slouken@libsdl.org
    6.24 +*/
    6.25 +#include "SDL_config.h"
    6.26 +
    6.27 +#include "SDL_video.h"
    6.28 +#include "SDL_blit.h"
    6.29 +
    6.30 +
    6.31 +#ifdef __SSE__
    6.32 +/* *INDENT-OFF* */
    6.33 +
    6.34 +#ifdef _MSC_VER
    6.35 +#define SSE_BEGIN \
    6.36 +    __m128 c128; \
    6.37 +    c128.m128_u32[0] = color; \
    6.38 +    c128.m128_u32[1] = color; \
    6.39 +    c128.m128_u32[2] = color; \
    6.40 +    c128.m128_u32[3] = color;
    6.41 +#else
    6.42 +#define SSE_BEGIN \
    6.43 +    DECLARE_ALIGNED(Uint32, cccc[4], 16); \
    6.44 +    cccc[0] = color; \
    6.45 +    cccc[1] = color; \
    6.46 +    cccc[2] = color; \
    6.47 +    cccc[3] = color; \
    6.48 +    __m128 c128 = *(__m128 *)cccc;
    6.49 +#endif
    6.50 +
    6.51 +#define SSE_WORK \
    6.52 +    for (i = n / 64; i--;) { \
    6.53 +        _mm_stream_ps((float *)(p+0), c128); \
    6.54 +        _mm_stream_ps((float *)(p+16), c128); \
    6.55 +        _mm_stream_ps((float *)(p+32), c128); \
    6.56 +        _mm_stream_ps((float *)(p+48), c128); \
    6.57 +        p += 64; \
    6.58 +    }
    6.59 +
    6.60 +#define SSE_END
    6.61 +
    6.62 +#define DEFINE_SSE_FILLRECT(bpp, type) \
    6.63 +static void \
    6.64 +SDL_FillRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
    6.65 +{ \
    6.66 +    SSE_BEGIN; \
    6.67 + \
    6.68 +    while (h--) { \
    6.69 +        int i, n = w * bpp; \
    6.70 +        Uint8 *p = pixels; \
    6.71 + \
    6.72 +        if (n > 15) { \
    6.73 +            int adjust = 16 - ((uintptr_t)p & 15); \
    6.74 +            if (adjust < 16) { \
    6.75 +                n -= adjust; \
    6.76 +                adjust /= bpp; \
    6.77 +                while (adjust--) { \
    6.78 +                    *((type *)p) = (type)color; \
    6.79 +                    p += bpp; \
    6.80 +                } \
    6.81 +            } \
    6.82 +            SSE_WORK; \
    6.83 +        } \
    6.84 +        if (n & 63) { \
    6.85 +            int remainder = (n & 63); \
    6.86 +            remainder /= bpp; \
    6.87 +            while (remainder--) { \
    6.88 +                *((type *)p) = (type)color; \
    6.89 +                p += bpp; \
    6.90 +            } \
    6.91 +        } \
    6.92 +        pixels += pitch; \
    6.93 +    } \
    6.94 + \
    6.95 +    SSE_END; \
    6.96 +}
    6.97 +
    6.98 +DEFINE_SSE_FILLRECT(1, Uint8)
    6.99 +DEFINE_SSE_FILLRECT(2, Uint16)
   6.100 +DEFINE_SSE_FILLRECT(4, Uint32)
   6.101 +
   6.102 +/* *INDENT-ON* */
   6.103 +#endif /* __SSE__ */
   6.104 +
   6.105 +#ifdef __MMX__
   6.106 +/* *INDENT-OFF* */
   6.107 +
   6.108 +#define MMX_BEGIN \
   6.109 +    __m64 c64 = _mm_set_pi32(color, color)
   6.110 +
   6.111 +#define MMX_WORK \
   6.112 +    for (i = n / 64; i--;) { \
   6.113 +        _mm_stream_pi((__m64 *)(p+0), c64); \
   6.114 +        _mm_stream_pi((__m64 *)(p+8), c64); \
   6.115 +        _mm_stream_pi((__m64 *)(p+16), c64); \
   6.116 +        _mm_stream_pi((__m64 *)(p+24), c64); \
   6.117 +        _mm_stream_pi((__m64 *)(p+32), c64); \
   6.118 +        _mm_stream_pi((__m64 *)(p+40), c64); \
   6.119 +        _mm_stream_pi((__m64 *)(p+48), c64); \
   6.120 +        _mm_stream_pi((__m64 *)(p+56), c64); \
   6.121 +        p += 64; \
   6.122 +    }
   6.123 +
   6.124 +#define MMX_END \
   6.125 +    _mm_empty()
   6.126 +
   6.127 +#define DEFINE_MMX_FILLRECT(bpp, type) \
   6.128 +static void \
   6.129 +SDL_FillRect##bpp##MMX(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \
   6.130 +{ \
   6.131 +    MMX_BEGIN; \
   6.132 + \
   6.133 +    while (h--) { \
   6.134 +        int i, n = w * bpp; \
   6.135 +        Uint8 *p = pixels; \
   6.136 + \
   6.137 +        if (n > 7) { \
   6.138 +            int adjust = 8 - ((uintptr_t)p & 7); \
   6.139 +            if (adjust < 8) { \
   6.140 +                n -= adjust; \
   6.141 +                adjust /= bpp; \
   6.142 +                while (adjust--) { \
   6.143 +                    *((type *)p) = (type)color; \
   6.144 +                    p += bpp; \
   6.145 +                } \
   6.146 +            } \
   6.147 +            MMX_WORK; \
   6.148 +        } \
   6.149 +        if (n & 63) { \
   6.150 +            int remainder = (n & 63); \
   6.151 +            remainder /= bpp; \
   6.152 +            while (remainder--) { \
   6.153 +                *((type *)p) = (type)color; \
   6.154 +                p += bpp; \
   6.155 +            } \
   6.156 +        } \
   6.157 +        pixels += pitch; \
   6.158 +    } \
   6.159 + \
   6.160 +    MMX_END; \
   6.161 +}
   6.162 +
   6.163 +DEFINE_MMX_FILLRECT(1, Uint8)
   6.164 +DEFINE_MMX_FILLRECT(2, Uint16)
   6.165 +DEFINE_MMX_FILLRECT(4, Uint32)
   6.166 +
   6.167 +/* *INDENT-ON* */
   6.168 +#endif /* __MMX__ */
   6.169 +
   6.170 +static void
   6.171 +SDL_FillRect1(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   6.172 +{
   6.173 +    while (h--) {
   6.174 +        int n = w;
   6.175 +        Uint8 *p = pixels;
   6.176 +
   6.177 +        if (n > 3) {
   6.178 +            switch ((uintptr_t) p & 3) {
   6.179 +            case 1:
   6.180 +                *p++ = (Uint8) color;
   6.181 +                --n;
   6.182 +            case 2:
   6.183 +                *p++ = (Uint8) color;
   6.184 +                --n;
   6.185 +            case 3:
   6.186 +                *p++ = (Uint8) color;
   6.187 +                --n;
   6.188 +            }
   6.189 +            SDL_memset4(p, color, (n >> 2));
   6.190 +        }
   6.191 +        if (n & 3) {
   6.192 +            p += (n & ~3);
   6.193 +            switch (n & 3) {
   6.194 +            case 3:
   6.195 +                *p++ = (Uint8) color;
   6.196 +            case 2:
   6.197 +                *p++ = (Uint8) color;
   6.198 +            case 1:
   6.199 +                *p++ = (Uint8) color;
   6.200 +            }
   6.201 +        }
   6.202 +        pixels += pitch;
   6.203 +    }
   6.204 +}
   6.205 +
   6.206 +static void
   6.207 +SDL_FillRect2(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   6.208 +{
   6.209 +    while (h--) {
   6.210 +        int n = w;
   6.211 +        Uint16 *p = (Uint16 *) pixels;
   6.212 +
   6.213 +        if (n > 1) {
   6.214 +            if ((uintptr_t) p & 2) {
   6.215 +                *p++ = (Uint16) color;
   6.216 +                --n;
   6.217 +            }
   6.218 +            SDL_memset4(p, color, (n >> 1));
   6.219 +        }
   6.220 +        if (n & 1) {
   6.221 +            p[n - 1] = (Uint16) color;
   6.222 +        }
   6.223 +        pixels += pitch;
   6.224 +    }
   6.225 +}
   6.226 +
   6.227 +static void
   6.228 +SDL_FillRect3(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   6.229 +{
   6.230 +    Uint8 r = (Uint8) ((color >> 16) & 0xFF);
   6.231 +    Uint8 g = (Uint8) ((color >> 8) & 0xFF);
   6.232 +    Uint8 b = (Uint8) (color & 0xFF);
   6.233 +
   6.234 +    while (h--) {
   6.235 +        int n = w;
   6.236 +        Uint8 *p = pixels;
   6.237 +
   6.238 +        while (n--) {
   6.239 +            *p++ = r;
   6.240 +            *p++ = g;
   6.241 +            *p++ = b;
   6.242 +        }
   6.243 +        pixels += pitch;
   6.244 +    }
   6.245 +}
   6.246 +
   6.247 +static void
   6.248 +SDL_FillRect4(Uint8 * pixels, int pitch, Uint32 color, int w, int h)
   6.249 +{
   6.250 +    while (h--) {
   6.251 +        SDL_memset4(pixels, color, w);
   6.252 +        pixels += pitch;
   6.253 +    }
   6.254 +}
   6.255 +
   6.256 +/* 
   6.257 + * This function performs a fast fill of the given rectangle with 'color'
   6.258 + */
   6.259 +int
   6.260 +SDL_FillRect(SDL_Surface * dst, SDL_Rect * dstrect, Uint32 color)
   6.261 +{
   6.262 +    Uint8 *pixels;
   6.263 +
   6.264 +    /* This function doesn't work on surfaces < 8 bpp */
   6.265 +    if (dst->format->BitsPerPixel < 8) {
   6.266 +        SDL_SetError("SDL_FillRect(): Unsupported surface format");
   6.267 +        return (-1);
   6.268 +    }
   6.269 +
   6.270 +    /* If 'dstrect' == NULL, then fill the whole surface */
   6.271 +    if (dstrect) {
   6.272 +        /* Perform clipping */
   6.273 +        if (!SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect)) {
   6.274 +            return (0);
   6.275 +        }
   6.276 +    } else {
   6.277 +        dstrect = &dst->clip_rect;
   6.278 +    }
   6.279 +
   6.280 +    /* Perform software fill */
   6.281 +    if (!dst->pixels) {
   6.282 +        SDL_SetError("SDL_FillRect(): You must lock the surface");
   6.283 +        return (-1);
   6.284 +    }
   6.285 +
   6.286 +    pixels =
   6.287 +        (Uint8 *) dst->pixels + dstrect->y * dst->pitch +
   6.288 +        dstrect->x * dst->format->BytesPerPixel;
   6.289 +
   6.290 +    switch (dst->format->BytesPerPixel) {
   6.291 +    case 1:
   6.292 +        {
   6.293 +            color |= (color << 8);
   6.294 +            color |= (color << 16);
   6.295 +#ifdef __SSE__
   6.296 +            if (SDL_HasSSE()) {
   6.297 +                SDL_FillRect1SSE(pixels, dst->pitch, color, dstrect->w,
   6.298 +                                 dstrect->h);
   6.299 +                break;
   6.300 +            }
   6.301 +#endif
   6.302 +#ifdef __MMX__
   6.303 +            if (SDL_HasMMX()) {
   6.304 +                SDL_FillRect1MMX(pixels, dst->pitch, color, dstrect->w,
   6.305 +                                 dstrect->h);
   6.306 +                break;
   6.307 +            }
   6.308 +#endif
   6.309 +            SDL_FillRect1(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   6.310 +            break;
   6.311 +        }
   6.312 +
   6.313 +    case 2:
   6.314 +        {
   6.315 +            color |= (color << 16);
   6.316 +#ifdef __SSE__
   6.317 +            if (SDL_HasSSE()) {
   6.318 +                SDL_FillRect2SSE(pixels, dst->pitch, color, dstrect->w,
   6.319 +                                 dstrect->h);
   6.320 +                break;
   6.321 +            }
   6.322 +#endif
   6.323 +#ifdef __MMX__
   6.324 +            if (SDL_HasMMX()) {
   6.325 +                SDL_FillRect2MMX(pixels, dst->pitch, color, dstrect->w,
   6.326 +                                 dstrect->h);
   6.327 +                break;
   6.328 +            }
   6.329 +#endif
   6.330 +            SDL_FillRect2(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   6.331 +            break;
   6.332 +        }
   6.333 +
   6.334 +    case 3:
   6.335 +        /* 24-bit RGB is a slow path, at least for now. */
   6.336 +        {
   6.337 +            SDL_FillRect3(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   6.338 +            break;
   6.339 +        }
   6.340 +
   6.341 +    case 4:
   6.342 +        {
   6.343 +#ifdef __SSE__
   6.344 +            if (SDL_HasSSE()) {
   6.345 +                SDL_FillRect4SSE(pixels, dst->pitch, color, dstrect->w,
   6.346 +                                 dstrect->h);
   6.347 +                break;
   6.348 +            }
   6.349 +#endif
   6.350 +#ifdef __MMX__
   6.351 +            if (SDL_HasMMX()) {
   6.352 +                SDL_FillRect4MMX(pixels, dst->pitch, color, dstrect->w,
   6.353 +                                 dstrect->h);
   6.354 +                break;
   6.355 +            }
   6.356 +#endif
   6.357 +            SDL_FillRect4(pixels, dst->pitch, color, dstrect->w, dstrect->h);
   6.358 +            break;
   6.359 +        }
   6.360 +    }
   6.361 +
   6.362 +    SDL_UnlockSurface(dst);
   6.363 +
   6.364 +    /* We're done! */
   6.365 +    return (0);
   6.366 +}
   6.367 +
   6.368 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/SDL_renderer_sw.c	Sat Dec 20 12:32:53 2008 +0000
     7.2 +++ b/src/video/SDL_renderer_sw.c	Sat Dec 20 13:14:28 2008 +0000
     7.3 @@ -60,6 +60,9 @@
     7.4                            int *pitch);
     7.5  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     7.6  static int SW_SetDrawColor(SDL_Renderer * renderer);
     7.7 +static int SW_SetDrawBlendMode(SDL_Renderer * renderer);
     7.8 +static int SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
     7.9 +                         int y2);
    7.10  static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
    7.11  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    7.12                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    7.13 @@ -223,11 +226,8 @@
    7.14      renderer->DisplayModeChanged = SW_DisplayModeChanged;
    7.15  
    7.16      renderer->SetDrawColor = SW_SetDrawColor;
    7.17 -    /* FIXME : Implement
    7.18 -       renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
    7.19 -       renderer->RenderLine = GL_RenderLine;
    7.20 -     */
    7.21 -
    7.22 +    renderer->SetDrawBlendMode = SW_SetDrawBlendMode;
    7.23 +    renderer->RenderLine = SW_RenderLine;
    7.24      renderer->RenderFill = SW_RenderFill;
    7.25      renderer->RenderCopy = SW_RenderCopy;
    7.26      renderer->RenderPresent = SW_RenderPresent;
    7.27 @@ -532,10 +532,65 @@
    7.28  }
    7.29  
    7.30  static int
    7.31 +SW_SetDrawBlendMode(SDL_Renderer * renderer)
    7.32 +{
    7.33 +    return 0;
    7.34 +}
    7.35 +
    7.36 +static int
    7.37 +SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
    7.38 +{
    7.39 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    7.40 +    int status;
    7.41 +
    7.42 +    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
    7.43 +        SDL_Rect rect;
    7.44 +
    7.45 +        if (x1 < x2) {
    7.46 +            rect.x = x1;
    7.47 +            rect.w = (x2 - x1) + 1;
    7.48 +        } else {
    7.49 +            rect.x = x2;
    7.50 +            rect.w = (x1 - x2) + 1;
    7.51 +        }
    7.52 +        if (y1 < y2) {
    7.53 +            rect.y = y1;
    7.54 +            rect.h = (y2 - y1) + 1;
    7.55 +        } else {
    7.56 +            rect.y = y2;
    7.57 +            rect.h = (y1 - y2) + 1;
    7.58 +        }
    7.59 +        SDL_AddDirtyRect(&data->dirty, &rect);
    7.60 +    }
    7.61 +
    7.62 +    if (data->renderer->LockTexture(data->renderer,
    7.63 +                                    data->texture[data->current_texture],
    7.64 +                                    NULL, 1, &data->surface.pixels,
    7.65 +                                    &data->surface.pitch) < 0) {
    7.66 +        return -1;
    7.67 +    }
    7.68 +
    7.69 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
    7.70 +        Uint32 color =
    7.71 +            SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
    7.72 +                        renderer->b, renderer->a);
    7.73 +
    7.74 +        status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color);
    7.75 +    } else {
    7.76 +        status =
    7.77 +            SDL_BlendLine(&data->surface, x1, y1, x2, y2, renderer->blendMode,
    7.78 +                          renderer->r, renderer->g, renderer->b, renderer->a);
    7.79 +    }
    7.80 +
    7.81 +    data->renderer->UnlockTexture(data->renderer,
    7.82 +                                  data->texture[data->current_texture]);
    7.83 +    return status;
    7.84 +}
    7.85 +
    7.86 +static int
    7.87  SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
    7.88  {
    7.89      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    7.90 -    Uint32 color;
    7.91      SDL_Rect real_rect;
    7.92      int status;
    7.93  
    7.94 @@ -543,22 +598,30 @@
    7.95          SDL_AddDirtyRect(&data->dirty, rect);
    7.96      }
    7.97  
    7.98 -    color = SDL_MapRGBA(data->surface.format,
    7.99 -                        renderer->r, renderer->g, renderer->b, renderer->a);
   7.100 -
   7.101      if (data->renderer->LockTexture(data->renderer,
   7.102                                      data->texture[data->current_texture],
   7.103                                      rect, 1, &data->surface.pixels,
   7.104                                      &data->surface.pitch) < 0) {
   7.105          return -1;
   7.106      }
   7.107 +
   7.108      data->surface.w = rect->w;
   7.109      data->surface.h = rect->h;
   7.110      data->surface.clip_rect.w = rect->w;
   7.111      data->surface.clip_rect.h = rect->h;
   7.112      real_rect = data->surface.clip_rect;
   7.113  
   7.114 -    status = SDL_FillRect(&data->surface, &real_rect, color);
   7.115 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
   7.116 +        Uint32 color =
   7.117 +            SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
   7.118 +                        renderer->b, renderer->a);
   7.119 +
   7.120 +        status = SDL_FillRect(&data->surface, &real_rect, color);
   7.121 +    } else {
   7.122 +        status =
   7.123 +            SDL_BlendRect(&data->surface, &real_rect, renderer->blendMode,
   7.124 +                          renderer->r, renderer->g, renderer->b, renderer->a);
   7.125 +    }
   7.126  
   7.127      data->renderer->UnlockTexture(data->renderer,
   7.128                                    data->texture[data->current_texture]);
     8.1 --- a/src/video/dummy/SDL_nullrender.c	Sat Dec 20 12:32:53 2008 +0000
     8.2 +++ b/src/video/dummy/SDL_nullrender.c	Sat Dec 20 13:14:28 2008 +0000
     8.3 @@ -32,6 +32,9 @@
     8.4  static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
     8.5                                                Uint32 flags);
     8.6  static int SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer);
     8.7 +static int SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer);
     8.8 +static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1,
     8.9 +                                int x2, int y2);
    8.10  static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
    8.11                                  const SDL_Rect * rect);
    8.12  static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
    8.13 @@ -90,6 +93,8 @@
    8.14      SDL_zerop(data);
    8.15  
    8.16      renderer->SetDrawColor = SDL_DUMMY_SetDrawColor;
    8.17 +    renderer->SetDrawBlendMode = SDL_DUMMY_SetDrawBlendMode;
    8.18 +    renderer->RenderLine = SDL_DUMMY_RenderLine;
    8.19      renderer->RenderFill = SDL_DUMMY_RenderFill;
    8.20      renderer->RenderCopy = SDL_DUMMY_RenderCopy;
    8.21      renderer->RenderPresent = SDL_DUMMY_RenderPresent;
    8.22 @@ -132,18 +137,54 @@
    8.23  }
    8.24  
    8.25  static int
    8.26 +SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer)
    8.27 +{
    8.28 +    return 0;
    8.29 +}
    8.30 +
    8.31 +static int
    8.32 +SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
    8.33 +{
    8.34 +    SDL_DUMMY_RenderData *data =
    8.35 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
    8.36 +    SDL_Surface *target = data->screens[data->current_screen];
    8.37 +    int status;
    8.38 +
    8.39 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
    8.40 +        Uint32 color =
    8.41 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
    8.42 +                        renderer->a);
    8.43 +
    8.44 +        status = SDL_DrawLine(target, x1, y1, x2, y2, color);
    8.45 +    } else {
    8.46 +        status =
    8.47 +            SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode,
    8.48 +                          renderer->r, renderer->g, renderer->b, renderer->a);
    8.49 +    }
    8.50 +    return status;
    8.51 +}
    8.52 +
    8.53 +static int
    8.54  SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
    8.55  {
    8.56      SDL_DUMMY_RenderData *data =
    8.57          (SDL_DUMMY_RenderData *) renderer->driverdata;
    8.58      SDL_Surface *target = data->screens[data->current_screen];
    8.59 -    Uint32 color;
    8.60      SDL_Rect real_rect = *rect;
    8.61 +    int status;
    8.62  
    8.63 -    color = SDL_MapRGBA(target->format,
    8.64 -                        renderer->r, renderer->g, renderer->b, renderer->a);
    8.65 +    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
    8.66 +        Uint32 color =
    8.67 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
    8.68 +                        renderer->a);
    8.69  
    8.70 -    return SDL_FillRect(target, &real_rect, color);
    8.71 +        status = SDL_FillRect(target, &real_rect, color);
    8.72 +    } else {
    8.73 +        status =
    8.74 +            SDL_BlendRect(target, &real_rect, renderer->blendMode,
    8.75 +                          renderer->r, renderer->g, renderer->b, renderer->a);
    8.76 +    }
    8.77 +    return status;
    8.78  }
    8.79  
    8.80  static int
     9.1 --- a/src/video/x11/SDL_x11render.c	Sat Dec 20 12:32:53 2008 +0000
     9.2 +++ b/src/video/x11/SDL_x11render.c	Sat Dec 20 13:14:28 2008 +0000
     9.3 @@ -597,6 +597,7 @@
     9.4  {
     9.5      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
     9.6      unsigned long foreground;
     9.7 +
     9.8      if (data->makedirty) {
     9.9          SDL_Rect rect;
    9.10