From 823bf721309a533059aa2d8067dfb1de63f8c0a3 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Sat, 22 Mar 2014 21:08:05 -0400 Subject: [PATCH] WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice --- src/core/winrt/SDL_winrtapp_direct3d.cpp | 20 +++++++++++--------- src/video/winrt/SDL_winrtvideo.cpp | 6 ------ src/video/winrt/SDL_winrtvideo_cpp.h | 3 --- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 2fd20a89d..02c1890cc 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -173,6 +173,8 @@ static void WINRT_SetDisplayOrientationsPreference(void *userdata, const char *n static void WINRT_ProcessWindowSizeChange() { + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + // Make the new window size be the one true fullscreen mode. // This change was initially done, in part, to allow the Direct3D 11.1 // renderer to receive window-resize events as a device rotates. @@ -192,31 +194,31 @@ WINRT_ProcessWindowSizeChange() // Make note of the old display mode, and it's old driverdata. SDL_DisplayMode oldDisplayMode; SDL_zero(oldDisplayMode); - if (WINRT_GlobalSDLVideoDevice) { - oldDisplayMode = WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode; + if (_this) { + oldDisplayMode = _this->displays[0].desktop_mode; } // Setup the new display mode in the appropriate spots. - if (WINRT_GlobalSDLVideoDevice) { + if (_this) { // Make a full copy of the display mode for display_modes[0], // one with with a separately malloced 'driverdata' field. // SDL_VideoQuit(), if called, will attempt to free the driverdata // fields in 'desktop_mode' and each entry in the 'display_modes' // array. - if (WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata) { + if (_this->displays[0].display_modes[0].driverdata) { // Free the previous mode's memory - SDL_free(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata); - WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0].driverdata = NULL; + SDL_free(_this->displays[0].display_modes[0].driverdata); + _this->displays[0].display_modes[0].driverdata = NULL; } - if (WINRT_DuplicateDisplayMode(&(WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0]), &newDisplayMode) != 0) { + if (WINRT_DuplicateDisplayMode(&(_this->displays[0].display_modes[0]), &newDisplayMode) != 0) { // Uh oh, something went wrong. A malloc call probably failed. SDL_free(newDisplayMode.driverdata); return; } // Install 'newDisplayMode' into 'current_mode' and 'desktop_mode'. - WINRT_GlobalSDLVideoDevice->displays[0].current_mode = newDisplayMode; - WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = newDisplayMode; + _this->displays[0].current_mode = newDisplayMode; + _this->displays[0].desktop_mode = newDisplayMode; } if (WINRT_GlobalSDLWindow) { diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index f54e9855b..f8ebee0f9 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -70,7 +70,6 @@ static SDL_bool WINRT_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo /* SDL-internal globals: */ SDL_Window * WINRT_GlobalSDLWindow = NULL; -SDL_VideoDevice * WINRT_GlobalSDLVideoDevice = NULL; /* WinRT driver bootstrap functions */ @@ -84,10 +83,6 @@ WINRT_Available(void) static void WINRT_DeleteDevice(SDL_VideoDevice * device) { - if (device == WINRT_GlobalSDLVideoDevice) { - WINRT_GlobalSDLVideoDevice = NULL; - } - if (device->driverdata) { SDL_VideoData * video_data = (SDL_VideoData *)device->driverdata; if (video_data->winrtEglWindow) { @@ -143,7 +138,6 @@ WINRT_CreateDevice(int devindex) device->GL_DeleteContext = WINRT_GLES_DeleteContext; #endif device->free = WINRT_DeleteDevice; - WINRT_GlobalSDLVideoDevice = device; return device; } diff --git a/src/video/winrt/SDL_winrtvideo_cpp.h b/src/video/winrt/SDL_winrtvideo_cpp.h index 119f5b8f2..a90f0437f 100644 --- a/src/video/winrt/SDL_winrtvideo_cpp.h +++ b/src/video/winrt/SDL_winrtvideo_cpp.h @@ -48,9 +48,6 @@ typedef struct SDL_VideoData { */ extern SDL_Window * WINRT_GlobalSDLWindow; -/* The global, WinRT, video device. */ -extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice; - /* Creates a display mode for Plain Direct3D (non-XAML) apps, using the lone, native window's settings. Pass in an allocated SDL_DisplayMode field to store the data in.