diff src/video/photon/SDL_photon.c @ 3500:4b594623401b

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.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Dec 2009 05:57:15 +0000
parents 0cbfec87e4f1
children 64ce267332c6
line wrap: on
line diff
--- a/src/video/photon/SDL_photon.c	Mon Nov 30 21:04:25 2009 +0000
+++ b/src/video/photon/SDL_photon.c	Tue Dec 01 05:57:15 2009 +0000
@@ -269,10 +269,6 @@
     device->VideoQuit = photon_videoquit;
     device->GetDisplayModes = photon_getdisplaymodes;
     device->SetDisplayMode = photon_setdisplaymode;
-    device->SetDisplayPalette = photon_setdisplaypalette;
-    device->GetDisplayPalette = photon_getdisplaypalette;
-    device->SetDisplayGammaRamp = photon_setdisplaygammaramp;
-    device->GetDisplayGammaRamp = photon_getdisplaygammaramp;
     device->CreateWindow = photon_createwindow;
     device->CreateWindowFrom = photon_createwindowfrom;
     device->SetWindowTitle = photon_setwindowtitle;
@@ -524,11 +520,10 @@
 }
 
 void
-photon_getdisplaymodes(_THIS)
+photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display)
 {
     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
+    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
     SDL_DisplayMode mode;
     PgVideoModes_t modes;
     PgVideoModeInfo_t modeinfo;
@@ -569,7 +564,7 @@
                 mode.refresh_rate = modeinfo.refresh_rates[jt];
                 mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
                 mode.driverdata = NULL;
-                SDL_AddDisplayMode(_this->current_display, &mode);
+                SDL_AddDisplayMode(display, &mode);
 
                 /* If mode is RGBA8888, add the same mode as RGBx888 */
                 if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
@@ -578,7 +573,7 @@
                     mode.refresh_rate = modeinfo.refresh_rates[jt];
                     mode.format = SDL_PIXELFORMAT_RGB888;
                     mode.driverdata = NULL;
-                    SDL_AddDisplayMode(_this->current_display, &mode);
+                    SDL_AddDisplayMode(display, &mode);
                 }
 
                 /* If mode is RGBA1555, add the same mode as RGBx555 */
@@ -588,7 +583,7 @@
                     mode.refresh_rate = modeinfo.refresh_rates[jt];
                     mode.format = SDL_PIXELFORMAT_RGB555;
                     mode.driverdata = NULL;
-                    SDL_AddDisplayMode(_this->current_display, &mode);
+                    SDL_AddDisplayMode(display, &mode);
                 }
 
                 jt++;
@@ -600,11 +595,10 @@
 }
 
 int
