comparison libass/ass_render.c @ 23017:f3b04984b0da

Rename glyph cache to bitmap cache.
author eugeni
date Fri, 20 Apr 2007 23:02:20 +0000
parents de389ca83df7
children a81c390d4a22
comparison
equal deleted inserted replaced
23016:a1ced37f2ee5 23017:f3b04984b0da
110 // int height; 110 // int height;
111 int be; // blur edges 111 int be; // blur edges
112 int shadow; 112 int shadow;
113 double frx, fry, frz; // rotation 113 double frx, fry, frz; // rotation
114 114
115 glyph_hash_key_t hash_key; 115 bitmap_hash_key_t hash_key;
116 } glyph_info_t; 116 } glyph_info_t;
117 117
118 typedef struct line_info_s { 118 typedef struct line_info_s {
119 int asc, desc; 119 int asc, desc;
120 } line_info_t; 120 } line_info_t;
250 priv->library = library; 250 priv->library = library;
251 priv->ftlibrary = ft; 251 priv->ftlibrary = ft;
252 // images_root and related stuff is zero-filled in calloc 252 // images_root and related stuff is zero-filled in calloc
253 253
254 ass_font_cache_init(); 254 ass_font_cache_init();
255 ass_glyph_cache_init(); 255 ass_bitmap_cache_init();
256 256
257 text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t)); 257 text_info.glyphs = calloc(MAX_GLYPHS, sizeof(glyph_info_t));
258 258
259 ass_init_exit: 259 ass_init_exit:
260 if (priv) mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_Init); 260 if (priv) mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_Init);
264 } 264 }
265 265
266 void ass_renderer_done(ass_renderer_t* priv) 266 void ass_renderer_done(ass_renderer_t* priv)
267 { 267 {
268 ass_font_cache_done(); 268 ass_font_cache_done();
269 ass_glyph_cache_done(); 269 ass_bitmap_cache_done();
270 if (render_context.stroker) { 270 if (render_context.stroker) {
271 FT_Stroker_Done(render_context.stroker); 271 FT_Stroker_Done(render_context.stroker);
272 render_context.stroker = 0; 272 render_context.stroker = 0;
273 } 273 }
274 if (priv && priv->ftlibrary) FT_Done_FreeType(priv->ftlibrary); 274 if (priv && priv->ftlibrary) FT_Done_FreeType(priv->ftlibrary);
384 static ass_image_t* render_text(text_info_t* text_info, int dst_x, int dst_y) 384 static ass_image_t* render_text(text_info_t* text_info, int dst_x, int dst_y)
385 { 385 {
386 int pen_x, pen_y; 386 int pen_x, pen_y;
387 int i, error; 387 int i, error;
388 bitmap_t* bm; 388 bitmap_t* bm;
389 glyph_hash_val_t hash_val; 389 bitmap_hash_val_t hash_val;
390 ass_image_t* head; 390 ass_image_t* head;
391 ass_image_t** tail = &head; 391 ass_image_t** tail = &head;
392 392
393 for (i = 0; i < text_info->length; ++i) { 393 for (i = 0; i < text_info->length; ++i) {
394 if (text_info->glyphs[i].glyph) { 394 if (text_info->glyphs[i].glyph) {
412 hash_val.bm_o = text_info->glyphs[i].bm_o; 412 hash_val.bm_o = text_info->glyphs[i].bm_o;
413 hash_val.bm = text_info->glyphs[i].bm; 413 hash_val.bm = text_info->glyphs[i].bm;
414 hash_val.bm_s = text_info->glyphs[i].bm_s; 414 hash_val.bm_s = text_info->glyphs[i].bm_s;
415 hash_val.advance.x = text_info->glyphs[i].advance.x; 415 hash_val.advance.x = text_info->glyphs[i].advance.x;
416 hash_val.advance.y = text_info->glyphs[i].advance.y; 416 hash_val.advance.y = text_info->glyphs[i].advance.y;
417 cache_add_glyph(&(text_info->glyphs[i].hash_key), &hash_val); 417 cache_add_bitmap(&(text_info->glyphs[i].hash_key), &hash_val);
418 } 418 }
419 419
420 } 420 }
421 } 421 }
422 422
1231 * \return 0 on success 1231 * \return 0 on success
1232 */ 1232 */
1233 static void get_glyph(int symbol, glyph_info_t* info, FT_Vector* advance) 1233 static void get_glyph(int symbol, glyph_info_t* info, FT_Vector* advance)
1234 { 1234 {
1235 int error; 1235 int error;
1236 glyph_hash_val_t* val; 1236 bitmap_hash_val_t* val;
1237 glyph_hash_key_t* key = &(info->hash_key); 1237 bitmap_hash_key_t* key = &(info->hash_key);
1238 1238
1239 key->font = render_context.font; 1239 key->font = render_context.font;
1240 key->size = render_context.font_size; 1240 key->size = render_context.font_size;
1241 key->ch = symbol; 1241 key->ch = symbol;
1242 key->outline = (render_context.border * 0xFFFF); // convert to 16.16 1242 key->outline = (render_context.border * 0xFFFF); // convert to 16.16
1248 key->advance = *advance; 1248 key->advance = *advance;
1249 key->bold = render_context.bold; 1249 key->bold = render_context.bold;
1250 key->italic = render_context.italic; 1250 key->italic = render_context.italic;
1251 key->be = render_context.be; 1251 key->be = render_context.be;
1252 1252
1253 val = cache_find_glyph(key); 1253 val = cache_find_bitmap(key);
1254 /* val = 0; */ 1254 /* val = 0; */
1255 1255
1256 if (val) { 1256 if (val) {
1257 info->glyph = info->outline_glyph = 0; 1257 info->glyph = info->outline_glyph = 0;
1258 info->bm = val->bm; 1258 info->bm = val->bm;
1966 } 1966 }
1967 1967
1968 static void ass_reconfigure(ass_renderer_t* priv) 1968 static void ass_reconfigure(ass_renderer_t* priv)
1969 { 1969 {
1970 priv->render_id = ++last_render_id; 1970 priv->render_id = ++last_render_id;
1971 ass_glyph_cache_reset(); 1971 ass_bitmap_cache_reset();
1972 ass_free_images(priv->prev_images_root); 1972 ass_free_images(priv->prev_images_root);
1973 priv->prev_images_root = 0; 1973 priv->prev_images_root = 0;
1974 } 1974 }
1975 1975
1976 void ass_set_frame_size(ass_renderer_t* priv, int w, int h) 1976 void ass_set_frame_size(ass_renderer_t* priv, int w, int h)