Date: Fri, 19 Dec 2008 20:17:35 +0100
authorSam Lantinga <slouken@libsdl.org>
Sat, 20 Dec 2008 12:00:00 +0000
changeset 28849dde605c7540
parent 2883 11626a53e7bc
child 2885 ca6499468250
Date: Fri, 19 Dec 2008 20:17:35 +0100
From: Couriersud
Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions

> For consistency you'd probably want:
> SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
> SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode);
> SDL_RenderLine(int x1, int y1, int x2, int y2);
> SDL_RenderFill(SDL_Rect *rect);
>
> You probably also want to add API functions query the current state.
>

I have implemented the above api for the opengl, x11, directfb and
software renderers. I have also renamed *TEXTUREBLENDMODE* constants to
BLENDMODE*. The unix build compiles. The windows renderer still needs to
be updated, but I have no windows development machine at hand. Have a
look at the x11 renderer for a sample.

Vector games now run at 90% both on opengl and directfb in comparison to
sdlmame's own opengl renderer. The same applies to raster games.

The diff also includes

a) Changed XDrawRect to XFillRect in x11 renderer
b) A number of changes to fix blending and modulation issues in the
directfb renderer.
TODO
XCodeiPhoneOS/Demos/src/accelerometer.c
XCodeiPhoneOS/Demos/src/happy.c
XCodeiPhoneOS/Demos/src/keyboard.c
XCodeiPhoneOS/Demos/src/touch.c
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_glfuncs.h
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_gles.c
src/video/SDL_renderer_sw.c
src/video/SDL_surface.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/directfb/SDL_DirectFB_render.c
src/video/dummy/SDL_nullrender.c
src/video/nds/SDL_ndsrender.c
src/video/win32/SDL_d3drender.c
src/video/win32/SDL_gdirender.c
src/video/x11/SDL_x11render.c
src/video/x11/SDL_x11sym.h
test/common.c
test/nds-test-progs/sprite/source/common.c
test/nds-test-progs/sprite2/source/common.c
test/nds-test-progs/sprite2/source/testsprite2.c
test/testsprite2.c
     1.1 --- a/TODO	Sat Dec 20 08:41:05 2008 +0000
     1.2 +++ b/TODO	Sat Dec 20 12:00:00 2008 +0000
     1.3 @@ -5,6 +5,7 @@
     1.4     - in progress, software support is done, Ryan is working on OpenGL shaders
     1.5   * Implement desktop video mode change notification?
     1.6   * Implement icon support (with translucency?)
     1.7 + * Add draw blend mode and line drawing support for software renderer and win32
     1.8   * Verify mouse grab support
     1.9   * Properly handle mouse grab with Vista DPI scaling
    1.10   * Make sure the mouse is where it's supposed to be when un-grabbed
     2.1 --- a/XCodeiPhoneOS/Demos/src/accelerometer.c	Sat Dec 20 08:41:05 2008 +0000
     2.2 +++ b/XCodeiPhoneOS/Demos/src/accelerometer.c	Sat Dec 20 12:00:00 2008 +0000
     2.3 @@ -145,7 +145,7 @@
     2.4      if (shipID == 0) {
     2.5          fatalError("could not create ship texture");
     2.6      }
     2.7 -    SDL_SetTextureBlendMode(shipID, SDL_TEXTUREBLENDMODE_BLEND);
     2.8 +    SDL_SetTextureBlendMode(shipID, SDL_BLENDMODE_BLEND);
     2.9  
    2.10      /* set the width and height of the ship from the surface dimensions */
    2.11      ship.rect.w = bmp_surface->w;
     3.1 --- a/XCodeiPhoneOS/Demos/src/happy.c	Sat Dec 20 08:41:05 2008 +0000
     3.2 +++ b/XCodeiPhoneOS/Demos/src/happy.c	Sat Dec 20 12:00:00 2008 +0000
     3.3 @@ -127,7 +127,7 @@
     3.4      if (texture_id == 0) {
     3.5          fatalError("could not create texture");
     3.6      }
     3.7 -    SDL_SetTextureBlendMode(texture_id, SDL_TEXTUREBLENDMODE_BLEND);
     3.8 +    SDL_SetTextureBlendMode(texture_id, SDL_BLENDMODE_BLEND);
     3.9  
    3.10      /* free up allocated memory */
    3.11      SDL_FreeSurface(bmp_surface_rgba);
     4.1 --- a/XCodeiPhoneOS/Demos/src/keyboard.c	Sat Dec 20 08:41:05 2008 +0000
     4.2 +++ b/XCodeiPhoneOS/Demos/src/keyboard.c	Sat Dec 20 12:00:00 2008 +0000
     4.3 @@ -223,7 +223,7 @@
     4.4              printf("texture creation failed: %s\n", SDL_GetError());
     4.5          } else {
     4.6              /* set blend mode for our texture */
     4.7 -            SDL_SetTextureBlendMode(textureID, SDL_TEXTUREBLENDMODE_BLEND);
     4.8 +            SDL_SetTextureBlendMode(textureID, SDL_BLENDMODE_BLEND);
     4.9          }
    4.10          SDL_FreeSurface(surface);
    4.11          SDL_FreeSurface(converted);
     5.1 --- a/XCodeiPhoneOS/Demos/src/touch.c	Sat Dec 20 08:41:05 2008 +0000
     5.2 +++ b/XCodeiPhoneOS/Demos/src/touch.c	Sat Dec 20 12:00:00 2008 +0000
     5.3 @@ -65,7 +65,7 @@
     5.4          fatalError("could not create brush texture");
     5.5      }
     5.6      /* additive blending -- laying strokes on top of eachother makes them brighter */
     5.7 -    SDL_SetTextureBlendMode(brushID, SDL_TEXTUREBLENDMODE_ADD);
     5.8 +    SDL_SetTextureBlendMode(brushID, SDL_BLENDMODE_ADD);
     5.9      /* set brush color (red) */
    5.10      SDL_SetTextureColorMod(brushID, 255, 100, 100);
    5.11  }
     6.1 --- a/include/SDL_video.h	Sat Dec 20 08:41:05 2008 +0000
     6.2 +++ b/include/SDL_video.h	Sat Dec 20 12:00:00 2008 +0000
     6.3 @@ -206,18 +206,18 @@
     6.4  } SDL_TextureModulate;
     6.5  
     6.6  /**
     6.7 - * \enum SDL_TextureBlendMode
     6.8 + * \enum SDL_BlendMode
     6.9   *
    6.10 - * \brief The texture blend mode used in SDL_RenderCopy()
    6.11 + * \brief The blend mode used in SDL_RenderCopy() and drawing operations
    6.12   */
    6.13  typedef enum
    6.14  {
    6.15 -    SDL_TEXTUREBLENDMODE_NONE = 0x00000000,     /**< No blending */
    6.16 -    SDL_TEXTUREBLENDMODE_MASK = 0x00000001,     /**< dst = A ? src : dst (alpha is mask) */
    6.17 -    SDL_TEXTUREBLENDMODE_BLEND = 0x00000002,    /**< dst = (src * A) + (dst * (1-A)) */
    6.18 -    SDL_TEXTUREBLENDMODE_ADD = 0x00000004,      /**< dst = (src * A) + dst */
    6.19 -    SDL_TEXTUREBLENDMODE_MOD = 0x00000008       /**< dst = src * dst */
    6.20 -} SDL_TextureBlendMode;
    6.21 +    SDL_BLENDMODE_NONE = 0x00000000,     /**< No blending */
    6.22 +    SDL_BLENDMODE_MASK = 0x00000001,     /**< dst = A ? src : dst (alpha is mask) */
    6.23 +    SDL_BLENDMODE_BLEND = 0x00000002,    /**< dst = (src * A) + (dst * (1-A)) */
    6.24 +    SDL_BLENDMODE_ADD = 0x00000004,      /**< dst = (src * A) + dst */
    6.25 +    SDL_BLENDMODE_MOD = 0x00000008       /**< dst = src * dst */
    6.26 +} SDL_BlendMode;
    6.27  
    6.28  /**
    6.29   * \enum SDL_TextureScaleMode
    6.30 @@ -1141,9 +1141,80 @@
    6.31                                                const SDL_Rect * rects);
    6.32  
    6.33  /**
    6.34 - * \fn void SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect *rect)
    6.35 + * \fn void SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    6.36 + *
    6.37 + * \brief Set the color used for drawing operations (Fill and Line).
    6.38 + *
    6.39 + * \param r The red value used to draw on the rendering target
    6.40 + * \param g The green value used to draw on the rendering target
    6.41 + * \param b The blue value used to draw on the rendering target
    6.42 + * \param a The alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255)
    6.43 + * \return 0 on success, or -1 if there is no rendering context current
    6.44 + */
    6.45 +extern DECLSPEC int SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b,
    6.46 +                                           Uint8 a);
    6.47 +
    6.48 +/**
    6.49 + * \fn void SDL_GetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    6.50 + *
    6.51 + * \brief Get the color used for drawing operations (Fill and Line).
    6.52 + *
    6.53 + * \param r A pointer to the red value used to draw on the rendering target
    6.54 + * \param g A pointer to the green value used to draw on the rendering target
    6.55 + * \param b A pointer to the blue value used to draw on the rendering target
    6.56 + * \param a A pointer to the alpha value used to draw on the rendering target, usually SDL_ALPHA_OPAQUE (255)
    6.57 + * \return 0 on success, or -1 if there is no rendering context current
    6.58 + */
    6.59 +extern DECLSPEC int SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b,
    6.60 +                                           Uint8 * a);
    6.61 +
    6.62 +/**
    6.63 + * \fn int SDL_SetRenderDrawBlendMode(int blendMode)
    6.64 + *
    6.65 + * \brief Set the blend mode used for drawing operations
    6.66 + *
    6.67 + * \param blendMode SDL_BlendMode to use for blending
    6.68 + *
    6.69 + * \return 0 on success, or -1 if there is no rendering context current
    6.70   *
    6.71 - * \brief Fill the current rendering target with the specified color.
    6.72 + * \note If the blend mode is not supported, the closest supported mode is chosen.
    6.73 + *
    6.74 + * \sa SDL_SetRenderDrawBlendMode()
    6.75 + */
    6.76 +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(int blendMode);
    6.77 +
    6.78 +/**
    6.79 + * \fn int SDL_GetRenderDrawBlendMode(int *blendMode)
    6.80 + *
    6.81 + * \brief Get the blend mode used for drawing operations
    6.82 + *
    6.83 + * \param blendMode A pointer filled in with the current blend mode
    6.84 + *
    6.85 + * \return 0 on success, or -1 if there is no rendering context current
    6.86 + *
    6.87 + * \sa SDL_SetRenderDrawBlendMode()
    6.88 + */
    6.89 +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);
    6.90 +
    6.91 +/**
    6.92 + * \fn void SDL_RenderLine(int x1, int y1, int x2, int y2)
    6.93 + *
    6.94 + * \brief Draw a line on the current rendering target.
    6.95 + *
    6.96 + * \param x1 The x coordinate of the start point
    6.97 + * \param y1 The y coordinate of the start point
    6.98 + * \param x2 The x coordinate of the end point
    6.99 + * \param y2 The y coordinate of the end point
   6.100 + *
   6.101 + * \return 0 on success, or -1 if there is no rendering context current
   6.102 + */
   6.103 +
   6.104 +extern DECLSPEC int SDLCALL SDL_RenderLine(int x1, int y1, int x2, int y2);
   6.105 +
   6.106 +/**
   6.107 + * \fn void SDL_RenderFill(const SDL_Rect *rect)
   6.108 + *
   6.109 + * \brief Fill the current rendering target with the drawing color.
   6.110   *
   6.111   * \param r The red value used to fill the rendering target
   6.112   * \param g The green value used to fill the rendering target
   6.113 @@ -1153,8 +1224,7 @@
   6.114   *
   6.115   * \return 0 on success, or -1 if there is no rendering context current
   6.116   */
   6.117 -extern DECLSPEC int SDLCALL SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   6.118 -                                           const SDL_Rect * rect);
   6.119 +extern DECLSPEC int SDLCALL SDL_RenderFill(const SDL_Rect * rect);
   6.120  
   6.121  /**
   6.122   * \fn int SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect *srcrect, const SDL_Rect *dstrect)
     7.1 --- a/src/SDL_compat.c	Sat Dec 20 08:41:05 2008 +0000
     7.2 +++ b/src/SDL_compat.c	Sat Dec 20 12:00:00 2008 +0000
     7.3 @@ -696,10 +696,10 @@
     7.4              value = 0xFF;
     7.5          }
     7.6          SDL_SetSurfaceAlphaMod(surface, value);
     7.7 -        SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
     7.8 +        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
     7.9      } else {
    7.10          SDL_SetSurfaceAlphaMod(surface, 0xFF);
    7.11 -        SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_NONE);
    7.12 +        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
    7.13      }
    7.14      SDL_SetSurfaceRLE(surface, (flag & SDL_RLEACCEL));
    7.15  
     8.1 --- a/src/video/SDL_glfuncs.h	Sat Dec 20 08:41:05 2008 +0000
     8.2 +++ b/src/video/SDL_glfuncs.h	Sat Dec 20 12:00:00 2008 +0000
     8.3 @@ -206,7 +206,7 @@
     8.4  SDL_PROC_UNUSED(void, glLightiv,
     8.5                  (GLenum light, GLenum pname, const GLint * params))
     8.6  SDL_PROC_UNUSED(void, glLineStipple, (GLint factor, GLushort pattern))
     8.7 -SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width))
     8.8 +SDL_PROC(void, glLineWidth, (GLfloat width))
     8.9  SDL_PROC_UNUSED(void, glListBase, (GLuint base))
    8.10  SDL_PROC(void, glLoadIdentity, (void))
    8.11  SDL_PROC_UNUSED(void, glLoadMatrixd, (const GLdouble * m))
    8.12 @@ -272,7 +272,7 @@
    8.13  SDL_PROC_UNUSED(void, glPixelTransferf, (GLenum pname, GLfloat param))
    8.14  SDL_PROC_UNUSED(void, glPixelTransferi, (GLenum pname, GLint param))
    8.15  SDL_PROC_UNUSED(void, glPixelZoom, (GLfloat xfactor, GLfloat yfactor))
    8.16 -SDL_PROC_UNUSED(void, glPointSize, (GLfloat size))
    8.17 +SDL_PROC(void, glPointSize, (GLfloat size))
    8.18  SDL_PROC_UNUSED(void, glPolygonMode, (GLenum face, GLenum mode))
    8.19  SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units))
    8.20  SDL_PROC_UNUSED(void, glPolygonStipple, (const GLubyte * mask))
    8.21 @@ -324,7 +324,7 @@
    8.22  SDL_PROC_UNUSED(void, glRectf,
    8.23                  (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
    8.24  SDL_PROC_UNUSED(void, glRectfv, (const GLfloat * v1, const GLfloat * v2))
    8.25 -SDL_PROC_UNUSED(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
    8.26 +SDL_PROC(void, glRecti, (GLint x1, GLint y1, GLint x2, GLint y2))
    8.27  SDL_PROC_UNUSED(void, glRectiv, (const GLint * v1, const GLint * v2))
    8.28  SDL_PROC_UNUSED(void, glRects,
    8.29                  (GLshort x1, GLshort y1, GLshort x2, GLshort y2))
     9.1 --- a/src/video/SDL_renderer_gl.c	Sat Dec 20 08:41:05 2008 +0000
     9.2 +++ b/src/video/SDL_renderer_gl.c	Sat Dec 20 12:00:00 2008 +0000
     9.3 @@ -51,14 +51,14 @@
     9.4  
     9.5      /* FOURCC format */
     9.6      switch (format) {
     9.7 -        case SDL_PIXELFORMAT_YV12:
     9.8 -        case SDL_PIXELFORMAT_IYUV:
     9.9 -        case SDL_PIXELFORMAT_YUY2:
    9.10 -        case SDL_PIXELFORMAT_UYVY:
    9.11 -        case SDL_PIXELFORMAT_YVYU:
    9.12 -            return 2;
    9.13 -        default:
    9.14 -            return 1;  /* shouldn't ever hit this. */
    9.15 +    case SDL_PIXELFORMAT_YV12:
    9.16 +    case SDL_PIXELFORMAT_IYUV:
    9.17 +    case SDL_PIXELFORMAT_YUY2:
    9.18 +    case SDL_PIXELFORMAT_UYVY:
    9.19 +    case SDL_PIXELFORMAT_YVYU:
    9.20 +        return 2;
    9.21 +    default:
    9.22 +        return 1;               /* shouldn't ever hit this. */
    9.23      }
    9.24  }
    9.25  
    9.26 @@ -96,10 +96,14 @@
    9.27  static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    9.28  static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    9.29                              int numrects, const SDL_Rect * rects);
    9.30 -static int GL_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
    9.31 -                         Uint8 a, const SDL_Rect * rect);
    9.32 +static int GL_SetDrawColor(SDL_Renderer * renderer);
    9.33 +static int GL_SetDrawBlendMode(SDL_Renderer * renderer);
    9.34 +static int GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    9.35 +                         int y2);
    9.36 +static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
    9.37  static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
    9.38                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
    9.39 +
    9.40  static void GL_RenderPresent(SDL_Renderer * renderer);
    9.41  static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    9.42  static void GL_DestroyRenderer(SDL_Renderer * renderer);
    9.43 @@ -113,9 +117,8 @@
    9.44        SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
    9.45       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    9.46        SDL_TEXTUREMODULATE_ALPHA),
    9.47 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
    9.48 -      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
    9.49 -      SDL_TEXTUREBLENDMODE_MOD),
    9.50 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
    9.51 +      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
    9.52       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
    9.53        SDL_TEXTURESCALEMODE_SLOW),
    9.54       15,
    9.55 @@ -186,7 +189,7 @@
    9.56      void *pixels;
    9.57      int pitch;
    9.58      SDL_DirtyRectList dirty;
    9.59 -int HACK_RYAN_FIXME;
    9.60 +    int HACK_RYAN_FIXME;
    9.61  } GL_TextureData;
    9.62  
    9.63  
    9.64 @@ -308,6 +311,9 @@
    9.65      renderer->LockTexture = GL_LockTexture;
    9.66      renderer->UnlockTexture = GL_UnlockTexture;
    9.67      renderer->DirtyTexture = GL_DirtyTexture;
    9.68 +    renderer->SetDrawColor = GL_SetDrawColor;
    9.69 +    renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
    9.70 +    renderer->RenderLine = GL_RenderLine;
    9.71      renderer->RenderFill = GL_RenderFill;
    9.72      renderer->RenderCopy = GL_RenderCopy;
    9.73      renderer->RenderPresent = GL_RenderPresent;
    9.74 @@ -429,6 +435,36 @@
    9.75      return renderer;
    9.76  }
    9.77  
    9.78 +static void
    9.79 +SetBlendMode(GL_RenderData * data, int blendMode)
    9.80 +{
    9.81 +    if (blendMode != data->blendMode) {
    9.82 +        switch (blendMode) {
    9.83 +        case SDL_BLENDMODE_NONE:
    9.84 +            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    9.85 +            data->glDisable(GL_BLEND);
    9.86 +            break;
    9.87 +        case SDL_BLENDMODE_MASK:
    9.88 +        case SDL_BLENDMODE_BLEND:
    9.89 +            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    9.90 +            data->glEnable(GL_BLEND);
    9.91 +            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    9.92 +            break;
    9.93 +        case SDL_BLENDMODE_ADD:
    9.94 +            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    9.95 +            data->glEnable(GL_BLEND);
    9.96 +            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    9.97 +            break;
    9.98 +        case SDL_BLENDMODE_MOD:
    9.99 +            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   9.100 +            data->glEnable(GL_BLEND);
   9.101 +            data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
   9.102 +            break;
   9.103 +        }
   9.104 +        data->blendMode = blendMode;
   9.105 +    }
   9.106 +}
   9.107 +
   9.108  static int
   9.109  GL_ActivateRenderer(SDL_Renderer * renderer)
   9.110  {
   9.111 @@ -476,7 +512,7 @@
   9.112  //#define DEBUG_PROGRAM_COMPILE 1
   9.113  
   9.114  static GLuint
   9.115 -compile_shader(GL_RenderData *data, GLenum shader_type, const char *_code)
   9.116 +compile_shader(GL_RenderData * data, GLenum shader_type, const char *_code)
   9.117  {
   9.118      const int have_texture_rects = data->GL_ARB_texture_rectangle_supported;
   9.119      const char *replacement = have_texture_rects ? "RECT" : "2D";
   9.120 @@ -496,16 +532,17 @@
   9.121      if (code == NULL)
   9.122          return 0;
   9.123  
   9.124 -    for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr+1, token)) {
   9.125 +    for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr + 1, token)) {
   9.126          memcpy(ptr, replacement, replacementlen);
   9.127 -        memmove(ptr+replacementlen, ptr+tokenlen, strlen(ptr+tokenlen)+1);
   9.128 +        memmove(ptr + replacementlen, ptr + tokenlen,
   9.129 +                strlen(ptr + tokenlen) + 1);
   9.130      }
   9.131  
   9.132  #if DEBUG_PROGRAM_COMPILE
   9.133      printf("compiling shader:\n%s\n\n", code);
   9.134  #endif
   9.135  
   9.136 -    data->glGetError();  /* flush any existing error state. */
   9.137 +    data->glGetError();         /* flush any existing error state. */
   9.138      data->glGenProgramsARB(1, &program);
   9.139      data->glBindProgramARB(shader_type, program);
   9.140      data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB,
   9.141 @@ -513,15 +550,14 @@
   9.142  
   9.143      SDL_free(code);
   9.144  
   9.145 -    if (data->glGetError() == GL_INVALID_OPERATION)
   9.146 -    {
   9.147 +    if (data->glGetError() == GL_INVALID_OPERATION) {
   9.148  #if DEBUG_PROGRAM_COMPILE
   9.149          GLint pos = 0;
   9.150          const GLubyte *errstr;
   9.151          data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
   9.152          errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB);
   9.153          printf("program compile error at position %d: %s\n\n",
   9.154 -                  (int) pos, (const char *) errstr);
   9.155 +               (int) pos, (const char *) errstr);
   9.156  #endif
   9.157          data->glBindProgramARB(shader_type, 0);
   9.158          data->glDeleteProgramsARB(1, &program);
   9.159 @@ -544,49 +580,33 @@
   9.160   * !!! FIXME: this ignores blendmodes, etc.
   9.161   * !!! FIXME: this could be more efficient...use a dot product for green, etc.
   9.162   */
   9.163 -static const char *fragment_program_UYVY_source_code =
   9.164 -    "!!ARBfp1.0\n"
   9.165 -
   9.166 +static const char *fragment_program_UYVY_source_code = "!!ARBfp1.0\n"
   9.167      /* outputs... */
   9.168      "OUTPUT outcolor = result.color;\n"
   9.169 -
   9.170      /* scratch registers... */
   9.171 -    "TEMP uyvy;\n"
   9.172 -    "TEMP luminance;\n"
   9.173 -    "TEMP work;\n"
   9.174 -
   9.175 +    "TEMP uyvy;\n" "TEMP luminance;\n" "TEMP work;\n"
   9.176      /* Halve the coordinates to grab the correct 32 bits for the fragment. */
   9.177      "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n"
   9.178 -
   9.179      /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */
   9.180      "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n"
   9.181 -
   9.182      /* Do subtractions (128/255, 16/255, 128/255, 16/255) */
   9.183      "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n"
   9.184 -
   9.185      /* Choose the luminance component by texcoord. */
   9.186      /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */
   9.187      "ADD luminance, uyvy.yyyy, uyvy.wwww;\n"
   9.188      "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n"
   9.189 -
   9.190      /* Multiply luminance by its magic value. */
   9.191      "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n"
   9.192 -
   9.193      /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */
   9.194      "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n"
   9.195 -
   9.196      /* Add luminance to Cr and Cb, store to RGB channels. */
   9.197      "ADD work.rgb, luminance, uyvy;\n"
   9.198 -
   9.199      /* Do final addition for Green channel.  (!!! FIXME: this should be a DPH?) */
   9.200      "ADD work.g, work.g, uyvy.w;\n"
   9.201 -
   9.202      /* Make sure alpha channel is fully opaque.  (!!! FIXME: blend modes!) */
   9.203      "MOV work.a, { 1.0 };\n"
   9.204 -
   9.205      /* Store out the final fragment color... */
   9.206      "MOV outcolor, work;\n"
   9.207 -
   9.208      /* ...and we're done! */
   9.209      "END\n";
   9.210  
   9.211 @@ -801,14 +821,15 @@
   9.212  
   9.213      /* YUV formats use RGBA but are really two bytes per pixel */
   9.214      if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) {
   9.215 -data->HACK_RYAN_FIXME = 2;
   9.216 +        data->HACK_RYAN_FIXME = 2;
   9.217      } else {
   9.218 -data->HACK_RYAN_FIXME = 1;
   9.219 +        data->HACK_RYAN_FIXME = 1;
   9.220      }
   9.221      texture_w /= data->HACK_RYAN_FIXME;
   9.222  
   9.223      data->format = format;
   9.224      data->formattype = type;
   9.225 +    renderdata->glEnable(data->type);
   9.226      renderdata->glBindTexture(data->type, data->texture);
   9.227      renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
   9.228                                  GL_NEAREST);
   9.229 @@ -894,6 +915,7 @@
   9.230          *palette++ = colors->b;
   9.231          ++colors;
   9.232      }
   9.233 +    renderdata->glEnable(data->type);
   9.234      renderdata->glBindTexture(data->type, data->texture);
   9.235      renderdata->glColorTableEXT(data->type, GL_RGB8, 256, GL_RGB,
   9.236                                  GL_UNSIGNED_BYTE, data->palette);
   9.237 @@ -934,7 +956,9 @@
   9.238      }
   9.239      renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   9.240      renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
   9.241 -                              (pitch / bytes_per_pixel(texture->format)) / ((GL_TextureData *)texture->driverdata)->HACK_RYAN_FIXME);
   9.242 +                              (pitch / bytes_per_pixel(texture->format)) /
   9.243 +                              ((GL_TextureData *) texture->driverdata)->
   9.244 +                              HACK_RYAN_FIXME);
   9.245  }
   9.246  
   9.247  static int
   9.248 @@ -953,15 +977,15 @@
   9.249  GL_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   9.250  {
   9.251      switch (texture->blendMode) {
   9.252 -    case SDL_TEXTUREBLENDMODE_NONE:
   9.253 -    case SDL_TEXTUREBLENDMODE_MASK:
   9.254 -    case SDL_TEXTUREBLENDMODE_BLEND:
   9.255 -    case SDL_TEXTUREBLENDMODE_ADD:
   9.256 -    case SDL_TEXTUREBLENDMODE_MOD:
   9.257 +    case SDL_BLENDMODE_NONE:
   9.258 +    case SDL_BLENDMODE_MASK:
   9.259 +    case SDL_BLENDMODE_BLEND:
   9.260 +    case SDL_BLENDMODE_ADD:
   9.261 +    case SDL_BLENDMODE_MOD:
   9.262          return 0;
   9.263      default:
   9.264          SDL_Unsupported();
   9.265 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   9.266 +        texture->blendMode = SDL_BLENDMODE_NONE;
   9.267          return -1;
   9.268      }
   9.269  }
   9.270 @@ -995,6 +1019,7 @@
   9.271  
   9.272      renderdata->glGetError();
   9.273      SetupTextureUpdate(renderdata, texture, pitch);
   9.274 +    renderdata->glEnable(data->type);
   9.275      renderdata->glBindTexture(data->type, data->texture);
   9.276      renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
   9.277                                  rect->h, data->format, data->formattype,
   9.278 @@ -1043,17 +1068,57 @@
   9.279  }
   9.280  
   9.281  static int
   9.282 -GL_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   9.283 -              const SDL_Rect * rect)
   9.284 +GL_SetDrawColor(SDL_Renderer * renderer)
   9.285 +{
   9.286 +    return 0;
   9.287 +}
   9.288 +
   9.289 +static int
   9.290 +GL_SetDrawBlendMode(SDL_Renderer * renderer)
   9.291 +{
   9.292 +    return 0;
   9.293 +}
   9.294 +
   9.295 +static int
   9.296 +GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
   9.297  {
   9.298      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   9.299      SDL_Window *window = SDL_GetWindowFromID(renderer->window);
   9.300  
   9.301 -    data->glClearColor((GLclampf) r * inv255f, (GLclampf) g * inv255f,
   9.302 -                       (GLclampf) b * inv255f, (GLclampf) a * inv255f);
   9.303 -    data->glViewport(rect->x, window->h - rect->y, rect->w, rect->h);
   9.304 -    data->glClear(GL_COLOR_BUFFER_BIT);
   9.305 -    data->glViewport(0, 0, window->w, window->h);
   9.306 +    data->glColor4f((GLfloat) renderer->r * inv255f,
   9.307 +                    (GLfloat) renderer->g * inv255f,
   9.308 +                    (GLfloat) renderer->b * inv255f,
   9.309 +                    (GLfloat) renderer->a * inv255f);
   9.310 +    SetBlendMode(data, renderer->blendMode);
   9.311 +    data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
   9.312 +
   9.313 +    return 0;
   9.314 +}
   9.315 +
   9.316 +static int
   9.317 +GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   9.318 +{
   9.319 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
   9.320 +    //data->glLineWidth(1.0);
   9.321 +    //data->glPointSize(1.0);
   9.322 +
   9.323 +    SetBlendMode(data, renderer->blendMode);
   9.324 +
   9.325 +    data->glColor4f((GLfloat) renderer->r * inv255f,
   9.326 +                    (GLfloat) renderer->g * inv255f,
   9.327 +                    (GLfloat) renderer->b * inv255f,
   9.328 +                    (GLfloat) renderer->a * inv255f);
   9.329 +
   9.330 +    if ((x1 == x2) && (y1 == y2)) {
   9.331 +        data->glBegin(GL_POINTS);
   9.332 +        data->glVertex2i(x1, y1);
   9.333 +        data->glEnd();
   9.334 +    } else {
   9.335 +        data->glBegin(GL_LINES);
   9.336 +        data->glVertex2i(x1, y1);
   9.337 +        data->glVertex2i(x2, y2);
   9.338 +        data->glEnd();
   9.339 +    }
   9.340      return 0;
   9.341  }
   9.342  
   9.343 @@ -1073,6 +1138,7 @@
   9.344          int pitch = texturedata->pitch;
   9.345  
   9.346          SetupTextureUpdate(data, texture, pitch);
   9.347 +        data->glEnable(texturedata->type);
   9.348          data->glBindTexture(texturedata->type, texturedata->texture);
   9.349          for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
   9.350              SDL_Rect *rect = &dirty->rect;
   9.351 @@ -1080,7 +1146,8 @@
   9.352                  (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
   9.353                            rect->x * bpp);
   9.354              data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
   9.355 -                                  rect->w / texturedata->HACK_RYAN_FIXME, rect->h, texturedata->format,
   9.356 +                                  rect->w / texturedata->HACK_RYAN_FIXME,
   9.357 +                                  rect->h, texturedata->format,
   9.358                                    texturedata->formattype, pixels);
   9.359          }
   9.360          SDL_ClearDirtyRects(&texturedata->dirty);
   9.361 @@ -1100,6 +1167,7 @@
   9.362      maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
   9.363      maxv *= texturedata->texh;
   9.364  
   9.365 +    data->glEnable(texturedata->type);
   9.366      data->glBindTexture(texturedata->type, texturedata->texture);
   9.367  
   9.368      if (texture->modMode) {
   9.369 @@ -1111,31 +1179,7 @@
   9.370          data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
   9.371      }
   9.372  
   9.373 -    if (texture->blendMode != data->blendMode) {
   9.374 -        switch (texture->blendMode) {
   9.375 -        case SDL_TEXTUREBLENDMODE_NONE:
   9.376 -            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   9.377 -            data->glDisable(GL_BLEND);
   9.378 -            break;
   9.379 -        case SDL_TEXTUREBLENDMODE_MASK:
   9.380 -        case SDL_TEXTUREBLENDMODE_BLEND:
   9.381 -            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   9.382 -            data->glEnable(GL_BLEND);
   9.383 -            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   9.384 -            break;
   9.385 -        case SDL_TEXTUREBLENDMODE_ADD:
   9.386 -            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   9.387 -            data->glEnable(GL_BLEND);
   9.388 -            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
   9.389 -            break;
   9.390 -        case SDL_TEXTUREBLENDMODE_MOD:
   9.391 -            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   9.392 -            data->glEnable(GL_BLEND);
   9.393 -            data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
   9.394 -            break;
   9.395 -        }
   9.396 -        data->blendMode = texture->blendMode;
   9.397 -    }
   9.398 +    SetBlendMode(data, texture->blendMode);
   9.399  
   9.400      if (texture->scaleMode != data->scaleMode) {
   9.401          switch (texture->scaleMode) {
   9.402 @@ -1176,6 +1220,9 @@
   9.403      if (texturedata->shader != 0) {
   9.404          data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
   9.405      }
   9.406 +
   9.407 +    data->glDisable(texturedata->type);
   9.408 +
   9.409      return 0;
   9.410  }
   9.411  
   9.412 @@ -1219,7 +1266,8 @@
   9.413                  data->glDisable(GL_FRAGMENT_PROGRAM_ARB);
   9.414                  data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
   9.415                  if (data->fragment_program_UYVY != 0) {
   9.416 -                    data->glDeleteProgramsARB(1, &data->fragment_program_UYVY);
   9.417 +                    data->glDeleteProgramsARB(1,
   9.418 +                                              &data->fragment_program_UYVY);
   9.419                  }
   9.420              }
   9.421  
    10.1 --- a/src/video/SDL_renderer_gles.c	Sat Dec 20 08:41:05 2008 +0000
    10.2 +++ b/src/video/SDL_renderer_gles.c	Sat Dec 20 12:00:00 2008 +0000
    10.3 @@ -85,9 +85,8 @@
    10.4        SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
    10.5       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    10.6        SDL_TEXTUREMODULATE_ALPHA),
    10.7 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
    10.8 -      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
    10.9 -      SDL_TEXTUREBLENDMODE_MOD),
   10.10 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
   10.11 +      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
   10.12       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
   10.13        SDL_TEXTURESCALEMODE_SLOW), 2,
   10.14       {
   10.15 @@ -499,15 +498,15 @@
   10.16  GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   10.17  {
   10.18      switch (texture->blendMode) {
   10.19 -    case SDL_TEXTUREBLENDMODE_NONE:
   10.20 -    case SDL_TEXTUREBLENDMODE_MASK:
   10.21 -    case SDL_TEXTUREBLENDMODE_BLEND:
   10.22 -    case SDL_TEXTUREBLENDMODE_ADD:
   10.23 -    case SDL_TEXTUREBLENDMODE_MOD:
   10.24 +    case SDL_BLENDMODE_NONE:
   10.25 +    case SDL_BLENDMODE_MASK:
   10.26 +    case SDL_BLENDMODE_BLEND:
   10.27 +    case SDL_BLENDMODE_ADD:
   10.28 +    case SDL_BLENDMODE_MOD:
   10.29          return 0;
   10.30      default:
   10.31          SDL_Unsupported();
   10.32 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   10.33 +        texture->blendMode = SDL_BLENDMODE_NONE;
   10.34          return -1;
   10.35      }
   10.36  }
   10.37 @@ -680,22 +679,22 @@
   10.38  
   10.39      if (texture->blendMode != data->blendMode) {
   10.40          switch (texture->blendMode) {
   10.41 -        case SDL_TEXTUREBLENDMODE_NONE:
   10.42 +        case SDL_BLENDMODE_NONE:
   10.43              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   10.44              data->glDisable(GL_BLEND);
   10.45              break;
   10.46 -        case SDL_TEXTUREBLENDMODE_MASK:
   10.47 -        case SDL_TEXTUREBLENDMODE_BLEND:
   10.48 +        case SDL_BLENDMODE_MASK:
   10.49 +        case SDL_BLENDMODE_BLEND:
   10.50              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   10.51              data->glEnable(GL_BLEND);
   10.52              data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
   10.53              break;
   10.54 -        case SDL_TEXTUREBLENDMODE_ADD:
   10.55 +        case SDL_BLENDMODE_ADD:
   10.56              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   10.57              data->glEnable(GL_BLEND);
   10.58              data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
   10.59              break;
   10.60 -        case SDL_TEXTUREBLENDMODE_MOD:
   10.61 +        case SDL_BLENDMODE_MOD:
   10.62              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
   10.63              data->glEnable(GL_BLEND);
   10.64              data->glBlendFunc(GL_ZERO, GL_SRC_COLOR);
    11.1 --- a/src/video/SDL_renderer_sw.c	Sat Dec 20 08:41:05 2008 +0000
    11.2 +++ b/src/video/SDL_renderer_sw.c	Sat Dec 20 12:00:00 2008 +0000
    11.3 @@ -59,8 +59,8 @@
    11.4                            const SDL_Rect * rect, int markDirty, void **pixels,
    11.5                            int *pitch);
    11.6  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    11.7 -static int SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
    11.8 -                         Uint8 a, const SDL_Rect * rect);
    11.9 +static int SW_SetDrawColor(SDL_Renderer * renderer);
   11.10 +static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
   11.11  static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   11.12                           const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   11.13  static void SW_RenderPresent(SDL_Renderer * renderer);
   11.14 @@ -77,9 +77,8 @@
   11.15        SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
   11.16       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
   11.17        SDL_TEXTUREMODULATE_ALPHA),
   11.18 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
   11.19 -      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
   11.20 -      SDL_TEXTUREBLENDMODE_MOD),
   11.21 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
   11.22 +      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
   11.23       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
   11.24       14,
   11.25       {
   11.26 @@ -222,6 +221,13 @@
   11.27      }
   11.28      renderer->ActivateRenderer = SW_ActivateRenderer;
   11.29      renderer->DisplayModeChanged = SW_DisplayModeChanged;
   11.30 +
   11.31 +    renderer->SetDrawColor = SW_SetDrawColor;
   11.32 +    /* FIXME : Implement
   11.33 +       renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
   11.34 +       renderer->RenderLine = GL_RenderLine;
   11.35 +     */
   11.36 +
   11.37      renderer->RenderFill = SW_RenderFill;
   11.38      renderer->RenderCopy = SW_RenderCopy;
   11.39      renderer->RenderPresent = SW_RenderPresent;
   11.40 @@ -520,8 +526,13 @@
   11.41  }
   11.42  
   11.43  static int
   11.44 -SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   11.45 -              const SDL_Rect * rect)
   11.46 +SW_SetDrawColor(SDL_Renderer * renderer)
   11.47 +{
   11.48 +    return 0;
   11.49 +}
   11.50 +
   11.51 +static int
   11.52 +SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
   11.53  {
   11.54      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
   11.55      Uint32 color;
   11.56 @@ -532,7 +543,8 @@
   11.57          SDL_AddDirtyRect(&data->dirty, rect);
   11.58      }
   11.59  
   11.60 -    color = SDL_MapRGBA(data->surface.format, r, g, b, a);
   11.61 +    color = SDL_MapRGBA(data->surface.format,
   11.62 +                        renderer->r, renderer->g, renderer->b, renderer->a);
   11.63  
   11.64      if (data->renderer->LockTexture(data->renderer,
   11.65                                      data->texture[data->current_texture],
    12.1 --- a/src/video/SDL_surface.c	Sat Dec 20 08:41:05 2008 +0000
    12.2 +++ b/src/video/SDL_surface.c	Sat Dec 20 12:00:00 2008 +0000
    12.3 @@ -140,7 +140,7 @@
    12.4  
    12.5      /* By default surface with an alpha mask are set up for blending */
    12.6      if (Amask) {
    12.7 -        SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
    12.8 +        SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
    12.9      }
   12.10  
   12.11      /* The surface is ready to go */
   12.12 @@ -336,7 +336,7 @@
   12.13      SDL_UnlockSurface(surface);
   12.14  
   12.15      SDL_SetColorKey(surface, 0, 0);
   12.16 -    SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
   12.17 +    SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
   12.18  }
   12.19  
   12.20  int
   12.21 @@ -434,18 +434,18 @@
   12.22      surface->map->info.flags &=
   12.23          ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
   12.24      switch (blendMode) {
   12.25 -    case SDL_TEXTUREBLENDMODE_NONE:
   12.26 +    case SDL_BLENDMODE_NONE:
   12.27          break;
   12.28 -    case SDL_TEXTUREBLENDMODE_MASK:
   12.29 +    case SDL_BLENDMODE_MASK:
   12.30          surface->map->info.flags |= SDL_COPY_MASK;
   12.31          break;
   12.32 -    case SDL_TEXTUREBLENDMODE_BLEND:
   12.33 +    case SDL_BLENDMODE_BLEND:
   12.34          surface->map->info.flags |= SDL_COPY_BLEND;
   12.35          break;
   12.36 -    case SDL_TEXTUREBLENDMODE_ADD:
   12.37 +    case SDL_BLENDMODE_ADD:
   12.38          surface->map->info.flags |= SDL_COPY_ADD;
   12.39          break;
   12.40 -    case SDL_TEXTUREBLENDMODE_MOD:
   12.41 +    case SDL_BLENDMODE_MOD:
   12.42          surface->map->info.flags |= SDL_COPY_MOD;
   12.43          break;
   12.44      default:
   12.45 @@ -483,19 +483,19 @@
   12.46              info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
   12.47                            SDL_COPY_MOD)) {
   12.48      case SDL_COPY_MASK:
   12.49 -        *blendMode = SDL_TEXTUREBLENDMODE_MASK;
   12.50 +        *blendMode = SDL_BLENDMODE_MASK;
   12.51          break;
   12.52      case SDL_COPY_BLEND:
   12.53 -        *blendMode = SDL_TEXTUREBLENDMODE_BLEND;
   12.54 +        *blendMode = SDL_BLENDMODE_BLEND;
   12.55          break;
   12.56      case SDL_COPY_ADD:
   12.57 -        *blendMode = SDL_TEXTUREBLENDMODE_ADD;
   12.58 +        *blendMode = SDL_BLENDMODE_ADD;
   12.59          break;
   12.60      case SDL_COPY_MOD:
   12.61 -        *blendMode = SDL_TEXTUREBLENDMODE_MOD;
   12.62 +        *blendMode = SDL_BLENDMODE_MOD;
   12.63          break;
   12.64      default:
   12.65 -        *blendMode = SDL_TEXTUREBLENDMODE_NONE;
   12.66 +        *blendMode = SDL_BLENDMODE_NONE;
   12.67          break;
   12.68      }
   12.69      return 0;
   12.70 @@ -835,7 +835,7 @@
   12.71       * alpha channel or alpha modulation */
   12.72      if ((surface->format->Amask && format->Amask) ||
   12.73          (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
   12.74 -        SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND);
   12.75 +        SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
   12.76      }
   12.77      if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
   12.78          SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
    13.1 --- a/src/video/SDL_sysvideo.h	Sat Dec 20 08:41:05 2008 +0000
    13.2 +++ b/src/video/SDL_sysvideo.h	Sat Dec 20 12:00:00 2008 +0000
    13.3 @@ -88,8 +88,11 @@
    13.4      void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
    13.5      void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    13.6                            int numrects, const SDL_Rect * rects);
    13.7 -    int (*RenderFill) (SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
    13.8 -                       Uint8 a, const SDL_Rect * rect);
    13.9 +    int (*SetDrawColor) (SDL_Renderer * renderer);
   13.10 +    int (*SetDrawBlendMode) (SDL_Renderer * renderer);
   13.11 +    int (*RenderLine) (SDL_Renderer * renderer, int x1, int y1, int x2,
   13.12 +                       int y2);
   13.13 +    int (*RenderFill) (SDL_Renderer * renderer, const SDL_Rect * rect);
   13.14      int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture,
   13.15                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   13.16      void (*RenderPresent) (SDL_Renderer * renderer);
   13.17 @@ -103,6 +106,9 @@
   13.18      /* The window associated with the renderer */
   13.19      SDL_WindowID window;
   13.20  
   13.21 +    Uint8 r, g, b, a;                   /**< Color for drawing operations values */
   13.22 +    int blendMode;                      /**< The drawing blend mode */
   13.23 +
   13.24      void *driverdata;
   13.25  };
   13.26  
    14.1 --- a/src/video/SDL_video.c	Sat Dec 20 08:41:05 2008 +0000
    14.2 +++ b/src/video/SDL_video.c	Sat Dec 20 12:00:00 2008 +0000
    14.3 @@ -1975,7 +1975,104 @@
    14.4  }
    14.5  
    14.6  int
    14.7 -SDL_RenderFill(Uint8 r, Uint8 g, Uint8 b, Uint8 a, const SDL_Rect * rect)
    14.8 +SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
    14.9 +{
   14.10 +    SDL_Renderer *renderer;
   14.11 +
   14.12 +    if (!_this) {
   14.13 +        SDL_UninitializedVideo();
   14.14 +        return -1;
   14.15 +    }
   14.16 +    renderer = SDL_CurrentDisplay.current_renderer;
   14.17 +    if (!renderer) {
   14.18 +        return -1;
   14.19 +    }
   14.20 +    if (!renderer->SetDrawColor) {
   14.21 +        SDL_Unsupported();
   14.22 +        return -1;
   14.23 +    }
   14.24 +    renderer->r = r;
   14.25 +    renderer->g = g;
   14.26 +    renderer->b = b;
   14.27 +    renderer->a = a;
   14.28 +    renderer->SetDrawColor(renderer);
   14.29 +    return 0;
   14.30 +}
   14.31 +
   14.32 +int
   14.33 +SDL_GetRenderDrawColor(Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
   14.34 +{
   14.35 +    SDL_Renderer *renderer;
   14.36 +
   14.37 +    if (!_this) {
   14.38 +        SDL_UninitializedVideo();
   14.39 +        return -1;
   14.40 +    }
   14.41 +    renderer = SDL_CurrentDisplay.current_renderer;
   14.42 +    if (!renderer) {
   14.43 +        return -1;
   14.44 +    }
   14.45 +    if (!renderer->SetDrawColor) {
   14.46 +        SDL_Unsupported();
   14.47 +        return -1;
   14.48 +    }
   14.49 +    if (r) {
   14.50 +        *r = renderer->r;
   14.51 +    }
   14.52 +    if (g) {
   14.53 +        *g = renderer->g;
   14.54 +    }
   14.55 +    if (b) {
   14.56 +        *b = renderer->b;
   14.57 +    }
   14.58 +    if (a) {
   14.59 +        *a = renderer->a;
   14.60 +    }
   14.61 +    return 0;
   14.62 +}
   14.63 +
   14.64 +int
   14.65 +SDL_SetRenderDrawBlendMode(int blendMode)
   14.66 +{
   14.67 +    SDL_Renderer *renderer;
   14.68 +
   14.69 +    if (!_this) {
   14.70 +        SDL_UninitializedVideo();
   14.71 +        return -1;
   14.72 +    }
   14.73 +    renderer = SDL_CurrentDisplay.current_renderer;
   14.74 +    if (!renderer) {
   14.75 +        return -1;
   14.76 +    }
   14.77 +    if (!renderer->SetDrawBlendMode) {
   14.78 +        SDL_Unsupported();
   14.79 +        return -1;
   14.80 +    }
   14.81 +    renderer->blendMode = blendMode;
   14.82 +    renderer->SetDrawBlendMode(renderer);
   14.83 +    return 0;
   14.84 +}
   14.85 +
   14.86 +int
   14.87 +SDL_GetRenderDrawBlendMode(int *blendMode)
   14.88 +{
   14.89 +    SDL_Renderer *renderer;
   14.90 +
   14.91 +    if (!_this) {
   14.92 +        SDL_UninitializedVideo();
   14.93 +        return -1;
   14.94 +    }
   14.95 +    renderer = SDL_CurrentDisplay.current_renderer;
   14.96 +    if (!renderer) {
   14.97 +        return -1;
   14.98 +    }
   14.99 +    *blendMode = renderer->blendMode;
  14.100 +    return 0;
  14.101 +}
  14.102 +
  14.103 +
  14.104 +int
  14.105 +SDL_RenderFill(const SDL_Rect * rect)
  14.106  {
  14.107      SDL_Renderer *renderer;
  14.108      SDL_Window *window;
  14.109 @@ -2003,7 +2100,42 @@
  14.110              return 0;
  14.111          }
  14.112      }
  14.113 -    return renderer->RenderFill(renderer, r, g, b, a, &real_rect);
  14.114 +    return renderer->RenderFill(renderer, &real_rect);
  14.115 +}
  14.116 +
  14.117 +int
  14.118 +SDL_RenderLine(int x1, int y1, int x2, int y2)
  14.119 +{
  14.120 +    SDL_Renderer *renderer;
  14.121 +    SDL_Window *window;
  14.122 +    SDL_Rect real_rect;
  14.123 +
  14.124 +    if (!_this) {
  14.125 +        SDL_UninitializedVideo();
  14.126 +        return -1;
  14.127 +    }
  14.128 +    renderer = SDL_CurrentDisplay.current_renderer;
  14.129 +    if (!renderer) {
  14.130 +        return -1;
  14.131 +    }
  14.132 +    if (!renderer->RenderLine) {
  14.133 +        SDL_Unsupported();
  14.134 +        return -1;
  14.135 +    }
  14.136 +#if 0
  14.137 +    //FIXME: Need line intersect routine
  14.138 +    window = SDL_GetWindowFromID(renderer->window);
  14.139 +    real_rect.x = 0;
  14.140 +    real_rect.y = 0;
  14.141 +    real_rect.w = window->w;
  14.142 +    real_rect.h = window->h;
  14.143 +    if (rect) {
  14.144 +        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  14.145 +            return 0;
  14.146 +        }
  14.147 +    }
  14.148 +#endif
  14.149 +    return renderer->RenderLine(renderer, x1, y1, x2, y2);
  14.150  }
  14.151  
  14.152  int
    15.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Sat Dec 20 08:41:05 2008 +0000
    15.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Sat Dec 20 12:00:00 2008 +0000
    15.3 @@ -71,8 +71,12 @@
    15.4  static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
    15.5                                    SDL_Texture * texture, int numrects,
    15.6                                    const SDL_Rect * rects);
    15.7 -static int DirectFB_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
    15.8 -                               Uint8 b, Uint8 a, const SDL_Rect * rect);
    15.9 +static int DirectFB_SetDrawColor(SDL_Renderer * renderer);
   15.10 +static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
   15.11 +static int DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
   15.12 +                               int x2, int y2);
   15.13 +static int DirectFB_RenderFill(SDL_Renderer * renderer,
   15.14 +                               const SDL_Rect * rect);
   15.15  static int DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   15.16                                 const SDL_Rect * srcrect,
   15.17                                 const SDL_Rect * dstrect);
   15.18 @@ -91,9 +95,8 @@
   15.19        SDL_RENDERER_ACCELERATED),
   15.20       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
   15.21        SDL_TEXTUREMODULATE_ALPHA),
   15.22 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
   15.23 -      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
   15.24 -      SDL_TEXTUREBLENDMODE_MOD),
   15.25 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
   15.26 +      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
   15.27       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
   15.28        SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
   15.29       14,
   15.30 @@ -122,6 +125,9 @@
   15.31      DFBSurfaceFlipFlags flipflags;
   15.32      int isyuvdirect;
   15.33      int size_changed;
   15.34 +    int lastBlendMode;
   15.35 +    DFBSurfaceBlittingFlags blitFlags;
   15.36 +    DFBSurfaceDrawingFlags drawFlags;
   15.37  } DirectFB_RenderData;
   15.38  
   15.39  typedef struct
   15.40 @@ -147,6 +153,79 @@
   15.41      dr->w = sr->w;
   15.42  }
   15.43  
   15.44 +
   15.45 +static int
   15.46 +TextureHasAlpha(DirectFB_TextureData * data)
   15.47 +{
   15.48 +    /* Drawing primitive ? */
   15.49 +    if (!data)
   15.50 +        return 0;
   15.51 +    switch (data->format) {
   15.52 +    case SDL_PIXELFORMAT_INDEX4LSB:
   15.53 +    case SDL_PIXELFORMAT_ARGB4444:
   15.54 +    case SDL_PIXELFORMAT_ARGB1555:
   15.55 +    case SDL_PIXELFORMAT_ARGB8888:
   15.56 +    case SDL_PIXELFORMAT_RGBA8888:
   15.57 +    case SDL_PIXELFORMAT_ABGR8888:
   15.58 +    case SDL_PIXELFORMAT_BGRA8888:
   15.59 +    case SDL_PIXELFORMAT_ARGB2101010:
   15.60 +        return 1;
   15.61 +    default:
   15.62 +        return 0;
   15.63 +    }
   15.64 +}
   15.65 +
   15.66 +static void
   15.67 +SetBlendMode(DirectFB_RenderData * data, int blendMode,
   15.68 +             DirectFB_TextureData * source)
   15.69 +{
   15.70 +    //FIXME: check for format change
   15.71 +    if (1 || data->lastBlendMode != blendMode) {
   15.72 +        switch (blendMode) {
   15.73 +        case SDL_BLENDMODE_NONE:
   15.74 +                                           /**< No blending */
   15.75 +            data->blitFlags = DSBLIT_NOFX;
   15.76 +            data->drawFlags = DSDRAW_NOFX;
   15.77 +            data->surface->SetSrcBlendFunction(data->surface, DSBF_ONE);
   15.78 +            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
   15.79 +            break;
   15.80 +        case SDL_BLENDMODE_MASK:
   15.81 +            data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
   15.82 +            data->drawFlags = DSDRAW_BLEND;
   15.83 +            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
   15.84 +            data->surface->SetDstBlendFunction(data->surface,
   15.85 +                                               DSBF_INVSRCALPHA);
   15.86 +            break;
   15.87 +        case SDL_BLENDMODE_BLEND:
   15.88 +            data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
   15.89 +            data->drawFlags = DSDRAW_BLEND;
   15.90 +            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
   15.91 +            data->surface->SetDstBlendFunction(data->surface,
   15.92 +                                               DSBF_INVSRCALPHA);
   15.93 +            break;
   15.94 +        case SDL_BLENDMODE_ADD:
   15.95 +            data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
   15.96 +            data->drawFlags = DSDRAW_BLEND;
   15.97 +            //FIXME: SRCALPHA kills performance on radeon ...
   15.98 +            //Eventually use a premultiplied texture
   15.99 +            if (0 && TextureHasAlpha(source))
  15.100 +                data->surface->SetSrcBlendFunction(data->surface,
  15.101 +                                                   DSBF_SRCALPHA);
  15.102 +            else
  15.103 +                data->surface->SetSrcBlendFunction(data->surface, DSBF_ONE);
  15.104 +            data->surface->SetDstBlendFunction(data->surface, DSBF_ONE);
  15.105 +            break;
  15.106 +        case SDL_BLENDMODE_MOD:
  15.107 +            data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
  15.108 +            data->drawFlags = DSDRAW_BLEND;
  15.109 +            data->surface->SetSrcBlendFunction(data->surface, DSBF_DESTCOLOR);
  15.110 +            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
  15.111 +            break;
  15.112 +        }
  15.113 +        data->lastBlendMode = blendMode;
  15.114 +    }
  15.115 +}
  15.116 +
  15.117  void
  15.118  DirectFB_AddRenderDriver(_THIS)
  15.119  {
  15.120 @@ -214,6 +293,9 @@
  15.121      renderer->LockTexture = DirectFB_LockTexture;
  15.122      renderer->UnlockTexture = DirectFB_UnlockTexture;
  15.123      renderer->DirtyTexture = DirectFB_DirtyTexture;
  15.124 +    renderer->SetDrawColor = DirectFB_SetDrawColor;
  15.125 +    renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
  15.126 +    renderer->RenderLine = DirectFB_RenderLine;
  15.127      renderer->RenderFill = DirectFB_RenderFill;
  15.128      renderer->RenderCopy = DirectFB_RenderCopy;
  15.129      renderer->RenderPresent = DirectFB_RenderPresent;
  15.130 @@ -304,7 +386,11 @@
  15.131      case SDL_PIXELFORMAT_INDEX4MSB:
  15.132          return DSPF_UNKNOWN;
  15.133      case SDL_PIXELFORMAT_RGB444:
  15.134 +#if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
  15.135 +        return DSPF_RGB444;
  15.136 +#else
  15.137          return DSPF_UNKNOWN;
  15.138 +#endif
  15.139      case SDL_PIXELFORMAT_BGR24:
  15.140          return DSPF_UNKNOWN;
  15.141      case SDL_PIXELFORMAT_BGR888:
  15.142 @@ -576,15 +662,15 @@
  15.143  DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
  15.144  {
  15.145      switch (texture->blendMode) {
  15.146 -    case SDL_TEXTUREBLENDMODE_NONE:
  15.147 -    case SDL_TEXTUREBLENDMODE_MASK:
  15.148 -    case SDL_TEXTUREBLENDMODE_BLEND:
  15.149 -    case SDL_TEXTUREBLENDMODE_ADD:
  15.150 -    case SDL_TEXTUREBLENDMODE_MOD:
  15.151 +    case SDL_BLENDMODE_NONE:
  15.152 +    case SDL_BLENDMODE_MASK:
  15.153 +    case SDL_BLENDMODE_BLEND:
  15.154 +    case SDL_BLENDMODE_ADD:
  15.155 +    case SDL_BLENDMODE_MOD:
  15.156          return 0;
  15.157      default:
  15.158          SDL_Unsupported();
  15.159 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
  15.160 +        texture->blendMode = SDL_BLENDMODE_NONE;
  15.161          return -1;
  15.162      }
  15.163  }
  15.164 @@ -710,13 +796,73 @@
  15.165  }
  15.166  
  15.167  static int
  15.168 -DirectFB_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
  15.169 -                    Uint8 a, const SDL_Rect * rect)
  15.170 +DirectFB_SetDrawColor(SDL_Renderer * renderer)
  15.171 +{
  15.172 +    return 0;
  15.173 +}
  15.174 +
  15.175 +static int
  15.176 +DirectFB_SetDrawBlendMode(SDL_Renderer * renderer)
  15.177 +{
  15.178 +    return 0;
  15.179 +}
  15.180 +
  15.181 +static int
  15.182 +PrepareDraw(SDL_Renderer * renderer)
  15.183 +{
  15.184 +    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
  15.185 +    DFBResult ret;
  15.186 +    Uint8 r, g, b, a;
  15.187 +
  15.188 +    r = renderer->r;
  15.189 +    g = renderer->g;
  15.190 +    b = renderer->b;
  15.191 +    a = renderer->a;
  15.192 +
  15.193 +    SetBlendMode(data, renderer->blendMode, NULL);
  15.194 +    SDL_DFB_CHECKERR(data->surface->
  15.195 +                     SetDrawingFlags(data->surface, data->drawFlags));
  15.196 +
  15.197 +    switch (renderer->blendMode) {
  15.198 +    case SDL_BLENDMODE_NONE:
  15.199 +    case SDL_BLENDMODE_MASK:
  15.200 +    case SDL_BLENDMODE_BLEND:
  15.201 +        break;
  15.202 +    case SDL_BLENDMODE_ADD:
  15.203 +    case SDL_BLENDMODE_MOD:
  15.204 +        r = ((int) r * (int) a) / 255;
  15.205 +        g = ((int) g * (int) a) / 255;
  15.206 +        b = ((int) b * (int) a) / 255;
  15.207 +        a = 255;
  15.208 +        break;
  15.209 +    }
  15.210 +
  15.211 +    SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, r, g, b, a));
  15.212 +    return 0;
  15.213 +  error:
  15.214 +    return -1;
  15.215 +}
  15.216 +
  15.217 +static int
  15.218 +DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
  15.219  {
  15.220      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
  15.221      DFBResult ret;
  15.222  
  15.223 -    SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, r, g, b, a));
  15.224 +    PrepareDraw(renderer);
  15.225 +    SDL_DFB_CHECKERR(data->surface->DrawLine(data->surface, x1, y1, x2, y2));
  15.226 +    return 0;
  15.227 +  error:
  15.228 +    return -1;
  15.229 +}
  15.230 +
  15.231 +static int
  15.232 +DirectFB_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
  15.233 +{
  15.234 +    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
  15.235 +    DFBResult ret;
  15.236 +
  15.237 +    PrepareDraw(renderer);
  15.238      SDL_DFB_CHECKERR(data->surface->
  15.239                       FillRectangle(data->surface, rect->x, rect->y, rect->w,
  15.240                                     rect->h));
  15.241 @@ -733,6 +879,7 @@
  15.242      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
  15.243      DirectFB_TextureData *texturedata =
  15.244          (DirectFB_TextureData *) texture->driverdata;
  15.245 +    Uint8 alpha = 0xFF;
  15.246      DFBResult ret;
  15.247  
  15.248      if (texturedata->display) {
  15.249 @@ -772,68 +919,45 @@
  15.250              }
  15.251              SDL_ClearDirtyRects(&texturedata->dirty);
  15.252          }
  15.253 +
  15.254 +        SDLtoDFBRect(srcrect, &sr);
  15.255 +        SDLtoDFBRect(dstrect, &dr);
  15.256 +
  15.257 +        SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, 0xFF,
  15.258 +                                                 0xFF, 0xFF, 0xFF));
  15.259 +        if (texture->
  15.260 +            modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
  15.261 +        {
  15.262 +            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
  15.263 +                alpha = texture->a;
  15.264 +                SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, 0xFF,
  15.265 +                                                         0xFF, 0xFF, alpha));
  15.266 +            }
  15.267 +            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
  15.268 +
  15.269 +                SDL_DFB_CHECKERR(data->surface->
  15.270 +                                 SetColor(data->surface, texture->r,
  15.271 +                                          texture->g, texture->b, alpha));
  15.272 +                flags |= DSBLIT_COLORIZE;
  15.273 +            }
  15.274 +            if (alpha < 0xFF)
  15.275 +                flags |= DSBLIT_SRC_PREMULTCOLOR;
  15.276 +        } else
  15.277 +            SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, 0xFF,
  15.278 +                                                     0xFF, 0xFF, 0xFF));
  15.279 +
  15.280 +        SetBlendMode(data, texture->blendMode, texturedata);
  15.281 +
  15.282 +        SDL_DFB_CHECKERR(data->surface->
  15.283 +                         SetBlittingFlags(data->surface,
  15.284 +                                          data->blitFlags | flags));
  15.285 +
  15.286  #if (DIRECTFB_MAJOR_VERSION == 1) && (DIRECTFB_MINOR_VERSION >= 2)
  15.287          SDL_DFB_CHECKERR(data->surface->SetRenderOptions(data->surface,
  15.288                                                           texturedata->
  15.289                                                           render_options));
  15.290  #endif
  15.291  
  15.292 -        SDLtoDFBRect(srcrect, &sr);
  15.293 -        SDLtoDFBRect(dstrect, &dr);
  15.294 -
  15.295 -        if (texture->
  15.296 -            modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
  15.297 -        {
  15.298 -            Uint8 alpha = 0xFF;
  15.299 -            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
  15.300 -                alpha = texture->a;
  15.301 -                flags |= DSBLIT_SRC_PREMULTCOLOR;
  15.302 -                SDL_DFB_CHECKERR(data->surface->SetColor(data->surface, 0xFF,
  15.303 -                                                         0xFF, 0xFF, alpha));
  15.304 -            }
  15.305 -            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
  15.306 -                SDL_DFB_CHECKERR(data->surface->
  15.307 -                                 SetColor(data->surface, texture->r,
  15.308 -                                          texture->g, texture->b, alpha));
  15.309 -                /* Only works together .... */
  15.310 -                flags |= DSBLIT_COLORIZE | DSBLIT_SRC_PREMULTCOLOR;
  15.311 -            }
  15.312 -        }
  15.313 -
  15.314 -        switch (texture->blendMode) {
  15.315 -        case SDL_TEXTUREBLENDMODE_NONE:
  15.316 -                                       /**< No blending */
  15.317 -            flags |= DSBLIT_NOFX;
  15.318 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_ONE);
  15.319 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
  15.320 -            break;
  15.321 -        case SDL_TEXTUREBLENDMODE_MASK:
  15.322 -            flags |= DSBLIT_BLEND_ALPHACHANNEL;
  15.323 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
  15.324 -            data->surface->SetDstBlendFunction(data->surface,
  15.325 -                                               DSBF_INVSRCALPHA);
  15.326 -            break;
  15.327 -        case SDL_TEXTUREBLENDMODE_BLEND:
  15.328 -            flags |= DSBLIT_BLEND_ALPHACHANNEL;
  15.329 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
  15.330 -            data->surface->SetDstBlendFunction(data->surface,
  15.331 -                                               DSBF_INVSRCALPHA);
  15.332 -            break;
  15.333 -        case SDL_TEXTUREBLENDMODE_ADD:
  15.334 -            flags |= DSBLIT_BLEND_ALPHACHANNEL;
  15.335 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_SRCALPHA);
  15.336 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ONE);
  15.337 -            break;
  15.338 -        case SDL_TEXTUREBLENDMODE_MOD:
  15.339 -            flags |= DSBLIT_BLEND_ALPHACHANNEL;
  15.340 -            data->surface->SetSrcBlendFunction(data->surface, DSBF_DESTCOLOR);
  15.341 -            data->surface->SetDstBlendFunction(data->surface, DSBF_ZERO);
  15.342 -            break;
  15.343 -        }
  15.344 -
  15.345 -        SDL_DFB_CHECKERR(data->surface->
  15.346 -                         SetBlittingFlags(data->surface, flags));
  15.347 -
  15.348          if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) {
  15.349              SDL_DFB_CHECKERR(data->surface->
  15.350                               Blit(data->surface, texturedata->surface,
    16.1 --- a/src/video/dummy/SDL_nullrender.c	Sat Dec 20 08:41:05 2008 +0000
    16.2 +++ b/src/video/dummy/SDL_nullrender.c	Sat Dec 20 12:00:00 2008 +0000
    16.3 @@ -31,8 +31,9 @@
    16.4  
    16.5  static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
    16.6                                                Uint32 flags);
    16.7 -static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
    16.8 -                                Uint8 b, Uint8 a, const SDL_Rect * rect);
    16.9 +static int SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer);
   16.10 +static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
   16.11 +                                const SDL_Rect * rect);
   16.12  static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
   16.13                                  SDL_Texture * texture,
   16.14                                  const SDL_Rect * srcrect,
   16.15 @@ -88,6 +89,7 @@
   16.16      }
   16.17      SDL_zerop(data);
   16.18  
   16.19 +    renderer->SetDrawColor = SDL_DUMMY_SetDrawColor;
   16.20      renderer->RenderFill = SDL_DUMMY_RenderFill;
   16.21      renderer->RenderCopy = SDL_DUMMY_RenderCopy;
   16.22      renderer->RenderPresent = SDL_DUMMY_RenderPresent;
   16.23 @@ -124,8 +126,13 @@
   16.24  }
   16.25  
   16.26  static int
   16.27 -SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
   16.28 -                     Uint8 a, const SDL_Rect * rect)
   16.29 +SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer)
   16.30 +{
   16.31 +    return 0;
   16.32 +}
   16.33 +
   16.34 +static int
   16.35 +SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
   16.36  {
   16.37      SDL_DUMMY_RenderData *data =
   16.38          (SDL_DUMMY_RenderData *) renderer->driverdata;
   16.39 @@ -133,7 +140,8 @@
   16.40      Uint32 color;
   16.41      SDL_Rect real_rect = *rect;
   16.42  
   16.43 -    color = SDL_MapRGBA(target->format, r, g, b, a);
   16.44 +    color = SDL_MapRGBA(target->format,
   16.45 +                        renderer->r, renderer->g, renderer->b, renderer->a);
   16.46  
   16.47      return SDL_FillRect(target, &real_rect, color);
   16.48  }
    17.1 --- a/src/video/nds/SDL_ndsrender.c	Sat Dec 20 08:41:05 2008 +0000
    17.2 +++ b/src/video/nds/SDL_ndsrender.c	Sat Dec 20 12:00:00 2008 +0000
    17.3 @@ -140,7 +140,7 @@
    17.4      {"nds",                     /* char* name */
    17.5       (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),  /* u32 flags */
    17.6       (SDL_TEXTUREMODULATE_NONE),        /* u32 mod_modes */
    17.7 -     (SDL_TEXTUREBLENDMODE_MASK),       /* u32 blend_modes */
    17.8 +     (SDL_BLENDMODE_MASK),      /* u32 blend_modes */
    17.9       (SDL_TEXTURESCALEMODE_FAST),       /* u32 scale_modes */
   17.10       3,                         /* u32 num_texture_formats */
   17.11       {
    18.1 --- a/src/video/win32/SDL_d3drender.c	Sat Dec 20 08:41:05 2008 +0000
    18.2 +++ b/src/video/win32/SDL_d3drender.c	Sat Dec 20 12:00:00 2008 +0000
    18.3 @@ -82,9 +82,8 @@
    18.4        SDL_RENDERER_ACCELERATED),
    18.5       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
    18.6        SDL_TEXTUREMODULATE_ALPHA),
    18.7 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
    18.8 -      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
    18.9 -      SDL_TEXTUREBLENDMODE_MOD),
   18.10 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
   18.11 +      SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
   18.12       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST |
   18.13        SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST),
   18.14       12,
   18.15 @@ -525,15 +524,15 @@
   18.16  D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   18.17  {
   18.18      switch (texture->blendMode) {
   18.19 -    case SDL_TEXTUREBLENDMODE_NONE:
   18.20 -    case SDL_TEXTUREBLENDMODE_MASK:
   18.21 -    case SDL_TEXTUREBLENDMODE_BLEND:
   18.22 -    case SDL_TEXTUREBLENDMODE_ADD:
   18.23 -    case SDL_TEXTUREBLENDMODE_MOD:
   18.24 +    case SDL_BLENDMODE_NONE:
   18.25 +    case SDL_BLENDMODE_MASK:
   18.26 +    case SDL_BLENDMODE_BLEND:
   18.27 +    case SDL_BLENDMODE_ADD:
   18.28 +    case SDL_BLENDMODE_MOD:
   18.29          return 0;
   18.30      default:
   18.31          SDL_Unsupported();
   18.32 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   18.33 +        texture->blendMode = SDL_BLENDMODE_NONE;
   18.34          return -1;
   18.35      }
   18.36  }
   18.37 @@ -798,12 +797,12 @@
   18.38      vertices[3].v = maxv;
   18.39  
   18.40      switch (texture->blendMode) {
   18.41 -    case SDL_TEXTUREBLENDMODE_NONE:
   18.42 +    case SDL_BLENDMODE_NONE:
   18.43          IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   18.44                                          FALSE);
   18.45          break;
   18.46 -    case SDL_TEXTUREBLENDMODE_MASK:
   18.47 -    case SDL_TEXTUREBLENDMODE_BLEND:
   18.48 +    case SDL_BLENDMODE_MASK:
   18.49 +    case SDL_BLENDMODE_BLEND:
   18.50          IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   18.51                                          TRUE);
   18.52          IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
   18.53 @@ -811,7 +810,7 @@
   18.54          IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
   18.55                                          D3DBLEND_INVSRCALPHA);
   18.56          break;
   18.57 -    case SDL_TEXTUREBLENDMODE_ADD:
   18.58 +    case SDL_BLENDMODE_ADD:
   18.59          IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   18.60                                          TRUE);
   18.61          IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
   18.62 @@ -819,7 +818,7 @@
   18.63          IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND,
   18.64                                          D3DBLEND_ONE);
   18.65          break;
   18.66 -    case SDL_TEXTUREBLENDMODE_MOD:
   18.67 +    case SDL_BLENDMODE_MOD:
   18.68          IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE,
   18.69                                          TRUE);
   18.70          IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND,
    19.1 --- a/src/video/win32/SDL_gdirender.c	Sat Dec 20 08:41:05 2008 +0000
    19.2 +++ b/src/video/win32/SDL_gdirender.c	Sat Dec 20 12:00:00 2008 +0000
    19.3 @@ -73,8 +73,7 @@
    19.4        SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
    19.5        SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
    19.6       (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA),
    19.7 -     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
    19.8 -      SDL_TEXTUREBLENDMODE_BLEND),
    19.9 +     (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND),
   19.10       (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
   19.11       14,
   19.12       {
   19.13 @@ -459,13 +458,13 @@
   19.14  GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   19.15  {
   19.16      switch (texture->blendMode) {
   19.17 -    case SDL_TEXTUREBLENDMODE_NONE:
   19.18 -    case SDL_TEXTUREBLENDMODE_MASK:
   19.19 -    case SDL_TEXTUREBLENDMODE_BLEND:
   19.20 +    case SDL_BLENDMODE_NONE:
   19.21 +    case SDL_BLENDMODE_MASK:
   19.22 +    case SDL_BLENDMODE_BLEND:
   19.23          return 0;
   19.24      default:
   19.25          SDL_Unsupported();
   19.26 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   19.27 +        texture->blendMode = SDL_BLENDMODE_NONE;
   19.28          return -1;
   19.29      }
   19.30  }
   19.31 @@ -617,8 +616,7 @@
   19.32          SelectPalette(data->memory_hdc, texturedata->hpal, TRUE);
   19.33          RealizePalette(data->memory_hdc);
   19.34      }
   19.35 -    if (texture->blendMode &
   19.36 -        (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) {
   19.37 +    if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) {
   19.38          BLENDFUNCTION blendFunc = {
   19.39              AC_SRC_OVER,
   19.40              0,
    20.1 --- a/src/video/x11/SDL_x11render.c	Sat Dec 20 08:41:05 2008 +0000
    20.2 +++ b/src/video/x11/SDL_x11render.c	Sat Dec 20 12:00:00 2008 +0000
    20.3 @@ -47,8 +47,11 @@
    20.4                             const SDL_Rect * rect, int markDirty,
    20.5                             void **pixels, int *pitch);
    20.6  static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    20.7 -static int X11_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
    20.8 -                          Uint8 a, const SDL_Rect * rect);
    20.9 +static int X11_SetDrawColor(SDL_Renderer * renderer);
   20.10 +static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
   20.11 +static int X11_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
   20.12 +                          int y2);
   20.13 +static int X11_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
   20.14  static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   20.15                            const SDL_Rect * srcrect, const SDL_Rect * dstrect);
   20.16  static void X11_RenderPresent(SDL_Renderer * renderer);
   20.17 @@ -65,7 +68,7 @@
   20.18        SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
   20.19        SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED),
   20.20       SDL_TEXTUREMODULATE_NONE,
   20.21 -     SDL_TEXTUREBLENDMODE_NONE,
   20.22 +     SDL_BLENDMODE_NONE,
   20.23       SDL_TEXTURESCALEMODE_NONE,
   20.24       0,
   20.25       {0},
   20.26 @@ -191,6 +194,9 @@
   20.27      renderer->UpdateTexture = X11_UpdateTexture;
   20.28      renderer->LockTexture = X11_LockTexture;
   20.29      renderer->UnlockTexture = X11_UnlockTexture;
   20.30 +    renderer->SetDrawColor = X11_SetDrawColor;
   20.31 +    renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
   20.32 +    renderer->RenderLine = X11_RenderLine;
   20.33      renderer->RenderFill = X11_RenderFill;
   20.34      renderer->RenderCopy = X11_RenderCopy;
   20.35      renderer->RenderPresent = X11_RenderPresent;
   20.36 @@ -445,11 +451,11 @@
   20.37  X11_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
   20.38  {
   20.39      switch (texture->blendMode) {
   20.40 -    case SDL_TEXTUREBLENDMODE_NONE:
   20.41 +    case SDL_BLENDMODE_NONE:
   20.42          return 0;
   20.43      default:
   20.44          SDL_Unsupported();
   20.45 -        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
   20.46 +        texture->blendMode = SDL_BLENDMODE_NONE;
   20.47          return -1;
   20.48      }
   20.49  }
   20.50 @@ -552,8 +558,73 @@
   20.51  }
   20.52  
   20.53  static int
   20.54 -X11_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
   20.55 -               const SDL_Rect * rect)
   20.56 +X11_SetDrawColor(SDL_Renderer * renderer)
   20.57 +{
   20.58 +    return 0;
   20.59 +}
   20.60 +
   20.61 +static int
   20.62 +X11_SetDrawBlendMode(SDL_Renderer * renderer)
   20.63 +{
   20.64 +    switch (renderer->blendMode) {
   20.65 +    case SDL_BLENDMODE_NONE:
   20.66 +        return 0;
   20.67 +    default:
   20.68 +        SDL_Unsupported();
   20.69 +        renderer->blendMode = SDL_BLENDMODE_NONE;
   20.70 +        return -1;
   20.71 +    }
   20.72 +}
   20.73 +
   20.74 +static Uint32
   20.75 +renderdrawcolor(SDL_Renderer * renderer, int premult)
   20.76 +{
   20.77 +    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   20.78 +    Uint8 r = renderer->r;
   20.79 +    Uint8 g = renderer->g;
   20.80 +    Uint8 b = renderer->b;
   20.81 +    Uint8 a = renderer->a;
   20.82 +    if (premult)
   20.83 +        return SDL_MapRGBA(data->format, ((int) r * (int) a) / 255,
   20.84 +                           ((int) g * (int) a) / 255,
   20.85 +                           ((int) b * (int) a) / 255, 255);
   20.86 +    else
   20.87 +        return SDL_MapRGBA(data->format, r, g, b, a);
   20.88 +}
   20.89 +
   20.90 +static int
   20.91 +X11_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   20.92 +{
   20.93 +    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   20.94 +    unsigned long foreground;
   20.95 +    if (data->makedirty) {
   20.96 +        SDL_Rect rect;
   20.97 +
   20.98 +        if (x1 < x2) {
   20.99 +            rect.x = x1;
  20.100 +            rect.w = (x2 - x1) + 1;
  20.101 +        } else {
  20.102 +            rect.x = x2;
  20.103 +            rect.w = (x1 - x2) + 1;
  20.104 +        }
  20.105 +        if (y1 < y2) {
  20.106 +            rect.y = y1;
  20.107 +            rect.h = (y2 - y1) + 1;
  20.108 +        } else {
  20.109 +            rect.y = y2;
  20.110 +            rect.h = (y1 - y2) + 1;
  20.111 +        }
  20.112 +        SDL_AddDirtyRect(&data->dirty, &rect);
  20.113 +    }
  20.114 +
  20.115 +    foreground = renderdrawcolor(renderer, 1);
  20.116 +    XSetForeground(data->display, data->gc, foreground);
  20.117 +    XDrawLine(data->display, data->drawable, data->gc, x1, y1, x2, y2);
  20.118 +
  20.119 +}
  20.120 +
  20.121 +static int
  20.122 +X11_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
  20.123  {
  20.124      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
  20.125      unsigned long foreground;
  20.126 @@ -562,9 +633,9 @@
  20.127          SDL_AddDirtyRect(&data->dirty, rect);
  20.128      }
  20.129  
  20.130 -    foreground = SDL_MapRGBA(data->format, r, g, b, a);
  20.131 +    foreground = renderdrawcolor(renderer, 1);
  20.132      XSetForeground(data->display, data->gc, foreground);
  20.133 -    XDrawRectangle(data->display, data->drawable, data->gc, rect->x, rect->y,
  20.134 +    XFillRectangle(data->display, data->drawable, data->gc, rect->x, rect->y,
  20.135                     rect->w, rect->h);
  20.136      return 0;
  20.137  }
    21.1 --- a/src/video/x11/SDL_x11sym.h	Sat Dec 20 08:41:05 2008 +0000
    21.2 +++ b/src/video/x11/SDL_x11sym.h	Sat Dec 20 12:00:00 2008 +0000
    21.3 @@ -51,6 +51,7 @@
    21.4  SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return)
    21.5  SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return)
    21.6  SDL_X11_SYM(int,XDrawRectangle,(Display* a,Drawable b,GC c,int d, int e, unsigned int f, unsigned int g),(a,b,c,d,e,f,g),return)
    21.7 +SDL_X11_SYM(int,XFillRectangle,(Display* a,Drawable b,GC c,int d, int e, unsigned int f, unsigned int g),(a,b,c,d,e,f,g),return)
    21.8  SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return)
    21.9  SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return)
   21.10  SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return)
   21.11 @@ -94,6 +95,7 @@
   21.12  SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return)
   21.13  SDL_X11_SYM(int,XPending,(Display* a),(a),return)
   21.14  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)
   21.15 +SDL_X11_SYM(int,XDrawLine,(Display* a, Drawable b, GC c, int d, int e, int f, int g),(a,b,c,d,e,f,g),return)
   21.16  SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
   21.17  SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
   21.18  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)
    22.1 --- a/test/common.c	Sat Dec 20 08:41:05 2008 +0000
    22.2 +++ b/test/common.c	Sat Dec 20 12:00:00 2008 +0000
    22.3 @@ -322,19 +322,19 @@
    22.4  PrintBlendMode(Uint32 flag)
    22.5  {
    22.6      switch (flag) {
    22.7 -    case SDL_TEXTUREBLENDMODE_NONE:
    22.8 +    case SDL_BLENDMODE_NONE:
    22.9          fprintf(stderr, "None");
   22.10          break;
   22.11 -    case SDL_TEXTUREBLENDMODE_MASK:
   22.12 +    case SDL_BLENDMODE_MASK:
   22.13          fprintf(stderr, "Mask");
   22.14          break;
   22.15 -    case SDL_TEXTUREBLENDMODE_BLEND:
   22.16 +    case SDL_BLENDMODE_BLEND:
   22.17          fprintf(stderr, "Blend");
   22.18          break;
   22.19 -    case SDL_TEXTUREBLENDMODE_ADD:
   22.20 +    case SDL_BLENDMODE_ADD:
   22.21          fprintf(stderr, "Add");
   22.22          break;
   22.23 -    case SDL_TEXTUREBLENDMODE_MOD:
   22.24 +    case SDL_BLENDMODE_MOD:
   22.25          fprintf(stderr, "Mod");
   22.26          break;
   22.27      default:
    23.1 --- a/test/nds-test-progs/sprite/source/common.c	Sat Dec 20 08:41:05 2008 +0000
    23.2 +++ b/test/nds-test-progs/sprite/source/common.c	Sat Dec 20 12:00:00 2008 +0000
    23.3 @@ -322,19 +322,19 @@
    23.4  PrintBlendMode(Uint32 flag)
    23.5  {
    23.6      switch (flag) {
    23.7 -    case SDL_TEXTUREBLENDMODE_NONE:
    23.8 +    case SDL_BLENDMODE_NONE:
    23.9          fprintf(stderr, "None");
   23.10          break;
   23.11 -    case SDL_TEXTUREBLENDMODE_MASK:
   23.12 +    case SDL_BLENDMODE_MASK:
   23.13          fprintf(stderr, "Mask");
   23.14          break;
   23.15 -    case SDL_TEXTUREBLENDMODE_BLEND:
   23.16 +    case SDL_BLENDMODE_BLEND:
   23.17          fprintf(stderr, "Blend");
   23.18          break;
   23.19 -    case SDL_TEXTUREBLENDMODE_ADD:
   23.20 +    case SDL_BLENDMODE_ADD:
   23.21          fprintf(stderr, "Add");
   23.22          break;
   23.23 -    case SDL_TEXTUREBLENDMODE_MOD:
   23.24 +    case SDL_BLENDMODE_MOD:
   23.25          fprintf(stderr, "Mod");
   23.26          break;
   23.27      default:
    24.1 --- a/test/nds-test-progs/sprite2/source/common.c	Sat Dec 20 08:41:05 2008 +0000
    24.2 +++ b/test/nds-test-progs/sprite2/source/common.c	Sat Dec 20 12:00:00 2008 +0000
    24.3 @@ -322,19 +322,19 @@
    24.4  PrintBlendMode(Uint32 flag)
    24.5  {
    24.6      switch (flag) {
    24.7 -    case SDL_TEXTUREBLENDMODE_NONE:
    24.8 +    case SDL_BLENDMODE_NONE:
    24.9          fprintf(stderr, "None");
   24.10          break;
   24.11 -    case SDL_TEXTUREBLENDMODE_MASK:
   24.12 +    case SDL_BLENDMODE_MASK:
   24.13          fprintf(stderr, "Mask");
   24.14          break;
   24.15 -    case SDL_TEXTUREBLENDMODE_BLEND:
   24.16 +    case SDL_BLENDMODE_BLEND:
   24.17          fprintf(stderr, "Blend");
   24.18          break;
   24.19 -    case SDL_TEXTUREBLENDMODE_ADD:
   24.20 +    case SDL_BLENDMODE_ADD:
   24.21          fprintf(stderr, "Add");
   24.22          break;
   24.23 -    case SDL_TEXTUREBLENDMODE_MOD:
   24.24 +    case SDL_BLENDMODE_MOD:
   24.25          fprintf(stderr, "Mod");
   24.26          break;
   24.27      default:
    25.1 --- a/test/nds-test-progs/sprite2/source/testsprite2.c	Sat Dec 20 08:41:05 2008 +0000
    25.2 +++ b/test/nds-test-progs/sprite2/source/testsprite2.c	Sat Dec 20 12:00:00 2008 +0000
    25.3 @@ -21,7 +21,7 @@
    25.4  static SDL_Rect *positions;
    25.5  static SDL_Rect *velocities;
    25.6  static int sprite_w, sprite_h;
    25.7 -static SDL_TextureBlendMode blendMode = SDL_TEXTUREBLENDMODE_MASK;
    25.8 +static SDL_BlendMode blendMode = SDL_BLENDMODE_MASK;
    25.9  static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
   25.10  
   25.11  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
    26.1 --- a/test/testsprite2.c	Sat Dec 20 08:41:05 2008 +0000
    26.2 +++ b/test/testsprite2.c	Sat Dec 20 12:00:00 2008 +0000
    26.3 @@ -20,7 +20,7 @@
    26.4  static SDL_Rect *positions;
    26.5  static SDL_Rect *velocities;
    26.6  static int sprite_w, sprite_h;
    26.7 -static SDL_TextureBlendMode blendMode = SDL_TEXTUREBLENDMODE_MASK;
    26.8 +static SDL_BlendMode blendMode = SDL_BLENDMODE_MASK;
    26.9  static SDL_TextureScaleMode scaleMode = SDL_TEXTURESCALEMODE_NONE;
   26.10  
   26.11  /* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
   26.12 @@ -119,7 +119,8 @@
   26.13  
   26.14      /* Move the sprite, bounce at the wall, and draw */
   26.15      n = 0;
   26.16 -    SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   26.17 +    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   26.18 +    SDL_RenderFill(NULL);
   26.19      for (i = 0; i < num_sprites; ++i) {
   26.20          position = &positions[i];
   26.21          velocity = &velocities[i];
   26.22 @@ -166,19 +167,19 @@
   26.23              if (SDL_strcasecmp(argv[i], "--blend") == 0) {
   26.24                  if (argv[i + 1]) {
   26.25                      if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
   26.26 -                        blendMode = SDL_TEXTUREBLENDMODE_NONE;
   26.27 +                        blendMode = SDL_BLENDMODE_NONE;
   26.28                          consumed = 2;
   26.29                      } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
   26.30 -                        blendMode = SDL_TEXTUREBLENDMODE_MASK;
   26.31 +                        blendMode = SDL_BLENDMODE_MASK;
   26.32                          consumed = 2;
   26.33                      } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
   26.34 -                        blendMode = SDL_TEXTUREBLENDMODE_BLEND;
   26.35 +                        blendMode = SDL_BLENDMODE_BLEND;
   26.36                          consumed = 2;
   26.37                      } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
   26.38 -                        blendMode = SDL_TEXTUREBLENDMODE_ADD;
   26.39 +                        blendMode = SDL_BLENDMODE_ADD;
   26.40                          consumed = 2;
   26.41                      } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
   26.42 -                        blendMode = SDL_TEXTUREBLENDMODE_MOD;
   26.43 +                        blendMode = SDL_BLENDMODE_MOD;
   26.44                          consumed = 2;
   26.45                      }
   26.46                  }
   26.47 @@ -230,7 +231,8 @@
   26.48      }
   26.49      for (i = 0; i < state->num_windows; ++i) {
   26.50          SDL_SelectRenderer(state->windows[i]);
   26.51 -        SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   26.52 +        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   26.53 +        SDL_RenderFill(NULL);
   26.54      }
   26.55      if (LoadSprite("icon.bmp") < 0) {
   26.56          quit(2);
   26.57 @@ -275,7 +277,8 @@
   26.58                  switch (event.window.event) {
   26.59                  case SDL_WINDOWEVENT_EXPOSED:
   26.60                      SDL_SelectRenderer(event.window.windowID);
   26.61 -                    SDL_RenderFill(0xA0, 0xA0, 0xA0, 0xFF, NULL);
   26.62 +                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   26.63 +                    SDL_RenderFill(NULL);
   26.64                      break;
   26.65                  }
   26.66                  break;