Skip to contentSkip to conversation

added glyph caching

PATCH New Vesa Jääskeläinen 1 participant 1 message Apr 6, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 added glyph caching

Hi,

This patch adds glyph caching to GRUB 2. It functions like a hash table with paging. If one hash table entry's page is full, new will be allocated and linked to previous. When font module is unloaded, cache will be freed. There is also a support to preload set of glyphs in order to fasten glyph loading times.

It also fixes issue in gfxterm with unknown glyph's character length. Problem caused incorrect rendering of menu entries.

Thanks,
Vesa Jääskeläinen

Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.230

ChangeLog +22 -0
diff -u -r1.230 ChangeLog
@@ -1,3 +1,25 @@
+2006-04-06  Vesa Jaaskelainen  <[email protected]>
+
+	* font/manager.c (GLYPH_CACHE_HASH_SIZE): New define.
+	(GLYPH_CACHE_MAX_PER_PAGE): Likewise.
+	(GLYPH_CACHE_PRELOAD): Likewise.
+	(GLYPH_CACHE_PRELOAD_START): Likewise.
+	(GLYPH_CACHE_PRELOAD_END): Likewise.
+	(glyph_cache_item): New structure.
+	(glyph_cache): Likewise.
+	(cache): New static variable.
+	(add_font): Added preloading of glyphs.
+	(get_hash): New function.
+	(cache_add_glyph): Likewise.
+	(cache_find_glyph): Likewise.
+	(cache_preload): Likewise.
+	(cache_clear): Likewise.
+	(grub_font_get_glyph): Added caching for glyphs.
+	(font_manager): Added cache clearing to module unloading.
+
+	* term/gfxterm.c (grub_gfxterm_getcharwidth): Fixed character 
+	length for unknown glyph.
+
 2006-04-01  Vesa Jaaskelainen  <[email protected]>
 
 	* util/unifont2pff.rb: Removed unnecessary byte ordering.  Now

Index: font/manager.c
===================================================================
RCS file: /sources/grub/grub2/font/manager.c,v
retrieving revision 1.8

manager.c +180 -2

223 lines not on this page · raw message

Index: term/gfxterm.c
===================================================================
RCS file: /sources/grub/grub2/term/gfxterm.c,v
retrieving revision 1.1

gfxterm.c +1 -2
diff -u -r1.1 gfxterm.c
@@ -641,8 +641,7 @@
 {
   struct grub_font_glyph glyph;
   
-  if (! grub_font_get_glyph (c, &glyph))
-    return 0;
+  grub_font_get_glyph (c, &glyph);
 
   return glyph.char_width;
 }