WinRT: code cleanup wrt. display mode(s)
authorDavid Ludwig <dludwig@pobox.com>
Tue, 27 Aug 2013 12:56:49 -0400
changeset 8503 90b33b6c6ab9
parent 8502 78d341895e9f
child 8504 3205689d1fff
WinRT: code cleanup wrt. display mode(s)
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 12:33:36 2013 -0400
+++ b/src/core/winrt/SDL_winrtapp.cpp	Tue Aug 27 12:56:49 2013 -0400
@@ -41,6 +41,7 @@
 
 extern SDL_Window * WINRT_GlobalSDLWindow;
 extern SDL_VideoDevice * WINRT_GlobalSDLVideoDevice;
+extern SDL_DisplayMode WINRT_CalcDisplayModeUsingNativeWindow();
 
 
 // Compile-time debugging options:
@@ -305,7 +306,7 @@
         // window-resize event as it appeared the SDL window didn't change
         // size, and the Direct3D 11.1 renderer wouldn't resize its swap
         // chain.
-        SDL_DisplayMode resizedDisplayMode = CalcCurrentDisplayMode();
+        SDL_DisplayMode resizedDisplayMode = WINRT_CalcDisplayModeUsingNativeWindow();
         WINRT_GlobalSDLVideoDevice->displays[0].current_mode = resizedDisplayMode;
         WINRT_GlobalSDLVideoDevice->displays[0].desktop_mode = resizedDisplayMode;
         WINRT_GlobalSDLVideoDevice->displays[0].display_modes[0] = resizedDisplayMode;
@@ -466,24 +467,3 @@
         SDL_FilterEvents(RemoveAppSuspendAndResumeEvents, 0);
     }
 }
-
-SDL_DisplayMode SDL_WinRTApp::CalcCurrentDisplayMode()
-{
-    // Create an empty, zeroed-out display mode:
-    SDL_DisplayMode mode;
-    SDL_zero(mode);
-
-    // Fill in most fields:
-    mode.format = SDL_PIXELFORMAT_RGB888;
-    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
-    mode.driverdata = NULL;
-
-    // Calculate the display size given the window size, taking into account
-    // the current display's DPI:
-    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; 
-    const float dipsPerInch = 96.0f;
-    mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
-    mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
-
-    return mode;
-}
--- a/src/core/winrt/SDL_winrtapp.h	Tue Aug 27 12:33:36 2013 -0400
+++ b/src/core/winrt/SDL_winrtapp.h	Tue Aug 27 12:56:49 2013 -0400
@@ -14,7 +14,6 @@
 
 internal:
     // SDL-specific methods
-    SDL_DisplayMode CalcCurrentDisplayMode();
     void PumpEvents();
     Windows::Foundation::Point TransformCursor(Windows::Foundation::Point rawPosition);
 
--- a/src/video/winrt/SDL_winrtvideo.cpp	Tue Aug 27 12:33:36 2013 -0400
+++ b/src/video/winrt/SDL_winrtvideo.cpp	Tue Aug 27 12:56:49 2013 -0400
@@ -147,10 +147,33 @@
     return 0;
 }
 
+SDL_DisplayMode
+WINRT_CalcDisplayModeUsingNativeWindow()
+{
+    // Create an empty, zeroed-out display mode:
+    SDL_DisplayMode mode;
+    SDL_zero(mode);
+
+    // Fill in most fields:
+    mode.format = SDL_PIXELFORMAT_RGB888;
+    mode.refresh_rate = 0;  // TODO, WinRT: see if refresh rate data is available, or relevant (for WinRT apps)
+    mode.driverdata = NULL;
+
+    // Calculate the display size given the window size, taking into account
+    // the current display's DPI:
+    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi; 
+    const float dipsPerInch = 96.0f;
+    mode.w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
+    mode.h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
+
+    return mode;
+}
+
+
 static int
 WINRT_InitModes(_THIS)
 {
-    SDL_DisplayMode mode = SDL_WinRTGlobalApp->CalcCurrentDisplayMode();
+    SDL_DisplayMode mode = WINRT_CalcDisplayModeUsingNativeWindow();
     if (SDL_AddBasicVideoDisplay(&mode) < 0) {
         return -1;
     }