Skip to content

Commit

Permalink
WinRT globals cleanup: Removed WINRT_GlobalSDLVideoDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLudwig committed Mar 23, 2014
1 parent b51a320 commit 823bf72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
20 changes: 11 additions & 9 deletions src/core/winrt/SDL_winrtapp_direct3d.cpp
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
6 changes: 0 additions & 6 deletions src/video/winrt/SDL_winrtvideo.cpp
Expand Up @@ -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 */
Expand All @@ -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) {
Expand Down Expand Up @@ -143,7 +138,6 @@ WINRT_CreateDevice(int devindex)
device->GL_DeleteContext = WINRT_GLES_DeleteContext;
#endif
device->free = WINRT_DeleteDevice;
WINRT_GlobalSDLVideoDevice = device;

return device;
}
Expand Down
3 changes: 0 additions & 3 deletions src/video/winrt/SDL_winrtvideo_cpp.h
Expand Up @@ -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.
Expand Down

0 comments on commit 823bf72

Please sign in to comment.