WinRT: moved the WinRT SDL_VideoDevice out of SDL_WinRTApp
authorDavid Ludwig <dludwig@pobox.com>
Tue, 27 Aug 2013 12:13:45 -0400
changeset 8498 333ae9a0f411
parent 8497 103bb054aa7d
child 8499 00e397f1b7a8
WinRT: moved the WinRT SDL_VideoDevice out of SDL_WinRTApp This was done to help pave the way for XAML support.
src/core/winrt/SDL_winrtapp.cpp
src/core/winrt/SDL_winrtapp.h
src/video/winrt/SDL_winrtvideo.cpp
--- a/src/core/winrt/SDL_winrtapp.cpp	Tue Aug 27 11:51:17 2013 -0400
+++ b/src/core/winrt/SDL_winrtapp.cpp	Tue Aug 27 12:13:45 2013 -0400
@@ -40,6 +40,7 @@
 #include "SDL_winrtapp.h"
 
 extern SDL_Window * WINRT_GlobalSDLWindow;
+extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice;
 
 
 // Compile-time debugging options:
@@ -145,8 +146,7 @@
 
 SDL_WinRTApp::SDL_WinRTApp() :
     m_windowClosed(false),
-    m_windowVisible(true),
-    m_sdlVideoDevice(NULL)
+    m_windowVisible(true)
 {
 }
 
@@ -306,9 +306,9 @@
         // size, and the Direct3D 11.1 renderer wouldn't resize its swap
         // chain.
         SDL_DisplayMode resizedDisplayMode = CalcCurrentDisplayMode();
-        m_sdlVideoDevice->displays[0].current_mode = resizedDisplayMode;
-        m_sdlVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
-        m_sdlVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
+        WINRT_GlobalSDLVideoDevice->displays[0].current_mode = resizedDisplayMode;
+        WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
+        WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
 
         // Send the window-resize event to the rest of SDL, and to apps:
         const int windowWidth = (int) ceil(args->Size.Width);
@@ -487,8 +487,3 @@
 
     return mode;
 }
-
-void SDL_WinRTApp::SetSDLVideoDevice(const SDL_VideoDevice * videoDevice)
-{
-    m_sdlVideoDevice = videoDevice;
-}
--- a/src/core/winrt/SDL_winrtapp.h	Tue Aug 27 11:51:17 2013 -0400
+++ b/src/core/winrt/SDL_winrtapp.h	Tue Aug 27 12:13:45 2013 -0400
@@ -16,7 +16,6 @@
     // SDL-specific methods
     SDL_DisplayMode CalcCurrentDisplayMode();
     void PumpEvents();
-    void SetSDLVideoDevice(const SDL_VideoDevice * videoDevice);
     Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
 
 protected:
@@ -40,5 +39,4 @@
 private:
     bool m_windowClosed;
     bool m_windowVisible;
-    const SDL_VideoDevice* m_sdlVideoDevice;
 };
--- a/src/video/winrt/SDL_winrtvideo.cpp	Tue Aug 27 11:51:17 2013 -0400
+++ b/src/video/winrt/SDL_winrtvideo.cpp	Tue Aug 27 12:13:45 2013 -0400
@@ -79,6 +79,11 @@
 SDL_Window * WINRT_GlobalSDLWindow = NULL;
 
 
+/* The global, WinRT, video device.
+*/
+SDL_VideoDevice * WINRT_GlobalSDLVideoDevice = NULL;
+
+
 /* WinRT driver bootstrap functions */
 
 static int
@@ -90,7 +95,9 @@
 static void
 WINRT_DeleteDevice(SDL_VideoDevice * device)
 {
-    SDL_WinRTGlobalApp->SetSDLVideoDevice(NULL);
+    if (device == WINRT_GlobalSDLVideoDevice) {
+        WINRT_GlobalSDLVideoDevice = NULL;
+    }
     SDL_free(device);
 }
 
@@ -118,7 +125,7 @@
     device->PumpEvents = WINRT_PumpEvents;
     device->GetWindowWMInfo = WINRT_GetWindowWMInfo;
     device->free = WINRT_DeleteDevice;
-    SDL_WinRTGlobalApp->SetSDLVideoDevice(device);
+    WINRT_GlobalSDLVideoDevice = NULL;
 
     return device;
 }