WinRT: display-information code cleanups
authorDavid Ludwig <dludwig@pobox.com>
Fri, 09 May 2014 21:28:52 -0400
changeset 8757 aeeeb47a5a77
parent 8756 d35c6e6ccbb4
child 8758 3b1ed6708ce9
WinRT: display-information code cleanups
src/core/winrt/SDL_winrtapp_direct3d.cpp
src/render/direct3d11/SDL_render_winrt.cpp
src/video/winrt/SDL_winrtpointerinput.cpp
src/video/winrt/SDL_winrtvideo.cpp
--- a/src/core/winrt/SDL_winrtapp_direct3d.cpp	Fri May 09 20:32:06 2014 -0400
+++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp	Fri May 09 21:28:52 2014 -0400
@@ -170,11 +170,7 @@
     // for details.  Microsoft's "Display orientation sample" also gives an
     // outline of how Windows treats device rotation
     // (http://code.msdn.microsoft.com/Display-Orientation-Sample-19a58e93).
-#if NTDDI_VERSION > NTDDI_WIN8
-    DisplayInformation::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
-#else
-    DisplayProperties::AutoRotationPreferences = (DisplayOrientations) orientationFlags;
-#endif
+    WINRT_DISPLAY_PROPERTY(AutoRotationPreferences) = (DisplayOrientations) orientationFlags;
 }
 
 static void
--- a/src/render/direct3d11/SDL_render_winrt.cpp	Fri May 09 20:32:06 2014 -0400
+++ b/src/render/direct3d11/SDL_render_winrt.cpp	Fri May 09 21:28:52 2014 -0400
@@ -23,6 +23,7 @@
 #if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
 
 #include "SDL_syswm.h"
+#include "../../video/winrt/SDL_winrtvideo_cpp.h"
 extern "C" {
 #include "../SDL_sysrender.h"
 }
@@ -79,11 +80,7 @@
 extern "C" DXGI_MODE_ROTATION
 D3D11_GetCurrentRotation()
 {
-#if NTDDI_VERSION > NTDDI_WIN8
-    const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
-#else
-    const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation;
-#endif
+    const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
 
     switch (currentOrientation) {
 
--- a/src/video/winrt/SDL_winrtpointerinput.cpp	Fri May 09 20:32:06 2014 -0400
+++ b/src/video/winrt/SDL_winrtpointerinput.cpp	Fri May 09 21:28:52 2014 -0400
@@ -87,7 +87,7 @@
     outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
     outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height;
 #else
-    switch (DisplayProperties::CurrentOrientation)
+    switch (WINRT_DISPLAY_PROPERTY(CurrentOrientation))
     {
         case DisplayOrientations::Portrait:
             outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width;
--- a/src/video/winrt/SDL_winrtvideo.cpp	Fri May 09 20:32:06 2014 -0400
+++ b/src/video/winrt/SDL_winrtvideo.cpp	Fri May 09 21:28:52 2014 -0400
@@ -185,11 +185,7 @@
 
     // Calculate the display size given the window size, taking into account
     // the current display's DPI:
-#if NTDDI_VERSION > NTDDI_WIN8
-    const float currentDPI = DisplayInformation::GetForCurrentView()->LogicalDpi;
-#else
-    const float currentDPI = Windows::Graphics::Display::DisplayProperties::LogicalDpi;
-#endif
+    const float currentDPI = WINRT_DISPLAY_PROPERTY(LogicalDpi);
     const float dipsPerInch = 96.0f;
     const int w = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Width * currentDPI) / dipsPerInch);
     const int h = (int) ((CoreWindow::GetForCurrentThread()->Bounds.Height * currentDPI) / dipsPerInch);
@@ -211,11 +207,7 @@
     mode->w = w;
     mode->h = h;
     mode->driverdata = driverdata;
-#if NTDDI_VERSION > NTDDI_WIN8
-    driverdata->currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
-#else
-    driverdata->currentOrientation = DisplayProperties::CurrentOrientation;
-#endif
+    driverdata->currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation);
 
 #if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8)
     // On Windows Phone 8.0, the native window's size is always in portrait,