annotate libass/ass_cache.c @ 19774:109e241c0cca

in mp_dvdnav_handle_input() assign the currently selected button, shown in the OSD by main()
author nicodvb
date Sat, 09 Sep 2006 22:40:22 +0000
parents 8f46b547db39
children bcc792bfa431
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
1 #include "config.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
2
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
3 #include <ft2build.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
4 #include FT_FREETYPE_H
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
5
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
6 #include <assert.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
7
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
8 #include "mp_msg.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
9 #include "ass_fontconfig.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
10 #include "ass_cache.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
11
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
12
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
13 typedef struct face_cache_item_s {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
14 face_desc_t desc;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
15 char* path;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
16 int index;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
17 FT_Face face;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
18 } face_cache_item_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
19
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
20 #define MAX_FACE_CACHE_SIZE 100
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
21
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
22 static face_cache_item_t* face_cache;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23 static int face_cache_size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
24
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
25 extern int no_more_font_messages;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
26
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
27 static int font_compare(face_desc_t* a, face_desc_t* b) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
28 if (strcmp(a->family, b->family) != 0)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
29 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
30 if (a->bold != b->bold)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
31 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
32 if (a->italic != b->italic)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
33 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34 return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
35 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
36
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
37 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38 * \brief Get a face object, either from cache or created through FreeType+FontConfig.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
39 * \param library FreeType library object
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
40 * \param fontconfig_priv fontconfig private data
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
41 * \param desc required face description
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
42 * \param face out: the face object
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
43 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
44 int ass_new_face(FT_Library library, void* fontconfig_priv, face_desc_t* desc, /*out*/ FT_Face* face)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
45 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
46 FT_Error error;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
47 int i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
48 char* path;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
49 int index;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
50 face_cache_item_t* item;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
51
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
52 for (i=0; i<face_cache_size; ++i)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
53 if (font_compare(desc, &(face_cache[i].desc))) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
54 *face = face_cache[i].face;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
55 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
56 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
57
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
58 if (face_cache_size == MAX_FACE_CACHE_SIZE) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
59 mp_msg(MSGT_GLOBAL, MSGL_FATAL, "Too many fonts\n");
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
60 return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
61 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
62
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
63 path = fontconfig_select(fontconfig_priv, desc->family, desc->bold, desc->italic, &index);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
64
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
65 error = FT_New_Face(library, path, index, face);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
66 if (error) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
67 if (!no_more_font_messages)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
68 mp_msg(MSGT_GLOBAL, MSGL_WARN, "Error opening font: %s, %d\n", path, index);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
69 no_more_font_messages = 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
70 return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
71 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
72
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
73 item = face_cache + face_cache_size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
74 item->path = strdup(path);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
75 item->index = index;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
76 item->face = *face;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
77 memcpy(&(item->desc), desc, sizeof(face_desc_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
78 face_cache_size++;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
79 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
80 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
81
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
82 void ass_face_cache_init(void)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
83 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
84 face_cache = calloc(MAX_FACE_CACHE_SIZE, sizeof(face_cache_item_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
85 face_cache_size = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
86 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
87
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
88 void ass_face_cache_done(void)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
89 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
90 int i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
91 for (i = 0; i < face_cache_size; ++i) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
92 face_cache_item_t* item = face_cache + i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
93 if (item->face) FT_Done_Face(item->face);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
94 if (item->path) free(item->path);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
95 // FIXME: free desc ?
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
96 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
97 free(face_cache);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
98 face_cache_size = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
99 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
100
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
101 //---------------------------------
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
102 // glyph cache
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
103
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
104 #define GLYPH_HASH_SIZE (0xFFFF + 13)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
105
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
106 typedef struct glyph_hash_item_s {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
107 glyph_hash_key_t key;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
108 glyph_hash_val_t val;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
109 struct glyph_hash_item_s* next;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
110 } glyph_hash_item_t;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
111
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
112 typedef glyph_hash_item_t* glyph_hash_item_p;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
113
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
114 static glyph_hash_item_p* glyph_hash_root;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
115 static int glyph_hash_size;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
116
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
117 static int glyph_compare(glyph_hash_key_t* a, glyph_hash_key_t* b) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
118 if (memcmp(a, b, sizeof(glyph_hash_key_t)) == 0)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
119 return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
120 else
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
121 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
122 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
123
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
124 static unsigned glyph_hash(glyph_hash_key_t* key) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
125 unsigned val = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
126 unsigned i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
127 for (i = 0; i < sizeof(key->face); ++i)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
128 val += *(unsigned char *)(&(key->face) + i);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
129 val <<= 21;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
130
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
131 if (key->bitmap) val &= 0x80000000;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
132 val += key->index;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
133 val += key->size << 8;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
134 val += key->outline << 3;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
135 val += key->advance.x << 10;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
136 val += key->advance.y << 16;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
137 val += key->bold << 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
138 val += key->italic << 20;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
139 return val;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
140 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
141
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
142 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
143 * \brief Add a glyph to glyph cache.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
144 * \param key hash key
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
145 * \param val hash val: 2 bitmap glyphs + some additional info
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
146 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
147 void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
148 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
149 unsigned hash = glyph_hash(key);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
150 glyph_hash_item_t** next = glyph_hash_root + (hash % GLYPH_HASH_SIZE);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
151 while (*next) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
152 if (glyph_compare(key, &((*next)->key)))
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
153 return;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
154 next = &((*next)->next);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
155 assert(next);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
156 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
157 (*next) = malloc(sizeof(glyph_hash_item_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
158 // (*next)->desc = glyph_key_copy(key, &((*next)->key));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
159 memcpy(&((*next)->key), key, sizeof(glyph_hash_key_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
160 memcpy(&((*next)->val), val, sizeof(glyph_hash_val_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
161 (*next)->next = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
162
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
163 glyph_hash_size ++;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
164 /* if (glyph_hash_size && (glyph_hash_size % 25 == 0)) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
165 printf("\nGlyph cache: %d entries, %d bytes\n", glyph_hash_size, glyph_hash_size * sizeof(glyph_hash_item_t));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
166 } */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
167 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
168
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
169 /**
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
170 * \brief Get a glyph from glyph cache.
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
171 * \param key hash key
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
172 * \return requested hash val or 0 if not found
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
173 */
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
174 glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
175 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
176 unsigned hash = glyph_hash(key);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
177 glyph_hash_item_t* item = glyph_hash_root[hash % GLYPH_HASH_SIZE];
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
178 while (item) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
179 if (glyph_compare(key, &(item->key))) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
180 return &(item->val);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
181 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
182 item = item->next;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
183 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
184 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
185 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
186
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
187 void ass_glyph_cache_init(void)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
188 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
189 glyph_hash_root = calloc(GLYPH_HASH_SIZE, sizeof(glyph_hash_item_p));
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
190 glyph_hash_size = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
191 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
192
19545
8f46b547db39 Simplify ass_glyph_cache_reset().
eugeni
parents: 19539
diff changeset
193 void ass_glyph_cache_done(void)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
194 {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
195 int i;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
196 for (i = 0; i < GLYPH_HASH_SIZE; ++i) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
197 glyph_hash_item_t* item = glyph_hash_root[i];
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
198 while (item) {
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
199 glyph_hash_item_t* next = item->next;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
200 if (item->val.glyph) FT_Done_Glyph(item->val.glyph);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
201 if (item->val.outline_glyph) FT_Done_Glyph(item->val.outline_glyph);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
202 free(item);
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
203 item = next;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
204 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
205 }
19545
8f46b547db39 Simplify ass_glyph_cache_reset().
eugeni
parents: 19539
diff changeset
206 free(glyph_hash_root);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
207 glyph_hash_size = 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
208 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
209
19545
8f46b547db39 Simplify ass_glyph_cache_reset().
eugeni
parents: 19539
diff changeset
210 void ass_glyph_cache_reset(void)
19539
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
211 {
19545
8f46b547db39 Simplify ass_glyph_cache_reset().
eugeni
parents: 19539
diff changeset
212 ass_glyph_cache_done();
8f46b547db39 Simplify ass_glyph_cache_reset().
eugeni
parents: 19539
diff changeset
213 ass_glyph_cache_init();
19539
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
214 }
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
215