Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
authorSam Lantinga <slouken@libsdl.org>
Wed, 23 Dec 2009 01:55:00 +0000
changeset 3596f638ded38b8a
parent 3595 b7c6828d4039
child 3597 7dec3fe9b580
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Renamed SDL_RenderPoint() and SDL_RenderLine() to SDL_RenderDrawPoint() and SDL_RenderDrawLine().
Added API for rectangle drawing (as opposed to filling)
Added placeholder API functions for circles and ellipses ... I'm not sure whether these will stay.
Optimized software line drawing quite a bit.
Added support for Wu's anti-aliased line drawing, currently disabled by default.
include/SDL_compat.h
include/SDL_surface.h
include/SDL_video.h
src/video/SDL_blendline.c
src/video/SDL_draw.h
src/video/SDL_drawline.c
src/video/SDL_drawpoint.c
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_sw.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullrender.c
src/video/ps3/SDL_ps3render.c
src/video/x11/SDL_x11render.c
src/video/x11/SDL_x11sym.h
test/automated/Makefile
test/automated/render/render.c
test/automated/surface/surface.c
test/automated/testsdl.c
test/testdraw2.c
test/testintersections.c
test/testnative.c
test/testsprite2.c
test/testspriteminimal.c
     1.1 --- a/include/SDL_compat.h	Fri Dec 18 08:19:18 2009 +0000
     1.2 +++ b/include/SDL_compat.h	Wed Dec 23 01:55:00 2009 +0000
     1.3 @@ -295,7 +295,9 @@
     1.4  extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval);
     1.5  extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable);
     1.6  
     1.7 -#define SDL_RenderFill  SDL_RenderRect
     1.8 +#define SDL_RenderPoint SDL_RenderDrawPoint
     1.9 +#define SDL_RenderLine SDL_RenderDrawLine
    1.10 +#define SDL_RenderFill(X)  (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()
    1.11  
    1.12  extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
    1.13  
     2.1 --- a/include/SDL_surface.h	Fri Dec 18 08:19:18 2009 +0000
     2.2 +++ b/include/SDL_surface.h	Wed Dec 23 01:55:00 2009 +0000
     2.3 @@ -411,12 +411,9 @@
     2.4  /**
     2.5   *  Blends a point with an RGBA value.
     2.6   *  
     2.7 - *  The color should be a pixel of the format used by the surface, and 
     2.8 - *  can be generated by the SDL_MapRGB() function.
     2.9 - *  
    2.10   *  \return 0 on success, or -1 on error.
    2.11   */
    2.12 -extern DECLSPEC int SDLCALL SDL_BlendDrawPoint
    2.13 +extern DECLSPEC int SDLCALL SDL_BlendPoint
    2.14      (SDL_Surface * dst, int x, int y,
    2.15       int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    2.16  extern DECLSPEC int SDLCALL SDL_BlendPoints
    2.17 @@ -464,9 +461,9 @@
    2.18      (SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color);
    2.19  
    2.20  /**
    2.21 - *  Blends the given rectangle with \c color.
    2.22 + *  Blends an RGBA value into the outline of the given rectangle.
    2.23   *  
    2.24 - *  If \c rect is NULL, the whole surface will have a blended outline of \c color.
    2.25 + *  If \c rect is NULL, the whole surface will have a blended outline.
    2.26   *  
    2.27   *  \return 0 on success, or -1 on error.
    2.28   */
    2.29 @@ -495,7 +492,7 @@
    2.30  /**
    2.31   *  Blends an RGBA value into the given rectangle.
    2.32   *  
    2.33 - *  If \c rect is NULL, the whole surface will be blended with \c color.
    2.34 + *  If \c rect is NULL, the whole surface will be blended with the color.
    2.35   *  
    2.36   *  \return This function returns 0 on success, or -1 on error.
    2.37   */
    2.38 @@ -506,6 +503,88 @@
    2.39      (SDL_Surface * dst, const SDL_Rect ** rects, int count,
    2.40       int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    2.41  
    2.42 +#if 0
    2.43 +/**
    2.44 + *  Draws the given circle with \c color.
    2.45 + *  
    2.46 + *  The color should be a pixel of the format used by the surface, and 
    2.47 + *  can be generated by the SDL_MapRGB() function.
    2.48 + *  
    2.49 + *  \return 0 on success, or -1 on error.
    2.50 + */
    2.51 +extern DECLSPEC int SDLCALL SDL_DrawCircle
    2.52 +    (SDL_Surface * dst, int x, int y, int radius, Uint32 color);
    2.53 +
    2.54 +/**
    2.55 + *  Blends an RGBA value into the outline of the given circle.
    2.56 + *  
    2.57 + *  \return 0 on success, or -1 on error.
    2.58 + */
    2.59 +extern DECLSPEC int SDLCALL SDL_BlendCircle
    2.60 +    (SDL_Surface * dst, int x, int y, int radius,
    2.61 +     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    2.62 +
    2.63 +/**
    2.64 + *  Fills the given circle with \c color.
    2.65 + *  
    2.66 + *  The color should be a pixel of the format used by the surface, and 
    2.67 + *  can be generated by the SDL_MapRGB() function.
    2.68 + *  
    2.69 + *  \return 0 on success, or -1 on error.
    2.70 + */
    2.71 +extern DECLSPEC int SDLCALL SDL_FillCircle
    2.72 +    (SDL_Surface * dst, int x, int y, int radius, Uint32 color);
    2.73 +
    2.74 +/**
    2.75 + *  Blends an RGBA value into the given circle.
    2.76 + *  
    2.77 + *  \return This function returns 0 on success, or -1 on error.
    2.78 + */
    2.79 +extern DECLSPEC int SDLCALL SDL_BlendFillCircle
    2.80 +    (SDL_Surface * dst, int x, int y, int radius,
    2.81 +     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    2.82 +
    2.83 +/**
    2.84 + *  Draws the given ellipse with \c color.
    2.85 + *  
    2.86 + *  The color should be a pixel of the format used by the surface, and 
    2.87 + *  can be generated by the SDL_MapRGB() function.
    2.88 + *  
    2.89 + *  \return 0 on success, or -1 on error.
    2.90 + */
    2.91 +extern DECLSPEC int SDLCALL SDL_DrawEllipse
    2.92 +    (SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);
    2.93 +
    2.94 +/**
    2.95 + *  Blends an RGBA value into the outline of the given ellipse.
    2.96 + *  
    2.97 + *  \return 0 on success, or -1 on error.
    2.98 + */
    2.99 +extern DECLSPEC int SDLCALL SDL_BlendEllipse
   2.100 +    (SDL_Surface * dst, int x, int y, int w, int h,
   2.101 +     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
   2.102 +
   2.103 +/**
   2.104 + *  Fills the given ellipse with \c color.
   2.105 + *  
   2.106 + *  The color should be a pixel of the format used by the surface, and 
   2.107 + *  can be generated by the SDL_MapRGB() function.
   2.108 + *  
   2.109 + *  \return 0 on success, or -1 on error.
   2.110 + */
   2.111 +extern DECLSPEC int SDLCALL SDL_FillEllipse
   2.112 +    (SDL_Surface * dst, int x, int y, int w, int h, Uint32 color);
   2.113 +
   2.114 +/**
   2.115 + *  Blends an RGBA value into the given ellipse.
   2.116 + *  
   2.117 + *  \return This function returns 0 on success, or -1 on error.
   2.118 + */
   2.119 +extern DECLSPEC int SDLCALL SDL_BlendFillEllipse
   2.120 +    (SDL_Surface * dst, int x, int y, int w, int h,
   2.121 +     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
   2.122 +#endif // 0
   2.123 +
   2.124  /**
   2.125   *  Performs a fast blit from the source surface to the destination surface.
   2.126   *  
     3.1 --- a/include/SDL_video.h	Fri Dec 18 08:19:18 2009 +0000
     3.2 +++ b/include/SDL_video.h	Wed Dec 23 01:55:00 2009 +0000
     3.3 @@ -1138,6 +1138,11 @@
     3.4  extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);
     3.5  
     3.6  /**
     3.7 + *  \brief Clear the current rendering target with the drawing color
     3.8 + */
     3.9 +extern DECLSPEC int SDLCALL SDL_RenderClear();
    3.10 +
    3.11 +/**
    3.12   *  \brief Draw a point on the current rendering target.
    3.13   *  
    3.14   *  \param x The x coordinate of the point.
    3.15 @@ -1145,7 +1150,7 @@
    3.16   *  
    3.17   *  \return 0 on success, or -1 if there is no rendering context current.
    3.18   */
    3.19 -extern DECLSPEC int SDLCALL SDL_RenderPoint(int x, int y);
    3.20 +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(int x, int y);
    3.21  
    3.22  /**
    3.23   *  \brief Draw some number of points on the current rendering target.
    3.24 @@ -1155,8 +1160,8 @@
    3.25   *  
    3.26   *  \return 0 on success, or -1 if there is no rendering context current.
    3.27   */
    3.28 -extern DECLSPEC int SDLCALL SDL_RenderPoints(const SDL_Point * points,
    3.29 -                                             int count);
    3.30 +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(const SDL_Point * points,
    3.31 +                                                 int count);
    3.32  
    3.33  /**
    3.34   *  \brief Draw a line on the current rendering target.
    3.35 @@ -1168,7 +1173,7 @@
    3.36   *  
    3.37   *  \return 0 on success, or -1 if there is no rendering context current.
    3.38   */
    3.39 -extern DECLSPEC int SDLCALL SDL_RenderLine(int x1, int y1, int x2, int y2);
    3.40 +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(int x1, int y1, int x2, int y2);
    3.41  
    3.42  /**
    3.43   *  \brief Draw a series of connected lines on the current rendering target.
    3.44 @@ -1178,18 +1183,37 @@
    3.45   *  
    3.46   *  \return 0 on success, or -1 if there is no rendering context current.
    3.47   */
    3.48 -extern DECLSPEC int SDLCALL SDL_RenderLines(const SDL_Point * points,
    3.49 -                                            int count);
    3.50 +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points,
    3.51 +                                                int count);
    3.52  
    3.53  /**
    3.54 - *  \brief Fill the current rendering target with the drawing color.
    3.55 + *  \brief Draw a rectangle on the current rendering target with the drawing color.
    3.56 + *  
    3.57 + *  \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
    3.58 + *  
    3.59 + *  \return 0 on success, or -1 if there is no rendering context current.
    3.60 + */
    3.61 +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(const SDL_Rect * rect);
    3.62 +
    3.63 +/**
    3.64 + *  \brief Draw some number of rectangles in the current rendering target with the drawing color.
    3.65 + *  
    3.66 + *  \param rects A pointer to an array of destination rectangles.
    3.67 + *  \param count The number of rectangles.
    3.68 + *  
    3.69 + *  \return 0 on success, or -1 if there is no rendering context current.
    3.70 + */
    3.71 +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rect, int count);
    3.72 +
    3.73 +/**
    3.74 + *  \brief Fill a rectangle on the current rendering target with the drawing color.
    3.75   *  
    3.76   *  \param rect A pointer to the destination rectangle, or NULL for the entire 
    3.77   *              rendering target.
    3.78   *  
    3.79   *  \return 0 on success, or -1 if there is no rendering context current.
    3.80   */
    3.81 -extern DECLSPEC int SDLCALL SDL_RenderRect(const SDL_Rect * rect);
    3.82 +extern DECLSPEC int SDLCALL SDL_RenderFillRect(const SDL_Rect * rect);
    3.83  
    3.84  /**
    3.85   *  \brief Fill some number of rectangles in the current rendering target with the drawing color.
    3.86 @@ -1199,7 +1223,37 @@
    3.87   *  
    3.88   *  \return 0 on success, or -1 if there is no rendering context current.
    3.89   */
    3.90 -extern DECLSPEC int SDLCALL SDL_RenderRects(const SDL_Rect ** rect, int count);
    3.91 +extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count);
    3.92 +
    3.93 +#if 0
    3.94 +/**
    3.95 + *  \brief Draw a circle on the current rendering target with the drawing color.
    3.96 + *  
    3.97 + *  \return 0 on success, or -1 if there is no rendering context current.
    3.98 + */
    3.99 +extern DECLSPEC int SDLCALL SDL_RenderDrawCircle(int x, int y, int radius);
   3.100 +
   3.101 +/**
   3.102 + *  \brief Fill a circle on the current rendering target with the drawing color.
   3.103 + *  
   3.104 + *  \return 0 on success, or -1 if there is no rendering context current.
   3.105 + */
   3.106 +extern DECLSPEC int SDLCALL SDL_RenderFillCircle(int x, int y, int radius);
   3.107 +
   3.108 +/**
   3.109 + *  \brief Draw an ellipse on the current rendering target with the drawing color.
   3.110 + *  
   3.111 + *  \return 0 on success, or -1 if there is no rendering context current.
   3.112 + */
   3.113 +extern DECLSPEC int SDLCALL SDL_RenderDrawEllipse(int x, int y, int w, int h);
   3.114 +
   3.115 +/**
   3.116 + *  \brief Fill an ellipse on the current rendering target with the drawing color.
   3.117 + *  
   3.118 + *  \return 0 on success, or -1 if there is no rendering context current.
   3.119 + */
   3.120 +extern DECLSPEC int SDLCALL SDL_RenderFillEllipse(int x, int y, int w, int h);
   3.121 +#endif // 0
   3.122  
   3.123  /**
   3.124   *  \brief Copy a portion of the texture to the current rendering target.
     4.1 --- a/src/video/SDL_blendline.c	Fri Dec 18 08:19:18 2009 +0000
     4.2 +++ b/src/video/SDL_blendline.c	Wed Dec 23 01:55:00 2009 +0000
     4.3 @@ -23,241 +23,713 @@
     4.4  
     4.5  #include "SDL_draw.h"
     4.6  
     4.7 -static int
     4.8 -SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
     4.9 -                     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
    4.10 -                     SDL_bool draw_end)
    4.11 +
    4.12 +static void
    4.13 +SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    4.14 +                   int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
    4.15 +                   SDL_bool draw_end)
    4.16  {
    4.17 -    unsigned inva = 0xff - a;
    4.18 +    const SDL_PixelFormat *fmt = dst->format;
    4.19 +    unsigned r, g, b, a, inva;
    4.20  
    4.21 -    switch (blendMode) {
    4.22 -    case SDL_BLENDMODE_BLEND:
    4.23 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB555, draw_end);
    4.24 -        break;
    4.25 -    case SDL_BLENDMODE_ADD:
    4.26 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB555, draw_end);
    4.27 -        break;
    4.28 -    case SDL_BLENDMODE_MOD:
    4.29 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB555, draw_end);
    4.30 -        break;
    4.31 -    default:
    4.32 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB555, draw_end);
    4.33 -        break;
    4.34 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
    4.35 +        r = DRAW_MUL(_r, _a);
    4.36 +        g = DRAW_MUL(_g, _a);
    4.37 +        b = DRAW_MUL(_b, _a);
    4.38 +        a = _a;
    4.39 +    } else {
    4.40 +        r = _r;
    4.41 +        g = _g;
    4.42 +        b = _b;
    4.43 +        a = _a;
    4.44      }
    4.45 -    return 0;
    4.46 -}
    4.47 +    inva = (a ^ 0xff);
    4.48  
    4.49 -static int
    4.50 -SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    4.51 -                     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
    4.52 -                     SDL_bool draw_end)
    4.53 -{
    4.54 -    unsigned inva = 0xff - a;
    4.55 -
    4.56 -    switch (blendMode) {
    4.57 -    case SDL_BLENDMODE_BLEND:
    4.58 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB565, draw_end);
    4.59 -        break;
    4.60 -    case SDL_BLENDMODE_ADD:
    4.61 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB565, draw_end);
    4.62 -        break;
    4.63 -    case SDL_BLENDMODE_MOD:
    4.64 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB565, draw_end);
    4.65 -        break;
    4.66 -    default:
    4.67 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB565, draw_end);
    4.68 -        break;
    4.69 -    }
    4.70 -    return 0;
    4.71 -}
    4.72 -
    4.73 -static int
    4.74 -SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    4.75 -                     int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
    4.76 -                     SDL_bool draw_end)
    4.77 -{
    4.78 -    unsigned inva = 0xff - a;
    4.79 -
    4.80 -    switch (blendMode) {
    4.81 -    case SDL_BLENDMODE_BLEND:
    4.82 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_RGB888, draw_end);
    4.83 -        break;
    4.84 -    case SDL_BLENDMODE_ADD:
    4.85 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_RGB888, draw_end);
    4.86 -        break;
    4.87 -    case SDL_BLENDMODE_MOD:
    4.88 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_RGB888, draw_end);
    4.89 -        break;
    4.90 -    default:
    4.91 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_RGB888, draw_end);
    4.92 -        break;
    4.93 -    }
    4.94 -    return 0;
    4.95 -}
    4.96 -
    4.97 -static int
    4.98 -SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
    4.99 -                       int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   4.100 -                       SDL_bool draw_end)
   4.101 -{
   4.102 -    unsigned inva = 0xff - a;
   4.103 -
   4.104 -    switch (blendMode) {
   4.105 -    case SDL_BLENDMODE_BLEND:
   4.106 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_BLEND_ARGB8888, draw_end);
   4.107 -        break;
   4.108 -    case SDL_BLENDMODE_ADD:
   4.109 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ADD_ARGB8888, draw_end);
   4.110 -        break;
   4.111 -    case SDL_BLENDMODE_MOD:
   4.112 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_MOD_ARGB8888, draw_end);
   4.113 -        break;
   4.114 -    default:
   4.115 -        DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY_ARGB8888, draw_end);
   4.116 -        break;
   4.117 -    }
   4.118 -    return 0;
   4.119 -}
   4.120 -
   4.121 -static int
   4.122 -SDL_BlendLine_RGB(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.123 -                  int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   4.124 -                  SDL_bool draw_end)
   4.125 -{
   4.126 -    SDL_PixelFormat *fmt = dst->format;
   4.127 -    unsigned inva = 0xff - a;
   4.128 -
   4.129 -    switch (fmt->BytesPerPixel) {
   4.130 -    case 2:
   4.131 +    if (y1 == y2) {
   4.132          switch (blendMode) {
   4.133          case SDL_BLENDMODE_BLEND:
   4.134 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_BLEND_RGB, draw_end);
   4.135 +            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.136              break;
   4.137          case SDL_BLENDMODE_ADD:
   4.138 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_ADD_RGB, draw_end);
   4.139 +            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.140              break;
   4.141          case SDL_BLENDMODE_MOD:
   4.142 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_MOD_RGB, draw_end);
   4.143 +            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.144              break;
   4.145          default:
   4.146 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY2_RGB, draw_end);
   4.147 +            HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
   4.148              break;
   4.149          }
   4.150 -        return 0;
   4.151 -    case 4:
   4.152 +    } else if (x1 == x2) {
   4.153          switch (blendMode) {
   4.154          case SDL_BLENDMODE_BLEND:
   4.155 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGB, draw_end);
   4.156 +            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.157              break;
   4.158          case SDL_BLENDMODE_ADD:
   4.159 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGB, draw_end);
   4.160 +            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.161              break;
   4.162          case SDL_BLENDMODE_MOD:
   4.163 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGB, draw_end);
   4.164 +            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.165              break;
   4.166          default:
   4.167 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGB, draw_end);
   4.168 +            VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
   4.169              break;
   4.170          }
   4.171 -        return 0;
   4.172 -    default:
   4.173 -        SDL_Unsupported();
   4.174 -        return -1;
   4.175 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.176 +        switch (blendMode) {
   4.177 +        case SDL_BLENDMODE_BLEND:
   4.178 +            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.179 +            break;
   4.180 +        case SDL_BLENDMODE_ADD:
   4.181 +            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.182 +            break;
   4.183 +        case SDL_BLENDMODE_MOD:
   4.184 +            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.185 +            break;
   4.186 +        default:
   4.187 +            DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
   4.188 +            break;
   4.189 +        }
   4.190 +    } else {
   4.191 +        switch (blendMode) {
   4.192 +        case SDL_BLENDMODE_BLEND:
   4.193 +            AALINE(x1, y1, x2, y2,
   4.194 +                   DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
   4.195 +                   draw_end);
   4.196 +            break;
   4.197 +        case SDL_BLENDMODE_ADD:
   4.198 +            AALINE(x1, y1, x2, y2,
   4.199 +                   DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
   4.200 +                   draw_end);
   4.201 +            break;
   4.202 +        case SDL_BLENDMODE_MOD:
   4.203 +            AALINE(x1, y1, x2, y2,
   4.204 +                   DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
   4.205 +                   draw_end);
   4.206 +            break;
   4.207 +        default:
   4.208 +            AALINE(x1, y1, x2, y2,
   4.209 +                   DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
   4.210 +                   draw_end);
   4.211 +            break;
   4.212 +        }
   4.213      }
   4.214  }
   4.215  
   4.216 -static int
   4.217 -SDL_BlendLine_RGBA(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.218 -                   int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   4.219 +static void
   4.220 +SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.221 +                     int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.222 +                     SDL_bool draw_end)
   4.223 +{
   4.224 +    const SDL_PixelFormat *fmt = dst->format;
   4.225 +    unsigned r, g, b, a, inva;
   4.226 +
   4.227 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.228 +        r = DRAW_MUL(_r, _a);
   4.229 +        g = DRAW_MUL(_g, _a);
   4.230 +        b = DRAW_MUL(_b, _a);
   4.231 +        a = _a;
   4.232 +    } else {
   4.233 +        r = _r;
   4.234 +        g = _g;
   4.235 +        b = _b;
   4.236 +        a = _a;
   4.237 +    }
   4.238 +    inva = (a ^ 0xff);
   4.239 +
   4.240 +    if (y1 == y2) {
   4.241 +        switch (blendMode) {
   4.242 +        case SDL_BLENDMODE_BLEND:
   4.243 +            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
   4.244 +            break;
   4.245 +        case SDL_BLENDMODE_ADD:
   4.246 +            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
   4.247 +            break;
   4.248 +        case SDL_BLENDMODE_MOD:
   4.249 +            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
   4.250 +            break;
   4.251 +        default:
   4.252 +            HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
   4.253 +            break;
   4.254 +        }
   4.255 +    } else if (x1 == x2) {
   4.256 +        switch (blendMode) {
   4.257 +        case SDL_BLENDMODE_BLEND:
   4.258 +            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
   4.259 +            break;
   4.260 +        case SDL_BLENDMODE_ADD:
   4.261 +            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
   4.262 +            break;
   4.263 +        case SDL_BLENDMODE_MOD:
   4.264 +            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
   4.265 +            break;
   4.266 +        default:
   4.267 +            VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
   4.268 +            break;
   4.269 +        }
   4.270 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.271 +        switch (blendMode) {
   4.272 +        case SDL_BLENDMODE_BLEND:
   4.273 +            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end);
   4.274 +            break;
   4.275 +        case SDL_BLENDMODE_ADD:
   4.276 +            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end);
   4.277 +            break;
   4.278 +        case SDL_BLENDMODE_MOD:
   4.279 +            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB555, draw_end);
   4.280 +            break;
   4.281 +        default:
   4.282 +            DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end);
   4.283 +            break;
   4.284 +        }
   4.285 +    } else {
   4.286 +        switch (blendMode) {
   4.287 +        case SDL_BLENDMODE_BLEND:
   4.288 +            AALINE(x1, y1, x2, y2,
   4.289 +                   DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
   4.290 +                   draw_end);
   4.291 +            break;
   4.292 +        case SDL_BLENDMODE_ADD:
   4.293 +            AALINE(x1, y1, x2, y2,
   4.294 +                   DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555,
   4.295 +                   draw_end);
   4.296 +            break;
   4.297 +        case SDL_BLENDMODE_MOD:
   4.298 +            AALINE(x1, y1, x2, y2,
   4.299 +                   DRAW_SETPIXELXY_MOD_RGB555, DRAW_SETPIXELXY_MOD_RGB555,
   4.300 +                   draw_end);
   4.301 +            break;
   4.302 +        default:
   4.303 +            AALINE(x1, y1, x2, y2,
   4.304 +                   DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555,
   4.305 +                   draw_end);
   4.306 +            break;
   4.307 +        }
   4.308 +    }
   4.309 +}
   4.310 +
   4.311 +static void
   4.312 +SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.313 +                     int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.314 +                     SDL_bool draw_end)
   4.315 +{
   4.316 +    const SDL_PixelFormat *fmt = dst->format;
   4.317 +    unsigned r, g, b, a, inva;
   4.318 +
   4.319 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.320 +        r = DRAW_MUL(_r, _a);
   4.321 +        g = DRAW_MUL(_g, _a);
   4.322 +        b = DRAW_MUL(_b, _a);
   4.323 +        a = _a;
   4.324 +    } else {
   4.325 +        r = _r;
   4.326 +        g = _g;
   4.327 +        b = _b;
   4.328 +        a = _a;
   4.329 +    }
   4.330 +    inva = (a ^ 0xff);
   4.331 +
   4.332 +    if (y1 == y2) {
   4.333 +        switch (blendMode) {
   4.334 +        case SDL_BLENDMODE_BLEND:
   4.335 +            HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
   4.336 +            break;
   4.337 +        case SDL_BLENDMODE_ADD:
   4.338 +            HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
   4.339 +            break;
   4.340 +        case SDL_BLENDMODE_MOD:
   4.341 +            HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
   4.342 +            break;
   4.343 +        default:
   4.344 +            HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
   4.345 +            break;
   4.346 +        }
   4.347 +    } else if (x1 == x2) {
   4.348 +        switch (blendMode) {
   4.349 +        case SDL_BLENDMODE_BLEND:
   4.350 +            VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
   4.351 +            break;
   4.352 +        case SDL_BLENDMODE_ADD:
   4.353 +            VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
   4.354 +            break;
   4.355 +        case SDL_BLENDMODE_MOD:
   4.356 +            VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
   4.357 +            break;
   4.358 +        default:
   4.359 +            VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
   4.360 +            break;
   4.361 +        }
   4.362 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.363 +        switch (blendMode) {
   4.364 +        case SDL_BLENDMODE_BLEND:
   4.365 +            DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end);
   4.366 +            break;
   4.367 +        case SDL_BLENDMODE_ADD:
   4.368 +            DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end);
   4.369 +            break;
   4.370 +        case SDL_BLENDMODE_MOD:
   4.371 +            DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB565, draw_end);
   4.372 +            break;
   4.373 +        default:
   4.374 +            DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end);
   4.375 +            break;
   4.376 +        }
   4.377 +    } else {
   4.378 +        switch (blendMode) {
   4.379 +        case SDL_BLENDMODE_BLEND:
   4.380 +            AALINE(x1, y1, x2, y2,
   4.381 +                   DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
   4.382 +                   draw_end);
   4.383 +            break;
   4.384 +        case SDL_BLENDMODE_ADD:
   4.385 +            AALINE(x1, y1, x2, y2,
   4.386 +                   DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565,
   4.387 +                   draw_end);
   4.388 +            break;
   4.389 +        case SDL_BLENDMODE_MOD:
   4.390 +            AALINE(x1, y1, x2, y2,
   4.391 +                   DRAW_SETPIXELXY_MOD_RGB565, DRAW_SETPIXELXY_MOD_RGB565,
   4.392 +                   draw_end);
   4.393 +            break;
   4.394 +        default:
   4.395 +            AALINE(x1, y1, x2, y2,
   4.396 +                   DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565,
   4.397 +                   draw_end);
   4.398 +            break;
   4.399 +        }
   4.400 +    }
   4.401 +}
   4.402 +
   4.403 +static void
   4.404 +SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.405 +                   int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.406                     SDL_bool draw_end)
   4.407  {
   4.408 -    SDL_PixelFormat *fmt = dst->format;
   4.409 -    unsigned inva = 0xff - a;
   4.410 +    const SDL_PixelFormat *fmt = dst->format;
   4.411 +    unsigned r, g, b, a, inva;
   4.412  
   4.413 -    switch (fmt->BytesPerPixel) {
   4.414 -    case 4:
   4.415 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.416 +        r = DRAW_MUL(_r, _a);
   4.417 +        g = DRAW_MUL(_g, _a);
   4.418 +        b = DRAW_MUL(_b, _a);
   4.419 +        a = _a;
   4.420 +    } else {
   4.421 +        r = _r;
   4.422 +        g = _g;
   4.423 +        b = _b;
   4.424 +        a = _a;
   4.425 +    }
   4.426 +    inva = (a ^ 0xff);
   4.427 +
   4.428 +    if (y1 == y2) {
   4.429          switch (blendMode) {
   4.430          case SDL_BLENDMODE_BLEND:
   4.431 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_BLEND_RGBA, draw_end);
   4.432 +            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.433              break;
   4.434          case SDL_BLENDMODE_ADD:
   4.435 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_ADD_RGBA, draw_end);
   4.436 +            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.437              break;
   4.438          case SDL_BLENDMODE_MOD:
   4.439 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_MOD_RGBA, draw_end);
   4.440 +            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.441              break;
   4.442          default:
   4.443 -            DRAWLINE(x1, y1, x2, y2, DRAW_SETPIXELXY4_RGBA, draw_end);
   4.444 +            HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
   4.445              break;
   4.446          }
   4.447 -        return 0;
   4.448 -    default:
   4.449 -        SDL_Unsupported();
   4.450 -        return -1;
   4.451 +    } else if (x1 == x2) {
   4.452 +        switch (blendMode) {
   4.453 +        case SDL_BLENDMODE_BLEND:
   4.454 +            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.455 +            break;
   4.456 +        case SDL_BLENDMODE_ADD:
   4.457 +            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.458 +            break;
   4.459 +        case SDL_BLENDMODE_MOD:
   4.460 +            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.461 +            break;
   4.462 +        default:
   4.463 +            VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
   4.464 +            break;
   4.465 +        }
   4.466 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.467 +        switch (blendMode) {
   4.468 +        case SDL_BLENDMODE_BLEND:
   4.469 +            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end);
   4.470 +            break;
   4.471 +        case SDL_BLENDMODE_ADD:
   4.472 +            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end);
   4.473 +            break;
   4.474 +        case SDL_BLENDMODE_MOD:
   4.475 +            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB, draw_end);
   4.476 +            break;
   4.477 +        default:
   4.478 +            DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end);
   4.479 +            break;
   4.480 +        }
   4.481 +    } else {
   4.482 +        switch (blendMode) {
   4.483 +        case SDL_BLENDMODE_BLEND:
   4.484 +            AALINE(x1, y1, x2, y2,
   4.485 +                   DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
   4.486 +                   draw_end);
   4.487 +            break;
   4.488 +        case SDL_BLENDMODE_ADD:
   4.489 +            AALINE(x1, y1, x2, y2,
   4.490 +                   DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB,
   4.491 +                   draw_end);
   4.492 +            break;
   4.493 +        case SDL_BLENDMODE_MOD:
   4.494 +            AALINE(x1, y1, x2, y2,
   4.495 +                   DRAW_SETPIXELXY4_MOD_RGB, DRAW_SETPIXELXY4_MOD_RGB,
   4.496 +                   draw_end);
   4.497 +            break;
   4.498 +        default:
   4.499 +            AALINE(x1, y1, x2, y2,
   4.500 +                   DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB,
   4.501 +                   draw_end);
   4.502 +            break;
   4.503 +        }
   4.504      }
   4.505  }
   4.506  
   4.507 +static void
   4.508 +SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.509 +                    int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.510 +                    SDL_bool draw_end)
   4.511 +{
   4.512 +    const SDL_PixelFormat *fmt = dst->format;
   4.513 +    unsigned r, g, b, a, inva;
   4.514 +
   4.515 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.516 +        r = DRAW_MUL(_r, _a);
   4.517 +        g = DRAW_MUL(_g, _a);
   4.518 +        b = DRAW_MUL(_b, _a);
   4.519 +        a = _a;
   4.520 +    } else {
   4.521 +        r = _r;
   4.522 +        g = _g;
   4.523 +        b = _b;
   4.524 +        a = _a;
   4.525 +    }
   4.526 +    inva = (a ^ 0xff);
   4.527 +
   4.528 +    if (y1 == y2) {
   4.529 +        switch (blendMode) {
   4.530 +        case SDL_BLENDMODE_BLEND:
   4.531 +            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
   4.532 +            break;
   4.533 +        case SDL_BLENDMODE_ADD:
   4.534 +            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
   4.535 +            break;
   4.536 +        case SDL_BLENDMODE_MOD:
   4.537 +            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
   4.538 +            break;
   4.539 +        default:
   4.540 +            HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
   4.541 +            break;
   4.542 +        }
   4.543 +    } else if (x1 == x2) {
   4.544 +        switch (blendMode) {
   4.545 +        case SDL_BLENDMODE_BLEND:
   4.546 +            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
   4.547 +            break;
   4.548 +        case SDL_BLENDMODE_ADD:
   4.549 +            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
   4.550 +            break;
   4.551 +        case SDL_BLENDMODE_MOD:
   4.552 +            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
   4.553 +            break;
   4.554 +        default:
   4.555 +            VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
   4.556 +            break;
   4.557 +        }
   4.558 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.559 +        switch (blendMode) {
   4.560 +        case SDL_BLENDMODE_BLEND:
   4.561 +            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end);
   4.562 +            break;
   4.563 +        case SDL_BLENDMODE_ADD:
   4.564 +            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end);
   4.565 +            break;
   4.566 +        case SDL_BLENDMODE_MOD:
   4.567 +            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGBA, draw_end);
   4.568 +            break;
   4.569 +        default:
   4.570 +            DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end);
   4.571 +            break;
   4.572 +        }
   4.573 +    } else {
   4.574 +        switch (blendMode) {
   4.575 +        case SDL_BLENDMODE_BLEND:
   4.576 +            AALINE(x1, y1, x2, y2,
   4.577 +                   DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
   4.578 +                   draw_end);
   4.579 +            break;
   4.580 +        case SDL_BLENDMODE_ADD:
   4.581 +            AALINE(x1, y1, x2, y2,
   4.582 +                   DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA,
   4.583 +                   draw_end);
   4.584 +            break;
   4.585 +        case SDL_BLENDMODE_MOD:
   4.586 +            AALINE(x1, y1, x2, y2,
   4.587 +                   DRAW_SETPIXELXY4_MOD_RGBA, DRAW_SETPIXELXY4_MOD_RGBA,
   4.588 +                   draw_end);
   4.589 +            break;
   4.590 +        default:
   4.591 +            AALINE(x1, y1, x2, y2,
   4.592 +                   DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA,
   4.593 +                   draw_end);
   4.594 +            break;
   4.595 +        }
   4.596 +    }
   4.597 +}
   4.598 +
   4.599 +static void
   4.600 +SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.601 +                     int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.602 +                     SDL_bool draw_end)
   4.603 +{
   4.604 +    const SDL_PixelFormat *fmt = dst->format;
   4.605 +    unsigned r, g, b, a, inva;
   4.606 +
   4.607 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.608 +        r = DRAW_MUL(_r, _a);
   4.609 +        g = DRAW_MUL(_g, _a);
   4.610 +        b = DRAW_MUL(_b, _a);
   4.611 +        a = _a;
   4.612 +    } else {
   4.613 +        r = _r;
   4.614 +        g = _g;
   4.615 +        b = _b;
   4.616 +        a = _a;
   4.617 +    }
   4.618 +    inva = (a ^ 0xff);
   4.619 +
   4.620 +    if (y1 == y2) {
   4.621 +        switch (blendMode) {
   4.622 +        case SDL_BLENDMODE_BLEND:
   4.623 +            HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
   4.624 +            break;
   4.625 +        case SDL_BLENDMODE_ADD:
   4.626 +            HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
   4.627 +            break;
   4.628 +        case SDL_BLENDMODE_MOD:
   4.629 +            HLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
   4.630 +            break;
   4.631 +        default:
   4.632 +            HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
   4.633 +            break;
   4.634 +        }
   4.635 +    } else if (x1 == x2) {
   4.636 +        switch (blendMode) {
   4.637 +        case SDL_BLENDMODE_BLEND:
   4.638 +            VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
   4.639 +            break;
   4.640 +        case SDL_BLENDMODE_ADD:
   4.641 +            VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
   4.642 +            break;
   4.643 +        case SDL_BLENDMODE_MOD:
   4.644 +            VLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
   4.645 +            break;
   4.646 +        default:
   4.647 +            VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
   4.648 +            break;
   4.649 +        }
   4.650 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.651 +        switch (blendMode) {
   4.652 +        case SDL_BLENDMODE_BLEND:
   4.653 +            DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end);
   4.654 +            break;
   4.655 +        case SDL_BLENDMODE_ADD:
   4.656 +            DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end);
   4.657 +            break;
   4.658 +        case SDL_BLENDMODE_MOD:
   4.659 +            DLINE(Uint32, DRAW_SETPIXEL_MOD_RGB888, draw_end);
   4.660 +            break;
   4.661 +        default:
   4.662 +            DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end);
   4.663 +            break;
   4.664 +        }
   4.665 +    } else {
   4.666 +        switch (blendMode) {
   4.667 +        case SDL_BLENDMODE_BLEND:
   4.668 +            AALINE(x1, y1, x2, y2,
   4.669 +                   DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
   4.670 +                   draw_end);
   4.671 +            break;
   4.672 +        case SDL_BLENDMODE_ADD:
   4.673 +            AALINE(x1, y1, x2, y2,
   4.674 +                   DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888,
   4.675 +                   draw_end);
   4.676 +            break;
   4.677 +        case SDL_BLENDMODE_MOD:
   4.678 +            AALINE(x1, y1, x2, y2,
   4.679 +                   DRAW_SETPIXELXY_MOD_RGB888, DRAW_SETPIXELXY_MOD_RGB888,
   4.680 +                   draw_end);
   4.681 +            break;
   4.682 +        default:
   4.683 +            AALINE(x1, y1, x2, y2,
   4.684 +                   DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888,
   4.685 +                   draw_end);
   4.686 +            break;
   4.687 +        }
   4.688 +    }
   4.689 +}
   4.690 +
   4.691 +static void
   4.692 +SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.693 +                       int blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
   4.694 +                       SDL_bool draw_end)
   4.695 +{
   4.696 +    const SDL_PixelFormat *fmt = dst->format;
   4.697 +    unsigned r, g, b, a, inva;
   4.698 +
   4.699 +    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.700 +        r = DRAW_MUL(_r, _a);
   4.701 +        g = DRAW_MUL(_g, _a);
   4.702 +        b = DRAW_MUL(_b, _a);
   4.703 +        a = _a;
   4.704 +    } else {
   4.705 +        r = _r;
   4.706 +        g = _g;
   4.707 +        b = _b;
   4.708 +        a = _a;
   4.709 +    }
   4.710 +    inva = (a ^ 0xff);
   4.711 +
   4.712 +    if (y1 == y2) {
   4.713 +        switch (blendMode) {
   4.714 +        case SDL_BLENDMODE_BLEND:
   4.715 +            HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
   4.716 +            break;
   4.717 +        case SDL_BLENDMODE_ADD:
   4.718 +            HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
   4.719 +            break;
   4.720 +        case SDL_BLENDMODE_MOD:
   4.721 +            HLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
   4.722 +            break;
   4.723 +        default:
   4.724 +            HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
   4.725 +            break;
   4.726 +        }
   4.727 +    } else if (x1 == x2) {
   4.728 +        switch (blendMode) {
   4.729 +        case SDL_BLENDMODE_BLEND:
   4.730 +            VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
   4.731 +            break;
   4.732 +        case SDL_BLENDMODE_ADD:
   4.733 +            VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
   4.734 +            break;
   4.735 +        case SDL_BLENDMODE_MOD:
   4.736 +            VLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
   4.737 +            break;
   4.738 +        default:
   4.739 +            VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
   4.740 +            break;
   4.741 +        }
   4.742 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
   4.743 +        switch (blendMode) {
   4.744 +        case SDL_BLENDMODE_BLEND:
   4.745 +            DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end);
   4.746 +            break;
   4.747 +        case SDL_BLENDMODE_ADD:
   4.748 +            DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end);
   4.749 +            break;
   4.750 +        case SDL_BLENDMODE_MOD:
   4.751 +            DLINE(Uint32, DRAW_SETPIXEL_MOD_ARGB8888, draw_end);
   4.752 +            break;
   4.753 +        default:
   4.754 +            DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end);
   4.755 +            break;
   4.756 +        }
   4.757 +    } else {
   4.758 +        switch (blendMode) {
   4.759 +        case SDL_BLENDMODE_BLEND:
   4.760 +            AALINE(x1, y1, x2, y2,
   4.761 +                   DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
   4.762 +                   draw_end);
   4.763 +            break;
   4.764 +        case SDL_BLENDMODE_ADD:
   4.765 +            AALINE(x1, y1, x2, y2,
   4.766 +                   DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888,
   4.767 +                   draw_end);
   4.768 +            break;
   4.769 +        case SDL_BLENDMODE_MOD:
   4.770 +            AALINE(x1, y1, x2, y2,
   4.771 +                   DRAW_SETPIXELXY_MOD_ARGB8888, DRAW_SETPIXELXY_MOD_ARGB8888,
   4.772 +                   draw_end);
   4.773 +            break;
   4.774 +        default:
   4.775 +            AALINE(x1, y1, x2, y2,
   4.776 +                   DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888,
   4.777 +                   draw_end);
   4.778 +            break;
   4.779 +        }
   4.780 +    }
   4.781 +}
   4.782 +
   4.783 +typedef void (*BlendLineFunc) (SDL_Surface * dst,
   4.784 +                               int x1, int y1, int x2, int y2,
   4.785 +                               int blendMode,
   4.786 +                               Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   4.787 +                               SDL_bool draw_end);
   4.788 +
   4.789 +static BlendLineFunc
   4.790 +SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt)
   4.791 +{
   4.792 +    switch (fmt->BytesPerPixel) {
   4.793 +    case 2:
   4.794 +        if (fmt->Rmask == 0x7C00) {
   4.795 +            return SDL_BlendLine_RGB555;
   4.796 +        } else if (fmt->Rmask == 0xF800) {
   4.797 +            return SDL_BlendLine_RGB565;
   4.798 +        } else {
   4.799 +            return SDL_BlendLine_RGB2;
   4.800 +        }
   4.801 +        break;
   4.802 +    case 4:
   4.803 +        if (fmt->Rmask == 0x00FF0000) {
   4.804 +            if (fmt->Amask) {
   4.805 +                return SDL_BlendLine_ARGB8888;
   4.806 +            } else {
   4.807 +                return SDL_BlendLine_RGB888;
   4.808 +            }
   4.809 +        } else {
   4.810 +            if (fmt->Amask) {
   4.811 +                return SDL_BlendLine_RGBA4;
   4.812 +            } else {
   4.813 +                return SDL_BlendLine_RGB4;
   4.814 +            }
   4.815 +        }
   4.816 +    }
   4.817 +    return NULL;
   4.818 +}
   4.819 +
   4.820  int
   4.821  SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.822                int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
   4.823  {
   4.824 -    /* This function doesn't work on surfaces < 8 bpp */
   4.825 -    if (dst->format->BitsPerPixel < 8) {
   4.826 +    BlendLineFunc func;
   4.827 +
   4.828 +    if (!dst) {
   4.829 +        SDL_SetError("SDL_BlendLine(): Passed NULL destination surface");
   4.830 +        return -1;
   4.831 +    }
   4.832 +
   4.833 +    func = SDL_CalculateBlendLineFunc(dst->format);
   4.834 +    if (!func) {
   4.835          SDL_SetError("SDL_BlendLine(): Unsupported surface format");
   4.836 -        return (-1);
   4.837 +        return -1;
   4.838      }
   4.839  
   4.840      /* Perform clipping */
   4.841 +    /* FIXME: We don't actually want to clip, as it may change line slope */
   4.842      if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
   4.843 -        return (0);
   4.844 +        return 0;
   4.845      }
   4.846  
   4.847 -
   4.848 -    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.849 -        r = DRAW_MUL(r, a);
   4.850 -        g = DRAW_MUL(g, a);
   4.851 -        b = DRAW_MUL(b, a);
   4.852 -    }
   4.853 -
   4.854 -    switch (dst->format->BitsPerPixel) {
   4.855 -    case 15:
   4.856 -        switch (dst->format->Rmask) {
   4.857 -        case 0x7C00:
   4.858 -            return SDL_BlendLine_RGB555(dst, x1, y1, x2, y2, blendMode, r, g,
   4.859 -                                        b, a, SDL_TRUE);
   4.860 -        }
   4.861 -        break;
   4.862 -    case 16:
   4.863 -        switch (dst->format->Rmask) {
   4.864 -        case 0xF800:
   4.865 -            return SDL_BlendLine_RGB565(dst, x1, y1, x2, y2, blendMode, r, g,
   4.866 -                                        b, a, SDL_TRUE);
   4.867 -        }
   4.868 -        break;
   4.869 -    case 32:
   4.870 -        switch (dst->format->Rmask) {
   4.871 -        case 0x00FF0000:
   4.872 -            if (!dst->format->Amask) {
   4.873 -                return SDL_BlendLine_RGB888(dst, x1, y1, x2, y2, blendMode, r,
   4.874 -                                            g, b, a, SDL_TRUE);
   4.875 -            } else {
   4.876 -                return SDL_BlendLine_ARGB8888(dst, x1, y1, x2, y2, blendMode,
   4.877 -                                              r, g, b, a, SDL_TRUE);
   4.878 -            }
   4.879 -            break;
   4.880 -        }
   4.881 -        break;
   4.882 -    default:
   4.883 -        break;
   4.884 -    }
   4.885 -
   4.886 -    if (!dst->format->Amask) {
   4.887 -        return SDL_BlendLine_RGB(dst, x1, y1, x2, y2, blendMode,
   4.888 -                                 r, g, b, a, SDL_TRUE);
   4.889 -    } else {
   4.890 -        return SDL_BlendLine_RGBA(dst, x1, y1, x2, y2, blendMode,
   4.891 -                                  r, g, b, a, SDL_TRUE);
   4.892 -    }
   4.893 +    func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE);
   4.894 +    return 0;
   4.895  }
   4.896  
   4.897  int
   4.898 @@ -267,64 +739,20 @@
   4.899      int i;
   4.900      int x1, y1;
   4.901      int x2, y2;
   4.902 -    int (*func)(SDL_Surface * dst, int x1, int y1, int x2, int y2,
   4.903 -                int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   4.904 -                SDL_bool draw_end) = NULL;
   4.905 -    int status = 0;
   4.906 +    SDL_bool draw_end;
   4.907 +    BlendLineFunc func;
   4.908  
   4.909      if (!dst) {
   4.910 -        SDL_SetError("Passed NULL destination surface");
   4.911 +        SDL_SetError("SDL_BlendLines(): Passed NULL destination surface");
   4.912          return -1;
   4.913      }
   4.914  
   4.915 -    /* This function doesn't work on surfaces < 8 bpp */
   4.916 -    if (dst->format->BitsPerPixel < 8) {
   4.917 +    func = SDL_CalculateBlendLineFunc(dst->format);
   4.918 +    if (!func) {
   4.919          SDL_SetError("SDL_BlendLines(): Unsupported surface format");
   4.920          return -1;
   4.921      }
   4.922  
   4.923 -    if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
   4.924 -        r = DRAW_MUL(r, a);
   4.925 -        g = DRAW_MUL(g, a);
   4.926 -        b = DRAW_MUL(b, a);
   4.927 -    }
   4.928 -
   4.929 -    /* FIXME: Does this function pointer slow things down significantly? */
   4.930 -    switch (dst->format->BitsPerPixel) {
   4.931 -    case 15:
   4.932 -        switch (dst->format->Rmask) {
   4.933 -        case 0x7C00:
   4.934 -            func = SDL_BlendLine_RGB555;
   4.935 -        }
   4.936 -        break;
   4.937 -    case 16:
   4.938 -        switch (dst->format->Rmask) {
   4.939 -        case 0xF800:
   4.940 -            func = SDL_BlendLine_RGB565;
   4.941 -        }
   4.942 -        break;
   4.943 -    case 32:
   4.944 -        switch (dst->format->Rmask) {
   4.945 -        case 0x00FF0000:
   4.946 -            if (!dst->format->Amask) {
   4.947 -                func = SDL_BlendLine_RGB888;
   4.948 -            } else {
   4.949 -                func = SDL_BlendLine_ARGB8888;
   4.950 -            }
   4.951 -            break;
   4.952 -        }
   4.953 -    default:
   4.954 -        break;
   4.955 -    }
   4.956 -
   4.957 -    if (!func) {
   4.958 -        if (!dst->format->Amask) {
   4.959 -            func = SDL_BlendLine_RGB;
   4.960 -        } else {
   4.961 -            func = SDL_BlendLine_RGBA;
   4.962 -        }
   4.963 -    }
   4.964 -
   4.965      for (i = 1; i < count; ++i) {
   4.966          x1 = points[i-1].x;
   4.967          y1 = points[i-1].y;
   4.968 @@ -337,12 +765,16 @@
   4.969              continue;
   4.970          }
   4.971  
   4.972 -        status = func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_FALSE);
   4.973 +        /* Draw the end if it was clipped */
   4.974 +        draw_end = (x2 != points[i].x || y2 != points[i].y);
   4.975 +
   4.976 +        func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end);
   4.977      }
   4.978      if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
   4.979 -        SDL_BlendPoint(dst, points[count-1].x, points[count-1].y, r, g, b, a);
   4.980 +        SDL_BlendPoint(dst, points[count-1].x, points[count-1].y,
   4.981 +                       blendMode, r, g, b, a);
   4.982      }
   4.983 -    return status;
   4.984 +    return 0;
   4.985  }
   4.986  
   4.987  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/SDL_draw.h	Fri Dec 18 08:19:18 2009 +0000
     5.2 +++ b/src/video/SDL_draw.h	Wed Dec 23 01:55:00 2009 +0000
     5.3 @@ -29,12 +29,20 @@
     5.4  
     5.5  #define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
     5.6  
     5.7 -#define DRAW_FASTSETPIXEL(x, y, type, bpp, color) \
     5.8 -    *(type *)((Uint8 *)dst->pixels + y * dst->pitch + x * bpp) = (type) color
     5.9 +#define DRAW_FASTSETPIXEL(type) \
    5.10 +    *pixel = (type) color
    5.11  
    5.12 -#define DRAW_FASTSETPIXEL1(x, y) DRAW_FASTSETPIXEL(x, y, Uint8, 1, color);
    5.13 -#define DRAW_FASTSETPIXEL2(x, y) DRAW_FASTSETPIXEL(x, y, Uint16, 2, color);
    5.14 -#define DRAW_FASTSETPIXEL4(x, y) DRAW_FASTSETPIXEL(x, y, Uint32, 4, color);
    5.15 +#define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
    5.16 +#define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
    5.17 +#define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
    5.18 +
    5.19 +#define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
    5.20 +    *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
    5.21 +                                   + (x) * bpp) = (type) color
    5.22 +
    5.23 +#define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
    5.24 +#define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
    5.25 +#define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
    5.26  
    5.27  #define DRAW_SETPIXEL(setpixel) \
    5.28  do { \
    5.29 @@ -74,7 +82,8 @@
    5.30  
    5.31  #define DRAW_SETPIXELXY(x, y, type, bpp, op) \
    5.32  do { \
    5.33 -    type *pixel = (type *)((Uint8 *)dst->pixels + y * dst->pitch + x * bpp); \
    5.34 +    type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
    5.35 +                                                + (x) * bpp); \
    5.36      op; \
    5.37  } while (0)
    5.38  
    5.39 @@ -283,7 +292,87 @@
    5.40  
    5.41  #define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
    5.42  
    5.43 -#define BRESENHAM(x1, y1, x2, y2, op, draw_end) \
    5.44 +/* Horizontal line */
    5.45 +#define HLINE(type, op, draw_end) \
    5.46 +{ \
    5.47 +    int length; \
    5.48 +    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
    5.49 +    type *pixel; \
    5.50 +    if (x1 <= x2) { \
    5.51 +        pixel = (type *)dst->pixels + y1 * pitch + x1; \
    5.52 +        length = draw_end ? (x2-x1+1) : (x2-x1); \
    5.53 +    } else { \
    5.54 +        pixel = (type *)dst->pixels + y1 * pitch + x2; \
    5.55 +        if (!draw_end) { \
    5.56 +            ++pixel; \
    5.57 +        } \
    5.58 +        length = draw_end ? (x1-x2+1) : (x1-x2); \
    5.59 +    } \
    5.60 +    while (length--) { \
    5.61 +        op; \
    5.62 +        ++pixel; \
    5.63 +    } \
    5.64 +}
    5.65 +
    5.66 +/* Vertical line */
    5.67 +#define VLINE(type, op, draw_end) \
    5.68 +{ \
    5.69 +    int length; \
    5.70 +    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
    5.71 +    type *pixel; \
    5.72 +    if (y1 <= y2) { \
    5.73 +        pixel = (type *)dst->pixels + y1 * pitch + x1; \
    5.74 +        length = draw_end ? (y2-y1+1) : (y2-y1); \
    5.75 +    } else { \
    5.76 +        pixel = (type *)dst->pixels + y2 * pitch + x1; \
    5.77 +        if (!draw_end) { \
    5.78 +            pixel += pitch; \
    5.79 +        } \
    5.80 +        length = draw_end ? (y1-y2+1) : (y1-y2); \
    5.81 +    } \
    5.82 +    while (length--) { \
    5.83 +        op; \
    5.84 +        pixel += pitch; \
    5.85 +    } \
    5.86 +}
    5.87 +
    5.88 +/* Diagonal line */
    5.89 +#define DLINE(type, op, draw_end) \
    5.90 +{ \
    5.91 +    int length; \
    5.92 +    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
    5.93 +    type *pixel; \
    5.94 +    if (y1 <= y2) { \
    5.95 +        pixel = (type *)dst->pixels + y1 * pitch + x1; \
    5.96 +        if (x1 <= x2) { \
    5.97 +            ++pitch; \
    5.98 +        } else { \
    5.99 +            --pitch; \
   5.100 +        } \
   5.101 +        length = (y2-y1); \
   5.102 +    } else { \
   5.103 +        pixel = (type *)dst->pixels + y2 * pitch + x2; \
   5.104 +        if (x2 <= x1) { \
   5.105 +            ++pitch; \
   5.106 +        } else { \
   5.107 +            --pitch; \
   5.108 +        } \
   5.109 +        if (!draw_end) { \
   5.110 +            pixel += pitch; \
   5.111 +        } \
   5.112 +        length = (y1-y2); \
   5.113 +    } \
   5.114 +    if (draw_end) { \
   5.115 +        ++length; \
   5.116 +    } \
   5.117 +    while (length--) { \
   5.118 +        op; \
   5.119 +        pixel += pitch; \
   5.120 +    } \
   5.121 +}
   5.122 +
   5.123 +/* Bresenham's line algorithm */
   5.124 +#define BLINE(x1, y1, x2, y2, op, draw_end) \
   5.125  { \
   5.126      int i, deltax, deltay, numpixels; \
   5.127      int d, dinc1, dinc2; \
   5.128 @@ -341,45 +430,123 @@
   5.129          } \
   5.130      } \
   5.131  }
   5.132 -#define DRAWLINE    BRESENHAM
   5.133  
   5.134 -/*
   5.135 - * Define draw rect macro
   5.136 - * (not tested, this level of optimization not needed ... yet?)
   5.137 - */
   5.138 -#define DRAWRECT(type, op) \
   5.139 -do { \
   5.140 -    int width = rect->w; \
   5.141 -    int height = rect->h; \
   5.142 -    int pitch = (dst->pitch / dst->format->BytesPerPixel); \
   5.143 -    int skip = pitch - width; \
   5.144 -    type *pixel; \
   5.145 -    pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
   5.146 -    { int n = (width+3)/4; \
   5.147 -        switch (width & 3) { \
   5.148 -        case 0: do {   op; pixel++; \
   5.149 -        case 3:        op; pixel++; \
   5.150 -        case 2:        op; pixel++; \
   5.151 -        case 1:        op; pixel++; \
   5.152 -                } while ( --n > 0 ); \
   5.153 +/* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
   5.154 +#define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
   5.155 +{ \
   5.156 +    Uint16 ErrorAdj, ErrorAcc; \
   5.157 +    Uint16 ErrorAccTemp, Weighting; \
   5.158 +    int DeltaX, DeltaY, Temp, XDir; \
   5.159 +    unsigned r, g, b, a, inva; \
   5.160 + \
   5.161 +    /* Draw the initial pixel, which is always exactly intersected by \
   5.162 +       the line and so needs no weighting */ \
   5.163 +    opaque_op(x1, y1); \
   5.164 + \
   5.165 +    /* Draw the final pixel, which is always exactly intersected by the line \
   5.166 +       and so needs no weighting */ \
   5.167 +    if (draw_end) { \
   5.168 +        opaque_op(x2, y2); \
   5.169 +    } \
   5.170 + \
   5.171 +    /* Make sure the line runs top to bottom */ \
   5.172 +    if (y1 > y2) { \
   5.173 +        Temp = y1; y1 = y2; y2 = Temp; \
   5.174 +        Temp = x1; x1 = x2; x2 = Temp; \
   5.175 +    } \
   5.176 +    DeltaY = y2 - y1; \
   5.177 + \
   5.178 +    if ((DeltaX = x2 - x1) >= 0) { \
   5.179 +        XDir = 1; \
   5.180 +    } else { \
   5.181 +        XDir = -1; \
   5.182 +        DeltaX = -DeltaX; /* make DeltaX positive */ \
   5.183 +    } \
   5.184 + \
   5.185 +    /* line is not horizontal, diagonal, or vertical */ \
   5.186 +    ErrorAcc = 0;  /* initialize the line error accumulator to 0 */ \
   5.187 + \
   5.188 +    /* Is this an X-major or Y-major line? */ \
   5.189 +    if (DeltaY > DeltaX) { \
   5.190 +        /* Y-major line; calculate 16-bit fixed-point fractional part of a \
   5.191 +          pixel that X advances each time Y advances 1 pixel, truncating the \
   5.192 +          result so that we won't overrun the endpoint along the X axis */ \
   5.193 +        ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
   5.194 +        /* Draw all pixels other than the first and last */ \
   5.195 +        while (--DeltaY) { \
   5.196 +            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
   5.197 +            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
   5.198 +            if (ErrorAcc <= ErrorAccTemp) { \
   5.199 +                /* The error accumulator turned over, so advance the X coord */ \
   5.200 +                x1 += XDir; \
   5.201 +            } \
   5.202 +            y1++; /* Y-major, so always advance Y */ \
   5.203 +            /* The IntensityBits most significant bits of ErrorAcc give us the \
   5.204 +             intensity weighting for this pixel, and the complement of the \
   5.205 +             weighting for the paired pixel */ \
   5.206 +            Weighting = ErrorAcc >> 8; \
   5.207 +            { \
   5.208 +                a = DRAW_MUL(_a, (Weighting ^ 255)); \
   5.209 +                r = DRAW_MUL(_r, a); \
   5.210 +                g = DRAW_MUL(_g, a); \
   5.211 +                b = DRAW_MUL(_b, a); \
   5.212 +                inva = (a ^ 0xFF); \
   5.213 +                blend_op(x1, y1); \
   5.214 +            } \
   5.215 +            { \
   5.216 +                a = DRAW_MUL(_a, Weighting); \
   5.217 +                r = DRAW_MUL(_r, a); \
   5.218 +                g = DRAW_MUL(_g, a); \
   5.219 +                b = DRAW_MUL(_b, a); \
   5.220 +                inva = (a ^ 0xFF); \
   5.221 +                blend_op(x1 + XDir, y1); \
   5.222 +            } \
   5.223 +        } \
   5.224 +    } else { \
   5.225 +        /* X-major line; calculate 16-bit fixed-point fractional part of a \
   5.226 +           pixel that Y advances each time X advances 1 pixel, truncating the \
   5.227 +           result to avoid overrunning the endpoint along the X axis */ \
   5.228 +        ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
   5.229 +        /* Draw all pixels other than the first and last */ \
   5.230 +        while (--DeltaX) { \
   5.231 +            ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */ \
   5.232 +            ErrorAcc += ErrorAdj;      /* calculate error for next pixel */ \
   5.233 +            if (ErrorAcc <= ErrorAccTemp) { \
   5.234 +                /* The error accumulator turned over, so advance the Y coord */ \
   5.235 +                y1++; \
   5.236 +            } \
   5.237 +            x1 += XDir; /* X-major, so always advance X */ \
   5.238 +            /* The IntensityBits most significant bits of ErrorAcc give us the \
   5.239 +              intensity weighting for this pixel, and the complement of the \
   5.240 +              weighting for the paired pixel */ \
   5.241 +            Weighting = ErrorAcc >> 8; \
   5.242 +            { \
   5.243 +                a = DRAW_MUL(_a, (Weighting ^ 255)); \
   5.244 +                r = DRAW_MUL(_r, a); \
   5.245 +                g = DRAW_MUL(_g, a); \
   5.246 +                b = DRAW_MUL(_b, a); \
   5.247 +                inva = (a ^ 0xFF); \
   5.248 +                blend_op(x1, y1); \
   5.249 +            } \
   5.250 +            { \
   5.251 +                a = DRAW_MUL(_a, Weighting); \
   5.252 +                r = DRAW_MUL(_r, a); \
   5.253 +                g = DRAW_MUL(_g, a); \
   5.254 +                b = DRAW_MUL(_b, a); \
   5.255 +                inva = (a ^ 0xFF); \
   5.256 +                blend_op(x1, y1 + 1); \
   5.257 +            } \
   5.258          } \
   5.259      } \
   5.260 -    pixel += skip; \
   5.261 -    width -= 1; \
   5.262 -    height -= 2; \
   5.263 -    while (height--) { \
   5.264 -        op; pixel += width; op; pixel += skip; \
   5.265 -    } \
   5.266 -    { int n = (width+3)/4; \
   5.267 -        switch (width & 3) { \
   5.268 -        case 0: do {   op; pixel++; \
   5.269 -        case 3:        op; pixel++; \
   5.270 -        case 2:        op; pixel++; \
   5.271 -        case 1:        op; pixel++; \
   5.272 -                } while ( --n > 0 ); \
   5.273 -        } \
   5.274 -    } \
   5.275 -} while (0)
   5.276 +}
   5.277 +
   5.278 +#ifdef AA_LINES
   5.279 +#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
   5.280 +            WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
   5.281 +#else
   5.282 +#define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
   5.283 +            BLINE(x1, y1, x2, y2, opaque_op, draw_end)
   5.284 +#endif
   5.285  
   5.286  /*
   5.287   * Define fill rect macro
     6.1 --- a/src/video/SDL_drawline.c	Fri Dec 18 08:19:18 2009 +0000
     6.2 +++ b/src/video/SDL_drawline.c	Wed Dec 23 01:55:00 2009 +0000
     6.3 @@ -23,17 +23,116 @@
     6.4  
     6.5  #include "SDL_draw.h"
     6.6  
     6.7 +static void
     6.8 +SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
     6.9 +              SDL_bool draw_end)
    6.10 +{
    6.11 +    if (y1 == y2) {
    6.12 +        HLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
    6.13 +    } else if (x1 == x2) {
    6.14 +        VLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
    6.15 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
    6.16 +        DLINE(Uint8, DRAW_FASTSETPIXEL1, draw_end);
    6.17 +    } else {
    6.18 +        BLINE(x1, y1, x2, y2, DRAW_FASTSETPIXELXY1, draw_end);
    6.19 +    }
    6.20 +}
    6.21 +
    6.22 +static void
    6.23 +SDL_DrawLine2(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
    6.24 +              SDL_bool draw_end)
    6.25 +{
    6.26 +    if (y1 == y2) {
    6.27 +        HLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
    6.28 +    } else if (x1 == x2) {
    6.29 +        VLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
    6.30 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
    6.31 +        DLINE(Uint16, DRAW_FASTSETPIXEL2, draw_end);
    6.32 +    } else {
    6.33 +        Uint8 _r, _g, _b, _a;
    6.34 +        const SDL_PixelFormat * fmt = dst->format;
    6.35 +        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
    6.36 +        if (fmt->Rmask == 0x7C00) {
    6.37 +            AALINE(x1, y1, x2, y2,
    6.38 +                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB555,
    6.39 +                   draw_end);
    6.40 +        } else if (fmt->Rmask == 0xF800) {
    6.41 +            AALINE(x1, y1, x2, y2,
    6.42 +                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY_BLEND_RGB565,
    6.43 +                   draw_end);
    6.44 +        } else {
    6.45 +            AALINE(x1, y1, x2, y2,
    6.46 +                   DRAW_FASTSETPIXELXY2, DRAW_SETPIXELXY2_BLEND_RGB,
    6.47 +                   draw_end);
    6.48 +        }
    6.49 +    }
    6.50 +}
    6.51 +
    6.52 +static void
    6.53 +SDL_DrawLine4(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color,
    6.54 +              SDL_bool draw_end)
    6.55 +{
    6.56 +    if (y1 == y2) {
    6.57 +        HLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
    6.58 +    } else if (x1 == x2) {
    6.59 +        VLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
    6.60 +    } else if (ABS(x1 - x2) == ABS(y1 - y2)) {
    6.61 +        DLINE(Uint32, DRAW_FASTSETPIXEL4, draw_end);
    6.62 +    } else {
    6.63 +        Uint8 _r, _g, _b, _a;
    6.64 +        const SDL_PixelFormat * fmt = dst->format;
    6.65 +        SDL_GetRGBA(color, fmt, &_r, &_g, &_b, &_a);
    6.66 +        if (fmt->Rmask == 0x00FF0000) {
    6.67 +            if (!fmt->Amask) {
    6.68 +                AALINE(x1, y1, x2, y2,
    6.69 +                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_RGB888,
    6.70 +                       draw_end);
    6.71 +            } else {
    6.72 +                AALINE(x1, y1, x2, y2,
    6.73 +                       DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY_BLEND_ARGB8888,
    6.74 +                       draw_end);
    6.75 +            }
    6.76 +        } else {
    6.77 +            AALINE(x1, y1, x2, y2,
    6.78 +                   DRAW_FASTSETPIXELXY4, DRAW_SETPIXELXY4_BLEND_RGB,
    6.79 +                   draw_end);
    6.80 +        }
    6.81 +    }
    6.82 +}
    6.83 +
    6.84 +typedef void (*DrawLineFunc) (SDL_Surface * dst,
    6.85 +                              int x1, int y1, int x2, int y2,
    6.86 +                              Uint32 color, SDL_bool draw_end);
    6.87 +
    6.88 +static DrawLineFunc
    6.89 +SDL_CalculateDrawLineFunc(const SDL_PixelFormat * fmt)
    6.90 +{
    6.91 +    switch (fmt->BytesPerPixel) {
    6.92 +    case 1:
    6.93 +        if (fmt->BitsPerPixel < 8) {
    6.94 +            break;
    6.95 +        }
    6.96 +        return SDL_DrawLine1;
    6.97 +    case 2:
    6.98 +        return SDL_DrawLine2;
    6.99 +    case 4:
   6.100 +        return SDL_DrawLine4;
   6.101 +    }
   6.102 +    return NULL;
   6.103 +}
   6.104  
   6.105  int
   6.106  SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
   6.107  {
   6.108 +    DrawLineFunc func;
   6.109 +
   6.110      if (!dst) {
   6.111 -        SDL_SetError("Passed NULL destination surface");
   6.112 +        SDL_SetError("SDL_DrawLine(): Passed NULL destination surface");
   6.113          return -1;
   6.114      }
   6.115  
   6.116 -    /* This function doesn't work on surfaces < 8 bpp */
   6.117 -    if (dst->format->BitsPerPixel < 8) {
   6.118 +    func = SDL_CalculateDrawLineFunc(dst->format);
   6.119 +    if (!func) {
   6.120          SDL_SetError("SDL_DrawLine(): Unsupported surface format");
   6.121          return -1;
   6.122      }
   6.123 @@ -41,23 +140,10 @@
   6.124      /* Perform clipping */
   6.125      /* FIXME: We don't actually want to clip, as it may change line slope */
   6.126      if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) {
   6.127 -        return (0);
   6.128 +        return 0;
   6.129      }
   6.130  
   6.131 -    switch (dst->format->BytesPerPixel) {
   6.132 -    case 1:
   6.133 -        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL1, SDL_TRUE);
   6.134 -        break;
   6.135 -    case 2:
   6.136 -        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL2, SDL_TRUE);
   6.137 -        break;
   6.138 -    case 3:
   6.139 -        SDL_Unsupported();
   6.140 -        return -1;
   6.141 -    case 4:
   6.142 -        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL4, SDL_TRUE);
   6.143 -        break;
   6.144 -    }
   6.145 +    func(dst, x1, y1, x2, y2, color, SDL_TRUE);
   6.146      return 0;
   6.147  }
   6.148  
   6.149 @@ -66,27 +152,27 @@
   6.150                Uint32 color)
   6.151  {
   6.152      int i;
   6.153 +    int x1, y1;
   6.154 +    int x2, y2;
   6.155 +    SDL_bool draw_end;
   6.156 +    DrawLineFunc func;
   6.157  
   6.158      if (!dst) {
   6.159 -        SDL_SetError("Passed NULL destination surface");
   6.160 +        SDL_SetError("SDL_DrawLines(): Passed NULL destination surface");
   6.161          return -1;
   6.162      }
   6.163  
   6.164 -    /* This function doesn't work on surfaces < 8 bpp */
   6.165 -    if (dst->format->BitsPerPixel < 8) {
   6.166 -        SDL_SetError("SDL_DrawLine(): Unsupported surface format");
   6.167 +    func = SDL_CalculateDrawLineFunc(dst->format);
   6.168 +    if (!func) {
   6.169 +        SDL_SetError("SDL_DrawLines(): Unsupported surface format");
   6.170          return -1;
   6.171      }
   6.172  
   6.173 -    if (count < 2) {
   6.174 -        return 0;
   6.175 -    }
   6.176 -
   6.177      for (i = 1; i < count; ++i) {
   6.178 -        int x1 = points[i-1].x;
   6.179 -        int y1 = points[i-1].y;
   6.180 -        int x2 = points[i].x;
   6.181 -        int y2 = points[i].y;
   6.182 +        x1 = points[i-1].x;
   6.183 +        y1 = points[i-1].y;
   6.184 +        x2 = points[i].x;
   6.185 +        y2 = points[i].y;
   6.186  
   6.187          /* Perform clipping */
   6.188          /* FIXME: We don't actually want to clip, as it may change line slope */
   6.189 @@ -94,20 +180,13 @@
   6.190              continue;
   6.191          }
   6.192  
   6.193 -        switch (dst->format->BytesPerPixel) {
   6.194 -        case 1:
   6.195 -            DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL1, SDL_TRUE);
   6.196 -            break;
   6.197 -        case 2:
   6.198 -            DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL2, SDL_TRUE);
   6.199 -            break;
   6.200 -        case 3:
   6.201 -            SDL_Unsupported();
   6.202 -            return -1;
   6.203 -        case 4:
   6.204 -            DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL4, SDL_TRUE);
   6.205 -            break;
   6.206 -        }
   6.207 +        /* Draw the end if it was clipped */
   6.208 +        draw_end = (x2 != points[i].x || y2 != points[i].y);
   6.209 +
   6.210 +        func(dst, x1, y1, x2, y2, color, draw_end);
   6.211 +    }
   6.212 +    if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) {
   6.213 +        SDL_DrawPoint(dst, points[count-1].x, points[count-1].y, color);
   6.214      }
   6.215      return 0;
   6.216  }
     7.1 --- a/src/video/SDL_drawpoint.c	Fri Dec 18 08:19:18 2009 +0000
     7.2 +++ b/src/video/SDL_drawpoint.c	Wed Dec 23 01:55:00 2009 +0000
     7.3 @@ -47,16 +47,16 @@
     7.4  
     7.5      switch (dst->format->BytesPerPixel) {
     7.6      case 1:
     7.7 -        DRAW_FASTSETPIXEL1(x, y);
     7.8 +        DRAW_FASTSETPIXELXY1(x, y);
     7.9          break;
    7.10      case 2:
    7.11 -        DRAW_FASTSETPIXEL2(x, y);
    7.12 +        DRAW_FASTSETPIXELXY2(x, y);
    7.13          break;
    7.14      case 3:
    7.15          SDL_Unsupported();
    7.16          return -1;
    7.17      case 4:
    7.18 -        DRAW_FASTSETPIXEL4(x, y);
    7.19 +        DRAW_FASTSETPIXELXY4(x, y);
    7.20          break;
    7.21      }
    7.22      return 0;
    7.23 @@ -97,16 +97,16 @@
    7.24  
    7.25          switch (dst->format->BytesPerPixel) {
    7.26          case 1:
    7.27 -            DRAW_FASTSETPIXEL1(x, y);
    7.28 +            DRAW_FASTSETPIXELXY1(x, y);
    7.29              break;
    7.30          case 2:
    7.31 -            DRAW_FASTSETPIXEL2(x, y);
    7.32 +            DRAW_FASTSETPIXELXY2(x, y);
    7.33              break;
    7.34          case 3:
    7.35              SDL_Unsupported();
    7.36              return -1;
    7.37          case 4:
    7.38 -            DRAW_FASTSETPIXEL4(x, y);
    7.39 +            DRAW_FASTSETPIXELXY4(x, y);
    7.40              break;
    7.41          }
    7.42      }
     8.1 --- a/src/video/SDL_renderer_gl.c	Fri Dec 18 08:19:18 2009 +0000
     8.2 +++ b/src/video/SDL_renderer_gl.c	Wed Dec 23 01:55:00 2009 +0000
     8.3 @@ -96,12 +96,15 @@
     8.4  static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     8.5  static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     8.6                              int numrects, const SDL_Rect * rects);
     8.7 -static int GL_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
     8.8 -                           int count);
     8.9 -static int GL_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
    8.10 -                          int count);
    8.11 -static int GL_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
    8.12 -                          int count);
    8.13 +static int GL_RenderClear(SDL_Renderer * renderer);
    8.14 +static int GL_RenderDrawPoints(SDL_Renderer * renderer,
    8.15 +                               const SDL_Point * points, int count);
    8.16 +static int GL_RenderDrawLines(SDL_Renderer * renderer,
    8.17 +                              const SDL_Point * points, int count);
    8.18 +static int GL_RenderDrawRects(SDL_Renderer * renderer,
    8.19 +                              const SDL_Rect ** rects, int count);
    8.20 +static int GL_RenderFillRects(SDL_Renderer * renderer,
    8.21 +                              const SDL_Rect ** rects, int count);
    8.22  static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    8.23                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    8.24  static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    8.25 @@ -306,9 +309,11 @@
    8.26      renderer->LockTexture = GL_LockTexture;
    8.27      renderer->UnlockTexture = GL_UnlockTexture;
    8.28      renderer->DirtyTexture = GL_DirtyTexture;
    8.29 -    renderer->RenderPoints = GL_RenderPoints;
    8.30 -    renderer->RenderLines = GL_RenderLines;
    8.31 -    renderer->RenderRects = GL_RenderRects;
    8.32 +    renderer->RenderClear = GL_RenderClear;
    8.33 +    renderer->RenderDrawPoints = GL_RenderDrawPoints;
    8.34 +    renderer->RenderDrawLines = GL_RenderDrawLines;
    8.35 +    renderer->RenderDrawRects = GL_RenderDrawRects;
    8.36 +    renderer->RenderFillRects = GL_RenderFillRects;
    8.37      renderer->RenderCopy = GL_RenderCopy;
    8.38      renderer->RenderReadPixels = GL_RenderReadPixels;
    8.39      renderer->RenderWritePixels = GL_RenderWritePixels;
    8.40 @@ -1114,7 +1119,23 @@
    8.41  }
    8.42  
    8.43  static int
    8.44 -GL_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
    8.45 +GL_RenderClear(SDL_Renderer * renderer)
    8.46 +{
    8.47 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    8.48 +
    8.49 +    data->glClearColor((GLfloat) renderer->r * inv255f,
    8.50 +                       (GLfloat) renderer->g * inv255f,
    8.51 +                       (GLfloat) renderer->b * inv255f,
    8.52 +                       (GLfloat) renderer->a * inv255f);
    8.53 +
    8.54 +    data->glClear(GL_COLOR_BUFFER_BIT);
    8.55 +
    8.56 +    return 0;
    8.57 +}
    8.58 +
    8.59 +static int
    8.60 +GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    8.61 +                    int count)
    8.62  {
    8.63      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    8.64      int i;
    8.65 @@ -1136,7 +1157,8 @@
    8.66  }
    8.67  
    8.68  static int
    8.69 -GL_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
    8.70 +GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    8.71 +                   int count)
    8.72  {
    8.73      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    8.74      int i;
    8.75 @@ -1199,7 +1221,46 @@
    8.76  }
    8.77  
    8.78  static int
    8.79 -GL_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
    8.80 +GL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
    8.81 +{
    8.82 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    8.83 +    int i, x, y;
    8.84 +    SDL_Point points[4];
    8.85 +
    8.86 +    GL_SetBlendMode(data, renderer->blendMode, 1);
    8.87 +
    8.88 +    data->glColor4f((GLfloat) renderer->r * inv255f,
    8.89 +                    (GLfloat) renderer->g * inv255f,
    8.90 +                    (GLfloat) renderer->b * inv255f,
    8.91 +                    (GLfloat) renderer->a * inv255f);
    8.92 +
    8.93 +    data->glBegin(GL_LINE_LOOP);
    8.94 +    for (i = 0; i < count; ++i) {
    8.95 +        const SDL_Rect *rect = rects[i];
    8.96 +
    8.97 +        x = rect->x;
    8.98 +        y = rect->y;
    8.99 +        data->glVertex2f(0.5f + x, 0.5f + y);
   8.100 +
   8.101 +        x = rect->x+rect->w-1;
   8.102 +        y = rect->y;
   8.103 +        data->glVertex2f(0.5f + x, 0.5f + y);
   8.104 +
   8.105 +        x = rect->x+rect->w-1;
   8.106 +        y = rect->y+rect->h-1;
   8.107 +        data->glVertex2f(0.5f + x, 0.5f + y);
   8.108 +
   8.109 +        x = rect->x;
   8.110 +        y = rect->y+rect->h-1;
   8.111 +        data->glVertex2f(0.5f + x, 0.5f + y);
   8.112 +    }
   8.113 +    data->glEnd();
   8.114 +
   8.115 +    return 0;
   8.116 +}
   8.117 +
   8.118 +static int
   8.119 +GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
   8.120  {
   8.121      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   8.122      int i;
     9.1 --- a/src/video/SDL_renderer_sw.c	Fri Dec 18 08:19:18 2009 +0000
     9.2 +++ b/src/video/SDL_renderer_sw.c	Wed Dec 23 01:55:00 2009 +0000
     9.3 @@ -59,12 +59,14 @@
     9.4                            const SDL_Rect * rect, int markDirty, void **pixels,
     9.5                            int *pitch);
     9.6  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     9.7 -static int SW_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
     9.8 -                           int count);
     9.9 -static int SW_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
    9.10 -                          int count);
    9.11 -static int SW_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
    9.12 -                          int count);
    9.13 +static int SW_RenderDrawPoints(SDL_Renderer * renderer,
    9.14 +                               const SDL_Point * points, int count);
    9.15 +static int SW_RenderDrawLines(SDL_Renderer * renderer,
    9.16 +                              const SDL_Point * points, int count);
    9.17 +static int SW_RenderDrawRects(SDL_Renderer * renderer,
    9.18 +                              const SDL_Rect ** rects, int count);
    9.19 +static int SW_RenderFillRects(SDL_Renderer * renderer,
    9.20 +                              const SDL_Rect ** rects, int count);
    9.21  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    9.22                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    9.23  static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
    9.24 @@ -230,9 +232,10 @@
    9.25      renderer->ActivateRenderer = SW_ActivateRenderer;
    9.26      renderer->DisplayModeChanged = SW_DisplayModeChanged;
    9.27  
    9.28 -    renderer->RenderPoints = SW_RenderPoints;
    9.29 -    renderer->RenderLines = SW_RenderLines;
    9.30 -    renderer->RenderRects = SW_RenderRects;
    9.31 +    renderer->RenderDrawPoints = SW_RenderDrawPoints;
    9.32 +    renderer->RenderDrawLines = SW_RenderDrawLines;
    9.33 +    renderer->RenderDrawRects = SW_RenderDrawRects;
    9.34 +    renderer->RenderFillRects = SW_RenderFillRects;
    9.35      renderer->RenderCopy = SW_RenderCopy;
    9.36      renderer->RenderReadPixels = SW_RenderReadPixels;
    9.37      renderer->RenderWritePixels = SW_RenderWritePixels;
    9.38 @@ -539,7 +542,8 @@
    9.39  }
    9.40  
    9.41  static int
    9.42 -SW_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
    9.43 +SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
    9.44 +                    int count)
    9.45  {
    9.46      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    9.47      SDL_Texture *texture = data->texture[data->current_texture];
    9.48 @@ -602,7 +606,8 @@
    9.49  }
    9.50  
    9.51  static int
    9.52 -SW_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
    9.53 +SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
    9.54 +                   int count)
    9.55  {
    9.56      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    9.57      SDL_Texture *texture = data->texture[data->current_texture];
    9.58 @@ -670,7 +675,65 @@
    9.59  }
    9.60  
    9.61  static int
    9.62 -SW_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
    9.63 +SW_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
    9.64 +                   int count)
    9.65 +{
    9.66 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    9.67 +    SDL_Texture *texture = data->texture[data->current_texture];
    9.68 +    SDL_Rect clip, rect;
    9.69 +    Uint32 color = 0;
    9.70 +    int i;
    9.71 +    int status = 0;
    9.72 +
    9.73 +    clip.x = 0;
    9.74 +    clip.y = 0;
    9.75 +    clip.w = texture->w;
    9.76 +    clip.h = texture->h;
    9.77 +
    9.78 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
    9.79 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
    9.80 +        color = SDL_MapRGBA(data->surface.format,
    9.81 +                            renderer->r, renderer->g, renderer->b,
    9.82 +                            renderer->a);
    9.83 +    }
    9.84 +
    9.85 +    for (i = 0; i < count; ++i) {
    9.86 +        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
    9.87 +            /* Nothing to draw */
    9.88 +            continue;
    9.89 +        }
    9.90 +
    9.91 +        if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
    9.92 +            SDL_AddDirtyRect(&data->dirty, &rect);
    9.93 +        }
    9.94 +
    9.95 +        if (data->renderer->LockTexture(data->renderer, texture, &rect, 1,
    9.96 +                                        &data->surface.pixels,
    9.97 +                                        &data->surface.pitch) < 0) {
    9.98 +            return -1;
    9.99 +        }
   9.100 +
   9.101 +        data->surface.clip_rect.w = data->surface.w = rect.w;
   9.102 +        data->surface.clip_rect.h = data->surface.h = rect.h;
   9.103 +
   9.104 +        if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   9.105 +            renderer->blendMode == SDL_BLENDMODE_MASK) {
   9.106 +            status = SDL_DrawRect(&data->surface, NULL, color);
   9.107 +        } else {
   9.108 +            status = SDL_BlendRect(&data->surface, NULL,
   9.109 +                                   renderer->blendMode,
   9.110 +                                   renderer->r, renderer->g, renderer->b,
   9.111 +                                   renderer->a);
   9.112 +        }
   9.113 +
   9.114 +        data->renderer->UnlockTexture(data->renderer, texture);
   9.115 +    }
   9.116 +    return status;
   9.117 +}
   9.118 +
   9.119 +static int
   9.120 +SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   9.121 +                   int count)
   9.122  {
   9.123      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   9.124      SDL_Texture *texture = data->texture[data->current_texture];
   9.125 @@ -714,10 +777,10 @@
   9.126              renderer->blendMode == SDL_BLENDMODE_MASK) {
   9.127              status = SDL_FillRect(&data->surface, NULL, color);
   9.128          } else {
   9.129 -            status = SDL_BlendRect(&data->surface, NULL,
   9.130 -                                   renderer->blendMode,
   9.131 -                                   renderer->r, renderer->g, renderer->b,
   9.132 -                                   renderer->a);
   9.133 +            status = SDL_BlendFillRect(&data->surface, NULL,
   9.134 +                                       renderer->blendMode,
   9.135 +                                       renderer->r, renderer->g, renderer->b,
   9.136 +                                       renderer->a);
   9.137          }
   9.138  
   9.139          data->renderer->UnlockTexture(data->renderer, texture);
    10.1 --- a/src/video/SDL_sysvideo.h	Fri Dec 18 08:19:18 2009 +0000
    10.2 +++ b/src/video/SDL_sysvideo.h	Wed Dec 23 01:55:00 2009 +0000
    10.3 @@ -90,12 +90,19 @@
    10.4                            int numrects, const SDL_Rect * rects);
    10.5      int (*SetDrawColor) (SDL_Renderer * renderer);
    10.6      int (*SetDrawBlendMode) (SDL_Renderer * renderer);
    10.7 -    int (*RenderPoints) (SDL_Renderer * renderer, const SDL_Point * points,
    10.8 -                         int count);
    10.9 -    int (*RenderLines) (SDL_Renderer * renderer, const SDL_Point * points,
   10.10 -                        int count);
   10.11 -    int (*RenderRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
   10.12 -                        int count);
   10.13 +    int (*RenderClear) (SDL_Renderer * renderer);
   10.14 +    int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points,
   10.15 +                             int count);
   10.16 +    int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points,
   10.17 +                            int count);
   10.18 +    int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
   10.19 +                            int count);
   10.20 +    int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects,
   10.21 +                            int count);
   10.22 +    int (*RenderDrawEllipse) (SDL_Renderer * renderer, int x, int y,
   10.23 +                              int w, int h);
   10.24 +    int (*RenderFillEllipse) (SDL_Renderer * renderer, int x, int y,
   10.25 +                              int w, int h);
   10.26      int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
   10.27                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   10.28      int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect,
    11.1 --- a/src/video/SDL_video.c	Fri Dec 18 08:19:18 2009 +0000
    11.2 +++ b/src/video/SDL_video.c	Wed Dec 23 01:55:00 2009 +0000
    11.3 @@ -2483,41 +2483,68 @@
    11.4  }
    11.5  
    11.6  int
    11.7 -SDL_RenderPoint(int x, int y)
    11.8 -{
    11.9 -    SDL_Point point;
   11.10 -
   11.11 -    point.x = x;
   11.12 -    point.y = y;
   11.13 -    return SDL_RenderPoints(&point, 1);
   11.14 -}
   11.15 -
   11.16 -int
   11.17 -SDL_RenderPoints(const SDL_Point * points, int count)
   11.18 +SDL_RenderClear()
   11.19  {
   11.20      SDL_Renderer *renderer;
   11.21  
   11.22 -    if (!points) {
   11.23 -        SDL_SetError("SDL_RenderPoints(): Passed NULL points");
   11.24 -        return -1;
   11.25 -    }
   11.26 -
   11.27      renderer = SDL_GetCurrentRenderer(SDL_TRUE);
   11.28      if (!renderer) {
   11.29          return -1;
   11.30      }
   11.31 -    if (!renderer->RenderPoints) {
   11.32 +    if (!renderer->RenderClear) {
   11.33 +        int blendMode = renderer->blendMode;
   11.34 +        int status;
   11.35 +
   11.36 +        if (blendMode >= SDL_BLENDMODE_BLEND) {
   11.37 +            SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   11.38 +        }
   11.39 +
   11.40 +        status = SDL_RenderFillRect(NULL);
   11.41 +
   11.42 +        if (blendMode >= SDL_BLENDMODE_BLEND) {
   11.43 +            SDL_SetRenderDrawBlendMode(blendMode);
   11.44 +        }
   11.45 +        return status;
   11.46 +    }
   11.47 +    return renderer->RenderClear(renderer);
   11.48 +}
   11.49 +
   11.50 +int
   11.51 +SDL_RenderDrawPoint(int x, int y)
   11.52 +{
   11.53 +    SDL_Point point;
   11.54 +
   11.55 +    point.x = x;
   11.56 +    point.y = y;
   11.57 +    return SDL_RenderDrawPoints(&point, 1);
   11.58 +}
   11.59 +
   11.60 +int
   11.61 +SDL_RenderDrawPoints(const SDL_Point * points, int count)
   11.62 +{
   11.63 +    SDL_Renderer *renderer;
   11.64 +
   11.65 +    if (!points) {
   11.66 +        SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points");
   11.67 +        return -1;
   11.68 +    }
   11.69 +
   11.70 +    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
   11.71 +    if (!renderer) {
   11.72 +        return -1;
   11.73 +    }
   11.74 +    if (!renderer->RenderDrawPoints) {
   11.75          SDL_Unsupported();
   11.76          return -1;
   11.77      }
   11.78      if (count < 1) {
   11.79          return 0;
   11.80      }
   11.81 -    return renderer->RenderPoints(renderer, points, count);
   11.82 +    return renderer->RenderDrawPoints(renderer, points, count);
   11.83  }
   11.84  
   11.85  int
   11.86 -SDL_RenderLine(int x1, int y1, int x2, int y2)
   11.87 +SDL_RenderDrawLine(int x1, int y1, int x2, int y2)
   11.88  {
   11.89      SDL_Point points[2];
   11.90  
   11.91 @@ -2525,16 +2552,16 @@
   11.92      points[0].y = y1;
   11.93      points[1].x = x2;
   11.94      points[1].y = y2;
   11.95 -    return SDL_RenderLines(points, 2);
   11.96 +    return SDL_RenderDrawLines(points, 2);
   11.97  }
   11.98  
   11.99  int
  11.100 -SDL_RenderLines(const SDL_Point * points, int count)
  11.101 +SDL_RenderDrawLines(const SDL_Point * points, int count)
  11.102  {
  11.103      SDL_Renderer *renderer;
  11.104  
  11.105      if (!points) {
  11.106 -        SDL_SetError("SDL_RenderLines(): Passed NULL points");
  11.107 +        SDL_SetError("SDL_RenderDrawLines(): Passed NULL points");
  11.108          return -1;
  11.109      }
  11.110  
  11.111 @@ -2542,30 +2569,30 @@
  11.112      if (!renderer) {
  11.113          return -1;
  11.114      }
  11.115 -    if (!renderer->RenderLines) {
  11.116 +    if (!renderer->RenderDrawLines) {
  11.117          SDL_Unsupported();
  11.118          return -1;
  11.119      }
  11.120      if (count < 2) {
  11.121          return 0;
  11.122      }
  11.123 -    return renderer->RenderLines(renderer, points, count);
  11.124 +    return renderer->RenderDrawLines(renderer, points, count);
  11.125  }
  11.126  
  11.127  int
  11.128 -SDL_RenderRect(const SDL_Rect * rect)
  11.129 +SDL_RenderDrawRect(const SDL_Rect * rect)
  11.130  {
  11.131 -    return SDL_RenderRects(&rect, 1);
  11.132 +    return SDL_RenderDrawRects(&rect, 1);
  11.133  }
  11.134  
  11.135  int
  11.136 -SDL_RenderRects(const SDL_Rect ** rects, int count)
  11.137 +SDL_RenderDrawRects(const SDL_Rect ** rects, int count)
  11.138  {
  11.139      SDL_Renderer *renderer;
  11.140      int i;
  11.141  
  11.142      if (!rects) {
  11.143 -        SDL_SetError("SDL_RenderRects(): Passed NULL rects");
  11.144 +        SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects");
  11.145          return -1;
  11.146      }
  11.147  
  11.148 @@ -2573,7 +2600,7 @@
  11.149      if (!renderer) {
  11.150          return -1;
  11.151      }
  11.152 -    if (!renderer->RenderRects) {
  11.153 +    if (!renderer->RenderDrawRects) {
  11.154          SDL_Unsupported();
  11.155          return -1;
  11.156      }
  11.157 @@ -2593,10 +2620,99 @@
  11.158              full_rect.w = window->w;
  11.159              full_rect.h = window->h;
  11.160              rect = &full_rect;
  11.161 -            return renderer->RenderRects(renderer, &rect, 1);
  11.162 +            return renderer->RenderDrawRects(renderer, &rect, 1);
  11.163          }
  11.164      }
  11.165 -    return renderer->RenderRects(renderer, rects, count);
  11.166 +    return renderer->RenderDrawRects(renderer, rects, count);
  11.167 +}
  11.168 +
  11.169 +int
  11.170 +SDL_RenderFillRect(const SDL_Rect * rect)
  11.171 +{
  11.172 +    return SDL_RenderFillRects(&rect, 1);
  11.173 +}
  11.174 +
  11.175 +int
  11.176 +SDL_RenderFillRects(const SDL_Rect ** rects, int count)
  11.177 +{
  11.178 +    SDL_Renderer *renderer;
  11.179 +    int i;
  11.180 +
  11.181 +    if (!rects) {
  11.182 +        SDL_SetError("SDL_RenderFillRects(): Passed NULL rects");
  11.183 +        return -1;
  11.184 +    }
  11.185 +
  11.186 +    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
  11.187 +    if (!renderer) {
  11.188 +        return -1;
  11.189 +    }
  11.190 +    if (!renderer->RenderFillRects) {
  11.191 +        SDL_Unsupported();
  11.192 +        return -1;
  11.193 +    }
  11.194 +    if (count < 1) {
  11.195 +        return 0;
  11.196 +    }
  11.197 +    /* Check for NULL rect, which means fill entire window */
  11.198 +    for (i = 0; i < count; ++i) {
  11.199 +        if (rects[i] == NULL) {
  11.200 +            SDL_Window *window;
  11.201 +            SDL_Rect full_rect;
  11.202 +            const SDL_Rect *rect;
  11.203 +
  11.204 +            window = SDL_GetWindowFromID(renderer->window);
  11.205 +            full_rect.x = 0;
  11.206 +            full_rect.y = 0;
  11.207 +            full_rect.w = window->w;
  11.208 +            full_rect.h = window->h;
  11.209 +            rect = &full_rect;
  11.210 +            return renderer->RenderFillRects(renderer, &rect, 1);
  11.211 +        }
  11.212 +    }
  11.213 +    return renderer->RenderFillRects(renderer, rects, count);
  11.214 +}
  11.215 +
  11.216 +int
  11.217 +SDL_RenderDrawCircle(int x, int y, int radius)
  11.218 +{
  11.219 +    return SDL_RenderDrawEllipse(x, y, 2*radius, 2*radius);
  11.220 +}
  11.221 +
  11.222 +int
  11.223 +SDL_RenderFillCircle(int x, int y, int radius)
  11.224 +{
  11.225 +    return SDL_RenderFillEllipse(x, y, 2*radius, 2*radius);
  11.226 +}
  11.227 +
  11.228 +int SDL_RenderDrawEllipse(int x, int y, int w, int h)
  11.229 +{
  11.230 +    SDL_Renderer *renderer;
  11.231 +
  11.232 +    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
  11.233 +    if (!renderer) {
  11.234 +        return -1;
  11.235 +    }
  11.236 +    if (!renderer->RenderDrawEllipse) {
  11.237 +        SDL_Unsupported();
  11.238 +        return -1;
  11.239 +    }
  11.240 +    return renderer->RenderDrawEllipse(renderer, x, y, w, h);
  11.241 +}
  11.242 +
  11.243 +int SDL_RenderFillEllipse(int x, int y, int w, int h)
  11.244 +{
  11.245 +    SDL_Renderer *renderer;
  11.246 +
  11.247 +    renderer = SDL_GetCurrentRenderer(SDL_TRUE);
  11.248 +    if (!renderer) {
  11.249 +        return -1;
  11.250 +    }
  11.251 +    if (!renderer->RenderFillEllipse) {
  11.252 +        SDL_Unsupported();
  11.253 +        return -1;
  11.254 +    }
  11.255 +    return renderer->RenderFillEllipse(renderer, x, y, w, h);
  11.256  }
  11.257  
  11.258  int
    12.1 --- a/src/video/dummy/SDL_nullrender.c	Fri Dec 18 08:19:18 2009 +0000
    12.2 +++ b/src/video/dummy/SDL_nullrender.c	Wed Dec 23 01:55:00 2009 +0000
    12.3 @@ -31,12 +31,14 @@
    12.4  
    12.5  static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
    12.6                                                Uint32 flags);
    12.7 -static int SDL_DUMMY_RenderPoints(SDL_Renderer * renderer,
    12.8 -                                  const SDL_Point * points, int count);
    12.9 -static int SDL_DUMMY_RenderLines(SDL_Renderer * renderer,
   12.10 -                                 const SDL_Point * points, int count);
   12.11 -static int SDL_DUMMY_RenderRects(SDL_Renderer * renderer,
   12.12 -                                 const SDL_Rect ** rects, int count);
   12.13 +static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
   12.14 +                                      const SDL_Point * points, int count);
   12.15 +static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
   12.16 +                                     const SDL_Point * points, int count);
   12.17 +static int SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer,
   12.18 +                                     const SDL_Rect ** rects, int count);
   12.19 +static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer,
   12.20 +                                     const SDL_Rect ** rects, int count);
   12.21  static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
   12.22                                  SDL_Texture * texture,
   12.23                                  const SDL_Rect * srcrect,
   12.24 @@ -100,9 +102,10 @@
   12.25      }
   12.26      SDL_zerop(data);
   12.27  
   12.28 -    renderer->RenderPoints = SDL_DUMMY_RenderPoints;
   12.29 -    renderer->RenderLines = SDL_DUMMY_RenderLines;
   12.30 -    renderer->RenderRects = SDL_DUMMY_RenderRects;
   12.31 +    renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints;
   12.32 +    renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines;
   12.33 +    renderer->RenderDrawRects = SDL_DUMMY_RenderDrawRects;
   12.34 +    renderer->RenderFillRects = SDL_DUMMY_RenderFillRects;
   12.35      renderer->RenderCopy = SDL_DUMMY_RenderCopy;
   12.36      renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
   12.37      renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
   12.38 @@ -140,8 +143,8 @@
   12.39  }
   12.40  
   12.41  static int
   12.42 -SDL_DUMMY_RenderPoints(SDL_Renderer * renderer,
   12.43 -                       const SDL_Point * points, int count)
   12.44 +SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer,
   12.45 +                           const SDL_Point * points, int count)
   12.46  {
   12.47      SDL_DUMMY_RenderData *data =
   12.48          (SDL_DUMMY_RenderData *) renderer->driverdata;
   12.49 @@ -162,8 +165,8 @@
   12.50  }
   12.51  
   12.52  static int
   12.53 -SDL_DUMMY_RenderLines(SDL_Renderer * renderer,
   12.54 -                      const SDL_Point * points, int count)
   12.55 +SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer,
   12.56 +                          const SDL_Point * points, int count)
   12.57  {
   12.58      SDL_DUMMY_RenderData *data =
   12.59          (SDL_DUMMY_RenderData *) renderer->driverdata;
   12.60 @@ -184,8 +187,31 @@
   12.61  }
   12.62  
   12.63  static int
   12.64 -SDL_DUMMY_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   12.65 -                      int count)
   12.66 +SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   12.67 +                          int count)
   12.68 +{
   12.69 +    SDL_DUMMY_RenderData *data =
   12.70 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   12.71 +    SDL_Surface *target = data->screens[data->current_screen];
   12.72 +
   12.73 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   12.74 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
   12.75 +        Uint32 color = SDL_MapRGBA(target->format,
   12.76 +                                   renderer->r, renderer->g, renderer->b,
   12.77 +                                   renderer->a);
   12.78 +
   12.79 +        return SDL_DrawRects(target, rects, count, color);
   12.80 +    } else {
   12.81 +        return SDL_BlendRects(target, rects, count,
   12.82 +                              renderer->blendMode,
   12.83 +                              renderer->r, renderer->g, renderer->b,
   12.84 +                              renderer->a);
   12.85 +    }
   12.86 +}
   12.87 +
   12.88 +static int
   12.89 +SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   12.90 +                          int count)
   12.91  {
   12.92      SDL_DUMMY_RenderData *data =
   12.93          (SDL_DUMMY_RenderData *) renderer->driverdata;
   12.94 @@ -199,10 +225,10 @@
   12.95  
   12.96          return SDL_FillRects(target, rects, count, color);
   12.97      } else {
   12.98 -        return SDL_BlendRects(target, rects, count,
   12.99 -                              renderer->blendMode,
  12.100 -                              renderer->r, renderer->g, renderer->b,
  12.101 -                              renderer->a);
  12.102 +        return SDL_BlendFillRects(target, rects, count,
  12.103 +                                  renderer->blendMode,
  12.104 +                                  renderer->r, renderer->g, renderer->b,
  12.105 +                                  renderer->a);
  12.106      }
  12.107  }
  12.108  
    13.1 --- a/src/video/ps3/SDL_ps3render.c	Fri Dec 18 08:19:18 2009 +0000
    13.2 +++ b/src/video/ps3/SDL_ps3render.c	Wed Dec 23 01:55:00 2009 +0000
    13.3 @@ -503,8 +503,9 @@
    13.4          status = SDL_FillRect(target, &real_rect, color);
    13.5      } else {
    13.6          status =
    13.7 -            SDL_BlendRect(target, &real_rect, renderer->blendMode,
    13.8 -                          renderer->r, renderer->g, renderer->b, renderer->a);
    13.9 +            SDL_BlendFillRect(target, &real_rect, renderer->blendMode,
   13.10 +                              renderer->r, renderer->g, renderer->b,
   13.11 +                              renderer->a);
   13.12      }
   13.13      return status;
   13.14  }
    14.1 --- a/src/video/x11/SDL_x11render.c	Fri Dec 18 08:19:18 2009 +0000
    14.2 +++ b/src/video/x11/SDL_x11render.c	Wed Dec 23 01:55:00 2009 +0000
    14.3 @@ -50,12 +50,14 @@
    14.4                             void **pixels, int *pitch);
    14.5  static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    14.6  static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
    14.7 -static int X11_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points,
    14.8 -                            int count);
    14.9 -static int X11_RenderLines(SDL_Renderer * renderer, const SDL_Point * points,
   14.10 -                           int count);
   14.11 -static int X11_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
   14.12 -                           int count);
   14.13 +static int X11_RenderDrawPoints(SDL_Renderer * renderer,
   14.14 +                                const SDL_Point * points, int count);
   14.15 +static int X11_RenderDrawLines(SDL_Renderer * renderer,
   14.16 +                               const SDL_Point * points, int count);
   14.17 +static int X11_RenderDrawRects(SDL_Renderer * renderer,
   14.18 +                               const SDL_Rect ** rects, int count);
   14.19 +static int X11_RenderFillRects(SDL_Renderer * renderer,
   14.20 +                               const SDL_Rect ** rects, int count);
   14.21  static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   14.22                            const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   14.23  static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
   14.24 @@ -208,9 +210,10 @@
   14.25      renderer->LockTexture = X11_LockTexture;
   14.26      renderer->UnlockTexture = X11_UnlockTexture;
   14.27      renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
   14.28 -    renderer->RenderPoints = X11_RenderPoints;
   14.29 -    renderer->RenderLines = X11_RenderLines;
   14.30 -    renderer->RenderRects = X11_RenderRects;
   14.31 +    renderer->RenderDrawPoints = X11_RenderDrawPoints;
   14.32 +    renderer->RenderDrawLines = X11_RenderDrawLines;
   14.33 +    renderer->RenderDrawRects = X11_RenderDrawRects;
   14.34 +    renderer->RenderFillRects = X11_RenderFillRects;
   14.35      renderer->RenderCopy = X11_RenderCopy;
   14.36      renderer->RenderReadPixels = X11_RenderReadPixels;
   14.37      renderer->RenderWritePixels = X11_RenderWritePixels;
   14.38 @@ -600,7 +603,8 @@
   14.39  }
   14.40  
   14.41  static int
   14.42 -X11_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
   14.43 +X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
   14.44 +                     int count)
   14.45  {
   14.46      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   14.47      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   14.48 @@ -649,7 +653,8 @@
   14.49  }
   14.50  
   14.51  static int
   14.52 -X11_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
   14.53 +X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
   14.54 +                    int count)
   14.55  {
   14.56      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   14.57      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   14.58 @@ -787,7 +792,52 @@
   14.59  }
   14.60  
   14.61  static int
   14.62 -X11_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
   14.63 +X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
   14.64 +{
   14.65 +    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   14.66 +    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   14.67 +    SDL_Rect clip, rect;
   14.68 +    unsigned long foreground;
   14.69 +    XRectangle *xrects, *xrect;
   14.70 +    int i, xcount;
   14.71 +
   14.72 +    clip.x = 0;
   14.73 +    clip.y = 0;
   14.74 +    clip.w = window->w;
   14.75 +    clip.h = window->h;
   14.76 +
   14.77 +    foreground = renderdrawcolor(renderer, 1);
   14.78 +    XSetForeground(data->display, data->gc, foreground);
   14.79 +
   14.80 +    xrect = xrects = SDL_stack_alloc(XRectangle, count);
   14.81 +    xcount = 0;
   14.82 +    for (i = 0; i < count; ++i) {
   14.83 +        if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
   14.84 +            continue;
   14.85 +        }
   14.86 +
   14.87 +        xrect->x = (short)rect.x;
   14.88 +        xrect->y = (short)rect.y;
   14.89 +        xrect->width = (unsigned short)rect.w;
   14.90 +        xrect->height = (unsigned short)rect.h;
   14.91 +        ++xrect;
   14.92 +        ++xcount;
   14.93 +
   14.94 +        if (data->makedirty) {
   14.95 +            SDL_AddDirtyRect(&data->dirty, &rect);
   14.96 +        }
   14.97 +    }
   14.98 +    if (xcount > 0) {
   14.99 +        XDrawRectangles(data->display, data->drawable, data->gc,
  14.100 +                        xrects, xcount);
  14.101 +    }
  14.102 +    SDL_stack_free(xpoints);
  14.103 +
  14.104 +    return 0;
  14.105 +}
  14.106 +
  14.107 +static int
  14.108 +X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
  14.109  {
  14.110      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
  14.111      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
    15.1 --- a/src/video/x11/SDL_x11sym.h	Fri Dec 18 08:19:18 2009 +0000
    15.2 +++ b/src/video/x11/SDL_x11sym.h	Wed Dec 23 01:55:00 2009 +0000
    15.3 @@ -50,6 +50,10 @@
    15.4  SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return)
    15.5  SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
    15.6  SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
    15.7 +SDL_X11_SYM(int,XDrawLines,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
    15.8 +SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return)
    15.9 +SDL_X11_SYM(int,XDrawPoints,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
   15.10 +SDL_X11_SYM(int,XDrawRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
   15.11  SDL_X11_SYM(int,XFillRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return)
   15.12  SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
   15.13  SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
   15.14 @@ -95,9 +99,6 @@
   15.15  SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
   15.16  SDL_X11_SYM(int,XPending,(Display* a),(a),return)
   15.17  SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
   15.18 -SDL_X11_SYM(int,XDrawLines,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
   15.19 -SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return)
   15.20 -SDL_X11_SYM(int,XDrawPoints,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return)
   15.21  SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
   15.22  SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
   15.23  SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
    16.1 --- a/test/automated/Makefile	Fri Dec 18 08:19:18 2009 +0000
    16.2 +++ b/test/automated/Makefile	Wed Dec 23 01:55:00 2009 +0000
    16.3 @@ -1,6 +1,6 @@
    16.4  
    16.5  
    16.6 -CFLAGS  := -W -Wall -Wextra -g `sdl-config --cflags`
    16.7 +CFLAGS  := -W -Wall -Wextra -g `sdl-config --cflags` -DSDL_NO_COMPAT
    16.8  LDFLAGS := `sdl-config --libs`
    16.9  
   16.10  # If it doesn't pick up defaults
    17.1 --- a/test/automated/render/render.c	Fri Dec 18 08:19:18 2009 +0000
    17.2 +++ b/test/automated/render/render.c	Wed Dec 23 01:55:00 2009 +0000
    17.3 @@ -341,9 +341,9 @@
    17.4     */
    17.5  
    17.6     /* Clear screen. */
    17.7 -   ret = SDL_RenderRect( NULL );
    17.8 +   ret = SDL_RenderFillRect( NULL );
    17.9     /*
   17.10 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
   17.11 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
   17.12        return -1;
   17.13     */
   17.14  
   17.15 @@ -413,8 +413,8 @@
   17.16     ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
   17.17     if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.18        return -1;
   17.19 -   ret = SDL_RenderRect( &rect );
   17.20 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
   17.21 +   ret = SDL_RenderFillRect( &rect );
   17.22 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
   17.23        return -1;
   17.24  
   17.25     /* Draw a rectangle. */
   17.26 @@ -425,8 +425,8 @@
   17.27     ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
   17.28     if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.29        return -1;
   17.30 -   ret = SDL_RenderRect( &rect );
   17.31 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
   17.32 +   ret = SDL_RenderFillRect( &rect );
   17.33 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
   17.34        return -1;
   17.35  
   17.36     /* Draw some points like so:
   17.37 @@ -439,8 +439,8 @@
   17.38           ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
   17.39           if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.40              return -1;
   17.41 -         ret = SDL_RenderPoint( x, y );
   17.42 -         if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
   17.43 +         ret = SDL_RenderDrawPoint( x, y );
   17.44 +         if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
   17.45              return -1;
   17.46        }
   17.47     }
   17.48 @@ -449,29 +449,29 @@
   17.49     ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
   17.50     if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.51        return -1;
   17.52 -   ret = SDL_RenderLine( 0, 30, 80, 30 );
   17.53 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.54 +   ret = SDL_RenderDrawLine( 0, 30, 80, 30 );
   17.55 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.56        return -1;
   17.57     ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
   17.58     if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.59        return -1;
   17.60 -   ret = SDL_RenderLine( 40, 30, 40, 60 );
   17.61 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.62 +   ret = SDL_RenderDrawLine( 40, 30, 40, 60 );
   17.63 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.64        return -1;
   17.65     ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
   17.66     if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
   17.67        return -1;
   17.68 -   ret = SDL_RenderLine( 0, 0, 29, 29 );
   17.69 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.70 +   ret = SDL_RenderDrawLine( 0, 0, 29, 29 );
   17.71 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.72        return -1;
   17.73 -   ret = SDL_RenderLine( 29, 30, 0, 59 );
   17.74 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.75 +   ret = SDL_RenderDrawLine( 29, 30, 0, 59 );
   17.76 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.77        return -1;
   17.78 -   ret = SDL_RenderLine( 79, 0, 50, 29 );
   17.79 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.80 +   ret = SDL_RenderDrawLine( 79, 0, 50, 29 );
   17.81 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.82        return -1;
   17.83 -   ret = SDL_RenderLine( 79, 59, 50, 30 );
   17.84 -   if (SDL_ATassert( "SDL_RenderLine", ret == 0))
   17.85 +   ret = SDL_RenderDrawLine( 79, 59, 50, 30 );
   17.86 +   if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
   17.87        return -1;
   17.88  
   17.89     /* See if it's the same. */
   17.90 @@ -506,8 +506,8 @@
   17.91     ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
   17.92     if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
   17.93        return -1;
   17.94 -   ret = SDL_RenderRect( NULL );
   17.95 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
   17.96 +   ret = SDL_RenderFillRect( NULL );
   17.97 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
   17.98        return -1;
   17.99     rect.x = 10;
  17.100     rect.y = 25;
  17.101 @@ -519,8 +519,8 @@
  17.102     ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
  17.103     if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.104        return -1;
  17.105 -   ret = SDL_RenderRect( &rect );
  17.106 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
  17.107 +   ret = SDL_RenderFillRect( &rect );
  17.108 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
  17.109        return -1;
  17.110     rect.x = 30;
  17.111     rect.y = 40;
  17.112 @@ -532,8 +532,8 @@
  17.113     ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
  17.114     if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.115        return -1;
  17.116 -   ret = SDL_RenderRect( &rect );
  17.117 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
  17.118 +   ret = SDL_RenderFillRect( &rect );
  17.119 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
  17.120        return -1;
  17.121     rect.x = 25;
  17.122     rect.y = 25;
  17.123 @@ -545,8 +545,8 @@
  17.124     ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
  17.125     if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.126        return -1;
  17.127 -   ret = SDL_RenderRect( &rect );
  17.128 -   if (SDL_ATassert( "SDL_RenderRect", ret == 0))
  17.129 +   ret = SDL_RenderFillRect( &rect );
  17.130 +   if (SDL_ATassert( "SDL_RenderFillRect", ret == 0))
  17.131        return -1;
  17.132  
  17.133     /* Draw blended lines, lines for everyone. */
  17.134 @@ -558,8 +558,8 @@
  17.135              (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
  17.136        if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.137           return -1;
  17.138 -      ret = SDL_RenderLine( 0, 0, i, 59 );
  17.139 -      if (SDL_ATassert( "SDL_RenderLine", ret == 0))
  17.140 +      ret = SDL_RenderDrawLine( 0, 0, i, 59 );
  17.141 +      if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
  17.142           return -1;
  17.143     }
  17.144     for (i=0; i<SCREEN_H; i+=2)  {
  17.145 @@ -570,8 +570,8 @@
  17.146              (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
  17.147        if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.148           return -1;
  17.149 -      ret = SDL_RenderLine( 0, 0, 79, i );
  17.150 -      if (SDL_ATassert( "SDL_RenderLine", ret == 0))
  17.151 +      ret = SDL_RenderDrawLine( 0, 0, 79, i );
  17.152 +      if (SDL_ATassert( "SDL_RenderDrawLine", ret == 0))
  17.153           return -1;
  17.154     }
  17.155  
  17.156 @@ -585,8 +585,8 @@
  17.157                 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
  17.158           if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
  17.159              return -1;
  17.160 -         ret = SDL_RenderPoint( i, j );
  17.161 -         if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
  17.162 +         ret = SDL_RenderDrawPoint( i, j );
  17.163 +         if (SDL_ATassert( "SDL_RenderDrawPoint", ret == 0))
  17.164              return -1;
  17.165        }
  17.166     }
    18.1 --- a/test/automated/surface/surface.c	Fri Dec 18 08:19:18 2009 +0000
    18.2 +++ b/test/automated/surface/surface.c	Wed Dec 23 01:55:00 2009 +0000
    18.3 @@ -56,8 +56,7 @@
    18.4  
    18.5     /* Set transparent pixel as the pixel at (0,0) */
    18.6     if (face->format->palette) {
    18.7 -      ret = SDL_SetColorKey(face, (SDL_SRCCOLORKEY | SDL_RLEACCEL),
    18.8 -            *(Uint8 *) face->pixels);
    18.9 +      ret = SDL_SetColorKey(face, SDL_RLEACCEL, *(Uint8 *) face->pixels);
   18.10        if (SDL_ATassert( "SDL_SetColorKey", ret == 0))
   18.11           return;
   18.12     }
   18.13 @@ -184,29 +183,29 @@
   18.14        return;
   18.15  
   18.16     /* Create some rectangles for each blend mode. */
   18.17 -   ret = SDL_BlendRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
   18.18 -   if (SDL_ATassert( "SDL_BlendRect", ret == 0))
   18.19 +   ret = SDL_BlendFillRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
   18.20 +   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
   18.21        return;
   18.22     rect.x = 10;
   18.23     rect.y = 25;
   18.24     rect.w = 40;
   18.25     rect.h = 25;
   18.26 -   ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
   18.27 -   if (SDL_ATassert( "SDL_BlendRect", ret == 0))
   18.28 +   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
   18.29 +   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
   18.30        return;
   18.31     rect.x = 30;
   18.32     rect.y = 40;
   18.33     rect.w = 45;
   18.34     rect.h = 15;
   18.35 -   ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
   18.36 -   if (SDL_ATassert( "SDL_BlendRect", ret == 0))
   18.37 +   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
   18.38 +   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
   18.39        return;
   18.40     rect.x = 25;
   18.41     rect.y = 25;
   18.42     rect.w = 25;
   18.43     rect.h = 25;
   18.44 -   ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
   18.45 -   if (SDL_ATassert( "SDL_BlendRect", ret == 0))
   18.46 +   ret = SDL_BlendFillRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
   18.47 +   if (SDL_ATassert( "SDL_BlendFillRect", ret == 0))
   18.48        return;
   18.49  
   18.50     /* Draw blended lines, lines for everyone. */
    19.1 --- a/test/automated/testsdl.c	Fri Dec 18 08:19:18 2009 +0000
    19.2 +++ b/test/automated/testsdl.c	Wed Dec 23 01:55:00 2009 +0000
    19.3 @@ -6,7 +6,6 @@
    19.4   * Released under Public Domain.
    19.5   */
    19.6  
    19.7 -
    19.8  #include "SDL.h"
    19.9  #include "SDL_at.h"
   19.10  
    20.1 --- a/test/testdraw2.c	Fri Dec 18 08:19:18 2009 +0000
    20.2 +++ b/test/testdraw2.c	Wed Dec 23 01:55:00 2009 +0000
    20.3 @@ -58,7 +58,7 @@
    20.4  
    20.5          x = rand() % window_w;
    20.6          y = rand() % window_h;
    20.7 -        SDL_RenderPoint(x, y);
    20.8 +        SDL_RenderDrawPoint(x, y);
    20.9      }
   20.10      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   20.11  }
   20.12 @@ -102,16 +102,16 @@
   20.13                                 (Uint8) current_color, (Uint8) current_alpha);
   20.14  
   20.15          if (i == 0) {
   20.16 -            SDL_RenderLine(0, 0, window_w - 1, window_h - 1);
   20.17 -            SDL_RenderLine(0, window_h - 1, window_w - 1, 0);
   20.18 -            SDL_RenderLine(0, window_h / 2, window_w - 1, window_h / 2);
   20.19 -            SDL_RenderLine(window_w / 2, 0, window_w / 2, window_h - 1);
   20.20 +            SDL_RenderDrawLine(0, 0, window_w - 1, window_h - 1);
   20.21 +            SDL_RenderDrawLine(0, window_h - 1, window_w - 1, 0);
   20.22 +            SDL_RenderDrawLine(0, window_h / 2, window_w - 1, window_h / 2);
   20.23 +            SDL_RenderDrawLine(window_w / 2, 0, window_w / 2, window_h - 1);
   20.24          } else {
   20.25              x1 = (rand() % (window_w*2)) - window_w;
   20.26              x2 = (rand() % (window_w*2)) - window_w;
   20.27              y1 = (rand() % (window_h*2)) - window_h;
   20.28              y2 = (rand() % (window_h*2)) - window_h;
   20.29 -            SDL_RenderLine(x1, y1, x2, y2);
   20.30 +            SDL_RenderDrawLine(x1, y1, x2, y2);
   20.31          }
   20.32      }
   20.33      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   20.34 @@ -159,7 +159,7 @@
   20.35          rect.h = rand() % (window_h / 2);
   20.36          rect.x = (rand() % (window_w*2) - window_w) - (rect.w / 2);
   20.37          rect.y = (rand() % (window_h*2) - window_h) - (rect.h / 2);
   20.38 -        SDL_RenderRect(&rect);
   20.39 +        SDL_RenderFillRect(&rect);
   20.40      }
   20.41      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   20.42  }
   20.43 @@ -231,7 +231,7 @@
   20.44      for (i = 0; i < state->num_windows; ++i) {
   20.45          SDL_SelectRenderer(state->windows[i]);
   20.46          SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   20.47 -        SDL_RenderRect(NULL);
   20.48 +        SDL_RenderClear();
   20.49      }
   20.50  
   20.51      srand(time(NULL));
   20.52 @@ -251,7 +251,7 @@
   20.53                  case SDL_WINDOWEVENT_EXPOSED:
   20.54                      SDL_SelectRenderer(event.window.windowID);
   20.55                      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   20.56 -                    SDL_RenderRect(NULL);
   20.57 +                    SDL_RenderClear();
   20.58                      break;
   20.59                  }
   20.60                  break;
   20.61 @@ -262,7 +262,7 @@
   20.62          for (i = 0; i < state->num_windows; ++i) {
   20.63              SDL_SelectRenderer(state->windows[i]);
   20.64              SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   20.65 -            SDL_RenderRect(NULL);
   20.66 +            SDL_RenderClear();
   20.67  
   20.68              DrawRects(state->windows[i]);
   20.69              DrawLines(state->windows[i]);
    21.1 --- a/test/testintersections.c	Fri Dec 18 08:19:18 2009 +0000
    21.2 +++ b/test/testintersections.c	Wed Dec 23 01:55:00 2009 +0000
    21.3 @@ -59,7 +59,7 @@
    21.4  
    21.5          x = rand() % window_w;
    21.6          y = rand() % window_h;
    21.7 -        SDL_RenderPoint(x, y);
    21.8 +        SDL_RenderDrawPoint(x, y);
    21.9      }
   21.10      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   21.11  }
   21.12 @@ -100,12 +100,12 @@
   21.13          SDL_SetRenderDrawColor(255, 255, 255, 255);
   21.14  
   21.15          if (i == -1) {
   21.16 -            SDL_RenderLine(0, 0, window_w - 1, window_h - 1);
   21.17 -            SDL_RenderLine(0, window_h - 1, window_w - 1, 0);
   21.18 -            SDL_RenderLine(0, window_h / 2, window_w - 1, window_h / 2);
   21.19 -            SDL_RenderLine(window_w / 2, 0, window_w / 2, window_h - 1);
   21.20 +            SDL_RenderDrawLine(0, 0, window_w - 1, window_h - 1);
   21.21 +            SDL_RenderDrawLine(0, window_h - 1, window_w - 1, 0);
   21.22 +            SDL_RenderDrawLine(0, window_h / 2, window_w - 1, window_h / 2);
   21.23 +            SDL_RenderDrawLine(window_w / 2, 0, window_w / 2, window_h - 1);
   21.24          } else {
   21.25 -            SDL_RenderLine(lines[i].x, lines[i].y, lines[i].w, lines[i].h);
   21.26 +            SDL_RenderDrawLine(lines[i].x, lines[i].y, lines[i].w, lines[i].h);
   21.27          }
   21.28      }
   21.29      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   21.30 @@ -150,7 +150,7 @@
   21.31      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   21.32      for (i = 0; i < num_rects; ++i) {
   21.33          SDL_SetRenderDrawColor(255, 127, 0, 255);
   21.34 -        SDL_RenderRect(&rects[i]);
   21.35 +        SDL_RenderFillRect(&rects[i]);
   21.36      }
   21.37      SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   21.38  }
   21.39 @@ -178,7 +178,7 @@
   21.40  
   21.41              if (SDL_IntersectRectAndLine(&r, &x1, &y1, &x2, &y2)) {
   21.42                  SDL_SetRenderDrawColor(0, 255, 55, 255);
   21.43 -                SDL_RenderLine(x1, y1, x2, y2);
   21.44 +                SDL_RenderDrawLine(x1, y1, x2, y2);
   21.45              }
   21.46          }
   21.47  
   21.48 @@ -197,7 +197,7 @@
   21.49              SDL_Rect r;
   21.50              if (SDL_IntersectRect(&rects[i], &rects[j], &r)) {
   21.51                  SDL_SetRenderDrawColor(255, 200, 0, 255);
   21.52 -                SDL_RenderRect(&r);
   21.53 +                SDL_RenderFillRect(&r);
   21.54              }
   21.55          }
   21.56  
   21.57 @@ -272,7 +272,7 @@
   21.58      for (i = 0; i < state->num_windows; ++i) {
   21.59          SDL_SelectRenderer(state->windows[i]);
   21.60          SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   21.61 -        SDL_RenderRect(NULL);
   21.62 +        SDL_RenderClear();
   21.63      }
   21.64  
   21.65      srand(time(NULL));
   21.66 @@ -326,7 +326,7 @@
   21.67                  case SDL_WINDOWEVENT_EXPOSED:
   21.68                      SDL_SelectRenderer(event.window.windowID);
   21.69                      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   21.70 -                    SDL_RenderRect(NULL);
   21.71 +                    SDL_RenderClear();
   21.72                      break;
   21.73                  }
   21.74                  break;
   21.75 @@ -337,7 +337,7 @@
   21.76          for (i = 0; i < state->num_windows; ++i) {
   21.77              SDL_SelectRenderer(state->windows[i]);
   21.78              SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   21.79 -            SDL_RenderRect(NULL);
   21.80 +            SDL_RenderClear();
   21.81  
   21.82              DrawRects(state->windows[i]);
   21.83              DrawPoints(state->windows[i]);
    22.1 --- a/test/testnative.c	Fri Dec 18 08:19:18 2009 +0000
    22.2 +++ b/test/testnative.c	Wed Dec 23 01:55:00 2009 +0000
    22.3 @@ -83,7 +83,7 @@
    22.4      /* Move the sprite, bounce at the wall, and draw */
    22.5      n = 0;
    22.6      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
    22.7 -    SDL_RenderRect(NULL);
    22.8 +    SDL_RenderClear();
    22.9      for (i = 0; i < NUM_SPRITES; ++i) {
   22.10          position = &positions[i];
   22.11          velocity = &velocities[i];
   22.12 @@ -158,7 +158,7 @@
   22.13      /* Clear the window, load the sprite and go! */
   22.14      SDL_SelectRenderer(window);
   22.15      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   22.16 -    SDL_RenderRect(NULL);
   22.17 +    SDL_RenderClear();
   22.18  
   22.19      sprite = LoadSprite(window, "icon.bmp");
   22.20      if (!sprite) {
   22.21 @@ -199,7 +199,7 @@
   22.22                  case SDL_WINDOWEVENT_EXPOSED:
   22.23                      SDL_SelectRenderer(event.window.windowID);
   22.24                      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   22.25 -                    SDL_RenderRect(NULL);
   22.26 +                    SDL_RenderClear();
   22.27                      break;
   22.28                  }
   22.29                  break;
    23.1 --- a/test/testsprite2.c	Fri Dec 18 08:19:18 2009 +0000
    23.2 +++ b/test/testsprite2.c	Wed Dec 23 01:55:00 2009 +0000
    23.3 @@ -139,21 +139,21 @@
    23.4  
    23.5      /* Draw a gray background */
    23.6      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
    23.7 -    SDL_RenderRect(NULL);
    23.8 +    SDL_RenderClear();
    23.9  
   23.10      /* Test points */
   23.11      SDL_SetRenderDrawColor(0xFF, 0x00, 0x00, 0xFF);
   23.12 -    SDL_RenderPoint(0, 0);
   23.13 -    SDL_RenderPoint(window_w-1, 0);
   23.14 -    SDL_RenderPoint(0, window_h-1);
   23.15 -    SDL_RenderPoint(window_w-1, window_h-1);
   23.16 +    SDL_RenderDrawPoint(0, 0);
   23.17 +    SDL_RenderDrawPoint(window_w-1, 0);
   23.18 +    SDL_RenderDrawPoint(0, window_h-1);
   23.19 +    SDL_RenderDrawPoint(window_w-1, window_h-1);
   23.20  
   23.21      /* Test horizontal and vertical lines */
   23.22      SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
   23.23 -    SDL_RenderLine(1, 0, window_w-2, 0);
   23.24 -    SDL_RenderLine(1, window_h-1, window_w-2, window_h-1);
   23.25 -    SDL_RenderLine(0, 1, 0, window_h-2);
   23.26 -    SDL_RenderLine(window_w-1, 1, window_w-1, window_h-2);
   23.27 +    SDL_RenderDrawLine(1, 0, window_w-2, 0);
   23.28 +    SDL_RenderDrawLine(1, window_h-1, window_w-2, window_h-1);
   23.29 +    SDL_RenderDrawLine(0, 1, 0, window_h-2);
   23.30 +    SDL_RenderDrawLine(window_w-1, 1, window_w-1, window_h-2);
   23.31  
   23.32      /* Test fill and copy */
   23.33      SDL_SetRenderDrawColor(0xFF, 0xFF, 0xFF, 0xFF);
   23.34 @@ -161,33 +161,33 @@
   23.35      temp.y = 1;
   23.36      temp.w = sprite_w;
   23.37      temp.h = sprite_h;
   23.38 -    SDL_RenderRect(&temp);
   23.39 +    SDL_RenderFillRect(&temp);
   23.40      SDL_RenderCopy(sprite, NULL, &temp);
   23.41      temp.x = window_w-sprite_w-1;
   23.42      temp.y = 1;
   23.43      temp.w = sprite_w;
   23.44      temp.h = sprite_h;
   23.45 -    SDL_RenderRect(&temp);
   23.46 +    SDL_RenderFillRect(&temp);
   23.47      SDL_RenderCopy(sprite, NULL, &temp);
   23.48      temp.x = 1;
   23.49      temp.y = window_h-sprite_h-1;
   23.50      temp.w = sprite_w;
   23.51      temp.h = sprite_h;
   23.52 -    SDL_RenderRect(&temp);
   23.53 +    SDL_RenderFillRect(&temp);
   23.54      SDL_RenderCopy(sprite, NULL, &temp);
   23.55      temp.x = window_w-sprite_w-1;
   23.56      temp.y = window_h-sprite_h-1;
   23.57      temp.w = sprite_w;
   23.58      temp.h = sprite_h;
   23.59 -    SDL_RenderRect(&temp);
   23.60 +    SDL_RenderFillRect(&temp);
   23.61      SDL_RenderCopy(sprite, NULL, &temp);
   23.62  
   23.63      /* Test diagonal lines */
   23.64      SDL_SetRenderDrawColor(0x00, 0xFF, 0x00, 0xFF);
   23.65 -    SDL_RenderLine(sprite_w, sprite_h,
   23.66 -                   window_w-sprite_w-2, window_h-sprite_h-2);
   23.67 -    SDL_RenderLine(window_w-sprite_w-2, sprite_h,
   23.68 -                   sprite_w, window_h-sprite_h-2);
   23.69 +    SDL_RenderDrawLine(sprite_w, sprite_h,
   23.70 +                       window_w-sprite_w-2, window_h-sprite_h-2);
   23.71 +    SDL_RenderDrawLine(window_w-sprite_w-2, sprite_h,
   23.72 +                       sprite_w, window_h-sprite_h-2);
   23.73  
   23.74      /* Move the sprite, bounce at the wall, and draw */
   23.75      n = 0;
   23.76 @@ -302,7 +302,7 @@
   23.77      for (i = 0; i < state->num_windows; ++i) {
   23.78          SDL_SelectRenderer(state->windows[i]);
   23.79          SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   23.80 -        SDL_RenderRect(NULL);
   23.81 +        SDL_RenderClear();
   23.82      }
   23.83      if (LoadSprite("icon.bmp") < 0) {
   23.84          quit(2);
   23.85 @@ -348,7 +348,7 @@
   23.86                  case SDL_WINDOWEVENT_EXPOSED:
   23.87                      SDL_SelectRenderer(event.window.windowID);
   23.88                      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   23.89 -                    SDL_RenderRect(NULL);
   23.90 +                    SDL_RenderClear();
   23.91                      break;
   23.92                  }
   23.93                  break;
    24.1 --- a/test/testspriteminimal.c	Fri Dec 18 08:19:18 2009 +0000
    24.2 +++ b/test/testspriteminimal.c	Wed Dec 23 01:55:00 2009 +0000
    24.3 @@ -87,7 +87,7 @@
    24.4  
    24.5      /* Draw a gray background */
    24.6      SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
    24.7 -    SDL_RenderRect(NULL);
    24.8 +    SDL_RenderClear();
    24.9  
   24.10      /* Move the sprite, bounce at the wall, and draw */
   24.11      for (i = 0; i < NUM_SPRITES; ++i) {