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

The test programs compile again.

The dummy video driver is partially functional now.
  • Loading branch information
slouken committed May 29, 2006
1 parent 19d098a commit 611acc99ad2bb0995ac8953b298ddfb05106a018
Showing with 165 additions and 16 deletions.
  1. +5 −0 include/SDL_compat.h
  2. +18 −0 include/SDL_events.h
  3. +17 −10 include/SDL_video.h
  4. +85 −4 src/SDL_compat.c
  5. +1 −1 src/video/SDL_sysvideo.h
  6. +22 −1 src/video/SDL_video.c
  7. +17 −0 src/video/dummy/SDL_nullvideo.c
@@ -25,6 +25,7 @@
#ifndef _SDL_compat_h
#define _SDL_compat_h

#include "SDL_video.h"
#include "SDL_syswm.h"

#include "begin_code.h"
@@ -59,6 +60,10 @@ extern "C" {
#define SDL_LOGPAL 0x01
#define SDL_PHYSPAL 0x02

#define SDL_ACTIVEEVENT SDL_EVENT_RESERVED1
#define SDL_VIDEORESIZE SDL_EVENT_RESERVED2
#define SDL_VIDEOEXPOSE SDL_EVENT_RESERVED3

typedef enum
{
SDL_GRAB_QUERY = -1,
@@ -269,6 +269,20 @@ typedef struct SDL_SysWMEvent
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
} SDL_SysWMEvent;

/* Typedefs for backwards compatibility */
typedef struct SDL_ActiveEvent
{
Uint8 type;
Uint8 gain;
Uint8 state;
} SDL_ActiveEvent;
typedef struct SDL_ResizeEvent
{
Uint8 type;
int w;
int h;
} SDL_ResizeEvent;

/**
* \union SDL_Event
*
@@ -288,6 +302,10 @@ typedef union SDL_Event
SDL_QuitEvent quit; /**< Quit request event data */
SDL_UserEvent user; /**< Custom event data */
SDL_SysWMEvent syswm; /**< System dependent window event data */

/* Temporarily here for backwards compatibility */
SDL_ActiveEvent active;
SDL_ResizeEvent resize;
} SDL_Event;


@@ -126,22 +126,29 @@ typedef int (*SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
struct SDL_Surface * dst, SDL_Rect * dstrect);


