Dummy video driver works again in high color video modes. Yay! SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Wed, 14 Jun 2006 08:41:13 +0000
branchSDL-1.3
changeset 16809488fca10677
parent 1679 153477a6cc31
child 1681 80a5e6a4e1e2
Dummy video driver works again in high color video modes. Yay!
src/SDL_compat.c
src/video/SDL_renderer_sw.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/SDL_yuv_sw.c
     1.1 --- a/src/SDL_compat.c	Wed Jun 14 06:26:35 2006 +0000
     1.2 +++ b/src/SDL_compat.c	Wed Jun 14 08:41:13 2006 +0000
     1.3 @@ -581,6 +581,12 @@
     1.4      return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
     1.5  }
     1.6  
     1.7 +void
     1.8 +SDL_WarpMouse(Uint16 x, Uint16 y)
     1.9 +{
    1.10 +    SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
    1.11 +}
    1.12 +
    1.13  Uint8
    1.14  SDL_GetAppState(void)
    1.15  {
     2.1 --- a/src/video/SDL_renderer_sw.c	Wed Jun 14 06:26:35 2006 +0000
     2.2 +++ b/src/video/SDL_renderer_sw.c	Wed Jun 14 08:41:13 2006 +0000
     2.3 @@ -33,6 +33,9 @@
     2.4  static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
     2.5                                       SDL_Texture * texture, void **pixels,
     2.6                                       int *pitch);
     2.7 +static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer,
     2.8 +                                    SDL_Texture * texture, SDL_Color * colors,
     2.9 +                                    int firstcolor, int ncolors);
    2.10  static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
    2.11                                  SDL_Texture * texture, SDL_Rect * rect,
    2.12                                  const void *pixels, int pitch);
    2.13 @@ -130,6 +133,7 @@
    2.14  
    2.15      renderer->CreateTexture = SDL_SW_CreateTexture;
    2.16      renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
    2.17 +    renderer->SetTexturePalette = SDL_SW_SetTexturePalette;
    2.18      renderer->UpdateTexture = SDL_SW_UpdateTexture;
    2.19      renderer->LockTexture = SDL_SW_LockTexture;
    2.20      renderer->UnlockTexture = SDL_SW_UnlockTexture;
    2.21 @@ -189,7 +193,7 @@
    2.22      return renderer;
    2.23  }
    2.24  
    2.25 -int
    2.26 +static int
    2.27  SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
    2.28  {
    2.29      SDL_Surface *surface;
    2.30 @@ -218,7 +222,7 @@
    2.31      return 0;
    2.32  }
    2.33  
    2.34 -int
    2.35 +static int
    2.36  SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
    2.37                            void **pixels, int *pitch)
    2.38  {
    2.39 @@ -229,7 +233,17 @@
    2.40      return 0;
    2.41  }
    2.42  
    2.43 -int
    2.44 +static int
    2.45 +SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
    2.46 +                         SDL_Color * colors, int firstcolor, int ncolors)
    2.47 +{
    2.48 +    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
    2.49 +
    2.50 +    SDL_SetColors(surface, colors, firstcolor, ncolors);
    2.51 +    return 0;
    2.52 +}
    2.53 +
    2.54 +static int
    2.55  SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    2.56                       SDL_Rect * rect, const void *pixels, int pitch)
    2.57  {
    2.58 @@ -251,7 +265,7 @@
    2.59      return 0;
    2.60  }
    2.61  
    2.62 -int
    2.63 +static int
    2.64  SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    2.65                     SDL_Rect * rect, int markDirty, void **pixels, int *pitch)
    2.66  {
    2.67 @@ -264,25 +278,25 @@
    2.68      return 0;
    2.69  }
    2.70  
    2.71 -void
    2.72 +static void
    2.73  SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
    2.74  {
    2.75  }
    2.76  
    2.77 -void
    2.78 +static void
    2.79  SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    2.80                      int numrects, SDL_Rect * rects)
    2.81  {
    2.82  }
    2.83  
    2.84 -void
    2.85 +static void
    2.86  SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
    2.87  {
    2.88      SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
    2.89      data->target = (SDL_Surface *) texture->driverdata;
    2.90  }
    2.91  
    2.92 -void
    2.93 +static void
    2.94  SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
    2.95  {
    2.96      SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
    2.97 @@ -297,7 +311,7 @@
    2.98      SDL_FillRect(data->target, rect, color);
    2.99  }
   2.100  
   2.101 -int
   2.102 +static int
   2.103  SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
   2.104                    SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode,
   2.105                    int scaleMode)
   2.106 @@ -318,7 +332,7 @@
   2.107      }
   2.108  }
   2.109  
   2.110 -int
   2.111 +static int
   2.112  SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
   2.113                          void *pixels, int pitch)
   2.114  {
   2.115 @@ -341,7 +355,7 @@
   2.116      return 0;
   2.117  }
   2.118  
   2.119 -int
   2.120 +static int
   2.121  SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
   2.122                           const void *pixels, int pitch)
   2.123  {
   2.124 @@ -364,7 +378,7 @@
   2.125      return 0;
   2.126  }
   2.127  
   2.128 -void
   2.129 +static void
   2.130  SDL_SW_RenderPresent(SDL_Renderer * renderer)
   2.131  {
   2.132      SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
   2.133 @@ -396,7 +410,7 @@
   2.134      data->current_screen = new_screen;
   2.135  }
   2.136  
   2.137 -void
   2.138 +static void
   2.139  SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
   2.140  {
   2.141      SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
   2.142 @@ -404,7 +418,7 @@
   2.143      SDL_FreeSurface(surface);
   2.144  }
   2.145  
   2.146 -void
   2.147 +static void
   2.148  SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
   2.149  {
   2.150      SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
     3.1 --- a/src/video/SDL_sysvideo.h	Wed Jun 14 06:26:35 2006 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Wed Jun 14 08:41:13 2006 +0000
     3.3 @@ -69,6 +69,9 @@
     3.4      int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
     3.5      int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
     3.6                                 void **pixels, int *pitch);
     3.7 +    int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
     3.8 +                              SDL_Color * colors, int firstcolor,
     3.9 +                              int ncolors);
    3.10      int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    3.11                            SDL_Rect * rect, const void *pixels, int pitch);
    3.12      int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
     4.1 --- a/src/video/SDL_video.c	Wed Jun 14 06:26:35 2006 +0000
     4.2 +++ b/src/video/SDL_video.c	Wed Jun 14 08:41:13 2006 +0000
     4.3 @@ -1029,8 +1029,15 @@
     4.4      if (index < 0) {
     4.5          int n = SDL_GetNumRenderers();
     4.6          for (index = 0; index < n; ++index) {
     4.7 -            if ((SDL_CurrentDisplay.render_drivers[index].info.
     4.8 -                 flags & flags) == flags) {
     4.9 +            SDL_RenderDriver *driver =
    4.10 +                &SDL_CurrentDisplay.render_drivers[index];
    4.11 +
    4.12 +            /* Skip minimal drivers in automatic scans */
    4.13 +            if (!(flags & SDL_Renderer_Minimal)
    4.14 +                && (driver->info.flags & SDL_Renderer_Minimal)) {
    4.15 +                continue;
    4.16 +            }
    4.17 +            if ((driver->info.flags & flags) == flags) {
    4.18                  break;
    4.19              }
    4.20          }
    4.21 @@ -1076,6 +1083,7 @@
    4.22  SDL_TextureID
    4.23  SDL_CreateTexture(Uint32 format, int access, int w, int h)
    4.24  {
    4.25 +    int hash;
    4.26      SDL_Renderer *renderer;
    4.27      SDL_Texture *texture;
    4.28  
    4.29 @@ -1106,6 +1114,12 @@
    4.30          SDL_free(texture);
    4.31          return 0;
    4.32      }
    4.33 +
    4.34 +    hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
    4.35 +    texture->next = SDL_CurrentDisplay.textures[hash];
    4.36 +    SDL_CurrentDisplay.textures[hash] = texture;
    4.37 +
    4.38 +    return texture->id;
    4.39  }
    4.40  
    4.41  SDL_TextureID
    4.42 @@ -1303,6 +1317,25 @@
    4.43  }
    4.44  
    4.45  int
    4.46 +SDL_SetTexturePalette(SDL_TextureID textureID, SDL_Color * colors,
    4.47 +                      int firstcolor, int ncolors)
    4.48 +{
    4.49 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    4.50 +    SDL_Renderer *renderer;
    4.51 +
    4.52 +    if (!texture) {
    4.53 +        return -1;
    4.54 +    }
    4.55 +
    4.56 +    renderer = texture->renderer;
    4.57 +    if (!renderer->SetTexturePalette) {
    4.58 +        return -1;
    4.59 +    }
    4.60 +    return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
    4.61 +                                       ncolors);
    4.62 +}
    4.63 +
    4.64 +int
    4.65  SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect * rect,
    4.66                    const void *pixels, int pitch)
    4.67  {
     5.1 --- a/src/video/SDL_yuv_sw.c	Wed Jun 14 06:26:35 2006 +0000
     5.2 +++ b/src/video/SDL_yuv_sw.c	Wed Jun 14 08:41:13 2006 +0000
     5.3 @@ -21,7 +21,7 @@
     5.4  */
     5.5  #include "SDL_config.h"
     5.6  
     5.7 -#if 0 /* TODO */
     5.8 +#if 0                           /* TODO */
     5.9  /* This is the software implementation of the YUV video overlay support */
    5.10  
    5.11  /* This code was derived from code carrying the following copyright notices: