SetDrawColor() and SetDrawBlendMode() are optional
authorSam Lantinga <slouken@libsdl.org>
Tue, 30 Dec 2008 07:14:11 +0000
changeset 29272133d2d300fd
parent 2926 27f2b5e7e899
child 2928 e171ce9bdbad
SetDrawColor() and SetDrawBlendMode() are optional
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_sw.c
src/video/SDL_video.c
src/video/directfb/SDL_DirectFB_render.c
src/video/dummy/SDL_nullrender.c
src/video/win32/SDL_gdirender.c
src/video/x11/SDL_x11render.c
     1.1 --- a/src/video/SDL_renderer_gl.c	Tue Dec 30 04:38:39 2008 +0000
     1.2 +++ b/src/video/SDL_renderer_gl.c	Tue Dec 30 07:14:11 2008 +0000
     1.3 @@ -96,8 +96,6 @@
     1.4  static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     1.5  static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     1.6                              int numrects, const SDL_Rect * rects);
     1.7 -static int GL_SetDrawColor(SDL_Renderer * renderer);
     1.8 -static int GL_SetDrawBlendMode(SDL_Renderer * renderer);
     1.9  static int GL_RenderPoint(SDL_Renderer * renderer, int x, int y);
    1.10  static int GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    1.11                           int y2);
    1.12 @@ -312,8 +310,6 @@
    1.13      renderer->LockTexture = GL_LockTexture;
    1.14      renderer->UnlockTexture = GL_UnlockTexture;
    1.15      renderer->DirtyTexture = GL_DirtyTexture;
    1.16 -    renderer->SetDrawColor = GL_SetDrawColor;
    1.17 -    renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
    1.18      renderer->RenderPoint = GL_RenderPoint;
    1.19      renderer->RenderLine = GL_RenderLine;
    1.20      renderer->RenderFill = GL_RenderFill;
    1.21 @@ -1071,18 +1067,6 @@
    1.22  }
    1.23  
    1.24  static int
    1.25 -GL_SetDrawColor(SDL_Renderer * renderer)
    1.26 -{
    1.27 -    return 0;
    1.28 -}
    1.29 -
    1.30 -static int
    1.31 -GL_SetDrawBlendMode(SDL_Renderer * renderer)
    1.32 -{
    1.33 -    return 0;
    1.34 -}
    1.35 -
    1.36 -static int
    1.37  GL_RenderPoint(SDL_Renderer * renderer, int x, int y)
    1.38  {
    1.39      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
     2.1 --- a/src/video/SDL_renderer_sw.c	Tue Dec 30 04:38:39 2008 +0000
     2.2 +++ b/src/video/SDL_renderer_sw.c	Tue Dec 30 07:14:11 2008 +0000
     2.3 @@ -59,8 +59,6 @@
     2.4                            const SDL_Rect * rect, int markDirty, void **pixels,
     2.5                            int *pitch);
     2.6  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     2.7 -static int SW_SetDrawColor(SDL_Renderer * renderer);
     2.8 -static int SW_SetDrawBlendMode(SDL_Renderer * renderer);
     2.9  static int SW_RenderPoint(SDL_Renderer * renderer, int x, int y);
    2.10  static int SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    2.11                           int y2);
    2.12 @@ -226,8 +224,6 @@
    2.13      renderer->ActivateRenderer = SW_ActivateRenderer;
    2.14      renderer->DisplayModeChanged = SW_DisplayModeChanged;
    2.15  
    2.16 -    renderer->SetDrawColor = SW_SetDrawColor;
    2.17 -    renderer->SetDrawBlendMode = SW_SetDrawBlendMode;
    2.18      renderer->RenderPoint = SW_RenderPoint;
    2.19      renderer->RenderLine = SW_RenderLine;
    2.20      renderer->RenderFill = SW_RenderFill;
    2.21 @@ -529,18 +525,6 @@
    2.22  }
    2.23  
    2.24  static int
    2.25 -SW_SetDrawColor(SDL_Renderer * renderer)
    2.26 -{
    2.27 -    return 0;
    2.28 -}
    2.29 -
    2.30 -static int
    2.31 -SW_SetDrawBlendMode(SDL_Renderer * renderer)
    2.32 -{
    2.33 -    return 0;
    2.34 -}
    2.35 -
    2.36 -static int
    2.37  SW_RenderPoint(SDL_Renderer * renderer, int x, int y)
    2.38  {
    2.39      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
     3.1 --- a/src/video/SDL_video.c	Tue Dec 30 04:38:39 2008 +0000
     3.2 +++ b/src/video/SDL_video.c	Tue Dec 30 07:14:11 2008 +0000
     3.3 @@ -1987,16 +1987,15 @@
     3.4      if (!renderer) {
     3.5          return -1;
     3.6      }
     3.7 -    if (!renderer->SetDrawColor) {
     3.8 -        SDL_Unsupported();
     3.9 -        return -1;
    3.10 -    }
    3.11      renderer->r = r;
    3.12      renderer->g = g;
    3.13      renderer->b = b;
    3.14      renderer->a = a;
    3.15 -    renderer->SetDrawColor(renderer);
    3.16 -    return 0;
    3.17 +    if (renderer->SetDrawColor) {
    3.18 +        return renderer->SetDrawColor(renderer);
    3.19 +    } else {
    3.20 +        return 0;
    3.21 +    }
    3.22  }
    3.23  
    3.24  int
    3.25 @@ -2012,10 +2011,6 @@
    3.26      if (!renderer) {
    3.27          return -1;
    3.28      }
    3.29 -    if (!renderer->SetDrawColor) {
    3.30 -        SDL_Unsupported();
    3.31 -        return -1;
    3.32 -    }
    3.33      if (r) {
    3.34          *r = renderer->r;
    3.35      }
    3.36 @@ -2028,7 +2023,6 @@
    3.37      if (a) {
    3.38          *a = renderer->a;
    3.39      }
    3.40 -    return 0;
    3.41  }
    3.42  
    3.43  int
    3.44 @@ -2044,13 +2038,12 @@
    3.45      if (!renderer) {
    3.46          return -1;
    3.47      }
    3.48 -    if (!renderer->SetDrawBlendMode) {
    3.49 -        SDL_Unsupported();
    3.50 -        return -1;
    3.51 +    renderer->blendMode = blendMode;
    3.52 +    if (renderer->SetDrawBlendMode) {
    3.53 +        return renderer->SetDrawBlendMode(renderer);
    3.54 +    } else {
    3.55 +        return 0;
    3.56      }
    3.57 -    renderer->blendMode = blendMode;
    3.58 -    renderer->SetDrawBlendMode(renderer);
    3.59 -    return 0;
    3.60  }
    3.61  
    3.62  int
     4.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Tue Dec 30 04:38:39 2008 +0000
     4.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Tue Dec 30 07:14:11 2008 +0000
     4.3 @@ -71,8 +71,6 @@
     4.4  static void DirectFB_DirtyTexture(SDL_Renderer * renderer,
     4.5                                    SDL_Texture * texture, int numrects,
     4.6                                    const SDL_Rect * rects);
     4.7 -static int DirectFB_SetDrawColor(SDL_Renderer * renderer);
     4.8 -static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
     4.9  static int DirectFB_RenderPoint(SDL_Renderer * renderer, int x, int y);
    4.10  static int DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
    4.11                                 int x2, int y2);
    4.12 @@ -294,8 +292,6 @@
    4.13      renderer->LockTexture = DirectFB_LockTexture;
    4.14      renderer->UnlockTexture = DirectFB_UnlockTexture;
    4.15      renderer->DirtyTexture = DirectFB_DirtyTexture;
    4.16 -    renderer->SetDrawColor = DirectFB_SetDrawColor;
    4.17 -    renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
    4.18      renderer->RenderPoint = DirectFB_RenderPoint;
    4.19      renderer->RenderLine = DirectFB_RenderLine;
    4.20      renderer->RenderFill = DirectFB_RenderFill;
    4.21 @@ -798,18 +794,6 @@
    4.22  }
    4.23  
    4.24  static int
    4.25 -DirectFB_SetDrawColor(SDL_Renderer * renderer)
    4.26 -{
    4.27 -    return 0;
    4.28 -}
    4.29 -
    4.30 -static int
    4.31 -DirectFB_SetDrawBlendMode(SDL_Renderer * renderer)
    4.32 -{
    4.33 -    return 0;
    4.34 -}
    4.35 -
    4.36 -static int
    4.37  PrepareDraw(SDL_Renderer * renderer)
    4.38  {
    4.39      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
     5.1 --- a/src/video/dummy/SDL_nullrender.c	Tue Dec 30 04:38:39 2008 +0000
     5.2 +++ b/src/video/dummy/SDL_nullrender.c	Tue Dec 30 07:14:11 2008 +0000
     5.3 @@ -31,8 +31,6 @@
     5.4  
     5.5  static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
     5.6                                                Uint32 flags);
     5.7 -static int SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer);
     5.8 -static int SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer);
     5.9  static int SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y);
    5.10  static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1,
    5.11                                  int x2, int y2);
    5.12 @@ -93,8 +91,6 @@
    5.13      }
    5.14      SDL_zerop(data);
    5.15  
    5.16 -    renderer->SetDrawColor = SDL_DUMMY_SetDrawColor;
    5.17 -    renderer->SetDrawBlendMode = SDL_DUMMY_SetDrawBlendMode;
    5.18      renderer->RenderPoint = SDL_DUMMY_RenderPoint;
    5.19      renderer->RenderLine = SDL_DUMMY_RenderLine;
    5.20      renderer->RenderFill = SDL_DUMMY_RenderFill;
    5.21 @@ -133,18 +129,6 @@
    5.22  }
    5.23  
    5.24  static int
    5.25 -SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer)
    5.26 -{
    5.27 -    return 0;
    5.28 -}
    5.29 -
    5.30 -static int
    5.31 -SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer)
    5.32 -{
    5.33 -    return 0;
    5.34 -}
    5.35 -
    5.36 -static int
    5.37  SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y)
    5.38  {
    5.39      SDL_DUMMY_RenderData *data =
     6.1 --- a/src/video/win32/SDL_gdirender.c	Tue Dec 30 04:38:39 2008 +0000
     6.2 +++ b/src/video/win32/SDL_gdirender.c	Tue Dec 30 07:14:11 2008 +0000
     6.3 @@ -55,6 +55,7 @@
     6.4                             const SDL_Rect * rect, int markDirty,
     6.5                             void **pixels, int *pitch);
     6.6  static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     6.7 +static int GDI_SetDrawBlendMode(SDL_Renderer * renderer);
     6.8  static int GDI_RenderPoint(SDL_Renderer * renderer, int x, int y);
     6.9  static int GDI_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    6.10                            int y2);
    6.11 @@ -175,6 +176,7 @@
    6.12      renderer->UpdateTexture = GDI_UpdateTexture;
    6.13      renderer->LockTexture = GDI_LockTexture;
    6.14      renderer->UnlockTexture = GDI_UnlockTexture;
    6.15 +    renderer->SetDrawBlendMode = GDI_SetDrawBlendMode;
    6.16      renderer->RenderPoint = GDI_RenderPoint;
    6.17      renderer->RenderLine = GDI_RenderLine;
    6.18      renderer->RenderFill = GDI_RenderFill;
    6.19 @@ -574,6 +576,19 @@
    6.20  }
    6.21  
    6.22  static int
    6.23 +GDI_SetDrawBlendMode(SDL_Renderer * renderer)
    6.24 +{
    6.25 +    switch (renderer->blendMode) {
    6.26 +    case SDL_BLENDMODE_NONE:
    6.27 +        return 0;
    6.28 +    default:
    6.29 +        SDL_Unsupported();
    6.30 +        renderer->blendMode = SDL_BLENDMODE_NONE;
    6.31 +        return -1;
    6.32 +    }
    6.33 +}
    6.34 +
    6.35 +static int
    6.36  GDI_RenderPoint(SDL_Renderer * renderer, int x, int y)
    6.37  {
    6.38      GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
     7.1 --- a/src/video/x11/SDL_x11render.c	Tue Dec 30 04:38:39 2008 +0000
     7.2 +++ b/src/video/x11/SDL_x11render.c	Tue Dec 30 07:14:11 2008 +0000
     7.3 @@ -47,7 +47,6 @@
     7.4                             const SDL_Rect * rect, int markDirty,
     7.5                             void **pixels, int *pitch);
     7.6  static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     7.7 -static int X11_SetDrawColor(SDL_Renderer * renderer);
     7.8  static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
     7.9  static int X11_RenderPoint(SDL_Renderer * renderer, int x, int y);
    7.10  static int X11_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    7.11 @@ -197,7 +196,6 @@
    7.12      renderer->UpdateTexture = X11_UpdateTexture;
    7.13      renderer->LockTexture = X11_LockTexture;
    7.14      renderer->UnlockTexture = X11_UnlockTexture;
    7.15 -    renderer->SetDrawColor = X11_SetDrawColor;
    7.16      renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
    7.17      renderer->RenderPoint = X11_RenderPoint;
    7.18      renderer->RenderLine = X11_RenderLine;
    7.19 @@ -564,12 +562,6 @@
    7.20  }
    7.21  
    7.22  static int
    7.23 -X11_SetDrawColor(SDL_Renderer * renderer)
    7.24 -{
    7.25 -    return 0;
    7.26 -}
    7.27 -
    7.28 -static int
    7.29  X11_SetDrawBlendMode(SDL_Renderer * renderer)
    7.30  {
    7.31      switch (renderer->blendMode) {