Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Dummy video driver works again in high color video modes. Yay!

  • Loading branch information
slouken committed Jun 14, 2006
1 parent 61cea60 commit b4cdcb82b65aa25c09e85970662e2912f72b1081
Showing with 73 additions and 17 deletions.
  1. +6 −0 src/SDL_compat.c
  2. +28 −14 src/video/SDL_renderer_sw.c
  3. +3 −0 src/video/SDL_sysvideo.h
  4. +35 −2 src/video/SDL_video.c
  5. +1 −1 src/video/SDL_yuv_sw.c
@@ -581,6 +581,12 @@ SDL_WM_GrabInput(SDL_GrabMode mode)
return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
}

void
SDL_WarpMouse(Uint16 x, Uint16 y)
{
SDL_WarpMouseInWindow(SDL_VideoWindow, x, y);
}

Uint8
SDL_GetAppState(void)
{
@@ -33,6 +33,9 @@ static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
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 @@ SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)

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 @@ SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)
return renderer;
}

int
static int
SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_Surface *surface;
@@ -218,7 +222,7 @@ SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return 0;
}

int
static int
SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
void **pixels, int *pitch)
{
@@ -229,7 +233,17 @@ SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
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 @@ SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
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 @@ SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
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_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
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 @@ SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
}
}

int
static int
SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
void *pixels, int pitch)
{
@@ -341,7 +355,7 @@ SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
return 0;
}

int
static int
SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
const void *pixels, int pitch)
{
@@ -364,7 +378,7 @@ SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
return 0;
}

void
static void
SDL_SW_RenderPresent(SDL_Renderer * renderer)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
@@ -396,15 +410,15 @@ SDL_SW_RenderPresent(SDL_Renderer * renderer)
data->current_screen = new_screen;
}

void
static void
SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
SDL_Surface *surface = (SDL_Surface *) texture->driverdata;

SDL_FreeSurface(surface);
}

void
static void
SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
{
SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
@@ -69,6 +69,9 @@ struct SDL_Renderer
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,
@@ -1029,8 +1029,15 @@ SDL_CreateRenderer(SDL_WindowID windowID, int index, Uint32 flags)
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_SelectRenderer(SDL_WindowID windowID)
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_CreateTexture(Uint32 format, int access, int w, int h)
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
@@ -1302,6 +1316,25 @@ SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch)
return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
}

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)
@@ -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:

0 comments on commit b4cdcb8

Please sign in to comment.