Commit 73bf140c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Use user_driver_funcs to pass driver to __wine_set_display_driver.

parent fd675485
......@@ -37,7 +37,7 @@ static char driver_load_error[80];
static BOOL CDECL nodrv_CreateWindow( HWND hwnd );
static BOOL load_desktop_driver( HWND hwnd, HMODULE *module )
static BOOL load_desktop_driver( HWND hwnd )
{
BOOL ret = FALSE;
HKEY hkey;
......@@ -61,21 +61,19 @@ static BOOL load_desktop_driver( HWND hwnd, HMODULE *module )
{
if (wcscmp( path, L"null" ))
{
ret = (*module = LoadLibraryW( path )) != NULL;
ret = LoadLibraryW( path ) != NULL;
if (!ret) ERR( "failed to load %s\n", debugstr_w(path) );
}
else
{
__wine_set_user_driver( &null_driver, WINE_GDI_DRIVER_VERSION );
*module = NULL;
ret = TRUE;
}
TRACE( "%s %p\n", debugstr_w(path), *module );
TRACE( "%s\n", debugstr_w(path) );
}
else
{
size = sizeof(driver_load_error);
*module = NULL;
RegQueryValueExA( hkey, "DriverError", NULL, NULL, (BYTE *)driver_load_error, &size );
}
RegCloseKey( hkey );
......@@ -88,9 +86,8 @@ static const struct user_driver_funcs *load_driver(void)
struct user_driver_funcs driver;
USEROBJECTFLAGS flags;
HWINSTA winstation;
HMODULE module;
if (!load_desktop_driver( GetDesktopWindow(), &module ) || USER_Driver == &lazy_load_driver)
if (!load_desktop_driver( GetDesktopWindow() ) || USER_Driver == &lazy_load_driver)
{
memset( &driver, 0, sizeof(driver) );
winstation = NtUserGetProcessWindowStation();
......@@ -101,7 +98,6 @@ static const struct user_driver_funcs *load_driver(void)
__wine_set_user_driver( &driver, WINE_GDI_DRIVER_VERSION );
}
if (module) __wine_set_display_driver( module );
register_builtin_classes();
return USER_Driver;
}
......@@ -652,5 +648,8 @@ void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT v
{
/* another thread beat us to it */
HeapFree( GetProcessHeap(), 0, driver );
driver = prev;
}
__wine_set_display_driver( driver, version );
}
......@@ -56,7 +56,7 @@ struct d3dkmt_device
struct list entry; /* List entry */
};
const struct gdi_dc_funcs *driver_funcs;
static const struct user_driver_funcs *user_driver;
static struct list d3dkmt_adapters = LIST_INIT( d3dkmt_adapters );
static struct list d3dkmt_devices = LIST_INIT( d3dkmt_devices );
......@@ -70,30 +70,16 @@ static pthread_mutex_t driver_lock = PTHREAD_MUTEX_INITIALIZER;
*/
const struct gdi_dc_funcs *get_display_driver(void)
{
if (!driver_funcs)
if (!user_driver)
{
if (!user_callbacks || !user_callbacks->pGetDesktopWindow() || !driver_funcs)
if (!user_callbacks || !user_callbacks->pGetDesktopWindow() || !user_driver)
{
static struct gdi_dc_funcs empty_funcs;
static struct user_driver_funcs empty_funcs;
WARN( "failed to load the display driver, falling back to null driver\n" );
driver_funcs = &empty_funcs;
__wine_set_display_driver( &empty_funcs, WINE_GDI_DRIVER_VERSION );
}
}
return driver_funcs;
}
void CDECL set_display_driver( void *proc )
{
const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int ) = proc;
const struct gdi_dc_funcs *funcs = NULL;
funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
if (!funcs)
{
ERR( "Could not create graphics driver\n" );
NtTerminateProcess( GetCurrentThread(), 1 );
}
InterlockedExchangePointer( (void **)&driver_funcs, (void *)funcs );
return &user_driver->dc_funcs;
}
struct monitor_info
......@@ -137,8 +123,8 @@ static BOOL CDECL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT
static BOOL CDECL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
{
if (!driver_funcs || !driver_funcs->pCreateCompatibleDC) return TRUE;
return driver_funcs->pCreateCompatibleDC( NULL, pdev );
if (!user_driver || !user_driver->dc_funcs.pCreateCompatibleDC) return TRUE;
return user_driver->dc_funcs.pCreateCompatibleDC( NULL, pdev );
}
static BOOL CDECL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR device, LPCWSTR output,
......@@ -746,6 +732,21 @@ const struct gdi_dc_funcs null_driver =
/******************************************************************************
* __wine_set_display_driver (win32u.@)
*/
void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version )
{
if (version != WINE_GDI_DRIVER_VERSION)
{
ERR( "version mismatch, driver wants %u but win32u has %u\n",
version, WINE_GDI_DRIVER_VERSION );
return;
}
InterlockedExchangePointer( (void **)&user_driver, funcs );
}
/******************************************************************************
* NtGdiExtEscape (win32u.@)
*
* Access capabilities of a particular device that are not available through GDI.
......
......@@ -1181,7 +1181,7 @@ static struct unix_funcs unix_funcs =
__wine_get_vulkan_driver,
__wine_get_wgl_driver,
__wine_make_gdi_object_system,
set_display_driver,
__wine_set_display_driver,
__wine_set_visible_region,
};
......
......@@ -213,7 +213,6 @@ extern const struct gdi_dc_funcs dib_driver DECLSPEC_HIDDEN;
extern const struct gdi_dc_funcs path_driver DECLSPEC_HIDDEN;
extern const struct gdi_dc_funcs font_driver DECLSPEC_HIDDEN;
extern const struct gdi_dc_funcs *get_display_driver(void) DECLSPEC_HIDDEN;
extern void CDECL set_display_driver( void *proc ) DECLSPEC_HIDDEN;
/* font.c */
......
......@@ -211,7 +211,7 @@ struct unix_funcs
const struct vulkan_funcs * (CDECL *get_vulkan_driver)( HDC hdc, UINT version );
struct opengl_funcs * (CDECL *get_wgl_driver)( HDC hdc, UINT version );
void (CDECL *make_gdi_object_system)( HGDIOBJ handle, BOOL set );
void (CDECL *set_display_driver)( void *proc );
void (CDECL *set_display_driver)( struct user_driver_funcs *funcs, UINT version );
void (CDECL *set_visible_region)( HDC hdc, HRGN hrgn, const RECT *vis_rect, const RECT *device_rect,
struct window_surface *surface );
};
......
......@@ -24,9 +24,6 @@
#include "ntgdi.h"
#include "win32u_private.h"
#include "wine/unixlib.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(gdi);
static const struct unix_funcs *unix_funcs;
......@@ -675,21 +672,9 @@ struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version )
/***********************************************************************
* __wine_set_display_driver (win32u.@)
*/
void CDECL __wine_set_display_driver( HMODULE module )
void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version )
{
void *wine_get_gdi_driver;
ANSI_STRING name_str;
if (!module) return;
RtlInitAnsiString( &name_str, "wine_get_gdi_driver" );
LdrGetProcedureAddress( module, &name_str, 0, &wine_get_gdi_driver );
if (!wine_get_gdi_driver)
{
ERR( "Could not create graphics driver %p\n", module );
return;
}
unix_funcs->set_display_driver( wine_get_gdi_driver );
return unix_funcs->set_display_driver( funcs, version );
}
static void *get_user_proc( const char *name, BOOL force_load )
......
......@@ -313,20 +313,6 @@ static const struct user_driver_funcs android_drv_funcs =
};
/******************************************************************************
* ANDROID_get_gdi_driver
*/
const struct gdi_dc_funcs * CDECL ANDROID_get_gdi_driver( unsigned int version )
{
if (version != WINE_GDI_DRIVER_VERSION)
{
ERR( "version mismatch, gdi32 wants %u but wineandroid has %u\n", version, WINE_GDI_DRIVER_VERSION );
return NULL;
}
return &android_drv_funcs.dc_funcs;
}
static const JNINativeMethod methods[] =
{
{ "wine_desktop_changed", "(II)V", desktop_changed },
......
# GDI driver
@ cdecl wine_get_gdi_driver(long) ANDROID_get_gdi_driver
# Desktop
@ cdecl wine_create_desktop(long long) ANDROID_create_desktop
......
......@@ -315,17 +315,3 @@ void init_user_driver(void)
{
__wine_set_user_driver( &macdrv_funcs, WINE_GDI_DRIVER_VERSION );
}
/******************************************************************************
* macdrv_get_gdi_driver
*/
const struct gdi_dc_funcs * CDECL macdrv_get_gdi_driver(unsigned int version)
{
if (version != WINE_GDI_DRIVER_VERSION)
{
ERR("version mismatch, gdi32 wants %u but winemac has %u\n", version, WINE_GDI_DRIVER_VERSION);
return NULL;
}
return &macdrv_funcs.dc_funcs;
}
# GDI driver
@ cdecl wine_get_gdi_driver(long) macdrv_get_gdi_driver
# System tray
@ cdecl wine_notify_icon(long ptr)
......
......@@ -433,17 +433,3 @@ void init_user_driver(void)
{
__wine_set_user_driver( &x11drv_funcs, WINE_GDI_DRIVER_VERSION );
}
/******************************************************************************
* X11DRV_get_gdi_driver
*/
const struct gdi_dc_funcs * CDECL X11DRV_get_gdi_driver( unsigned int version )
{
if (version != WINE_GDI_DRIVER_VERSION)
{
ERR( "version mismatch, gdi32 wants %u but winex11 has %u\n", version, WINE_GDI_DRIVER_VERSION );
return NULL;
}
return &x11drv_funcs.dc_funcs;
}
# GDI driver
@ cdecl wine_get_gdi_driver(long) X11DRV_get_gdi_driver
# WinTab32
@ cdecl AttachEventQueueToTablet(long) X11DRV_AttachEventQueueToTablet
@ cdecl GetCurrentPacket(ptr) X11DRV_GetCurrentPacket
......
......@@ -167,7 +167,7 @@ struct gdi_dc_funcs
};
/* increment this when you change the DC function table */
#define WINE_GDI_DRIVER_VERSION 69
#define WINE_GDI_DRIVER_VERSION 70
#define GDI_PRIORITY_NULL_DRV 0 /* null driver */
#define GDI_PRIORITY_FONT_DRV 100 /* any font driver */
......@@ -310,7 +310,7 @@ WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
const RECT *device_rect, struct window_surface *surface );
extern void CDECL __wine_set_display_driver( HMODULE module );
extern void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version );
extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver( HDC hdc, UINT version );
......
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