gdi32: Use pthread mutex in dib driver.

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 2021-10-04 15:03:16 +01:00 committed by Alexandre Julliard
parent ea65f57aca
commit fb6421f229
2 changed files with 5 additions and 14 deletions

View File

@ -23,6 +23,7 @@
#endif
#include <assert.h>
#include <pthread.h>
#include "ntgdi_private.h"
#include "dibdrv.h"
@ -59,14 +60,7 @@ struct cached_font
static struct list font_cache = LIST_INIT( font_cache );
static CRITICAL_SECTION font_cache_cs;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &font_cache_cs,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": font_cache_cs") }
};
static CRITICAL_SECTION font_cache_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
static pthread_mutex_t font_cache_lock = PTHREAD_MUTEX_INITIALIZER;
static BOOL brush_rect( dibdrv_physdev *pdev, dib_brush *brush, const RECT *rect, HRGN clip )
@ -575,7 +569,7 @@ static struct cached_font *add_cached_font( DC *dc, HFONT hfont, UINT aa_flags )
font.aa_flags = aa_flags;
font.hash = font_cache_hash( &font );
EnterCriticalSection( &font_cache_cs );
pthread_mutex_lock( &font_cache_lock );
LIST_FOR_EACH_ENTRY( ptr, &font_cache, struct cached_font, entry )
{
if (!font_cache_cmp( &font, ptr ))
@ -608,7 +602,7 @@ static struct cached_font *add_cached_font( DC *dc, HFONT hfont, UINT aa_flags )
}
else if (!(ptr = malloc( sizeof(*ptr) )))
{
LeaveCriticalSection( &font_cache_cs );
pthread_mutex_unlock( &font_cache_lock );
return NULL;
}
@ -617,7 +611,7 @@ static struct cached_font *add_cached_font( DC *dc, HFONT hfont, UINT aa_flags )
memset( ptr->glyphs, 0, sizeof(ptr->glyphs) );
done:
list_add_head( &font_cache, &ptr->entry );
LeaveCriticalSection( &font_cache_cs );
pthread_mutex_unlock( &font_cache_lock );
TRACE( "%d %s -> %p\n", ptr->lf.lfHeight, debugstr_w(ptr->lf.lfFaceName), ptr );
return ptr;
}

View File

@ -395,7 +395,4 @@ static inline LONG win32u_wcstol( LPCWSTR s, LPWSTR *end, INT base )
#define wcsrchr(s,c) win32u_wcsrchr(s,c)
#define wcstol(s,e,b) win32u_wcstol(s,e,b)
#define EnterCriticalSection RtlEnterCriticalSection
#define LeaveCriticalSection RtlLeaveCriticalSection
#endif /* __WINE_WIN32U_PRIVATE */