summaryrefslogtreecommitdiff
path: root/pango/pangowin32.c
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2019-07-22 17:07:36 +0800
committerMatthias Clasen <mclasen@redhat.com>2019-07-25 01:01:31 -0400
commit451bdb03e82caa54fe432e202aac9349c213a13c (patch)
treea6c2b0736214df71a1321cdc643357f28fed4ad6 /pango/pangowin32.c
parent85b32f41ae958ce269f2946b36b2d682903a89e1 (diff)
downloadpango-451bdb03e82caa54fe432e202aac9349c213a13c.tar.gz
PangoWin32: Make font discovery thread-safe
Make font discovery using GDI/Unicscribe on Windows thread-safe, by: -Making the alias HashTable a part of the _PangoWin32FontMap struct, so that we only need to initialize this once when we initialize the PangoFontMap on Win32. Make sure that we fill in that hash table with the fonts items we ask from the system once and only once as we initialize the PangoWin32FontMap. -Make the warned_fonts HashTable a part of the _PangoWin32FontMap struct as well, and create the HashTable when we init the PangoWin32FontMap. -Make the access to the common HDC in pangowin32.c where Alex mentioned that could be thread-unsafe done through pango_win32_get_dc(). At this point the test-pangocairo-threads will pass in Meson, tested for 20 successive rounds using 'meson test test-pangocairo-threads'. Note that we still get the "Pango-WARNING **:hh:mm:ss.sss: All font fallbacks failed!!!", but at least we are doing much better on PangoWin32 in terms of thread-safety.
Diffstat (limited to 'pango/pangowin32.c')
-rw-r--r--pango/pangowin32.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 8d175760..09750199 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -456,15 +456,15 @@ pango_win32_font_get_glyph_extents (PangoFont *font,
if (!info)
{
+ HDC hdc = pango_win32_get_dc ();
+
info = g_new0 (PangoWin32GlyphInfo, 1);
memset (&gm, 0, sizeof (gm));
hfont = _pango_win32_font_get_hfont (font);
- SelectObject (_pango_win32_hdc, hfont);
- /* FIXME: (Alex) This constant reuse of _pango_win32_hdc is
- not thread-safe */
- res = GetGlyphOutlineA (_pango_win32_hdc,
+ SelectObject (hdc, hfont);
+ res = GetGlyphOutlineA (hdc,
glyph_index,
GGO_METRICS | GGO_GLYPH_INDEX,
&gm,