From: <man...@us...> - 2015-05-20 21:07:31
|
Revision: 5127 http://sourceforge.net/p/modplug/code/5127 Author: manxorist Date: 2015-05-20 21:07:25 +0000 (Wed, 20 May 2015) Log Message: ----------- [Ref] Provide negated versions of the version test functions in mpt::Windows::Version. [Ref] Make mpt::Windows::Version available in non-Windows builds and just return false for every query there. This works the same way our compiler version test macros work. It simplifies cases in which a simple flag must be different on some specific versions of Windows. We can safe a whole #if MPT_OS_WINDOWS preprocessor test in this case which will provide better code readability. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.cpp trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/mptrack/CImageListEx.cpp trunk/OpenMPT/sounddev/SoundDeviceManager.cpp Modified: trunk/OpenMPT/common/misc_util.cpp =================================================================== --- trunk/OpenMPT/common/misc_util.cpp 2015-05-20 21:00:28 UTC (rev 5126) +++ trunk/OpenMPT/common/misc_util.cpp 2015-05-20 21:07:25 UTC (rev 5127) @@ -800,6 +800,13 @@ } +bool IsBefore(mpt::Windows::Version::Number version) +//-------------------------------------------------- +{ + return (SystemVersion < (uint32)version); +} + + bool IsAtLeast(mpt::Windows::Version::Number version) //--------------------------------------------------- { @@ -807,6 +814,13 @@ } +bool Is9x() +//--------- +{ + return !SystemIsNT; +} + + bool IsNT() //--------- { @@ -814,6 +828,13 @@ } +bool IsOriginal() +//--------------- +{ + return !SystemIsWine; +} + + bool IsWine() //----------- { @@ -824,6 +845,18 @@ #else // !MODPLUG_TRACKER +bool IsBefore(mpt::Windows::Version::Number version) +//-------------------------------------------------- +{ + OSVERSIONINFOEXW versioninfoex; + MemsetZero(versioninfoex); + versioninfoex.dwOSVersionInfoSize = sizeof(versioninfoex); + GetVersionExW((LPOSVERSIONINFOW)&versioninfoex); + uint32 SystemVersion = ((uint32)mpt::saturate_cast<uint8>(versioninfoex.dwMajorVersion) << 8) | ((uint32)mpt::saturate_cast<uint8>(versioninfoex.dwMinorVersion) << 0); + return (SystemVersion < (uint32)version); +} + + bool IsAtLeast(mpt::Windows::Version::Number version) //--------------------------------------------------- { Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2015-05-20 21:00:28 UTC (rev 5126) +++ trunk/OpenMPT/common/misc_util.h 2015-05-20 21:07:25 UTC (rev 5127) @@ -877,8 +877,6 @@ } // namespace Util -#if MPT_OS_WINDOWS - namespace mpt { namespace Windows @@ -908,29 +906,68 @@ #if defined(MODPLUG_TRACKER) +#if MPT_OS_WINDOWS + // Initializes version information. // Version information is cached in order to be safely available in audio real-time contexts. // Checking version information (especially detecting Wine) can be slow. void Init(); +static inline bool IsWindows() { return true; } + +bool IsBefore(mpt::Windows::Version::Number version); bool IsAtLeast(mpt::Windows::Version::Number version); + +bool Is9x(); bool IsNT(); + +bool IsOriginal(); bool IsWine(); +#else // !MPT_OS_WINDOWS + +static inline void Init() { return; } + +static inline bool IsWindows() { return false; } + +static inline bool IsBefore(mpt::Windows::Version::Number /* version */ ) { return false; } +static inline bool IsAtLeast(mpt::Windows::Version::Number /* version */ ) { return false; } + +static inline bool Is9x() { return false; } +static inline bool IsNT() { return false; } + +static inline bool IsOriginal() { return false; } +static inline bool IsWine() { return false; } + +#endif // MPT_OS_WINDOWS + #else // !MODPLUG_TRACKER +#if MPT_OS_WINDOWS + +static inline bool IsWindows() { return true; } + +bool IsBefore(mpt::Windows::Version::Number version); bool IsAtLeast(mpt::Windows::Version::Number version); +#else // !MPT_OS_WINDOWS + +static inline bool IsWindows() { return false; } + +static inline bool IsBefore(mpt::Windows::Version::Number /* version */ ) { return false; } +static inline bool IsAtLeast(mpt::Windows::Version::Number /* version */ ) { return false; } + +#endif // MPT_OS_WINDOWS + #endif // MODPLUG_TRACKER + } // namespace Version } // namespace Windows } // namespace mpt -#endif // MPT_OS_WINDOWS - #if defined(MPT_WITH_DYNBIND) namespace mpt Modified: trunk/OpenMPT/mptrack/CImageListEx.cpp =================================================================== --- trunk/OpenMPT/mptrack/CImageListEx.cpp 2015-05-20 21:00:28 UTC (rev 5126) +++ trunk/OpenMPT/mptrack/CImageListEx.cpp 2015-05-20 21:07:25 UTC (rev 5127) @@ -45,7 +45,7 @@ // Icons with alpha transparency screw up in Windows 2000 and older as well as Wine 1.4 and older. // They all support 1-bit transparency, though, so we pre-multiply all pixels with the default button face colour and create a transparency mask. // Additionally, since we create a bitmap that fits the device's bit depth, we apply this fix when using a bit depth that doesn't have an alpha channel. - if(!mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinXP) + if(mpt::Windows::Version::IsBefore(mpt::Windows::Version::WinXP) || mpt::Windows::Version::IsWine() || GetDeviceCaps(dc->GetSafeHdc(), BITSPIXEL) * GetDeviceCaps(dc->GetSafeHdc(), PLANES) < 32) { Modified: trunk/OpenMPT/sounddev/SoundDeviceManager.cpp =================================================================== --- trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-05-20 21:00:28 UTC (rev 5126) +++ trunk/OpenMPT/sounddev/SoundDeviceManager.cpp 2015-05-20 21:07:25 UTC (rev 5127) @@ -96,7 +96,7 @@ typePriorities[SoundDevice::TypePORTAUDIO_DS] = 18; typePriorities[SoundDevice::TypeASIO] = 10; typePriorities[SoundDevice::TypePORTAUDIO_WDMKS] = -1; - } else if(!mpt::Windows::Version::IsNT()) + } else if(mpt::Windows::Version::Is9x()) { // Win9x typePriorities[SoundDevice::TypeWAVEOUT] = 29; typePriorities[SoundDevice::TypeDSOUND] = 28; @@ -105,7 +105,7 @@ typePriorities[SoundDevice::TypeASIO] = 1; typePriorities[SoundDevice::TypePORTAUDIO_WDMKS] = -1; typePriorities[SoundDevice::TypePORTAUDIO_WASAPI] = -2; - } else if(!mpt::Windows::Version::IsAtLeast(mpt::Windows::Version::WinVista)) + } else if(mpt::Windows::Version::IsBefore(mpt::Windows::Version::WinVista)) { // WinXP typePriorities[SoundDevice::TypeWAVEOUT] = 29; typePriorities[SoundDevice::TypeASIO] = 28; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |