Commit d81cf4ed authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

win32u: Introduce a get_display_depth() helper to retrieve emulated display depth.

Using EnumDisplaySettings() directly to query display depth has a high overhead when using the XRandR 1.0 display device handler on some NVIDIA setups. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51420 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53382
parent 8e976387
...@@ -207,18 +207,13 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap ) ...@@ -207,18 +207,13 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
case BITSPIXEL: case BITSPIXEL:
{ {
UNICODE_STRING display; UNICODE_STRING display;
DEVMODEW devmode;
DC *dc; DC *dc;
if (NtGdiGetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY) if (NtGdiGetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY)
{ {
dc = get_nulldrv_dc( dev ); dc = get_nulldrv_dc( dev );
memset( &devmode, 0, sizeof(devmode) );
devmode.dmSize = sizeof(devmode);
RtlInitUnicodeString( &display, dc->display ); RtlInitUnicodeString( &display, dc->display );
if (NtUserEnumDisplaySettings( &display, ENUM_CURRENT_SETTINGS, &devmode, 0 ) && return get_display_depth( &display );
(devmode.dmFields & DM_BITSPERPEL) && devmode.dmBitsPerPel)
return devmode.dmBitsPerPel;
} }
return 32; return 32;
} }
...@@ -764,6 +759,11 @@ static BOOL nulldrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LP ...@@ -764,6 +759,11 @@ static BOOL nulldrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LP
return FALSE; /* use default implementation */ return FALSE; /* use default implementation */
} }
static INT nulldrv_GetDisplayDepth( LPCWSTR name, BOOL is_primary )
{
return 32;
}
static BOOL nulldrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param ) static BOOL nulldrv_UpdateDisplayDevices( const struct gdi_device_manager *manager, BOOL force, void *param )
{ {
return FALSE; return FALSE;
...@@ -1077,6 +1077,11 @@ static BOOL loaderdrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, ...@@ -1077,6 +1077,11 @@ static BOOL loaderdrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary,
return load_driver()->pGetCurrentDisplaySettings( name, is_primary, mode ); return load_driver()->pGetCurrentDisplaySettings( name, is_primary, mode );
} }
static INT loaderdrv_GetDisplayDepth( LPCWSTR name, BOOL is_primary )
{
return load_driver()->pGetDisplayDepth( name, is_primary );
}
static void loaderdrv_SetCursor( HCURSOR cursor ) static void loaderdrv_SetCursor( HCURSOR cursor )
{ {
load_driver()->pSetCursor( cursor ); load_driver()->pSetCursor( cursor );
...@@ -1179,6 +1184,7 @@ static const struct user_driver_funcs lazy_load_driver = ...@@ -1179,6 +1184,7 @@ static const struct user_driver_funcs lazy_load_driver =
/* display modes */ /* display modes */
loaderdrv_ChangeDisplaySettings, loaderdrv_ChangeDisplaySettings,
loaderdrv_GetCurrentDisplaySettings, loaderdrv_GetCurrentDisplaySettings,
loaderdrv_GetDisplayDepth,
loaderdrv_UpdateDisplayDevices, loaderdrv_UpdateDisplayDevices,
/* windowing functions */ /* windowing functions */
loaderdrv_CreateDesktopWindow, loaderdrv_CreateDesktopWindow,
...@@ -1254,6 +1260,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version ...@@ -1254,6 +1260,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
SET_USER_FUNC(UpdateClipboard); SET_USER_FUNC(UpdateClipboard);
SET_USER_FUNC(ChangeDisplaySettings); SET_USER_FUNC(ChangeDisplaySettings);
SET_USER_FUNC(GetCurrentDisplaySettings); SET_USER_FUNC(GetCurrentDisplaySettings);
SET_USER_FUNC(GetDisplayDepth);
SET_USER_FUNC(UpdateDisplayDevices); SET_USER_FUNC(UpdateDisplayDevices);
SET_USER_FUNC(CreateDesktopWindow); SET_USER_FUNC(CreateDesktopWindow);
SET_USER_FUNC(CreateWindow); SET_USER_FUNC(CreateWindow);
......
...@@ -2655,6 +2655,31 @@ static unsigned int active_monitor_count(void) ...@@ -2655,6 +2655,31 @@ static unsigned int active_monitor_count(void)
return count; return count;
} }
INT get_display_depth( UNICODE_STRING *name )
{
struct display_device *device;
INT depth;
if (!lock_display_devices())
return 32;
if (name && name->Length)
device = find_adapter_device_by_name( name );
else
device = find_adapter_device_by_id( 0 ); /* use primary adapter */
if (!device)
{
unlock_display_devices();
return 32;
}
depth = user_driver->pGetDisplayDepth( device->device_name,
!!(device->state_flags & DISPLAY_DEVICE_PRIMARY_DEVICE) );
unlock_display_devices();
return depth;
}
/*********************************************************************** /***********************************************************************
* NtUserEnumDisplayMonitors (win32u.@) * NtUserEnumDisplayMonitors (win32u.@)
*/ */
......
...@@ -334,6 +334,7 @@ extern BOOL enable_thunk_lock DECLSPEC_HIDDEN; ...@@ -334,6 +334,7 @@ extern BOOL enable_thunk_lock DECLSPEC_HIDDEN;
extern HBRUSH get_55aa_brush(void) DECLSPEC_HIDDEN; extern HBRUSH get_55aa_brush(void) DECLSPEC_HIDDEN;
extern DWORD get_dialog_base_units(void) DECLSPEC_HIDDEN; extern DWORD get_dialog_base_units(void) DECLSPEC_HIDDEN;
extern LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, int *height ) DECLSPEC_HIDDEN; extern LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, int *height ) DECLSPEC_HIDDEN;
extern INT get_display_depth( UNICODE_STRING *name ) DECLSPEC_HIDDEN;
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN; extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN; extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
extern BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info ) DECLSPEC_HIDDEN; extern BOOL get_monitor_info( HMONITOR handle, MONITORINFO *info ) DECLSPEC_HIDDEN;
......
...@@ -927,6 +927,14 @@ BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR devname, BOOL is_primary, LPDEVMOD ...@@ -927,6 +927,14 @@ BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR devname, BOOL is_primary, LPDEVMOD
return TRUE; return TRUE;
} }
/***********************************************************************
* GetDisplayDepth (MACDRV.@)
*
*/
INT macdrv_GetDisplayDepth(LPCWSTR name, BOOL is_primary)
{
return get_default_bpp();
}
/*********************************************************************** /***********************************************************************
* GetDeviceGammaRamp (MACDRV.@) * GetDeviceGammaRamp (MACDRV.@)
......
...@@ -276,6 +276,7 @@ static const struct user_driver_funcs macdrv_funcs = ...@@ -276,6 +276,7 @@ static const struct user_driver_funcs macdrv_funcs =
.pDestroyCursorIcon = macdrv_DestroyCursorIcon, .pDestroyCursorIcon = macdrv_DestroyCursorIcon,
.pDestroyWindow = macdrv_DestroyWindow, .pDestroyWindow = macdrv_DestroyWindow,
.pGetCurrentDisplaySettings = macdrv_GetCurrentDisplaySettings, .pGetCurrentDisplaySettings = macdrv_GetCurrentDisplaySettings,
.pGetDisplayDepth = macdrv_GetDisplayDepth,
.pUpdateDisplayDevices = macdrv_UpdateDisplayDevices, .pUpdateDisplayDevices = macdrv_UpdateDisplayDevices,
.pGetCursorPos = macdrv_GetCursorPos, .pGetCursorPos = macdrv_GetCursorPos,
.pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList, .pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList,
......
...@@ -124,6 +124,7 @@ extern BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) DECLSPEC_HIDDEN; ...@@ -124,6 +124,7 @@ extern BOOL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) DECLSPEC_HIDDEN;
extern void macdrv_Beep(void) DECLSPEC_HIDDEN; extern void macdrv_Beep(void) DECLSPEC_HIDDEN;
extern LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid) DECLSPEC_HIDDEN; extern LONG macdrv_ChangeDisplaySettings(LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid) DECLSPEC_HIDDEN;
extern BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode) DECLSPEC_HIDDEN; extern BOOL macdrv_GetCurrentDisplaySettings(LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode) DECLSPEC_HIDDEN;
extern INT macdrv_GetDisplayDepth(LPCWSTR name, BOOL is_primary) DECLSPEC_HIDDEN;
extern LRESULT macdrv_ClipboardWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN; extern LRESULT macdrv_ClipboardWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) DECLSPEC_HIDDEN;
extern BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, extern BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager,
BOOL force, void *param ) DECLSPEC_HIDDEN; BOOL force, void *param ) DECLSPEC_HIDDEN;
......
...@@ -239,6 +239,16 @@ static DWORD get_display_depth(ULONG_PTR display_id) ...@@ -239,6 +239,16 @@ static DWORD get_display_depth(ULONG_PTR display_id)
return screen_bpp; return screen_bpp;
} }
INT X11DRV_GetDisplayDepth(LPCWSTR name, BOOL is_primary)
{
ULONG_PTR id;
if (settings_handler.get_id( name, is_primary, &id ))
return get_display_depth( id );
return screen_bpp;
}
/*********************************************************************** /***********************************************************************
* GetCurrentDisplaySettings (X11DRV.@) * GetCurrentDisplaySettings (X11DRV.@)
* *
......
...@@ -405,6 +405,7 @@ static const struct user_driver_funcs x11drv_funcs = ...@@ -405,6 +405,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pClipCursor = X11DRV_ClipCursor, .pClipCursor = X11DRV_ClipCursor,
.pChangeDisplaySettings = X11DRV_ChangeDisplaySettings, .pChangeDisplaySettings = X11DRV_ChangeDisplaySettings,
.pGetCurrentDisplaySettings = X11DRV_GetCurrentDisplaySettings, .pGetCurrentDisplaySettings = X11DRV_GetCurrentDisplaySettings,
.pGetDisplayDepth = X11DRV_GetDisplayDepth,
.pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices, .pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices,
.pCreateDesktopWindow = X11DRV_CreateDesktopWindow, .pCreateDesktopWindow = X11DRV_CreateDesktopWindow,
.pCreateWindow = X11DRV_CreateWindow, .pCreateWindow = X11DRV_CreateWindow,
......
...@@ -216,6 +216,7 @@ extern BOOL X11DRV_GetCursorPos( LPPOINT pos ) DECLSPEC_HIDDEN; ...@@ -216,6 +216,7 @@ extern BOOL X11DRV_GetCursorPos( LPPOINT pos ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_ClipCursor( LPCRECT clip ) DECLSPEC_HIDDEN; extern BOOL X11DRV_ClipCursor( LPCRECT clip ) DECLSPEC_HIDDEN;
extern LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid ) DECLSPEC_HIDDEN; extern LONG X11DRV_ChangeDisplaySettings( LPDEVMODEW displays, LPCWSTR primary_name, HWND hwnd, DWORD flags, LPVOID lpvoid ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode ) DECLSPEC_HIDDEN; extern BOOL X11DRV_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LPDEVMODEW devmode ) DECLSPEC_HIDDEN;
extern INT X11DRV_GetDisplayDepth( LPCWSTR name, BOOL is_primary ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager, extern BOOL X11DRV_UpdateDisplayDevices( const struct gdi_device_manager *device_manager,
BOOL force, void *param ) DECLSPEC_HIDDEN; BOOL force, void *param ) DECLSPEC_HIDDEN;
extern BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) DECLSPEC_HIDDEN; extern BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) DECLSPEC_HIDDEN;
......
...@@ -299,6 +299,7 @@ struct user_driver_funcs ...@@ -299,6 +299,7 @@ struct user_driver_funcs
/* display modes */ /* display modes */
LONG (*pChangeDisplaySettings)(LPDEVMODEW,LPCWSTR,HWND,DWORD,LPVOID); LONG (*pChangeDisplaySettings)(LPDEVMODEW,LPCWSTR,HWND,DWORD,LPVOID);
BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,BOOL,LPDEVMODEW); BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,BOOL,LPDEVMODEW);
INT (*pGetDisplayDepth)(LPCWSTR,BOOL);
BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*); BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*);
/* windowing functions */ /* windowing functions */
BOOL (*pCreateDesktopWindow)(HWND); BOOL (*pCreateDesktopWindow)(HWND);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment