mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-01 23:40:53 +00:00
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
This commit is contained in:
parent
8e9763871b
commit
d81cf4ed55
|
@ -207,18 +207,13 @@ static INT CDECL nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
|
|||
case BITSPIXEL:
|
||||
{
|
||||
UNICODE_STRING display;
|
||||
DEVMODEW devmode;
|
||||
DC *dc;
|
||||
|
||||
if (NtGdiGetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY)
|
||||
{
|
||||
dc = get_nulldrv_dc( dev );
|
||||
memset( &devmode, 0, sizeof(devmode) );
|
||||
devmode.dmSize = sizeof(devmode);
|
||||
RtlInitUnicodeString( &display, dc->display );
|
||||
if (NtUserEnumDisplaySettings( &display, ENUM_CURRENT_SETTINGS, &devmode, 0 ) &&
|
||||
(devmode.dmFields & DM_BITSPERPEL) && devmode.dmBitsPerPel)
|
||||
return devmode.dmBitsPerPel;
|
||||
return get_display_depth( &display );
|
||||
}
|
||||
return 32;
|
||||
}
|
||||
|
@ -764,6 +759,11 @@ static BOOL nulldrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary, LP
|
|||
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 )
|
||||
{
|
||||
return FALSE;
|
||||
|
@ -1077,6 +1077,11 @@ static BOOL loaderdrv_GetCurrentDisplaySettings( LPCWSTR name, BOOL is_primary,
|
|||
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 )
|
||||
{
|
||||
load_driver()->pSetCursor( cursor );
|
||||
|
@ -1179,6 +1184,7 @@ static const struct user_driver_funcs lazy_load_driver =
|
|||
/* display modes */
|
||||
loaderdrv_ChangeDisplaySettings,
|
||||
loaderdrv_GetCurrentDisplaySettings,
|
||||
loaderdrv_GetDisplayDepth,
|
||||
loaderdrv_UpdateDisplayDevices,
|
||||
/* windowing functions */
|
||||
loaderdrv_CreateDesktopWindow,
|
||||
|
@ -1254,6 +1260,7 @@ void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version
|
|||
SET_USER_FUNC(UpdateClipboard);
|
||||
SET_USER_FUNC(ChangeDisplaySettings);
|
||||
SET_USER_FUNC(GetCurrentDisplaySettings);
|
||||
SET_USER_FUNC(GetDisplayDepth);
|
||||
SET_USER_FUNC(UpdateDisplayDevices);
|
||||
SET_USER_FUNC(CreateDesktopWindow);
|
||||
SET_USER_FUNC(CreateWindow);
|
||||
|
|
|
@ -2655,6 +2655,31 @@ static unsigned int active_monitor_count(void)
|
|||
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.@)
|
||||
*/
|
||||
|
|
|
@ -334,6 +334,7 @@ extern BOOL enable_thunk_lock DECLSPEC_HIDDEN;
|
|||
extern HBRUSH get_55aa_brush(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 INT get_display_depth( UNICODE_STRING *name ) DECLSPEC_HIDDEN;
|
||||
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
|
||||
extern UINT get_monitor_dpi( HMONITOR monitor ) 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
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetDisplayDepth (MACDRV.@)
|
||||
*
|
||||
*/
|
||||
INT macdrv_GetDisplayDepth(LPCWSTR name, BOOL is_primary)
|
||||
{
|
||||
return get_default_bpp();
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* GetDeviceGammaRamp (MACDRV.@)
|
||||
|
|
|
@ -276,6 +276,7 @@ static const struct user_driver_funcs macdrv_funcs =
|
|||
.pDestroyCursorIcon = macdrv_DestroyCursorIcon,
|
||||
.pDestroyWindow = macdrv_DestroyWindow,
|
||||
.pGetCurrentDisplaySettings = macdrv_GetCurrentDisplaySettings,
|
||||
.pGetDisplayDepth = macdrv_GetDisplayDepth,
|
||||
.pUpdateDisplayDevices = macdrv_UpdateDisplayDevices,
|
||||
.pGetCursorPos = macdrv_GetCursorPos,
|
||||
.pGetKeyboardLayoutList = macdrv_GetKeyboardLayoutList,
|
||||
|
|
|
@ -124,6 +124,7 @@ static inline RECT rect_from_cgrect(CGRect cgrect)
|
|||
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 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 BOOL macdrv_UpdateDisplayDevices( const struct gdi_device_manager *device_manager,
|
||||
BOOL force, void *param ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -239,6 +239,16 @@ static DWORD get_display_depth(ULONG_PTR display_id)
|
|||
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.@)
|
||||
*
|
||||
|
|
|
@ -405,6 +405,7 @@ static const struct user_driver_funcs x11drv_funcs =
|
|||
.pClipCursor = X11DRV_ClipCursor,
|
||||
.pChangeDisplaySettings = X11DRV_ChangeDisplaySettings,
|
||||
.pGetCurrentDisplaySettings = X11DRV_GetCurrentDisplaySettings,
|
||||
.pGetDisplayDepth = X11DRV_GetDisplayDepth,
|
||||
.pUpdateDisplayDevices = X11DRV_UpdateDisplayDevices,
|
||||
.pCreateDesktopWindow = X11DRV_CreateDesktopWindow,
|
||||
.pCreateWindow = X11DRV_CreateWindow,
|
||||
|
|
|
@ -216,6 +216,7 @@ extern BOOL X11DRV_GetCursorPos( LPPOINT pos ) 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 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,
|
||||
BOOL force, void *param ) DECLSPEC_HIDDEN;
|
||||
extern BOOL X11DRV_CreateDesktopWindow( HWND hwnd ) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -299,6 +299,7 @@ struct user_driver_funcs
|
|||
/* display modes */
|
||||
LONG (*pChangeDisplaySettings)(LPDEVMODEW,LPCWSTR,HWND,DWORD,LPVOID);
|
||||
BOOL (*pGetCurrentDisplaySettings)(LPCWSTR,BOOL,LPDEVMODEW);
|
||||
INT (*pGetDisplayDepth)(LPCWSTR,BOOL);
|
||||
BOOL (*pUpdateDisplayDevices)(const struct gdi_device_manager *,BOOL,void*);
|
||||
/* windowing functions */
|
||||
BOOL (*pCreateDesktopWindow)(HWND);
|
||||
|
|
Loading…
Reference in a new issue