Correct usage of GetVersion() windows calls. Review: http://codereview.appspot.com/4579049
git-svn-id: http://angleproject.googlecode.com/svn/trunk@688 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/libEGL/Surface.cpp b/src/libEGL/Surface.cpp
index 2c32038..eafe5e2 100644
--- a/src/libEGL/Surface.cpp
+++ b/src/libEGL/Surface.cpp
@@ -22,6 +22,23 @@
namespace egl
{
+
+namespace
+{
+const int versionWindowsVista = MAKEWORD(0x00, 0x06);
+const int versionWindows7 = MAKEWORD(0x01, 0x06);
+
+// Return the version of the operating system in a format suitable for ordering
+// comparison.
+int getComparableOSVersion()
+{
+ DWORD version = GetVersion();
+ int majorVersion = LOBYTE(LOWORD(version));
+ int minorVersion = HIBYTE(LOWORD(version));
+ return MAKEWORD(minorVersion, majorVersion);
+}
+}
+
Surface::Surface(Display *display, const Config *config, HWND window)
: mDisplay(display), mConfig(config), mWindow(window)
{
@@ -78,7 +95,7 @@
// Modify present parameters for this window, if we are composited,
// to minimize the amount of queuing done by DWM between our calls to
// present and the actual screen.
- if (mWindow && (LOWORD(GetVersion()) >= 0x60)) {
+ if (mWindow && (getComparableOSVersion() >= versionWindowsVista)) {
BOOL isComposited;
HRESULT result = DwmIsCompositionEnabled(&isComposited);
if (SUCCEEDED(result) && isComposited) {
@@ -165,7 +182,7 @@
D3DPRESENT_PARAMETERS presentParameters = {0};
HRESULT result;
- bool useFlipEx = (LOWORD(GetVersion()) >= 0x61) && mDisplay->isD3d9ExDevice();
+ bool useFlipEx = (getComparableOSVersion() >= versionWindows7) && mDisplay->isD3d9ExDevice();
// FlipEx causes unseemly stretching when resizing windows AND when one
// draws outside of the WM_PAINT callback. While this is seldom a problem in