winex11: Use pthread for surface locking.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-04-18 14:40:26 +02:00 committed by Alexandre Julliard
parent acfec2f94c
commit e395c161ed
4 changed files with 19 additions and 8 deletions

View File

@ -3,7 +3,7 @@ MODULE = winex11.drv
IMPORTS = uuid user32 gdi32 win32u
DELAYIMPORTS = comctl32 ole32 shell32 imm32
EXTRAINCL = $(X_CFLAGS)
EXTRALIBS = $(X_LIBS) $(X_EXTRA_LIBS)
EXTRALIBS = $(X_LIBS) $(X_EXTRA_LIBS) $(PTHREAD_LIBS)
EXTRADLLFLAGS = -mcygwin

View File

@ -1583,7 +1583,7 @@ struct x11drv_window_surface
#ifdef HAVE_LIBXXSHM
XShmSegmentInfo shminfo;
#endif
CRITICAL_SECTION crit;
pthread_mutex_t mutex;
BITMAPINFO info; /* variable size, must be last */
};
@ -1831,7 +1831,7 @@ static void x11drv_surface_lock( struct window_surface *window_surface )
{
struct x11drv_window_surface *surface = get_x11_surface( window_surface );
EnterCriticalSection( &surface->crit );
pthread_mutex_lock( &surface->mutex );
}
/***********************************************************************
@ -1841,7 +1841,7 @@ static void x11drv_surface_unlock( struct window_surface *window_surface )
{
struct x11drv_window_surface *surface = get_x11_surface( window_surface );
LeaveCriticalSection( &surface->crit );
pthread_mutex_unlock( &surface->mutex );
}
/***********************************************************************
@ -1987,8 +1987,6 @@ static void x11drv_surface_destroy( struct window_surface *window_surface )
surface->image->data = NULL;
XDestroyImage( surface->image );
}
surface->crit.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &surface->crit );
if (surface->region) NtGdiDeleteObjectApp( surface->region );
HeapFree( GetProcessHeap(), 0, surface );
}
@ -2026,8 +2024,7 @@ struct window_surface *create_surface( Window window, const XVisualInfo *vis, co
surface->info.bmiHeader.biSizeImage = get_dib_image_size( &surface->info );
if (format->bits_per_pixel > 8) set_color_info( vis, &surface->info, use_alpha );
InitializeCriticalSection( &surface->crit );
surface->crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": surface");
init_recursive_mutex( &surface->mutex );
surface->header.funcs = &x11drv_surface_funcs;
surface->header.rect = *rect;

View File

@ -42,6 +42,18 @@ static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
static const struct user_driver_funcs x11drv_funcs;
static const struct gdi_dc_funcs *xrender_funcs;
void init_recursive_mutex( pthread_mutex_t *mutex )
{
pthread_mutexattr_t attr;
pthread_mutexattr_init( &attr );
pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE );
pthread_mutex_init( mutex, &attr );
pthread_mutexattr_destroy( &attr );
}
/**********************************************************************
* device_init
*

View File

@ -28,6 +28,7 @@
#include <limits.h>
#include <stdarg.h>
#include <pthread.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
#include <X11/Xutil.h>
@ -702,6 +703,7 @@ extern POINT root_to_virtual_screen( INT x, INT y ) DECLSPEC_HIDDEN;
extern RECT get_host_primary_monitor_rect(void) DECLSPEC_HIDDEN;
extern RECT get_work_area( const RECT *monitor_rect ) DECLSPEC_HIDDEN;
extern void xinerama_init( unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
extern void init_recursive_mutex( pthread_mutex_t *mutex ) DECLSPEC_HIDDEN;
#define DEPTH_COUNT 3
extern const unsigned int *depths DECLSPEC_HIDDEN;