Added patch to improve startup performance by delaying font initialization.

This commit is contained in:
Sebastian Lackner 2015-08-15 18:39:18 +02:00
parent 2c35b17c61
commit faac0015a6
5 changed files with 192 additions and 1 deletions

View File

@ -39,7 +39,7 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [7]:**
**Bug fixes and features included in the next upcoming release [8]:**
* Add IDragSourceHelper stub interface ([Wine Bug #24699](https://bugs.winehq.org/show_bug.cgi?id=24699))
* Catch invalid memory accesses in imagehlp.CheckSumMappedFile
@ -47,6 +47,7 @@ Included bug fixes and improvements
* Implement enumeration of sound devices and basic properties to dxdiagn ([Wine Bug #32613](https://bugs.winehq.org/show_bug.cgi?id=32613))
* Implement special handling for calling GetChildContainer with an empty string ([Wine Bug #38014](https://bugs.winehq.org/show_bug.cgi?id=38014))
* Implement vcomp locking functions ([Wine Bug #26688](https://bugs.winehq.org/show_bug.cgi?id=26688))
* Improve startup performance by delaying font initialization
* Properly implement imagehlp.ImageLoad and ImageUnload

2
debian/changelog vendored
View File

@ -7,6 +7,8 @@ wine-staging (1.7.50) UNRELEASED; urgency=low
* Added patch to implement special handling for calling GetChildContainer with
an empty string.
* Added patch for shell32 IDragSourceHelper stub interface.
* Added patch to improve startup performance by delaying font initialization
(fixes Wine Staging Bug #401).
* Removed patch to move security cookie initialization from memory management
to loader.
-- Sebastian Lackner <sebastian@fds-team.de> Tue, 11 Aug 2015 06:12:14 +0200

View File

@ -0,0 +1,170 @@
From 029c387205b7a5d0d62df10512ae068980313bc3 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 15 Aug 2015 07:41:17 +0200
Subject: gdi32: Perform lazy initialization of fonts to improve startup
performance.
---
dlls/gdi32/dc.c | 8 +++-----
dlls/gdi32/freetype.c | 48 +++++++++++++++++++++++++++++++++---------------
2 files changed, 36 insertions(+), 20 deletions(-)
diff --git a/dlls/gdi32/dc.c b/dlls/gdi32/dc.c
index 5146f5b..91ad953 100644
--- a/dlls/gdi32/dc.c
+++ b/dlls/gdi32/dc.c
@@ -147,11 +147,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 1187598..446212f 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -110,6 +110,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
@@ -3112,6 +3115,7 @@ INT WineEngAddFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
{
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 */
@@ -3154,6 +3158,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 */
@@ -3192,6 +3197,7 @@ BOOL WineEngRemoveFontResourceEx(LPCWSTR file, DWORD flags, PVOID pdv)
{
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 */
@@ -3513,10 +3519,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
@@ -3948,8 +3957,6 @@ static BOOL init_freetype(void)
FT_SimpleVersion = ((FT_Version.major << 16) & 0xff0000) |
((FT_Version.minor << 8) & 0x00ff00) |
((FT_Version.patch ) & 0x0000ff);
-
- font_driver = &freetype_funcs;
return TRUE;
sym_not_found:
@@ -4136,20 +4143,12 @@ static void reorder_font_list(void)
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)
{
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();
@@ -4158,7 +4157,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);
@@ -4185,6 +4184,20 @@ 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;
+}
static LONG calc_ppem_for_height(FT_Face ft_face, LONG height)
{
@@ -4856,8 +4869,12 @@ static BOOL select_charmap(FT_Face ft_face, FT_Encoding encoding)
static BOOL 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;
@@ -8124,6 +8141,7 @@ static BOOL 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.5.0

View File

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

View File

@ -125,6 +125,7 @@ patch_enable_all ()
enable_fltmgr_Stub_SYS="$1"
enable_fonts_Missing_Fonts="$1"
enable_gdi32_Default_Palette="$1"
enable_gdi32_Lazy_Font_Initialization="$1"
enable_gdi32_MaxPixelFormats="$1"
enable_gdi32_MultiMonitor="$1"
enable_gdiplus_GdipCreateEffect="$1"
@ -462,6 +463,9 @@ patch_enable ()
gdi32-Default_Palette)
enable_gdi32_Default_Palette="$2"
;;
gdi32-Lazy_Font_Initialization)
enable_gdi32_Lazy_Font_Initialization="$2"
;;
gdi32-MaxPixelFormats)
enable_gdi32_MaxPixelFormats="$2"
;;
@ -2948,6 +2952,18 @@ if test "$enable_gdi32_Default_Palette" -eq 1; then
) >> "$patchlist"
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
(
echo '+ { "Sebastian Lackner", "gdi32: Perform lazy initialization of fonts to improve startup performance.", 1 },';
) >> "$patchlist"
fi
# Patchset gdi32-MaxPixelFormats
# |
# | This patchset fixes the following Wine bugs: