Commit 1cd715e9 authored by Sam Lantinga's avatar Sam Lantinga

Work in progress on multi-display support:

* Added display parameter to many internal functions so video modes can be set on displays that aren't the public current one.
* The fullscreen mode is associated with fullscreen windows - not displays, so different windows more naturally have a mode associated with them based on their width and height.  It's no longer necessary to specify a fullscreen mode, a default one will be picked automatically for fullscreen windows.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404241
parent 3e860cdc
......@@ -50,7 +50,8 @@ extern "C" {
* \sa SDL_GetDesktopDisplayMode()
* \sa SDL_GetCurrentDisplayMode()
* \sa SDL_GetClosestDisplayMode()
* \sa SDL_SetDisplayMode()
* \sa SDL_SetWindowDisplayMode()
* \sa SDL_GetWindowDisplayMode()
*/
typedef struct
{
......@@ -427,23 +428,25 @@ extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const
/**
* \brief Set the display mode used when a fullscreen window is visible
* on the currently selected display.
* on the currently selected display. By default the window's
* dimensions and the desktop format and refresh rate are used.
*
* \param mode The mode to use, or NULL for the desktop mode.
* \param mode The mode to use, or NULL for the default mode.
*
* \return 0 on success, or -1 if setting the display mode failed.
*
* \sa SDL_SetWindowFullscreen()
*/
extern DECLSPEC int SDLCALL SDL_SetFullscreenDisplayMode(const SDL_DisplayMode
extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_WindowID windowID,
const SDL_DisplayMode
* mode);
/**
* \brief Fill in information about the display mode used when a fullscreen
* window is visible on the currently selected display.
*/
extern DECLSPEC int SDLCALL SDL_GetFullscreenDisplayMode(SDL_DisplayMode *
mode);
extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_WindowID windowID,
SDL_DisplayMode * mode);
/**
* \brief Set the palette entries for indexed display modes.
......@@ -680,7 +683,7 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_WindowID windowID);
*
* \return 0 on success, or -1 if setting the display mode failed.
*
* \sa SDL_SetFullscreenDisplayMode()
* \sa SDL_WindowDisplayMode()
*/
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_WindowID windowID,
int fullscreen);
......
......@@ -482,7 +482,6 @@ SDL_Surface *
SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
{
SDL_DisplayMode desktop_mode;
SDL_DisplayMode mode;
int window_x = SDL_WINDOWPOS_UNDEFINED;
int window_y = SDL_WINDOWPOS_UNDEFINED;
Uint32 window_flags;
......@@ -552,7 +551,6 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
window_flags |= SDL_WINDOW_BORDERLESS;
}
GetEnvironmentWindowPosition(width, height, &window_x, &window_y);
SDL_SetFullscreenDisplayMode(NULL);
SDL_VideoWindow =
SDL_CreateWindow(wm_title, window_x, window_y, width, height,
window_flags);
......@@ -611,14 +609,14 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
return NULL;
}
}
mode.format = desired_format;
mode.w = width;
mode.h = height;
mode.refresh_rate = 0;
/* Set the desired display mode */
/* Set up the desired display mode */
if (flags & SDL_FULLSCREEN) {
if (SDL_SetFullscreenDisplayMode(&mode) < 0) {
SDL_DisplayMode mode;
SDL_zero(mode);
mode.format = desired_format;
if (SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode) < 0) {
return NULL;
}
}
......
......@@ -113,30 +113,39 @@ SDL_GetGamma(float *red, float *green, float *blue)
return succeeded;
}
static void
SDL_UninitializedVideo()
{
SDL_SetError("Video subsystem has not been initialized");
}
int
SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
const Uint16 * blue)
SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
int succeeded;
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
/* Lazily allocate the gamma tables */
if (!SDL_CurrentDisplay.gamma) {
SDL_GetGammaRamp(NULL, NULL, NULL);
if (!display->gamma) {
if (SDL_GetGammaRampForDisplay(display, NULL, NULL, NULL) < 0) {
return -1;
}
}
/* Fill the gamma table with the new values */
if (red) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[0 * 256], red,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[0 * 256], red, 256 * sizeof(*display->gamma));
}
if (green) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[1 * 256], green,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[1 * 256], green, 256 * sizeof(*display->gamma));
}
if (blue) {
SDL_memcpy(&SDL_CurrentDisplay.gamma[2 * 256], blue,
256 * sizeof(*SDL_CurrentDisplay.gamma));
SDL_memcpy(&display->gamma[2 * 256], blue, 256 * sizeof(*display->gamma));
}
/* Try to set the gamma ramp in the driver */
......@@ -144,7 +153,7 @@ SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
if (_this && _this->SetDisplayGammaRamp) {
if (SDL_GetFocusWindow()) {
succeeded =
_this->SetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
_this->SetDisplayGammaRamp(_this, display, display->gamma);
} else {
succeeded = 0;
}
......@@ -155,50 +164,73 @@ SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green,
}
int
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
return SDL_SetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
}
int
SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
/* Lazily allocate the gamma table */
if (!SDL_CurrentDisplay.gamma) {
size_t rampsize = (3 * 256 * sizeof(*SDL_CurrentDisplay.gamma));
if (!display->gamma) {
size_t rampsize = (3 * 256 * sizeof(*display->gamma));
SDL_CurrentDisplay.gamma = SDL_malloc(rampsize * 2);
if (!SDL_CurrentDisplay.gamma) {
display->gamma = SDL_malloc(rampsize * 2);
if (!display->gamma) {
SDL_OutOfMemory();
return -1;
}
if (_this && _this->GetDisplayGammaRamp) {
/* Get the real hardware gamma */
_this->GetDisplayGammaRamp(_this, SDL_CurrentDisplay.gamma);
_this->GetDisplayGammaRamp(_this, display, display->gamma);
} else {
/* Assume an identity gamma */
int i;
for (i = 0; i < 256; ++i) {
SDL_CurrentDisplay.gamma[0 * 256 + i] = (i << 8) | i;
SDL_CurrentDisplay.gamma[1 * 256 + i] = (i << 8) | i;
SDL_CurrentDisplay.gamma[2 * 256 + i] = (i << 8) | i;
display->gamma[0 * 256 + i] = (i << 8) | i;
display->gamma[1 * 256 + i] = (i << 8) | i;
display->gamma[2 * 256 + i] = (i << 8) | i;
}
}
SDL_CurrentDisplay.saved_gamma = SDL_CurrentDisplay.gamma + (3 * 256);
SDL_memcpy(SDL_CurrentDisplay.saved_gamma, SDL_CurrentDisplay.gamma,
rampsize);
display->saved_gamma = display->gamma + (3 * 256);
SDL_memcpy(display->saved_gamma, display->gamma, rampsize);
}
/* Just copy from our internal table */
if (red) {
SDL_memcpy(red, &SDL_CurrentDisplay.gamma[0 * 256],
256 * sizeof(*red));
SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red));
}
if (green) {
SDL_memcpy(green, &SDL_CurrentDisplay.gamma[1 * 256],
256 * sizeof(*green));
SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green));
}
if (blue) {
SDL_memcpy(blue, &SDL_CurrentDisplay.gamma[2 * 256],
256 * sizeof(*blue));
SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue));
}
return 0;
}
int
SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue)
{
SDL_VideoDevice *_this = SDL_GetVideoDevice();
if (!_this) {
SDL_UninitializedVideo();
return -1;
}
return SDL_GetGammaRampForDisplay(&SDL_CurrentDisplay, red, green, blue);
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -139,6 +139,8 @@ struct SDL_Window
int display;
SDL_Renderer *renderer;
SDL_DisplayMode fullscreen_mode;
void *userdata;
void *driverdata;
};
......@@ -158,7 +160,6 @@ struct SDL_VideoDisplay
SDL_DisplayMode *display_modes;
SDL_DisplayMode desktop_mode;
SDL_DisplayMode current_mode;
SDL_DisplayMode fullscreen_mode;
SDL_Palette *palette;
Uint16 *gamma;
......@@ -213,7 +214,7 @@ struct SDL_VideoDevice
* Get a list of the available display modes. e.g.
* SDL_AddDisplayMode(_this->current_display, mode)
*/
void (*GetDisplayModes) (_THIS);
void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display);
/*
* Setting the display mode is independent of creating windows, so
......@@ -221,19 +222,19 @@ struct SDL_VideoDevice
* their data updated accordingly, including the display surfaces
* associated with them.
*/
int (*SetDisplayMode) (_THIS, SDL_DisplayMode * mode);
int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
/* Set the color entries of the display palette */
int (*SetDisplayPalette) (_THIS, SDL_Palette * palette);
int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
/* Get the color entries of the display palette */
int (*GetDisplayPalette) (_THIS, SDL_Palette * palette);
int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette);
/* Set the gamma ramp */
int (*SetDisplayGammaRamp) (_THIS, Uint16 * ramp);
int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
/* Get the gamma ramp */
int (*GetDisplayGammaRamp) (_THIS, Uint16 * ramp);
int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
/* * * */
/*
......@@ -405,10 +406,19 @@ extern VideoBootStrap PND_bootstrap;
extern SDL_VideoDevice *SDL_GetVideoDevice();
extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode);
extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display);
extern SDL_bool
SDL_AddDisplayMode(int displayIndex, const SDL_DisplayMode * mode);
extern void
SDL_AddRenderDriver(int displayIndex, const SDL_RenderDriver * driver);
extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode);
extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display);
extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode);
extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest);
extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode);
extern int SDL_SetDisplayPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors);
extern int SDL_GetDisplayPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors);
extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver);
extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue);
extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue);
extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags);
extern SDL_Window *SDL_GetWindowFromID(SDL_WindowID windowID);
......
This diff is collapsed.
......@@ -35,8 +35,8 @@ typedef struct
} SDL_DisplayModeData;
extern void Cocoa_InitModes(_THIS);
extern void Cocoa_GetDisplayModes(_THIS);
extern int Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void Cocoa_QuitModes(_THIS);
#endif /* _SDL_cocoamodes_h */
......
......@@ -190,18 +190,18 @@ Cocoa_InitModes(_THIS)
static void
AddDisplayMode(const void *moderef, void *context)
{
SDL_VideoDevice *_this = (SDL_VideoDevice *) context;
SDL_VideoDisplay *display = (SDL_VideoDisplay *) context;
SDL_DisplayMode mode;
if (GetDisplayMode(moderef, &mode)) {
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(display, &mode);
}
}
void
Cocoa_GetDisplayModes(_THIS)
Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
CFArrayRef modes;
CFRange range;
......@@ -211,13 +211,13 @@ Cocoa_GetDisplayModes(_THIS)
}
range.location = 0;
range.length = CFArrayGetCount(modes);
CFArrayApplyFunction(modes, range, AddDisplayMode, _this);
CFArrayApplyFunction(modes, range, AddDisplayMode, display);
}
int
Cocoa_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
CGError result;
......@@ -279,21 +279,17 @@ ERR_NO_CAPTURE:
void
Cocoa_QuitModes(_THIS)
{
int i, saved_display;
int i;
saved_display = _this->current_display;
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
if (display->current_mode.driverdata != display->desktop_mode.driverdata) {
_this->current_display = i;
Cocoa_SetDisplayMode(_this, &display->desktop_mode);
Cocoa_SetDisplayMode(_this, display, &display->desktop_mode);
}
}
CGReleaseAllDisplays();
ShowMenuBar();
_this->current_display = saved_display;
}
/* vi: set ts=4 sw=4 expandtab: */
......@@ -197,7 +197,7 @@ cbLayers(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc,
}
static void
CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, SDL_DisplayMode * mode)
{
SDL_DFB_DEVICEDATA(_this);
DFBDisplayLayerConfig config;
......@@ -219,7 +219,7 @@ CheckSetDisplayMode(_THIS, DFB_DisplayData * data, SDL_DisplayMode * mode)
SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer,
DLSCL_SHARED));
if (failed == 0)
SDL_AddDisplayMode(_this->current_display, mode);
SDL_AddDisplayMode(display, mode);
else
SDL_DFB_DEBUG("Mode %d x %d not available: %x\n", mode->w,
mode->h, failed);
......@@ -356,11 +356,10 @@ DirectFB_InitModes(_THIS)
}
void
DirectFB_GetDisplayModes(_THIS)
DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DFB_DEVICEDATA(_this);
DFB_DisplayData *dispdata =
(DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
SDL_DisplayMode mode;
struct modes_callback_t data;
int i;
......@@ -376,25 +375,23 @@ DirectFB_GetDisplayModes(_THIS)
mode = data.modelist[i];
mode.format = SDL_PIXELFORMAT_ARGB8888;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB888;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB24;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_RGB565;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
mode.format = SDL_PIXELFORMAT_INDEX8;
CheckSetDisplayMode(_this, dispdata, &mode);
CheckSetDisplayMode(_this, display, dispdata, &mode);
}
SDL_DFB_FREE(data.modelist);
return;
error:
SDL_DFB_FREE(data.modelist);
return;
}
int
DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
/*
* FIXME: video mode switch is currently broken for 1.2.0
......@@ -402,7 +399,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
*/
SDL_DFB_DEVICEDATA(_this);
DFB_DisplayData *data = (DFB_DisplayData *) SDL_CurrentDisplay.driverdata;
DFB_DisplayData *data = (DFB_DisplayData *) display->driverdata;
DFBDisplayLayerConfig config, rconfig;
DFBDisplayLayerConfigFlags fail = 0;
DFBResult ret;
......@@ -459,7 +456,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
data->pixelformat = rconfig.pixelformat;
data->cw = config.width;
data->ch = config.height;
SDL_CurrentDisplay.current_mode = *mode;
display->current_mode = *mode;
return 0;
error:
......@@ -474,18 +471,16 @@ DirectFB_QuitModes(_THIS)
DFBResult ret;
int i;
SDL_SelectVideoDisplay(0);
SDL_GetDesktopDisplayMode(&tmode);
tmode.format = SDL_PIXELFORMAT_UNKNOWN;
DirectFB_SetDisplayMode(_this, &tmode);
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata;
SDL_GetDesktopDisplayMode(&tmode);
DirectFB_SetDisplayMode(_this, &tmode);
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
tmode.format = SDL_PIXELFORMAT_UNKNOWN;
DirectFB_SetDisplayMode(_this, display, &tmode);
for (i = 0; i < SDL_GetNumVideoDisplays(); i++) {
DFB_DisplayData *dispdata =
(DFB_DisplayData *) _this->displays[i].driverdata;
SDL_GetDesktopDisplayModeForDisplay(display, &tmode);
DirectFB_SetDisplayMode(_this, display, &tmode);
if (dispdata->layer) {
SDL_DFB_CHECK(dispdata->
......
......@@ -48,8 +48,8 @@ struct _DFB_DisplayData
extern void DirectFB_InitModes(_THIS);
extern void DirectFB_GetDisplayModes(_THIS);
extern int DirectFB_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void DirectFB_QuitModes(_THIS);
#endif /* _SDL_directfb_modes_h */
......
......@@ -234,7 +234,7 @@ DirectFB_AddRenderDriver(_THIS)
{
int i;
for (i = 0; i < _this->num_displays; i++)
SDL_AddRenderDriver(i, &DirectFB_RenderDriver);
SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver);
}
static int
......@@ -264,6 +264,8 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette)
SDL_DFB_CHECKERR(surfpal->SetEntries(surfpal, entries, ncolors, 0));
return 0;
error:
#else
SDL_Unsupported();
#endif
return -1;
}
......
......@@ -56,11 +56,6 @@ static void DirectFB_VideoQuit(_THIS);
static int DirectFB_Available(void);
static SDL_VideoDevice *DirectFB_CreateDevice(int devindex);
#if 0
static int DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
static int DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
#endif
VideoBootStrap DirectFB_bootstrap = {
"directfb", "DirectFB",
DirectFB_Available, DirectFB_CreateDevice
......@@ -103,13 +98,6 @@ DirectFB_CreateDevice(int devindex)
device->VideoQuit = DirectFB_VideoQuit;
device->GetDisplayModes = DirectFB_GetDisplayModes;
device->SetDisplayMode = DirectFB_SetDisplayMode;
#if 0
device->SetDisplayGammaRamp = DirectFB_SetDisplayGammaRamp;
device->GetDisplayGammaRamp = DirectFB_GetDisplayGammaRamp;
#else
device->SetDisplayGammaRamp = NULL;
device->GetDisplayGammaRamp = NULL;
#endif
device->PumpEvents = DirectFB_PumpEventsWindow;
device->CreateWindow = DirectFB_CreateWindow;
device->CreateWindowFrom = DirectFB_CreateWindowFrom;
......@@ -300,17 +288,3 @@ DirectFB_VideoQuit(_THIS)
devdata->initialized = 0;
}
#if 0
static int
DirectFB_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
return -1;
}
static int
DirectFB_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
{
return -1;
}
#endif
......@@ -108,10 +108,6 @@ PND_create()
device->VideoQuit = PND_videoquit;
device->GetDisplayModes = PND_getdisplaymodes;
device->SetDisplayMode = PND_setdisplaymode;
device->SetDisplayPalette = PND_setdisplaypalette;
device->GetDisplayPalette = PND_getdisplaypalette;
device->SetDisplayGammaRamp = PND_setdisplaygammaramp;
device->GetDisplayGammaRamp = PND_getdisplaygammaramp;
device->CreateWindow = PND_createwindow;
device->CreateWindowFrom = PND_createwindowfrom;
device->SetWindowTitle = PND_setwindowtitle;
......@@ -191,54 +187,17 @@ PND_videoquit(_THIS)
}
void
PND_getdisplaymodes(_THIS)
PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
{
}
int
PND_setdisplaymode(_THIS, SDL_DisplayMode * mode)
PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
return 0;
}
int
PND_setdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display palette operation has been failed */
return -1;
}
int
PND_getdisplaypalette(_THIS, SDL_Palette * palette)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Getting display palette operation has been failed */
return -1;
}
int
PND_setdisplaygammaramp(_THIS, Uint16 * ramp)
{
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
/* Setting display gamma ramp operation has been failed */
return -1;
}
int
PND_getdisplaygammaramp(_THIS, Uint16 * ramp)
{
/* Getting display gamma ramp operation has been failed */
return -1;
}
int
PND_createwindow(_THIS, SDL_Window * window)
{
......@@ -458,7 +417,7 @@ PND_gl_createcontext(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
EGLBoolean status;
int32_t gfstatus;
EGLint configs;
......@@ -857,7 +816,7 @@ PND_gl_swapwindow(_THIS, SDL_Window * window)
SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
SDL_DisplayData *didata =
(SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
if (phdata->egl_initialized != SDL_TRUE) {
......
This diff is collapsed.
......@@ -53,6 +53,8 @@ photon_addinputdevices(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_VideoDisplay *display = &_this->displays[it];
/* Clear SDL mouse structure */
SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse));
......@@ -74,7 +76,7 @@ photon_addinputdevices(_THIS)
photon_mouse.FreeMouse = photon_freemouse;
/* Get display data */
didata = (SDL_DisplayData *) _this->displays[it].driverdata;
didata = (SDL_DisplayData *) display->driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata = didata;
......
......@@ -276,7 +276,7 @@ photon_addrenderdriver(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &photon_renderdriver);
SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver);
}
}
......
......@@ -84,7 +84,8 @@ static PS3_DisplayModeData ps3fb_data[] = {
};
void
PS3_GetDisplayModes(_THIS) {
PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
deprintf(1, "+PS3_GetDisplayModes()\n");
SDL_DisplayMode mode;
unsigned int nummodes;
......@@ -98,13 +99,13 @@ PS3_GetDisplayModes(_THIS) {
/* Add DisplayMode to list */
deprintf(2, "Adding resolution %u x %u\n", ps3fb_modedb[n].w, ps3fb_modedb[n].h);
SDL_AddDisplayMode(_this->current_display, &ps3fb_modedb[n]);
SDL_AddDisplayMode(display, &ps3fb_modedb[n]);
}
deprintf(1, "-PS3_GetDisplayModes()\n");
}
int
PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
deprintf(1, "+PS3_SetDisplayMode()\n");
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
......@@ -123,13 +124,14 @@ PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
}
void
PS3_QuitModes(_THIS) {
PS3_QuitModes(_THIS)
{
deprintf(1, "+PS3_QuitModes()\n");
/* There was no mem allocated for driverdata */
int i, j;
for (i = _this->num_displays; i--;) {
SDL_VideoDisplay *display = &_this->displays[i];
for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
for (j = display->num_display_modes; j--;) {
display->display_modes[j].driverdata = NULL;
}
......
......@@ -25,8 +25,8 @@
#define _SDL_ps3modes_h
extern void PS3_InitModes(_THIS);
extern void PS3_GetDisplayModes(_THIS);
extern int PS3_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void PS3_QuitModes(_THIS);
#endif /* SDL_ps3modes_h */
......
......@@ -60,6 +60,8 @@ gf_addinputdevices(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_VideoDisplay *display = &_this->displays[it];
/* Clear SDL mouse structure */
SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse));
......@@ -81,7 +83,7 @@ gf_addinputdevices(_THIS)
gf_mouse.FreeMouse = gf_freemouse;
/* Get display data */
didata = (SDL_DisplayData *) _this->displays[it].driverdata;
didata = (SDL_DisplayData *) display->driverdata;
/* Store SDL_DisplayData pointer in the mouse driver internals */
mdata->didata = didata;
......
......@@ -261,7 +261,7 @@ gf_addrenderdriver(_THIS)
uint32_t it;
for (it = 0; it < _this->num_displays; it++) {
SDL_AddRenderDriver(it, &gf_renderdriver);
SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver);
}
}
......
This diff is collapsed.
......@@ -25,12 +25,12 @@
int
WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
......@@ -47,12 +47,12 @@ WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
}
int
WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
#ifdef _WIN32_WCE
return -1;
#else
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
HDC hdc;
BOOL succeeded = FALSE;
......
......@@ -24,8 +24,8 @@
#ifndef _SDL_win32gamma_h
#define _SDL_win32gamma_h
extern int WIN_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int WIN_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
extern int WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
#endif /* _SDL_win32gamma_h */
......
......@@ -41,7 +41,6 @@ WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
if (!data) {
return SDL_FALSE;
}
SDL_memcpy(data->DeviceName, deviceName, sizeof(data->DeviceName));
data->DeviceMode = devmode;
data->DeviceMode.dmFields =
(DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY |
......@@ -196,9 +195,9 @@ WIN_InitModes(_THIS)
}
void
WIN_GetDisplayModes(_THIS)
WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
{
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
DWORD i;
SDL_DisplayMode mode;
......@@ -207,15 +206,16 @@ WIN_GetDisplayModes(_THIS)
break;
}
if (mode.format != SDL_PIXELFORMAT_UNKNOWN)
if (!SDL_AddDisplayMode(_this->current_display, &mode)) {
if (!SDL_AddDisplayMode(display, &mode)) {
SDL_free(mode.driverdata);
}
}
}
int
WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
{
SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
LONG status;
......@@ -228,8 +228,8 @@ WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
#endif
status =
ChangeDisplaySettingsEx(data->DeviceName, &data->DeviceMode, NULL,
CDS_FULLSCREEN, NULL);
ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode,
NULL, CDS_FULLSCREEN, NULL);
if (status == DISP_CHANGE_SUCCESSFUL) {
return 0;
} else {
......
......@@ -31,13 +31,12 @@ typedef struct
typedef struct
{
TCHAR DeviceName[32];
DEVMODE DeviceMode;
} SDL_DisplayModeData;
extern void WIN_InitModes(_THIS);
extern void WIN_GetDisplayModes(_THIS);
extern int WIN_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void WIN_QuitModes(_THIS);
#endif /* _SDL_win32modes_h */
......
......@@ -124,7 +124,7 @@ X11_TrackColormap(Display * display, int scrNum, Colormap colormap,
cool. If not, then we just fail */
int
X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp)
{
Visual *visual;
Display *display;
......@@ -214,7 +214,7 @@ X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp)
}
int
X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp)
X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp)
{
int i;
......
......@@ -30,7 +30,7 @@ extern void X11_TrackColormap(Display * display, int scrNum,
Colormap colormap,
Visual * visual, XColor * ramp);
extern int X11_SetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int X11_GetDisplayGammaRamp(_THIS, Uint16 * ramp);
extern int X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
extern int X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp);
#endif
......@@ -311,10 +311,10 @@ restore_mode(Display * display, SDL_DisplayData * data)
#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
void
X11_GetDisplayModes(_THIS)
X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
{
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
#if SDL_VIDEO_DRIVER_X11_XINERAMA
int xinerama_major, xinerama_minor;
int screens;
......@@ -341,7 +341,7 @@ X11_GetDisplayModes(_THIS)
* we have to use the same format for all windows and all display modes.
* (or support recreating the window with a new visual behind the scenes)
*/
mode.format = SDL_CurrentDisplay.current_mode.format;
mode.format = sdl_display->current_mode.format;
mode.driverdata = NULL;
data->use_xinerama = 0;
......@@ -382,14 +382,14 @@ X11_GetDisplayModes(_THIS)
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
/* Add the head xinerama mode */
mode.w = data->xinerama_info.width;
mode.h = data->xinerama_info.height;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
}
#endif /* SDL_VIDEO_DRIVER_X11_XINERAMA */
......@@ -426,7 +426,7 @@ X11_GetDisplayModes(_THIS)
"XRANDR: mode = %4d[%d], w = %4d, h = %4d, rate = %4d\n",
i, j, mode.w, mode.h, mode.refresh_rate);
#endif
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
}
......@@ -462,7 +462,7 @@ X11_GetDisplayModes(_THIS)
mode.w = modes[i]->hdisplay;
mode.h = modes[i]->vdisplay;
mode.refresh_rate = calculate_rate(modes[i]);
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
XFree(modes);
......@@ -475,7 +475,7 @@ X11_GetDisplayModes(_THIS)
mode.w = screen_w;
mode.h = screen_h;
mode.refresh_rate = 0;
SDL_AddDisplayMode(_this->current_display, &mode);
SDL_AddDisplayMode(sdl_display, &mode);
}
#ifdef X11MODES_DEBUG
if (data->use_xinerama) {
......@@ -672,10 +672,10 @@ set_best_resolution(Display * display, SDL_DisplayData * data, int w, int h,
}
int
X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
X11_SetDisplayMode(_THIS, SDL_VideoDisplay * sdl_display, SDL_DisplayMode * mode)
{
Display *display = ((SDL_VideoData *) _this->driverdata)->display;
SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
SDL_DisplayData *data = (SDL_DisplayData *) sdl_display->driverdata;
set_best_resolution(display, data, mode->w, mode->h, mode->refresh_rate);
return 0;
......
......@@ -55,8 +55,8 @@ typedef struct
} SDL_DisplayData;
extern void X11_InitModes(_THIS);
extern void X11_GetDisplayModes(_THIS);
extern int X11_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void X11_QuitModes(_THIS);
#endif /* _SDL_x11modes_h */
......
......@@ -76,7 +76,7 @@ CommonCreateState(char **argv, Uint32 flags)
state->argv = argv;
state->flags = flags;
state->window_title = argv[0];
state->window_flags = SDL_WINDOW_SHOWN;
state->window_flags = 0;
state->window_x = SDL_WINDOWPOS_UNDEFINED;
state->window_y = SDL_WINDOWPOS_UNDEFINED;
state->window_w = DEFAULT_WINDOW_WIDTH;
......@@ -737,6 +737,7 @@ CommonInit(CommonState * state)
}
}
SDL_zero(fullscreen_mode);
switch (state->depth) {
case 8:
fullscreen_mode.format = SDL_PIXELFORMAT_INDEX8;
......@@ -754,14 +755,7 @@ CommonInit(CommonState * state)
fullscreen_mode.format = SDL_PIXELFORMAT_RGB888;
break;
}
fullscreen_mode.w = state->window_w;
fullscreen_mode.h = state->window_h;
fullscreen_mode.refresh_rate = state->refresh_rate;
if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
}
state->windows =
(SDL_WindowID *) SDL_malloc(state->num_windows *
......@@ -789,6 +783,13 @@ CommonInit(CommonState * state)
return SDL_FALSE;
}
if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
}
SDL_ShowWindow(state->windows[i]);
if (!state->skip_renderer
&& (state->renderdriver
|| !(state->window_flags & SDL_WINDOW_OPENGL))) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment