Mercurial > mplayer.hg
changeset 23017:f3b04984b0da
Rename glyph cache to bitmap cache.
author | eugeni |
---|---|
date | Fri, 20 Apr 2007 23:02:20 +0000 |
parents | a1ced37f2ee5 |
children | a4517aa83565 |
files | libass/ass_cache.c libass/ass_cache.h libass/ass_render.c |
diffstat | 3 files changed, 40 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/libass/ass_cache.c Fri Apr 20 23:00:30 2007 +0000 +++ b/libass/ass_cache.c Fri Apr 20 23:02:20 2007 +0000 @@ -217,13 +217,13 @@ } //--------------------------------- -// glyph cache +// bitmap cache -hashmap_t* glyph_cache; +hashmap_t* bitmap_cache; -static void glyph_hash_dtor(void* key, size_t key_size, void* value, size_t value_size) +static void bitmap_hash_dtor(void* key, size_t key_size, void* value, size_t value_size) { - glyph_hash_val_t* v = value; + bitmap_hash_val_t* v = value; if (v->bm) ass_free_bitmap(v->bm); if (v->bm_o) ass_free_bitmap(v->bm_o); if (v->bm_s) ass_free_bitmap(v->bm_s); @@ -231,37 +231,37 @@ free(value); } -void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val) +void cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val) { - hashmap_insert(glyph_cache, key, val); + hashmap_insert(bitmap_cache, key, val); } /** - * \brief Get a glyph from glyph cache. + * \brief Get a bitmap from bitmap 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) +bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key) { - return hashmap_find(glyph_cache, key); + return hashmap_find(bitmap_cache, key); } -void ass_glyph_cache_init(void) +void ass_bitmap_cache_init(void) { - glyph_cache = hashmap_init(sizeof(glyph_hash_key_t), - sizeof(glyph_hash_val_t), + bitmap_cache = hashmap_init(sizeof(bitmap_hash_key_t), + sizeof(bitmap_hash_val_t), 0xFFFF + 13, - glyph_hash_dtor, NULL, NULL); + bitmap_hash_dtor, NULL, NULL); } -void ass_glyph_cache_done(void) +void ass_bitmap_cache_done(void) { - hashmap_done(glyph_cache); + hashmap_done(bitmap_cache); } -void ass_glyph_cache_reset(void) +void ass_bitmap_cache_reset(void) { - ass_glyph_cache_done(); - ass_glyph_cache_init(); + ass_bitmap_cache_done(); + ass_bitmap_cache_init(); }
--- a/libass/ass_cache.h Fri Apr 20 23:00:30 2007 +0000 +++ b/libass/ass_cache.h Fri Apr 20 23:02:20 2007 +0000 @@ -27,8 +27,8 @@ void ass_font_cache_done(void); -// describes a glyph; glyphs with equivalents structs are considered identical -typedef struct glyph_hash_key_s { +// describes a bitmap; bitmaps with equivalents structs are considered identical +typedef struct bitmap_hash_key_s { char bitmap; // bool : true = bitmap, false = outline ass_font_t* font; int size; // font size @@ -37,28 +37,27 @@ int bold, italic; char be; // blur edges - // the following affects bitmap glyphs only unsigned scale_x, scale_y; // 16.16 int frx, fry, frz; // signed 16.16 FT_Vector advance; // subpixel shift vector -} glyph_hash_key_t; +} bitmap_hash_key_t; -typedef struct glyph_hash_val_s { - bitmap_t* bm; // the actual glyph bitmaps +typedef struct bitmap_hash_val_s { + bitmap_t* bm; // the actual bitmaps bitmap_t* bm_o; bitmap_t* bm_s; FT_BBox bbox_scaled; // bbox after scaling, but before rotation - FT_Vector advance; // 26.6, advance distance to the next glyph in line -} glyph_hash_val_t; + FT_Vector advance; // 26.6, advance distance to the next bitmap in line +} bitmap_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); +void ass_bitmap_cache_init(void); +void cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val); +bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key); +void ass_bitmap_cache_reset(void); +void ass_bitmap_cache_done(void); -typedef struct hashmap_s hashmap_t; +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); typedef unsigned (*hashmap_hash_t)(void* key, size_t key_size);
--- a/libass/ass_render.c Fri Apr 20 23:00:30 2007 +0000 +++ b/libass/ass_render.c Fri Apr 20 23:02:20 2007 +0000 @@ -112,7 +112,7 @@ int shadow; double frx, fry, frz; // rotation - glyph_hash_key_t hash_key; + bitmap_hash_key_t hash_key; } glyph_info_t; typedef struct line_info_s { @@ -252,7 +252,7 @@ // images_root and related stuff is zero-filled in calloc ass_font_cache_init(); - ass_glyph_cache_init(); + ass_bitmap_cache_init(); text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t)); @@ -266,7 +266,7 @@ void ass_renderer_done(ass_renderer_t* priv) { ass_font_cache_done(); - ass_glyph_cache_done(); + ass_bitmap_cache_done(); if (render_context.stroker) { FT_Stroker_Done(render_context.stroker); render_context.stroker = 0; @@ -386,7 +386,7 @@ int pen_x, pen_y; int i, error; bitmap_t* bm; - glyph_hash_val_t hash_val; + bitmap_hash_val_t hash_val; ass_image_t* head; ass_image_t** tail = &head; @@ -414,7 +414,7 @@ hash_val.bm_s = text_info->glyphs[i].bm_s; hash_val.advance.x = text_info->glyphs[i].advance.x; hash_val.advance.y = text_info->glyphs[i].advance.y; - cache_add_glyph(&(text_info->glyphs[i].hash_key), &hash_val); + cache_add_bitmap(&(text_info->glyphs[i].hash_key), &hash_val); } } @@ -1233,8 +1233,8 @@ static void get_glyph(int symbol, glyph_info_t* info, FT_Vector* advance) { int error; - glyph_hash_val_t* val; - glyph_hash_key_t* key = &(info->hash_key); + bitmap_hash_val_t* val; + bitmap_hash_key_t* key = &(info->hash_key); key->font = render_context.font; key->size = render_context.font_size; @@ -1250,7 +1250,7 @@ key->italic = render_context.italic; key->be = render_context.be; - val = cache_find_glyph(key); + val = cache_find_bitmap(key); /* val = 0; */ if (val) { @@ -1968,7 +1968,7 @@ static void ass_reconfigure(ass_renderer_t* priv) { priv->render_id = ++last_render_id; - ass_glyph_cache_reset(); + ass_bitmap_cache_reset(); ass_free_images(priv->prev_images_root); priv->prev_images_root = 0; }