DXGL r786 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r785‎ | r786 | r787 >
Date:01:42, 27 February 2018
Author:admin
Status:new
Tags:
Comment:
Add new DPI scaling modes to ddraw, including for Windows 10 v1703, not yet in DXGL Config.
Remove DPI manifest from DXGL Config (lets ddraw set it instead)
List display modes for upcoming Additional display modes option in glDirectDraw.cpp
Modified paths:
  • /cfgmgr/cfgmgr.c (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /dxglcfg/xp.manifest (modified) (history)

Diff [purge]

Index: cfgmgr/cfgmgr.c
@@ -1109,6 +1109,9 @@
11101110 BOOL DPIAwarePM = FALSE;
11111111 HMODULE hSHCore = NULL;
11121112 HMODULE hUser32 = NULL;
 1113+ HRESULT(WINAPI *_SetProcessDpiAwareness)(DWORD value);
 1114+ BOOL(WINAPI *_SetProcessDpiAwarenessContext)(HANDLE value);
 1115+ BOOL(WINAPI *_SetProcessDPIAware)();
11131116 GetModuleFileName(NULL, filename, MAX_PATH);
11141117 _tcscpy(regkey, regkeybase);
11151118 _tcscat(regkey, _T("Profiles\\"));
@@ -1163,13 +1166,14 @@
11641167 else DelCompatFlag(_T("HIGHDPIAWARE"),initial);
11651168 if (initial)
11661169 {
1167 - if (cfg->DPIScale == 1)
 1170+ switch(cfg->DPIScale)
11681171 {
 1172+ case 1: // Per-monitor DPI Aware V1
11691173 hSHCore = LoadLibrary(_T("SHCore.dll"));
11701174 if (hSHCore)
11711175 {
1172 - HRESULT(WINAPI *_SetProcessDpiAwareness)(DWORD value)
1173 - = (HRESULT(WINAPI*)(DWORD))GetProcAddress(hSHCore, "SetProcessDpiAwareness");
 1176+ _SetProcessDpiAwareness =
 1177+ (HRESULT(WINAPI*)(DWORD))GetProcAddress(hSHCore, "SetProcessDpiAwareness");
11741178 if (_SetProcessDpiAwareness)
11751179 {
11761180 DPIAwarePM = TRUE;
@@ -1181,13 +1185,76 @@
11821186 hUser32 = LoadLibrary(_T("User32.dll"));
11831187 if (hUser32)
11841188 {
1185 - BOOL(WINAPI *_SetProcessDPIAware)()
1186 - = (BOOL(WINAPI*)())GetProcAddress(hUser32, "SetProcessDPIAware");
 1189+ _SetProcessDPIAware =
 1190+ (BOOL(WINAPI*)())GetProcAddress(hUser32, "SetProcessDPIAware");
11871191 if (_SetProcessDPIAware) _SetProcessDPIAware();
11881192 }
11891193 }
11901194 if (hSHCore) FreeLibrary(hSHCore);
11911195 if (hUser32) FreeLibrary(hUser32);
 1196+ break;
 1197+ case 3: // System DPI Aware
 1198+ hSHCore = LoadLibrary(_T("SHCore.dll"));
 1199+ if (hSHCore)
 1200+ {
 1201+ _SetProcessDpiAwareness =
 1202+ (HRESULT(WINAPI*)(DWORD))GetProcAddress(hSHCore, "SetProcessDpiAwareness");
 1203+ if (_SetProcessDpiAwareness)
 1204+ {
 1205+ DPIAwarePM = TRUE;
 1206+ _SetProcessDpiAwareness(1);
 1207+ }
 1208+ }
 1209+ if (!DPIAwarePM)
 1210+ {
 1211+ hUser32 = LoadLibrary(_T("User32.dll"));
 1212+ if (hUser32)
 1213+ {
 1214+ _SetProcessDPIAware =
 1215+ (BOOL(WINAPI*)())GetProcAddress(hUser32, "SetProcessDPIAware");
 1216+ if (_SetProcessDPIAware) _SetProcessDPIAware();
 1217+ }
 1218+ }
 1219+ if (hSHCore) FreeLibrary(hSHCore);
 1220+ if (hUser32) FreeLibrary(hUser32);
 1221+ break;
 1222+ case 4: // Per-monitor DPI Aware V2
 1223+ hUser32 = LoadLibrary(_T("User32.dll"));
 1224+ if (hUser32)
 1225+ {
 1226+ _SetProcessDpiAwarenessContext =
 1227+ (BOOL(WINAPI*)(HANDLE))GetProcAddress(hUser32, "SetProcessDpiAwarenessContext");
 1228+ if (_SetProcessDpiAwarenessContext) _SetProcessDpiAwarenessContext(-4);
 1229+ }
 1230+ if (!_SetProcessDpiAwarenessContext)
 1231+ {
 1232+ hSHCore = LoadLibrary(_T("SHCore.dll"));
 1233+ if (hSHCore)
 1234+ {
 1235+ _SetProcessDpiAwareness =
 1236+ (HRESULT(WINAPI*)(DWORD))GetProcAddress(hSHCore, "SetProcessDpiAwareness");
 1237+ if (_SetProcessDpiAwareness)
 1238+ {
 1239+ DPIAwarePM = TRUE;
 1240+ _SetProcessDpiAwareness(2);
 1241+ }
 1242+ }
 1243+ if (!DPIAwarePM)
 1244+ {
 1245+ if (!hUser32) hUser32 = LoadLibrary(_T("User32.dll"));
 1246+ if (hUser32)
 1247+ {
 1248+ _SetProcessDPIAware =
 1249+ (BOOL(WINAPI*)())GetProcAddress(hUser32, "SetProcessDPIAware");
 1250+ if (_SetProcessDPIAware) _SetProcessDPIAware();
 1251+ }
 1252+ }
 1253+ }
 1254+ if (hSHCore) FreeLibrary(hSHCore);
 1255+ if (hUser32) FreeLibrary(hUser32);
 1256+ break;
 1257+ default:
 1258+ break;
11921259 }
11931260 }
11941261 //if(!cfg->colormode) DelCompatFlag(_T("DWM8And16BitMitigation"), initial); // Windows 10 compatibility issues; not needed?
Index: ddraw/glDirectDraw.cpp
@@ -133,6 +133,125 @@
134134 const int END_EXTRAMODESCOUNT = __LINE__ - 4;
135135 const int numextramodes = END_EXTRAMODESCOUNT - START_EXTRAMODESCOUNT;
136136
 137+const int START_LOWRESMODES = __LINE__;
 138+const int LowResModes[][3] =
 139+{
 140+ { 320,200,70 },
 141+ { 320,240,60 },
 142+ { 320,400,70 },
 143+ { 320,480,60 },
 144+ { 640,400,70 }
 145+};
 146+const int END_LOWRESMODES = __LINE__ - 4;
 147+const int NumLowResModes = END_LOWRESMODES - START_LOWRESMODES;
 148+
 149+const int START_UNCOMMONLOWRESMODES = __LINE__;
 150+const int UncommonLowResModes[][3] =
 151+{
 152+ { 360,200,70 },
 153+ { 360,240,60 },
 154+ { 360,400,70 },
 155+ { 360,480,60 },
 156+ { 400,300,60 }
 157+};
 158+const int END_UNCOMMONLOWRESMODES = __LINE__ - 4;
 159+const int NumUncommonLowResModes = END_LOWRESMODES - START_LOWRESMODES;
 160+
 161+const int START_UNCOMMONSDMODES = __LINE__;
 162+const int UncommonSDModes[][3] =
 163+{
 164+ { 512,384,60 },
 165+ { 640,350,70 },
 166+ { 640,360,60 },
 167+ { 720,400,70 },
 168+ { 720,480,60 },
 169+ { 960,540,60 },
 170+ { 960,600,60 },
 171+ { 960,720,60 },
 172+ { 1024,600,60 }
 173+};
 174+const int END_UNCOMMONSDMODES = __LINE__ - 4;
 175+const int NumUncommonSDModes = END_UNCOMMONSDMODES - START_UNCOMMONSDMODES;
 176+
 177+const int START_HDMODES = __LINE__;
 178+const int HDModes[][3] =
 179+{
 180+ { 1024,800,60 },
 181+ { 1280,720,60 },
 182+ { 1280,800,60 },
 183+ { 1360,768,60 },
 184+ { 1366,768,60 },
 185+ { 1400,1050,60 },
 186+ { 1440,900,60 },
 187+ { 1600,800,60 },
 188+ { 1680,1050,60 },
 189+ { 1920,1080,60 },
 190+ { 1920,1200,60 },
 191+ { 2048,1080,60 }
 192+};
 193+const int END_HDMODES = __LINE__ - 4;
 194+const int NumHDModes = END_HDMODES - START_HDMODES;
 195+
 196+const int START_UHDMODES = __LINE__;
 197+const int UHDModes[][3] =
 198+{
 199+ { 2560,1080,60 },
 200+ { 2560,1440,60 },
 201+ { 2560,1600,60 },
 202+ { 2560,1920,60 },
 203+ { 2560,2048,60 },
 204+ { 2800,2100,60 },
 205+ { 3200,1800,60 },
 206+ { 3200,2048,60 },
 207+ { 3840,2160,60 },
 208+ { 3840,2400,60 },
 209+ { 4096,2304,60 },
 210+ { 4096,3072,60 }
 211+};
 212+const int END_UHDMODES = __LINE__ - 4;
 213+const int NumUHDModes = END_UHDMODES - START_UHDMODES;
 214+
 215+const int START_UHD2MODES = __LINE__;
 216+const int UHD2Modes[][3] =
 217+{
 218+ { 5120,2880,60 },
 219+ { 5120,3200,60 },
 220+ { 5120,4096,60 },
 221+ { 6400,4800,60 },
 222+ { 7680,4320,60 },
 223+ { 7680,4800,60 },
 224+ { 8192,4608,60 }
 225+};
 226+const int END_UHD2MODES = __LINE__ - 4;
 227+const int NumUHD2Modes = END_UHDMODES - START_UHDMODES;
 228+
 229+const int START_UNCOMMONMODES = __LINE__;
 230+const int UncommonModes[][3] =
 231+{
 232+ { 240,160,60 },
 233+ { 256,224,60 },
 234+ { 256,240,60 },
 235+ { 320,175,60 },
 236+ { 320,224,60 },
 237+ { 400,240,60 },
 238+ { 416,312,75 },
 239+ { 512,448,60 },
 240+ { 512,480,60 },
 241+ { 576,432,60 },
 242+ { 640,200,60 },
 243+ { 640,512,60 },
 244+ { 700,525,60 },
 245+ { 720,350,70 },
 246+ { 720,450,60 },
 247+ { 800,512,60 },
 248+ { 832,624,75 },
 249+ { 840,525,60 },
 250+ { 896,672,60 },
 251+ { 928,696,60 },
 252+};
 253+const int END_UNCOMMONMODES = __LINE__ - 4;
 254+const int NumUncommonModes = END_UNCOMMONMODES - START_UNCOMMONMODES;
 255+
137256 const int START_DOUBLEDMODESCOUNT = __LINE__;
138257 const int DoubledModes[] [5] =
139258 {
Index: ddraw/glRenderer.cpp
@@ -1811,6 +1811,16 @@
18121812 */
18131813 void glRenderer_Delete(glRenderer *This)
18141814 {
 1815+ switch (dxglcfg.fullmode)
 1816+ {
 1817+ case 2:
 1818+ case 3:
 1819+ case 4:
 1820+ SaveWindowSettings(&dxglcfg);
 1821+ break;
 1822+ default:
 1823+ break;
 1824+ }
18151825 EnterCriticalSection(&This->cs);
18161826 This->opcode = OP_DELETE;
18171827 SetEvent(This->start);
Index: dxglcfg/xp.manifest
@@ -28,9 +28,4 @@
2929 <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
3030 </application>
3131 </compatibility>
32 - <asmv3:application>
33 - <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
34 - <dpiAware>true/pm</dpiAware>
35 - </asmv3:windowsSettings>
36 - </asmv3:application>
3732 </assembly>
\ No newline at end of file