From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/driver.c | 91 ----------------------------------------- dlls/gdi32/objects.c | 97 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 92 deletions(-)
diff --git a/dlls/gdi32/driver.c b/dlls/gdi32/driver.c index 3073f745f92..f370d088585 100644 --- a/dlls/gdi32/driver.c +++ b/dlls/gdi32/driver.c @@ -32,11 +32,6 @@ #include "ddrawgdi.h" #include "wine/winbase16.h" #include "winuser.h" -#include "winternl.h" -#include "initguid.h" -#include "devguid.h" -#include "setupapi.h" -#include "ddk/d3dkmthk.h"
#include "ntgdi_private.h" #include "wine/list.h" @@ -45,8 +40,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(driver);
-DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2); - struct graphics_driver { struct list entry; @@ -163,20 +156,6 @@ BOOL is_display_device( LPCWSTR name ) return TRUE; }
-static HANDLE get_display_device_init_mutex( void ) -{ - HANDLE mutex = CreateMutexW( NULL, FALSE, L"display_device_init" ); - - WaitForSingleObject( mutex, INFINITE ); - return mutex; -} - -static void release_display_device_init_mutex( HANDLE mutex ) -{ - ReleaseMutex( mutex ); - CloseHandle( mutex ); -} - #ifdef __i386__ static const WCHAR printer_env[] = L"w32x86"; #elif defined __x86_64__ @@ -1249,76 +1228,6 @@ NTSTATUS WINAPI NtGdiDdDDICloseAdapter( const D3DKMT_CLOSEADAPTER *desc ) return status; }
-/****************************************************************************** - * D3DKMTOpenAdapterFromGdiDisplayName [GDI32.@] - */ -NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc ) -{ - WCHAR *end, key_nameW[MAX_PATH], bufferW[MAX_PATH]; - HDEVINFO devinfo = INVALID_HANDLE_VALUE; - NTSTATUS status = STATUS_UNSUCCESSFUL; - D3DKMT_OPENADAPTERFROMLUID luid_desc; - SP_DEVINFO_DATA device_data; - DWORD size, state_flags; - DEVPROPTYPE type; - HANDLE mutex; - int index; - - TRACE("(%p)\n", desc); - - if (!desc) - return STATUS_UNSUCCESSFUL; - - TRACE("DeviceName: %s\n", wine_dbgstr_w( desc->DeviceName )); - if (wcsnicmp( desc->DeviceName, L"\\.\DISPLAY", lstrlenW(L"\\.\DISPLAY") )) - return STATUS_UNSUCCESSFUL; - - index = wcstol( desc->DeviceName + lstrlenW(L"\\.\DISPLAY"), &end, 10 ) - 1; - if (*end) - return STATUS_UNSUCCESSFUL; - - /* Get adapter LUID from SetupAPI */ - mutex = get_display_device_init_mutex(); - - size = sizeof( bufferW ); - swprintf( key_nameW, MAX_PATH, L"\Device\Video%d", index ); - if (RegGetValueW( HKEY_LOCAL_MACHINE, L"HARDWARE\DEVICEMAP\VIDEO", key_nameW, RRF_RT_REG_SZ, NULL, bufferW, &size )) - goto done; - - /* Strip \Registry\Machine\ prefix and retrieve Wine specific data set by the display driver */ - lstrcpyW( key_nameW, bufferW + 18 ); - size = sizeof( state_flags ); - if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, L"StateFlags", RRF_RT_REG_DWORD, NULL, - &state_flags, &size )) - goto done; - - if (!(state_flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) - goto done; - - size = sizeof( bufferW ); - if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, L"GPUID", RRF_RT_REG_SZ, NULL, bufferW, &size )) - goto done; - - devinfo = SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_DISPLAY, NULL ); - device_data.cbSize = sizeof( device_data ); - SetupDiOpenDeviceInfoW( devinfo, bufferW, NULL, 0, &device_data ); - if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type, - (BYTE *)&luid_desc.AdapterLuid, sizeof( luid_desc.AdapterLuid ), - NULL, 0)) - goto done; - - if ((status = NtGdiDdDDIOpenAdapterFromLuid( &luid_desc ))) goto done; - - desc->hAdapter = luid_desc.hAdapter; - desc->AdapterLuid = luid_desc.AdapterLuid; - desc->VidPnSourceId = index; - -done: - SetupDiDestroyDeviceInfoList( devinfo ); - release_display_device_init_mutex( mutex ); - return status; -} - /****************************************************************************** * NtGdiDdDDIOpenAdapterFromLuid (win32u.@) */ diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c index 3acafbc9331..4225437aa4a 100644 --- a/dlls/gdi32/objects.c +++ b/dlls/gdi32/objects.c @@ -19,9 +19,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include <stdlib.h> + +#include "ntstatus.h" +#define WIN32_NO_STATUS #include "gdi_private.h" +#include "winuser.h" +#include "winreg.h" #include "winnls.h" -#include "winternl.h" +#include "initguid.h" +#include "devguid.h" +#include "setupapi.h"
#include "wine/rbtree.h" #include "wine/debug.h" @@ -29,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdi);
+DEFINE_DEVPROPKEY(DEVPROPKEY_GPU_LUID, 0x60b193cb, 0x5276, 0x4d0f, 0x96, 0xfc, 0xf1, 0x73, 0xab, 0xad, 0x3e, 0xc6, 2); + struct hdc_list { HDC hdc; @@ -619,3 +629,88 @@ UINT WINAPI SetDIBColorTable( HDC hdc, UINT start, UINT count, const RGBQUAD *co { return NtGdiDoPalette( hdc, start, count, (void *)colors, NtGdiSetDIBColorTable, FALSE ); } + +static HANDLE get_display_device_init_mutex( void ) +{ + HANDLE mutex = CreateMutexW( NULL, FALSE, L"display_device_init" ); + + WaitForSingleObject( mutex, INFINITE ); + return mutex; +} + +static void release_display_device_init_mutex( HANDLE mutex ) +{ + ReleaseMutex( mutex ); + CloseHandle( mutex ); +} + +/*********************************************************************** + * D3DKMTOpenAdapterFromGdiDisplayName (GDI32.@) + */ +NTSTATUS WINAPI D3DKMTOpenAdapterFromGdiDisplayName( D3DKMT_OPENADAPTERFROMGDIDISPLAYNAME *desc ) +{ + WCHAR *end, key_nameW[MAX_PATH], bufferW[MAX_PATH]; + HDEVINFO devinfo = INVALID_HANDLE_VALUE; + NTSTATUS status = STATUS_UNSUCCESSFUL; + D3DKMT_OPENADAPTERFROMLUID luid_desc; + SP_DEVINFO_DATA device_data; + DWORD size, state_flags; + DEVPROPTYPE type; + HANDLE mutex; + int index; + + TRACE("(%p)\n", desc); + + if (!desc) + return STATUS_UNSUCCESSFUL; + + TRACE("DeviceName: %s\n", wine_dbgstr_w( desc->DeviceName )); + if (wcsnicmp( desc->DeviceName, L"\\.\DISPLAY", lstrlenW(L"\\.\DISPLAY") )) + return STATUS_UNSUCCESSFUL; + + index = wcstol( desc->DeviceName + lstrlenW(L"\\.\DISPLAY"), &end, 10 ) - 1; + if (*end) + return STATUS_UNSUCCESSFUL; + + /* Get adapter LUID from SetupAPI */ + mutex = get_display_device_init_mutex(); + + size = sizeof( bufferW ); + swprintf( key_nameW, MAX_PATH, L"\Device\Video%d", index ); + if (RegGetValueW( HKEY_LOCAL_MACHINE, L"HARDWARE\DEVICEMAP\VIDEO", key_nameW, + RRF_RT_REG_SZ, NULL, bufferW, &size )) + goto done; + + /* Strip \Registry\Machine\ prefix and retrieve Wine specific data set by the display driver */ + lstrcpyW( key_nameW, bufferW + 18 ); + size = sizeof( state_flags ); + if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, L"StateFlags", RRF_RT_REG_DWORD, NULL, + &state_flags, &size )) + goto done; + + if (!(state_flags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) + goto done; + + size = sizeof( bufferW ); + if (RegGetValueW( HKEY_CURRENT_CONFIG, key_nameW, L"GPUID", RRF_RT_REG_SZ, NULL, bufferW, &size )) + goto done; + + devinfo = SetupDiCreateDeviceInfoList( &GUID_DEVCLASS_DISPLAY, NULL ); + device_data.cbSize = sizeof( device_data ); + SetupDiOpenDeviceInfoW( devinfo, bufferW, NULL, 0, &device_data ); + if (!SetupDiGetDevicePropertyW( devinfo, &device_data, &DEVPROPKEY_GPU_LUID, &type, + (BYTE *)&luid_desc.AdapterLuid, sizeof( luid_desc.AdapterLuid ), + NULL, 0)) + goto done; + + if ((status = NtGdiDdDDIOpenAdapterFromLuid( &luid_desc ))) goto done; + + desc->hAdapter = luid_desc.hAdapter; + desc->AdapterLuid = luid_desc.AdapterLuid; + desc->VidPnSourceId = index; + +done: + SetupDiDestroyDeviceInfoList( devinfo ); + release_display_device_init_mutex( mutex ); + return status; +}