From db6974eda1dc1fada95af97ea53c369db58fda41 Mon Sep 17 00:00:00 2001 From: Jonas Kümmerlin Date: Mon, 1 Jun 2020 12:03:57 +0200 Subject: replace windows version checks with compat bits this saves us from calling GetVersion() and massaging the result in hot code paths --- alf/alfcompat.h | 65 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 19 deletions(-) (limited to 'alf/alfcompat.h') diff --git a/alf/alfcompat.h b/alf/alfcompat.h index 8186492..eeb70da 100644 --- a/alf/alfcompat.h +++ b/alf/alfcompat.h @@ -15,25 +15,6 @@ extern IMAGE_DOS_HEADER __ImageBase; #endif #define ALF_HINSTANCE ((HINSTANCE)&__ImageBase) -static inline BOOL ALF_Compat_IsMinWindowsVersion(DWORD major, DWORD minor) -{ - DWORD v = GetVersion(); - DWORD vMajor = LOBYTE(LOWORD(v)); - DWORD vMinor = HIBYTE(LOWORD(v)); - - return vMajor > major || (vMajor == major && vMinor >= minor); -} - -static inline BOOL ALF_Compat_IsWin9x(void) -{ - return GetVersion() >= 0x80000000; -} - -static inline BOOL ALF_Compat_IsWinNT(void) -{ - return GetVersion() < 0x80000000; -} - typedef struct { UINT cbSize; int iBorderWidth; @@ -144,3 +125,49 @@ extern HRESULT (WINAPI *ALF_Compat_EndBufferedAnimation)(ALF_Compat_HANIMATIONBU extern BOOL (WINAPI *ALF_Compat_BufferedPaintRenderAnimation)(HWND,HDC); extern HRESULT (WINAPI *ALF_Compat_GetThemeTransitionDuration)(HTHEME,int,int,int,int,DWORD*); extern HRESULT (WINAPI *ALF_Compat_GetThemeColor)(HTHEME,int,int,int,COLORREF*); + +// compatibility bits + +#define ALF_COMPAT_ISNT 1 +#define ALF_COMPAT_IS40 2 +#define ALF_COMPAT_ISW2K 4 +#define ALF_COMPAT_ISXP 8 +#define ALF_COMPAT_ISVISTA 16 +#define ALF_COMPAT_ISCOMCTLV6 32 + +extern DWORD _alf_compatBits; + +static inline BOOL ALF_Compat_IsWin9x(void) +{ + return !(_alf_compatBits & ALF_COMPAT_ISNT); +} + +static inline BOOL ALF_Compat_IsNT(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISNT); +} + +static inline BOOL ALF_Compat_Is40(void) // both NT 4.0 and Win95 +{ + return !!(_alf_compatBits & ALF_COMPAT_IS40); +} + +static inline BOOL ALF_Compat_Is2k(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISW2K); +} + +static inline BOOL ALF_Compat_IsXP(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISXP); +} + +static inline BOOL ALF_Compat_IsVista(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISVISTA); +} + +static inline BOOL ALF_Compat_IsComCtlV6(void) +{ + return !!(_alf_compatBits & ALF_COMPAT_ISCOMCTLV6); +} -- cgit v1.2.3