Rebase against d45b3d4fdd7cbcfdba70c327ab90976a3b658da2.

This commit is contained in:
Alistair Leslie-Hughes 2020-10-01 08:58:16 +10:00
parent 76a479203b
commit e634569429
4 changed files with 2 additions and 189 deletions

View File

@ -1,172 +0,0 @@
From cafe4ce8b7c5d0d3c9df47277e6cd53bb8e71b32 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 15 Aug 2015 07:41:17 +0200
Subject: [PATCH] gdi32: Perform lazy initialization of fonts to improve
startup performance.
---
dlls/gdi32/dc.c | 8 +++----
dlls/gdi32/freetype.c | 49 ++++++++++++++++++++++++++++++-------------
2 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index c24b96e2750..ecc095dffec 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -148,11 +148,9 @@ DC *alloc_dc_ptr( WORD magic )
}
dc->nulldrv.hdc = dc->hSelf;
- if (font_driver && !font_driver->pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL ))
- {
- free_dc_ptr( dc );
- return NULL;
- }
+ if (font_driver)
+ font_driver->pCreateDC( &dc->physDev, NULL, NULL, NULL, NULL );
+
return dc;
}
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index 31ad56706ac..91cd6327431 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -108,6 +108,9 @@
WINE_DEFAULT_DEBUG_CHANNEL(font);
+static RTL_RUN_ONCE init_once = RTL_RUN_ONCE_INIT;
+static DWORD WINAPI freetype_lazy_init(RTL_RUN_ONCE *once, void *param, void **context);
+
#ifdef HAVE_FREETYPE
#ifndef HAVE_FT_TRUETYPEENGINETYPE
@@ -3291,6 +3294,7 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
WCHAR path[MAX_PATH];
INT ret = 0;
+ RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL );
GDI_CheckNotLock();
if (ft_handle) /* do it only if we have freetype up and running */
@@ -3325,6 +3329,7 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
*/
HANDLE WineEngAddFontMemResourceEx(PVOID pbFont, DWORD cbFont, PVOID pdv, DWORD *pcFonts)
{
+ RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL );
GDI_CheckNotLock();
if (ft_handle) /* do it only if we have freetype up and running */
@@ -3364,6 +3369,7 @@ BOOL WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
WCHAR path[MAX_PATH];
INT ret = 0;
+ RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL );
GDI_CheckNotLock();
if (ft_handle) /* do it only if we have freetype up and running */
@@ -3677,10 +3683,13 @@ static BOOL create_fot( const WCHAR *resource, const WCHAR *font_file, const str
BOOL WineEngCreateScalableFontResource( DWORD hidden, LPCWSTR resource,
LPCWSTR font_file, LPCWSTR font_path )
{
- char *unix_name = get_ttf_file_name( font_file, font_path );
+ char *unix_name;
struct fontdir fontdir;
BOOL ret = FALSE;
+ RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL );
+
+ unix_name = get_ttf_file_name( font_file, font_path );
if (!unix_name || !get_fontdir( unix_name, &fontdir ))
SetLastError( ERROR_INVALID_PARAMETER );
else
@@ -4194,8 +4203,6 @@ static BOOL init_freetype(void)
FT_UInt interpreter_version = 35;
pFT_Property_Set( library, "truetype", "interpreter-version", &interpreter_version );
}
-
- font_driver = &freetype_funcs;
return TRUE;
sym_not_found:
@@ -4366,21 +4373,13 @@ static void reorder_font_list(void)
default_sans = set_default( default_sans_list );
}
-/*************************************************************
- * WineEngInit
- *
- * Initialize FreeType library and create a list of available faces
- */
-BOOL WineEngInit(void)
+static DWORD WINAPI freetype_lazy_init(RTL_RUN_ONCE *once, void *param, void **context)
{
HKEY hkey;
DWORD disposition;
HANDLE font_mutex;
- /* update locale dependent font info in registry */
- update_font_info();
-
- if(!init_freetype()) return FALSE;
+ if(!init_freetype()) return TRUE;
#ifdef SONAME_LIBFONTCONFIG
init_fontconfig();
@@ -4406,7 +4405,7 @@ BOOL WineEngInit(void)
if((font_mutex = CreateMutexW(NULL, FALSE, font_mutex_nameW)) == NULL)
{
ERR("Failed to create font mutex\n");
- return FALSE;
+ return TRUE;
}
WaitForSingleObject(font_mutex, INFINITE);
@@ -4433,6 +4432,21 @@ BOOL WineEngInit(void)
return TRUE;
}
+/*************************************************************
+ * WineEngInit
+ *
+ * Initialize FreeType library and create a list of available faces
+ */
+BOOL WineEngInit(void)
+{
+ /* update locale dependent font info in registry */
+ update_font_info();
+
+ /* The rest will be initialized later in freetype_lazy_init */
+ font_driver = &freetype_funcs;
+ return TRUE;
+}
+
/* Some fonts have large usWinDescent values, as a result of storing signed short
in unsigned field. That's probably caused by sTypoDescent vs usWinDescent confusion in
some font generation tools. */
@@ -5175,8 +5189,12 @@ static BOOL select_charmap(FT_Face ft_face, FT_Encoding encoding)
static BOOL CDECL freetype_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
LPCWSTR output, const DEVMODEW *devmode )
{
- struct freetype_physdev *physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) );
+ struct freetype_physdev *physdev;
+
+ RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL );
+ if (!ft_handle) return FALSE;
+ physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) );
if (!physdev) return FALSE;
push_dc_driver( dev, &physdev->dev, &freetype_funcs );
return TRUE;
@@ -8753,6 +8771,7 @@ static BOOL CDECL freetype_FontIsLinked( PHYSDEV dev )
*/
BOOL WINAPI GetRasterizerCaps( LPRASTERIZER_STATUS lprs, UINT cbNumBytes)
{
+ /* RtlRunOnceExecuteOnce( &init_once, freetype_lazy_init, NULL, NULL ); */
lprs->nSize = sizeof(RASTERIZER_STATUS);
lprs->wFlags = TT_AVAILABLE | TT_ENABLED;
lprs->nLanguageID = 0;
--
2.25.1

View File

@ -1,2 +0,0 @@
Fixes: Improve startup performance by delaying font initialization

View File

@ -51,7 +51,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "23c6dd55b8c983ec88cada0a6d6c75ee9cd93976"
echo "d45b3d4fdd7cbcfdba70c327ab90976a3b658da2"
}
# Show version information
@ -127,7 +127,6 @@ patch_enable_all ()
enable_dxdiagn_GetChildContainer_Leaf_Nodes="$1"
enable_explorer_Video_Registry_Key="$1"
enable_fonts_Missing_Fonts="$1"
enable_gdi32_Lazy_Font_Initialization="$1"
enable_gdi32_rotation="$1"
enable_gdiplus_Performance_Improvements="$1"
enable_imagehlp_BindImageEx="$1"
@ -472,9 +471,6 @@ patch_enable ()
fonts-Missing_Fonts)
enable_fonts_Missing_Fonts="$2"
;;
gdi32-Lazy_Font_Initialization)
enable_gdi32_Lazy_Font_Initialization="$2"
;;
gdi32-rotation)
enable_gdi32_rotation="$2"
;;
@ -2463,15 +2459,6 @@ if test "$enable_fonts_Missing_Fonts" -eq 1; then
patch_apply fonts-Missing_Fonts/0005-Add-licenses-for-fonts-as-separate-files.patch
fi
# Patchset gdi32-Lazy_Font_Initialization
# |
# | Modified files:
# | * dlls/gdi32/dc.c, dlls/gdi32/freetype.c
# |
if test "$enable_gdi32_Lazy_Font_Initialization" -eq 1; then
patch_apply gdi32-Lazy_Font_Initialization/0001-gdi32-Perform-lazy-initialization-of-fonts-to-improv.patch
fi
# Patchset gdi32-rotation
# |
# | This patchset fixes the following Wine bugs:

View File

@ -1 +1 @@
23c6dd55b8c983ec88cada0a6d6c75ee9cd93976
d45b3d4fdd7cbcfdba70c327ab90976a3b658da2