/* Useful for determining the video hardware capabilities */
/**
* \struct SDL_VideoInfo
*
* \brief Useful for determining the video hardware capabilities
*/
typedef struct SDL_VideoInfo
{
Uint32 hw_available:1; /* Flag: Can you create hardware surfaces? */
Uint32 wm_available:1; /* Flag: Can you talk to a window manager? */
Uint32 hw_available:1; /**< Flag: Can you create hardware surfaces? */
Uint32 wm_available:1; /**< Flag: Can you talk to a window manager? */
Uint32 UnusedBits1:6;
Uint32 UnusedBits2:1;
Uint32 blit_hw:1; /* Flag: Accelerated blits HW --> HW */
Uint32 blit_hw_CC:1; /* Flag: Accelerated blits with Colorkey */
Uint32 blit_hw_A:1; /* Flag: Accelerated blits with Alpha */
Uint32 blit_sw:1; /* Flag: Accelerated blits SW --> HW */
Uint32 blit_sw_CC:1; /* Flag: Accelerated blits with Colorkey */
Uint32 blit_sw_A:1; /* Flag: Accelerated blits with Alpha */
Uint32 blit_fill:1; /* Flag: Accelerated color fill */
Uint32 blit_hw:1; /**< Flag: Accelerated blits HW --> HW */
Uint32 blit_hw_CC:1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_hw_A:1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_sw:1; /**< Flag: Accelerated blits SW --> HW */
Uint32 blit_sw_CC:1; /**< Flag: Accelerated blits with Colorkey */
Uint32 blit_sw_A:1; /**< Flag: Accelerated blits with Alpha */
Uint32 blit_fill:1; /**< Flag: Accelerated color fill */
Uint32 UnusedBits3:16;
Uint32 video_mem; /* The total amount of video memory (in K) */

/* Here for backwards compatibility */
SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

/**
@@ -129,9 +129,68 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
return modes;
}

static int (*orig_eventfilter) (const SDL_Event * event);

static int
SDL_CompatEventFilter(const SDL_Event * event)
{
SDL_Event fake;

switch (event->type) {
case SDL_WINDOWEVENT:
switch (event->window.event) {
case SDL_WINDOWEVENT_RESIZED:
fake.type = SDL_VIDEORESIZE;
fake.resize.w = event->window.data1;
fake.resize.h = event->window.data2;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_MINIMIZED:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 0;
fake.active.state = SDL_APPACTIVE;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_RESTORED:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 1;
fake.active.state = SDL_APPACTIVE;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_ENTER:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 1;
fake.active.state = SDL_APPMOUSEFOCUS;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_LEAVE:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 0;
fake.active.state = SDL_APPMOUSEFOCUS;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 1;
fake.active.state = SDL_APPINPUTFOCUS;
SDL_PushEvent(&fake);
break;
case SDL_WINDOWEVENT_FOCUS_LOST:
fake.type = SDL_ACTIVEEVENT;
fake.active.gain = 1;
fake.active.state = SDL_APPINPUTFOCUS;
SDL_PushEvent(&fake);
break;
}
}
return orig_eventfilter(event);
}

SDL_Surface *
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
int (*filter) (const SDL_Event * event);
const SDL_DisplayMode *desktop_mode;
SDL_DisplayMode mode;
int i;
Uint32 window_flags;
@@ -147,6 +206,13 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
/* Destroy existing window */
SDL_DestroyWindow(window);

/* Set up the event filter */
filter = SDL_GetEventFilter();
if (filter != SDL_CompatEventFilter) {
orig_eventfilter = filter;
}
SDL_SetEventFilter(SDL_CompatEventFilter);

/* Create a new window */
window_flags = SDL_WINDOW_SHOWN;
if (flags & SDL_FULLSCREEN) {
@@ -167,12 +233,20 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
}

/* Set up the desired display mode */
desktop_format = SDL_GetDesktopDisplayMode()->format;
if ((bpp == SDL_BITSPERPIXEL(desktop_format)) ||
(desktop_format && (flags & SDL_ANYFORMAT))) {
desktop_mode = SDL_GetDesktopDisplayMode();
desktop_format = desktop_mode->format;
if (desktop_format && ((flags & SDL_ANYFORMAT)
|| (bpp == SDL_BITSPERPIXEL(desktop_format)))) {
desired_format = desktop_format;
} else {
switch (bpp) {
case 0:
if (desktop_format) {
desired_format = desktop_format;
} else {
desired_format = SDL_PixelFormat_RGB888;
}
break;
case 8:
desired_format = SDL_PixelFormat_Index8;
break;
@@ -204,7 +278,14 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
return NULL;
}
} else {
mode = *SDL_GetDesktopDisplayMode();
if (desktop_format) {
mode.format = desktop_format;
}
if (desktop_mode->w && desktop_mode->h) {
mode.w = desktop_mode->w;
mode.h = desktop_mode->h;
}
mode.refresh_rate = desktop_mode->refresh_rate;
}
if (SDL_SetDisplayMode(&mode) < 0) {
return NULL;
@@ -434,7 +434,7 @@ extern VideoBootStrap glSDL_bootstrap;

extern SDL_VideoDevice *SDL_GetVideoDevice();
extern void SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
extern void SDL_AddVideoDisplay(SDL_VideoDisplay * display);
extern void SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
extern void SDL_AddDisplayMode(int display, const SDL_DisplayMode * mode);
extern SDL_Window *SDL_GetWindowFromSurface(SDL_Surface * surface);

@@ -233,6 +233,7 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
_this->name = bootstrap[i]->name;
_this->next_window_id = 1;


/* Set some very sane GL defaults */
_this->gl_config.driver_loaded = 0;
_this->gl_config.dll_handle = NULL;
@@ -267,6 +268,16 @@ SDL_VideoInit(const char *driver_name, Uint32 flags)
return (-1);
}

/* Temporarily here for backwards compatibility */
{
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;

SDL_PixelFormatEnumToMasks(SDL_GetDesktopDisplayMode()->format, &bpp,
&Rmask, &Gmask, &Bmask, &Amask);
_this->info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
}

/* Sort the video modes */
for (i = 0; i < _this->num_displays; ++i) {
SDL_qsort(_this->displays[i].display_modes,
@@ -325,7 +336,7 @@ SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode)
}

void
SDL_AddVideoDisplay(SDL_VideoDisplay * display)
SDL_AddVideoDisplay(const SDL_VideoDisplay * display)
{
SDL_VideoDisplay *displays;

@@ -1034,6 +1045,14 @@ SDL_CreateWindowSurface(SDL_WindowID windowID, Uint32 format, Uint32 flags)
return NULL;
}
window->surface->flags |= SDL_SCREEN_SURFACE;

/* If we have a palettized surface, create a default palette */
if (window->surface->format->palette) {
SDL_Color colors[256];
SDL_PixelFormat *vf = window->surface->format;
SDL_DitherColors(colors, vf->BitsPerPixel);
SDL_SetColors(window->surface, colors, 0, vf->palette->ncolors);
}
}
surface = window->surface;

@@ -1059,6 +1078,7 @@ SDL_CreateWindowSurface(SDL_WindowID windowID, Uint32 format, Uint32 flags)
return NULL;
}
window->shadow->flags |= SDL_SHADOW_SURFACE;

