From 4bb7c96c1c5e6d525a63d7dd2c83f8df8e01f3b0 Mon Sep 17 00:00:00 2001 From: Zhiyi Zhang Date: Fri, 15 Oct 2021 09:56:51 +0800 Subject: [PATCH 42/51] winex11.drv: Initialize XRender extension on module load. To: wine-devel@winehq.org XRender functions need to be called later before the creation of the first X11DRV_PDEVICE. Signed-off-by: Zhiyi Zhang --- dlls/winex11.drv/init.c | 2 +- dlls/winex11.drv/x11drv.h | 4 +++- dlls/winex11.drv/x11drv_main.c | 2 ++ dlls/winex11.drv/xrender.c | 23 ++++++++++++++--------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/dlls/winex11.drv/init.c b/dlls/winex11.drv/init.c index b801d20c725..16f82c364b3 100644 --- a/dlls/winex11.drv/init.c +++ b/dlls/winex11.drv/init.c @@ -62,7 +62,7 @@ void init_recursive_mutex( pthread_mutex_t *mutex ) static void device_init(void) { /* Initialize XRender */ - xrender_funcs = X11DRV_XRender_Init(); + xrender_funcs = get_xrender_funcs(); /* Init Xcursor */ X11DRV_Xcursor_Init(); diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 730210c0eaa..44698dc22dd 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -278,7 +278,8 @@ extern INT X11DRV_YWStoDS( HDC hdc, INT height ) DECLSPEC_HIDDEN; extern BOOL client_side_graphics DECLSPEC_HIDDEN; extern BOOL client_side_with_render DECLSPEC_HIDDEN; extern BOOL shape_layered_windows DECLSPEC_HIDDEN; -extern const struct gdi_dc_funcs *X11DRV_XRender_Init(void) DECLSPEC_HIDDEN; +extern void X11DRV_XRender_Init(void) DECLSPEC_HIDDEN; +extern const struct gdi_dc_funcs *get_xrender_funcs(void) DECLSPEC_HIDDEN; extern struct opengl_funcs *get_glx_driver(UINT) DECLSPEC_HIDDEN; extern const struct vulkan_funcs *get_vulkan_driver(UINT) DECLSPEC_HIDDEN; @@ -442,6 +443,7 @@ extern BOOL show_systray DECLSPEC_HIDDEN; extern BOOL grab_pointer DECLSPEC_HIDDEN; extern BOOL grab_fullscreen DECLSPEC_HIDDEN; extern BOOL usexcomposite DECLSPEC_HIDDEN; +extern BOOL usexrender DECLSPEC_HIDDEN; extern BOOL managed_mode DECLSPEC_HIDDEN; extern BOOL decorated_mode DECLSPEC_HIDDEN; extern BOOL private_color_map DECLSPEC_HIDDEN; diff --git a/dlls/winex11.drv/x11drv_main.c b/dlls/winex11.drv/x11drv_main.c index cd627a9b151..1e5cd5fae6b 100644 --- a/dlls/winex11.drv/x11drv_main.c +++ b/dlls/winex11.drv/x11drv_main.c @@ -65,6 +65,7 @@ Window root_window; BOOL usexvidmode = TRUE; BOOL usexrandr = TRUE; BOOL usexcomposite = TRUE; +BOOL usexrender = FALSE; BOOL use_xkb = TRUE; BOOL use_take_focus = TRUE; BOOL use_primary_selection = FALSE; @@ -681,6 +682,7 @@ static BOOL process_attach(void) #ifdef SONAME_LIBXCOMPOSITE X11DRV_XComposite_Init(); #endif + X11DRV_XRender_Init(); X11DRV_XInput2_Init(); #ifdef HAVE_XKB diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c index be64da90290..97392eba0b7 100644 --- a/dlls/winex11.drv/xrender.c +++ b/dlls/winex11.drv/xrender.c @@ -158,6 +158,11 @@ static inline struct xrender_physdev *get_xrender_dev( PHYSDEV dev ) static const struct gdi_dc_funcs xrender_funcs; +const struct gdi_dc_funcs *get_xrender_funcs(void) +{ + return usexrender ? &xrender_funcs : NULL; +} + static gsCacheEntry *glyphsetCache = NULL; static DWORD glyphsetCacheSize = 0; static INT lastfree = -1; @@ -314,14 +319,14 @@ static int load_xrender_formats(void) * Let's see if our XServer has the extension available * */ -const struct gdi_dc_funcs *X11DRV_XRender_Init(void) +void X11DRV_XRender_Init(void) { int event_base, i; - if (!client_side_with_render) return NULL; - if (!(xrender_handle = dlopen(SONAME_LIBXRENDER, RTLD_NOW))) return NULL; + if (!client_side_with_render) return; + if (!(xrender_handle = dlopen(SONAME_LIBXRENDER, RTLD_NOW))) return; -#define LOAD_FUNCPTR(f) if((p##f = dlsym(xrender_handle, #f)) == NULL) return NULL +#define LOAD_FUNCPTR(f) if((p##f = dlsym(xrender_handle, #f)) == NULL) return #define LOAD_OPTIONAL_FUNCPTR(f) p##f = dlsym(xrender_handle, #f) LOAD_FUNCPTR(XRenderAddGlyphs); LOAD_FUNCPTR(XRenderChangePicture); @@ -345,7 +350,7 @@ const struct gdi_dc_funcs *X11DRV_XRender_Init(void) #undef LOAD_OPTIONAL_FUNCPTR #undef LOAD_FUNCPTR - if (!pXRenderQueryExtension(gdi_display, &event_base, &xrender_error_base)) return NULL; + if (!pXRenderQueryExtension(gdi_display, &event_base, &xrender_error_base)) return; TRACE("Xrender is up and running error_base = %d\n", xrender_error_base); if(!load_xrender_formats()) /* This fails in buggy versions of libXrender.so */ @@ -353,13 +358,13 @@ const struct gdi_dc_funcs *X11DRV_XRender_Init(void) ERR_(winediag)("Wine has detected that you probably have a buggy version " "of libXrender. Because of this client side font rendering " "will be disabled. Please upgrade this library.\n"); - return NULL; + return; } if (!default_visual.red_mask || !default_visual.green_mask || !default_visual.blue_mask) { WARN("one or more of the colour masks are 0, disabling XRENDER. Try running in 16-bit mode or higher.\n"); - return NULL; + return; } glyphsetCache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, @@ -373,7 +378,7 @@ const struct gdi_dc_funcs *X11DRV_XRender_Init(void) } glyphsetCache[i-1].next = -1; - return &xrender_funcs; + usexrender = TRUE; } /* Helper function to convert from a color packed in a 32-bit integer to a XRenderColor */ @@ -2258,7 +2263,7 @@ static const struct gdi_dc_funcs xrender_funcs = #else /* SONAME_LIBXRENDER */ -const struct gdi_dc_funcs *X11DRV_XRender_Init(void) +void X11DRV_XRender_Init(void) { TRACE("XRender support not compiled in.\n"); return NULL; -- 2.32.0