Module: wine Branch: master Commit: 06dced4eaae078ea701eb8bb593075801fff75ac URL: http://source.winehq.org/git/wine.git/?a=commit;h=06dced4eaae078ea701eb8bb59...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Dec 7 14:36:22 2012 +0100
gdi32: Keep track of the number of fonts on the unused list.
---
dlls/gdi32/freetype.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 5cf34ca..ce8bbd9 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -375,6 +375,7 @@ struct enum_charset_list {
static struct list gdi_font_list = LIST_INIT(gdi_font_list); static struct list unused_gdi_font_list = LIST_INIT(unused_gdi_font_list); +static unsigned int unused_font_count; #define UNUSED_CACHE_SIZE 10 static struct list system_links = LIST_INIT(system_links);
@@ -4307,6 +4308,7 @@ static GdiFont *find_in_cache(HFONT hfont, const LOGFONTW *plf, const FMAT2 *pma hflist = HeapAlloc(GetProcessHeap(), 0, sizeof(*hflist)); hflist->hfont = hfont; list_add_head(&ret->hfontlist, &hflist->entry); + unused_font_count--; return ret; } return NULL; @@ -5021,7 +5023,6 @@ BOOL WineEngDestroyFontInstance(HFONT handle) GdiFont *gdiFont, *next; HFONTLIST *hflist, *hfnext; BOOL ret = FALSE; - int i = 0;
GDI_CheckNotLock(); EnterCriticalSection( &freetype_cs ); @@ -5044,17 +5045,16 @@ BOOL WineEngDestroyFontInstance(HFONT handle) TRACE("Moving to Unused list\n"); list_remove(&gdiFont->entry); list_add_head(&unused_gdi_font_list, &gdiFont->entry); + if (unused_font_count > UNUSED_CACHE_SIZE) + { + gdiFont = LIST_ENTRY( list_tail( &unused_gdi_font_list ), struct tagGdiFont, entry ); + TRACE("freeing %p\n", gdiFont); + list_remove(&gdiFont->entry); + free_font(gdiFont); + } + else unused_font_count++; } } - - - LIST_FOR_EACH_ENTRY_SAFE( gdiFont, next, &unused_gdi_font_list, struct tagGdiFont, entry ) - { - if (i++ < UNUSED_CACHE_SIZE) continue; - TRACE("freeing %p\n", gdiFont); - list_remove(&gdiFont->entry); - free_font(gdiFont); - } LeaveCriticalSection( &freetype_cs ); return ret; }