[cairo-commit] 2 commits - src/cairo-mutex-list-private.h src/win32
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Jan 17 07:24:27 UTC 2021
src/cairo-mutex-list-private.h | 1 +
src/win32/cairo-win32-font.c | 18 +++++++++++++++++-
2 files changed, 18 insertions(+), 1 deletion(-)
New commits:
commit 0224c7802fe637102a63361fce0618b530997ef8
Merge: 4258fbd3b e2ba2e00a
Author: Uli Schlachter <psychon at znc.in>
Date: Sun Jan 17 08:24:00 2021 +0100
Merge gitlab.freedesktop.org:pcpenpal/cairo
commit e2ba2e00a97b9fc496d985572302ad57972a59d2
Author: Yongsu Park <pcpenpal at gmail.com>
Date: Wed Mar 11 21:13:09 2020 +0900
win32: Make font dc thread local
diff --git a/src/cairo-mutex-list-private.h b/src/cairo-mutex-list-private.h
index f46afadb0..ca7403006 100644
--- a/src/cairo-mutex-list-private.h
+++ b/src/cairo-mutex-list-private.h
@@ -53,6 +53,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_font_map_mutex)
#if CAIRO_HAS_WIN32_FONT
CAIRO_MUTEX_DECLARE (_cairo_win32_font_face_mutex)
+CAIRO_MUTEX_DECLARE (_cairo_win32_font_dc_mutex)
#endif
#if CAIRO_HAS_XLIB_SURFACE
diff --git a/src/win32/cairo-win32-font.c b/src/win32/cairo-win32-font.c
index 1f217573b..058403513 100644
--- a/src/win32/cairo-win32-font.c
+++ b/src/win32/cairo-win32-font.c
@@ -162,8 +162,19 @@ _cairo_win32_scaled_font_init_glyph_path (cairo_win32_scaled_font_t *scaled_font
static HDC
_get_global_font_dc (void)
{
- static HDC hdc;
+ static DWORD hdc_tls_index;
+ HDC hdc;
+
+ if (!hdc_tls_index) {
+ CAIRO_MUTEX_LOCK (_cairo_win32_font_dc_mutex);
+ if (!hdc_tls_index) {
+ hdc_tls_index = TlsAlloc ();
+ assert (hdc_tls_index != TLS_OUT_OF_INDEXES);
+ }
+ CAIRO_MUTEX_UNLOCK (_cairo_win32_font_dc_mutex);
+ }
+ hdc = TlsGetValue (hdc_tls_index);
if (!hdc) {
hdc = CreateCompatibleDC (NULL);
if (!hdc) {
@@ -176,6 +187,11 @@ _get_global_font_dc (void)
DeleteDC (hdc);
return NULL;
}
+
+ if (!TlsSetValue (hdc_tls_index, hdc)) {
+ DeleteDC (hdc);
+ return NULL;
+ }
}
return hdc;
More information about the cairo-commit
mailing list