surface = window->shadow;

/* 8-bit shadow surfaces report that they have exclusive palette */
@@ -1401,6 +1421,7 @@ SDL_VideoQuit(void)
if (_this->displays) {
SDL_free(_this->displays);
}
SDL_free(_this->info.vfmt);
_this->free(_this);
_this = NULL;
}
@@ -53,6 +53,8 @@ static int DUMMY_VideoInit(_THIS);
static int DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode);
static void DUMMY_CreateWindowSurface(_THIS, SDL_Window * window,
Uint32 flags);
static void DUMMY_UpdateWindowSurface(_THIS, SDL_Window * window,
int numrects, SDL_Rect * rects);
static void DUMMY_VideoQuit(_THIS);

/* DUMMY driver bootstrap functions */
@@ -100,6 +102,7 @@ DUMMY_CreateDevice(int devindex)
device->VideoInit = DUMMY_VideoInit;
device->SetDisplayMode = DUMMY_SetDisplayMode;
device->CreateWindowSurface = DUMMY_CreateWindowSurface;
device->UpdateWindowSurface = DUMMY_UpdateWindowSurface;
device->VideoQuit = DUMMY_VideoQuit;
device->InitOSKeymap = DUMMY_InitOSKeymap;
device->PumpEvents = DUMMY_PumpEvents;
@@ -132,6 +135,7 @@ DUMMY_VideoInit(_THIS)
static int
DUMMY_SetDisplayMode(_THIS, const SDL_DisplayMode * mode)
{
SDL_CurrentDisplay.current_mode = *mode;
return 0;
}

@@ -148,6 +152,19 @@ DUMMY_CreateWindowSurface(_THIS, SDL_Window * window, Uint32 flags)
Bmask, Amask);
}

static void
DUMMY_UpdateWindowSurface(_THIS, SDL_Window * window, int numrects,
SDL_Rect * rects)
{
static int frame_number;
if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
char file[128];
SDL_snprintf(file, sizeof(file), "SDL_screen-%8.8d.bmp",
++frame_number);
SDL_SaveBMP(window->surface, file);
}
}

/* Note: If we are terminated, this could be called in the middle of
another SDL video routine -- notably UpdateRects.
*/

0 comments on commit 611acc9

Please sign in to comment.