-photon_setdisplaymode(_THIS, SDL_DisplayMode * mode)
+photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
 {
     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
+    SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata;
     PgVideoModes_t modes;
     PgVideoModeInfo_t modeinfo;
     PgDisplaySettings_t modesettings;
@@ -651,15 +645,15 @@
         tempmode.refresh_rate = 0x0000FFFF;
 
         /* Check if window width and height matches one of our modes */
-        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
-            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
-                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
-                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
+        for (it = 0; it < display->num_display_modes; it++) {
+            if ((display->display_modes[it].w == mode->w) &&
+                (display->display_modes[it].h == mode->h) &&
+                (display->display_modes[it].format == mode->format))
             {
                 /* Find the lowest refresh rate available */
                 if (tempmode.refresh_rate >
-                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
-                    tempmode = SDL_CurrentDisplay.display_modes[it];
+                    display->display_modes[it].refresh_rate) {
+                    tempmode = display->display_modes[it];
                 }
             }
         }
@@ -680,21 +674,21 @@
         tempmode.refresh_rate = 0x0000FFFF;
 
         /* Check if window width and height matches one of our modes */
-        for (it = 0; it < SDL_CurrentDisplay.num_display_modes; it++) {
-            if ((SDL_CurrentDisplay.display_modes[it].w == mode->w) &&
-                (SDL_CurrentDisplay.display_modes[it].h == mode->h) &&
-                (SDL_CurrentDisplay.display_modes[it].format == mode->format))
+        for (it = 0; it < display->num_display_modes; it++) {
+            if ((display->display_modes[it].w == mode->w) &&
+                (display->display_modes[it].h == mode->h) &&
+                (display->display_modes[it].format == mode->format))
             {
                 /* Find the lowest refresh rate available */
                 if (tempmode.refresh_rate >
-                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
-                    tempmode = SDL_CurrentDisplay.display_modes[it];
+                    display->display_modes[it].refresh_rate) {
+                    tempmode = display->display_modes[it];
                 }
 
                 /* Check if requested refresh rate found */
                 if (refresh_rate ==
-                    SDL_CurrentDisplay.display_modes[it].refresh_rate) {
-                    tempmode = SDL_CurrentDisplay.display_modes[it];
+                    display->display_modes[it].refresh_rate) {
+                    tempmode = display->display_modes[it];
                     break;
                 }
             }
@@ -779,48 +773,11 @@
 }
 
 int
-photon_setdisplaypalette(_THIS, SDL_Palette * palette)
-{
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
-
-    /* Setting display palette operation has been failed */
-    return -1;
-}
-
-int
-photon_getdisplaypalette(_THIS, SDL_Palette * palette)
-{
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
-
-    /* Getting display palette operation has been failed */
-    return -1;
-}
-
-int
-photon_setdisplaygammaramp(_THIS, Uint16 * ramp)
-{
-    SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
-
-    /* Setting display gamma ramp operation has been failed */
-    return -1;
-}
-
-int
-photon_getdisplaygammaramp(_THIS, Uint16 * ramp)
-{
-    /* Getting display gamma ramp operation has been failed */
-    return -1;
-}
-
-int
 photon_createwindow(_THIS, SDL_Window * window)
 {
     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
     SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
+        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
     SDL_WindowData *wdata;
     PhDim_t winsize;
     PhPoint_t winpos;
@@ -1098,7 +1055,7 @@
 {
     SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
     SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
+        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
     PhPoint_t winpos;
     int32_t status;
 
@@ -1266,7 +1223,7 @@
 {
     SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata;
     SDL_DisplayData *didata =
-        (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
+        (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata;
     SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata;
     int32_t status;
 
@@ -1457,7 +1414,7 @@
     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;
@@ -1984,7 +1941,7 @@
     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;
     PhRect_t dst_rect;
     PhRect_t src_rect;
     int32_t status;
@@ -2093,7 +2050,7 @@
     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;
     SDL_bool makecurrent=SDL_FALSE;
     int32_t gfstatus;
 
@@ -2194,7 +2151,6 @@
     PhEvent_t *event = (PhEvent_t *) eventbuffer;
     int32_t status;
     uint32_t finish = 0;
-    uint32_t it;
     SDL_Window *window;
     SDL_WindowData *wdata;
 
@@ -2211,23 +2167,22 @@
             {
                 /* Find a window, to which this handle destinated */
                 status = 0;
-                for (it = 0; it < SDL_CurrentDisplay.num_windows; it++) {
-                    wdata =
-                        (SDL_WindowData *) SDL_CurrentDisplay.windows[it].
-                        driverdata;
+                for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) {
+                    SDL_VideoDisplay *display = SDL_GetVideoDisplay(i);
+                    for (j = 0; j < display->num_windows; ++j) {
+                        wdata = (SDL_WindowData *) display->windows[j].driverdata;
 
-                    /* Find the proper window */
-                    if (wdata->window != NULL) {
-                        if (PtWidgetRid(wdata->window) ==
-                            event->collector.rid) {
-                            window =
-                                (SDL_Window *) & SDL_CurrentDisplay.
-                                windows[it];
-                            status = 1;
-                            break;
+                        /* Find the proper window */
+                        if (wdata->window != NULL) {
+                            if (PtWidgetRid(wdata->window) ==
+                                event->collector.rid) {
+                                window = (SDL_Window *) &display->windows[it];
+                                status = 1;
+                                break;
+                            }
+                        } else {
+                            continue;
                         }
-                    } else {
-                        continue;
                     }
                 }
                 if (status == 0) {