mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-27 22:06:58 +08:00
Add outline glyph cache (unused yet).
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23036 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,28 @@ bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user