[MPlayer-cvslog] r23036 - in trunk/libass: ass_cache.c ass_cache.h

eugeni subversion at mplayerhq.hu
Sat Apr 21 01:04:21 CEST 2007


Author: eugeni
Date: Sat Apr 21 01:04:21 2007
New Revision: 23036

Modified:
   trunk/libass/ass_cache.c
   trunk/libass/ass_cache.h

Log:
Add outline glyph cache (unused yet).


Modified: trunk/libass/ass_cache.c
==============================================================================
--- trunk/libass/ass_cache.c	(original)
+++ trunk/libass/ass_cache.c	Sat Apr 21 01:04:21 2007
@@ -265,3 +265,49 @@ void ass_bitmap_cache_reset(void)
 	ass_bitmap_cache_init();
 }
 
+//---------------------------------
+// glyph cache
+
+hashmap_t* glyph_cache;
+
+static void glyph_hash_dtor(void* key, size_t key_size, void* value, size_t value_size)
+{
+	glyph_hash_val_t* v = value;
+	if (v->glyph) FT_Done_Glyph(v->glyph);
+	free(key);
+	free(value);
+}
+
+void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val)
+{
+	hashmap_insert(glyph_cache, key, val);
+}
+
+/**
+ * \brief Get a glyph from glyph cache.
+ * \param key hash key
+ * \return requested hash val or 0 if not found
+*/ 
+glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key)
+{
+	return hashmap_find(glyph_cache, key);
+}
+
+void ass_glyph_cache_init(void)
+{
+	glyph_cache = hashmap_init(sizeof(glyph_hash_key_t),
+				   sizeof(glyph_hash_val_t),
+				   0xFFFF + 13,
+				   glyph_hash_dtor, NULL, NULL);
+}
+
+void ass_glyph_cache_done(void)
+{
+	hashmap_done(glyph_cache);
+}
+
+void ass_glyph_cache_reset(void)
+{
+	ass_glyph_cache_done();
+	ass_glyph_cache_init();
+}

Modified: trunk/libass/ass_cache.h
==============================================================================
--- trunk/libass/ass_cache.h	(original)
+++ trunk/libass/ass_cache.h	Sat Apr 21 01:04:21 2007
@@ -57,6 +57,28 @@ bitmap_hash_val_t* cache_find_bitmap(bit
 void ass_bitmap_cache_reset(void);
 void ass_bitmap_cache_done(void);
 
+// describes an outline glyph
+typedef struct glyph_hash_key_s {
+	ass_font_t* font;
+	int size; // font size
+	uint32_t ch; // character code
+	int bold, italic;
+	unsigned scale_x, scale_y; // 16.16
+	FT_Vector advance; // subpixel shift vector
+} glyph_hash_key_t;
+
+typedef struct glyph_hash_val_s {
+	FT_Glyph glyph;
+	FT_BBox bbox_scaled; // bbox after scaling, but before rotation
+	FT_Vector advance; // 26.6, advance distance to the next bitmap in line
+} glyph_hash_val_t;
+
+void ass_glyph_cache_init(void);
+void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val);
+glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key);
+void ass_glyph_cache_reset(void);
+void ass_glyph_cache_done(void);
+
 typedef struct hashmap_s hashmap_t; 
 typedef void (*hashmap_item_dtor_t)(void* key, size_t key_size, void* value, size_t value_size);
 typedef int (*hashmap_key_compare_t)(void* key1, void* key2, size_t key_size);



More information about the MPlayer-cvslog mailing list