Commit 2b804c56 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Convert gdi font list to use list.h.

parent 990ec26c
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "gdi_private.h" #include "gdi_private.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(font); WINE_DEFAULT_DEBUG_CHANNEL(font);
...@@ -189,6 +190,7 @@ typedef struct { ...@@ -189,6 +190,7 @@ typedef struct {
} GM; } GM;
struct tagGdiFont { struct tagGdiFont {
struct list entry;
FT_Face ft_face; FT_Face ft_face;
XFORM xform; XFORM xform;
LPWSTR name; LPWSTR name;
...@@ -206,12 +208,11 @@ struct tagGdiFont { ...@@ -206,12 +208,11 @@ struct tagGdiFont {
SHORT yMin; SHORT yMin;
OUTLINETEXTMETRICW *potm; OUTLINETEXTMETRICW *potm;
FONTSIGNATURE fs; FONTSIGNATURE fs;
struct tagGdiFont *next;
}; };
#define INIT_GM_SIZE 128 #define INIT_GM_SIZE 128
static GdiFont GdiFontList = NULL; static struct list gdi_font_list = LIST_INIT(gdi_font_list);
static Family *FontList = NULL; static Family *FontList = NULL;
...@@ -1329,7 +1330,6 @@ static GdiFont alloc_font(void) ...@@ -1329,7 +1330,6 @@ static GdiFont alloc_font(void)
ret->gmsize = INIT_GM_SIZE; ret->gmsize = INIT_GM_SIZE;
ret->gm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ret->gm = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
ret->gmsize * sizeof(*ret->gm)); ret->gmsize * sizeof(*ret->gm));
ret->next = NULL;
ret->potm = NULL; ret->potm = NULL;
ret->xform.eM11 = ret->xform.eM22 = 1.0; ret->xform.eM11 = ret->xform.eM22 = 1.0;
return ret; return ret;
...@@ -1507,6 +1507,7 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -1507,6 +1507,7 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
BOOL bd, it, can_use_bitmap; BOOL bd, it, can_use_bitmap;
LOGFONTW lf; LOGFONTW lf;
CHARSETINFO csi; CHARSETINFO csi;
struct list *elem_ptr;
if (!GetObjectW( hfont, sizeof(lf), &lf )) return NULL; if (!GetObjectW( hfont, sizeof(lf), &lf )) return NULL;
can_use_bitmap = GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_RA_ABLE; can_use_bitmap = GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_RA_ABLE;
...@@ -1517,8 +1518,9 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -1517,8 +1518,9 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
lf.lfEscapement); lf.lfEscapement);
/* check the cache first */ /* check the cache first */
for(ret = GdiFontList; ret; ret = ret->next) { LIST_FOR_EACH(elem_ptr, &gdi_font_list) {
if(ret->hfont == hfont && !memcmp(&ret->xform, &dc->xformWorld2Vport, offsetof(XFORM, eDx)) && ret = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
if(ret->hfont == hfont && !memcmp(&ret->xform, &dc->xformWorld2Vport, offsetof(XFORM, eDx)) &&
(can_use_bitmap || FT_IS_SCALABLE(ret->ft_face))) { (can_use_bitmap || FT_IS_SCALABLE(ret->ft_face))) {
TRACE("returning cached gdiFont(%p) for hFont %p\n", ret, hfont); TRACE("returning cached gdiFont(%p) for hFont %p\n", ret, hfont);
...@@ -1702,19 +1704,19 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -1702,19 +1704,19 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
TRACE("caching: gdiFont=%p hfont=%p\n", ret, hfont); TRACE("caching: gdiFont=%p hfont=%p\n", ret, hfont);
ret->hfont = hfont; ret->hfont = hfont;
ret->aveWidth= lf.lfWidth; ret->aveWidth= lf.lfWidth;
ret->next = GdiFontList; list_add_head(&gdi_font_list, &ret->entry);
GdiFontList = ret;
return ret; return ret;
} }
static void DumpGdiFontList(void) static void dump_gdi_font_list(void)
{ {
GdiFont gdiFont; GdiFont gdiFont;
LOGFONTW lf;
struct list *elem_ptr;
TRACE("---------- gdiFont Cache ----------\n"); TRACE("---------- gdiFont Cache ----------\n");
for(gdiFont = GdiFontList; gdiFont; gdiFont = gdiFont->next) { LIST_FOR_EACH(elem_ptr, &gdi_font_list) {
LOGFONTW lf; gdiFont = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
GetObjectW( gdiFont->hfont, sizeof(lf), &lf ); GetObjectW( gdiFont->hfont, sizeof(lf), &lf );
TRACE("gdiFont=%p hfont=%p (%s)\n", TRACE("gdiFont=%p hfont=%p (%s)\n",
gdiFont, gdiFont->hfont, debugstr_w(lf.lfFaceName)); gdiFont, gdiFont->hfont, debugstr_w(lf.lfFaceName));
...@@ -1730,30 +1732,22 @@ static void DumpGdiFontList(void) ...@@ -1730,30 +1732,22 @@ static void DumpGdiFontList(void)
BOOL WineEngDestroyFontInstance(HFONT handle) BOOL WineEngDestroyFontInstance(HFONT handle)
{ {
GdiFont gdiFont; GdiFont gdiFont;
GdiFont gdiPrev = NULL;
BOOL ret = FALSE; BOOL ret = FALSE;
struct list *elem_ptr;
TRACE("destroying hfont=%p\n", handle); TRACE("destroying hfont=%p\n", handle);
if(TRACE_ON(font)) if(TRACE_ON(font))
DumpGdiFontList(); dump_gdi_font_list();
gdiFont = GdiFontList; elem_ptr = list_head(&gdi_font_list);
while(gdiFont) { while(elem_ptr) {
if(gdiFont->hfont == handle) { gdiFont = LIST_ENTRY(elem_ptr, struct tagGdiFont, entry);
if(gdiPrev) { elem_ptr = list_next(&gdi_font_list, elem_ptr);
gdiPrev->next = gdiFont->next; if(gdiFont->hfont == handle) {
free_font(gdiFont); list_remove(&gdiFont->entry);
gdiFont = gdiPrev->next; free_font(gdiFont);
} else { ret = TRUE;
GdiFontList = gdiFont->next; }
free_font(gdiFont);
gdiFont = GdiFontList;
}
ret = TRUE;
} else {
gdiPrev = gdiFont;
gdiFont = gdiFont->next;
}
} }
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment