changeset 1680:9488fca10677 SDL-1.3

Dummy video driver works again in high color video modes. Yay!
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jun 2006 08:41:13 +0000
parents 153477a6cc31
children 80a5e6a4e1e2
files 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
diffstat 5 files changed, 73 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/SDL_compat.c	Wed Jun 14 06:26:35 2006 +0000
+++ b/src/SDL_compat.c	Wed Jun 14 08:41:13 2006 +0000
@@ -581,6 +581,12 @@
     return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
 }
 
+void
+SDL_WarpMouse(Uint16 x, Uint16 y)
+{
+    SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
+}
+
 Uint8
 SDL_GetAppState(void)
 {
--- a/src/video/SDL_renderer_sw.c	Wed Jun 14 06:26:35 2006 +0000
+++ b/src/video/SDL_renderer_sw.c	Wed Jun 14 08:41:13 2006 +0000
@@ -33,6 +33,9 @@
 static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
                                      SDL_Texture * texture, void **pixels,
                                      int *pitch);
+static int SDL_SW_SetTexturePalette(SDL_Renderer * renderer,
+                                    SDL_Texture * texture, SDL_Color * colors,
+                                    int firstcolor, int ncolors);
 static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
                                 SDL_Texture * texture, SDL_Rect * rect,
                                 const void *pixels, int pitch);
@@ -130,6 +133,7 @@
 
     renderer->CreateTexture = SDL_SW_CreateTexture;
     renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
+    renderer->SetTexturePalette = SDL_SW_SetTexturePalette;
     renderer->UpdateTexture = SDL_SW_UpdateTexture;
     renderer->LockTexture = SDL_SW_LockTexture;
     renderer->UnlockTexture = SDL_SW_UnlockTexture;
@@ -189,7 +193,7 @@
     return renderer;
 }
 
-int
+static int
 SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     SDL_Surface *surface;
@@ -218,7 +222,7 @@
     return 0;
 }
 
-int
+static int
 SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
                           void **pixels, int *pitch)
 {
@@ -229,7 +233,17 @@
     return 0;
 }
 
-int
+static int
+SDL_SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
+                         SDL_Color * colors, int firstcolor, int ncolors)
+{
+    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
+
+    SDL_SetColors(surface, colors, firstcolor, ncolors);
+    return 0;
+}
+
+static int
 SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                      SDL_Rect * rect, const void *pixels, int pitch)
 {
@@ -251,7 +265,7 @@
     return 0;
 }
 
-int
+static int
 SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                    SDL_Rect * rect, int markDirty, void **pixels, int *pitch)
 {
@@ -264,25 +278,25 @@
     return 0;
 }
 
-void
+static void
 SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
 }
 
-void
+static void
 SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                     int numrects, SDL_Rect * rects)
 {
 }
 
-void
+static void
 SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
     data->target = (SDL_Surface *) texture->driverdata;
 }
 
-void
+static void
 SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
 {
     SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
@@ -297,7 +311,7 @@
     SDL_FillRect(data->target, rect, color);
 }
 
-int
+static int
 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
                   SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode,
                   int scaleMode)
@@ -318,7 +332,7 @@
     }
 }
 
-int
+static int
 SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
                         void *pixels, int pitch)
 {
@@ -341,7 +355,7 @@
     return 0;
 }
 
-int
+static int
 SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
                          const void *pixels, int pitch)
 {
@@ -364,7 +378,7 @@
     return 0;
 }
 
-void
+static void
 SDL_SW_RenderPresent(SDL_Renderer * renderer)
 {
     SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
@@ -396,7 +410,7 @@
     data->current_screen = new_screen;
 }
 
-void
+static void
 SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
 {
     SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
@@ -404,7 +418,7 @@
     SDL_FreeSurface(surface);
 }
 
-void
+static void
 SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
 {
     SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
--- a/src/video/SDL_sysvideo.h	Wed Jun 14 06:26:35 2006 +0000
+++ b/src/video/SDL_sysvideo.h	Wed Jun 14 08:41:13 2006 +0000
@@ -69,6 +69,9 @@
     int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
     int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
                                void **pixels, int *pitch);
+    int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture,
+                              SDL_Color * colors, int firstcolor,
+                              int ncolors);
     int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
                           SDL_Rect * rect, const void *pixels, int pitch);
     int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
--- a/src/video/SDL_video.c	Wed Jun 14 06:26:35 2006 +0000
+++ b/src/video/SDL_video.c	Wed Jun 14 08:41:13 2006 +0000
@@ -1029,8 +1029,15 @@
     if (index < 0) {
         int n = SDL_GetNumRenderers();
         for (index = 0; index < n; ++index) {
-            if ((SDL_CurrentDisplay.render_drivers[index].info.
-                 flags & flags) == flags) {
+            SDL_RenderDriver *driver =
+                &SDL_CurrentDisplay.render_drivers[index];
+
+            /* Skip minimal drivers in automatic scans */
+            if (!(flags & SDL_Renderer_Minimal)
+                && (driver->info.flags & SDL_Renderer_Minimal)) {
+                continue;
+            }
+            if ((driver->info.flags & flags) == flags) {
                 break;
             }
         }
@@ -1076,6 +1083,7 @@
 SDL_TextureID
 SDL_CreateTexture(Uint32 format, int access, int w, int h)
 {
+    int hash;
     SDL_Renderer *renderer;
     SDL_Texture *texture;
 
@@ -1106,6 +1114,12 @@
         SDL_free(texture);
         return 0;
     }
+
+    hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));
+    texture->next = SDL_CurrentDisplay.textures[hash];
+    SDL_CurrentDisplay.textures[hash] = texture;
+
+    return texture->id;
 }
 
 SDL_TextureID
@@ -1303,6 +1317,25 @@
 }
 
 int
+SDL_SetTexturePalette(SDL_TextureID textureID, SDL_Color * colors,
+                      int firstcolor, int ncolors)
+{
+    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
+    SDL_Renderer *renderer;
+
+    if (!texture) {
+        return -1;
+    }
+
+    renderer = texture->renderer;
+    if (!renderer->SetTexturePalette) {
+        return -1;
+    }
+    return renderer->SetTexturePalette(renderer, texture, colors, firstcolor,
+                                       ncolors);
+}
+
+int
 SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect * rect,
                   const void *pixels, int pitch)
 {
--- a/src/video/SDL_yuv_sw.c	Wed Jun 14 06:26:35 2006 +0000
+++ b/src/video/SDL_yuv_sw.c	Wed Jun 14 08:41:13 2006 +0000
@@ -21,7 +21,7 @@
 */
 #include "SDL_config.h"
 
-#if 0 /* TODO */
+#if 0                           /* TODO */
 /* This is the software implementation of the YUV video overlay support */
 
 /* This code was derived from code carrying the following copyright notices: