annotate libass/ass_cache.c @ 30124:248d9886d0b0

Fix compilation if FreeType is not available, in particular do not try to build libass and use the internal ass.h as a stub for structs needed for EOSD.
author reimar
date Fri, 01 Jan 2010 18:51:59 +0000
parents 0f1b5b68af32
children 48d020c5ceca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
2 // vim:ts=8:sw=8:noet:ai:
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
3 /*
26723
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
5 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
6 * This file is part of libass.
26723
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
7 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
8 * libass is free software; you can redistribute it and/or modify
26723
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
9 * it under the terms of the GNU General Public License as published by
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
11 * (at your option) any later version.
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
12 *
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
13 * libass is distributed in the hope that it will be useful,
26723
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
16 * GNU General Public License for more details.
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
17 *
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
18 * You should have received a copy of the GNU General Public License along
26738
588ce97b44f2 Speak of libass instead of MPlayer in the libass license headers.
diego
parents: 26723
diff changeset
19 * with libass; if not, write to the Free Software Foundation, Inc.,
26723
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0f892cd714b2 Use standard license header.
diego
parents: 23214
diff changeset
21 */
20008
fa122b7c71c6 Add copyright notice and vim/emacs comments to libass and vf_ass.c.
eugeni
parents: 19965
diff changeset
22
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
23 #include "config.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
24
22292
2f3f27a014ef Add some missing includes.
eugeni
parents: 22215
diff changeset
25 #include <inttypes.h>
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
26 #include <ft2build.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
27 #include FT_FREETYPE_H
19846
bcc792bfa431 Store bitmap glyphs in a separate struct, instead of FreeType's internal buffer.
eugeni
parents: 19545
diff changeset
28 #include FT_GLYPH_H
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
29
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
30 #include <assert.h>
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
31
21026
d138463e820b Collect all includes of mplayer headers in libass in a single file (mputils.h).
eugeni
parents: 20637
diff changeset
32 #include "mputils.h"
21458
7af6c25a0cfc Keep embedded fonts in ass_library_t and perform actual disk write
eugeni
parents: 21348
diff changeset
33 #include "ass.h"
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
34 #include "ass_fontconfig.h"
21322
bb55f4f7b3cb Fix compilation broken in previous commit.
eugeni
parents: 21317
diff changeset
35 #include "ass_font.h"
19846
bcc792bfa431 Store bitmap glyphs in a separate struct, instead of FreeType's internal buffer.
eugeni
parents: 19545
diff changeset
36 #include "ass_bitmap.h"
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
37 #include "ass_cache.h"
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
38
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
39
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
40 typedef struct hashmap_item_s {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
41 void* key;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
42 void* value;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
43 struct hashmap_item_s* next;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
44 } hashmap_item_t;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
45 typedef hashmap_item_t* hashmap_item_p;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
46
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
47 struct hashmap_s {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
48 int nbuckets;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
49 size_t key_size, value_size;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
50 hashmap_item_p* root;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
51 hashmap_item_dtor_t item_dtor; // a destructor for hashmap key/value pairs
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
52 hashmap_key_compare_t key_compare;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
53 hashmap_hash_t hash;
23019
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
54 // stats
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
55 int hit_count;
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
56 int miss_count;
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
57 int count;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
58 };
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
59
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
60 #define FNV1_32A_INIT (unsigned)0x811c9dc5
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
61
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
62 static inline unsigned fnv_32a_buf(void* buf, size_t len, unsigned hval)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
63 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
64 unsigned char *bp = buf;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
65 unsigned char *be = bp + len;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
66 while (bp < be) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
67 hval ^= (unsigned)*bp++;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
68 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
69 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
70 return hval;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
71 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
72 static inline unsigned fnv_32a_str(char* str, unsigned hval)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
73 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
74 unsigned char* s = (unsigned char*)str;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
75 while (*s) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
76 hval ^= (unsigned)*s++;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
77 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
78 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
79 return hval;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
80 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
81
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
82 static unsigned hashmap_hash(void* buf, size_t len)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
83 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
84 return fnv_32a_buf(buf, len, FNV1_32A_INIT);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
85 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
86
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
87 static int hashmap_key_compare(void* a, void* b, size_t size)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
88 {
26759
8eff880f638c cosmetics: Remove useless parentheses from return statements.
diego
parents: 26738
diff changeset
89 return memcmp(a, b, size) == 0;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
90 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
91
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
92 static void hashmap_item_dtor(void* key, size_t key_size, void* value, size_t value_size)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
93 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
94 free(key);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
95 free(value);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
96 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
97
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
98 hashmap_t* hashmap_init(size_t key_size, size_t value_size, int nbuckets,
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
99 hashmap_item_dtor_t item_dtor, hashmap_key_compare_t key_compare,
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
100 hashmap_hash_t hash)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
101 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
102 hashmap_t* map = calloc(1, sizeof(hashmap_t));
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
103 map->nbuckets = nbuckets;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
104 map->key_size = key_size;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
105 map->value_size = value_size;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
106 map->root = calloc(nbuckets, sizeof(hashmap_item_p));
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
107 map->item_dtor = item_dtor ? item_dtor : hashmap_item_dtor;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
108 map->key_compare = key_compare ? key_compare : hashmap_key_compare;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
109 map->hash = hash ? hash : hashmap_hash;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
110 return map;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
111 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
112
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
113 void hashmap_done(hashmap_t* map)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
114 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
115 int i;
23019
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
116 // print stats
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
117 if (map->count > 0 || map->hit_count + map->miss_count > 0)
23020
1cce8d37847e Oops, fix compilation broken in r23037.
eugeni
parents: 23019
diff changeset
118 mp_msg(MSGT_ASS, MSGL_V, "cache statistics: \n total accesses: %d\n hits: %d\n misses: %d\n object count: %d\n",
23019
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
119 map->hit_count + map->miss_count, map->hit_count, map->miss_count, map->count);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28860
diff changeset
120
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
121 for (i = 0; i < map->nbuckets; ++i) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
122 hashmap_item_t* item = map->root[i];
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
123 while (item) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
124 hashmap_item_t* next = item->next;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
125 map->item_dtor(item->key, map->key_size, item->value, map->value_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
126 free(item);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
127 item = next;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
128 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
129 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
130 free(map->root);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
131 free(map);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
132 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
133
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
134 // does nothing if key already exists
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
135 void* hashmap_insert(hashmap_t* map, void* key, void* value)
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
136 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
137 unsigned hash = map->hash(key, map->key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
138 hashmap_item_t** next = map->root + (hash % map->nbuckets);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
139 while (*next) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
140 if (map->key_compare(key, (*next)->key, map->key_size))
23214
bb2f626c72a4 Fix stupid bug in r23229.
eugeni
parents: 23211
diff changeset
141 return (*next)->value;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
142 next = &((*next)->next);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
143 assert(next);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
144 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
145 (*next) = malloc(sizeof(hashmap_item_t));
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
146 (*next)->key = malloc(map->key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
147 (*next)->value = malloc(map->value_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
148 memcpy((*next)->key, key, map->key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
149 memcpy((*next)->value, value, map->value_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
150 (*next)->next = 0;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
151
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
152 map->count ++;
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
153 return (*next)->value;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
154 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
155
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
156 void* hashmap_find(hashmap_t* map, void* key)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
157 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
158 unsigned hash = map->hash(key, map->key_size);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
159 hashmap_item_t* item = map->root[hash % map->nbuckets];
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
160 while (item) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
161 if (map->key_compare(key, item->key, map->key_size)) {
23019
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
162 map->hit_count++;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
163 return item->value;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
164 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
165 item = item->next;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
166 }
23019
4934af4fdd0f Collect hit/miss statistic in hash map, and print in -v mode.
eugeni
parents: 23018
diff changeset
167 map->miss_count++;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
168 return 0;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
169 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
170
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
171 //---------------------------------
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
172 // font cache
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
173
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
174 hashmap_t* font_cache;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
175
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
176 static unsigned font_desc_hash(void* buf, size_t len)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
177 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
178 ass_font_desc_t* desc = buf;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
179 unsigned hval;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
180 hval = fnv_32a_str(desc->family, FNV1_32A_INIT);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
181 hval = fnv_32a_buf(&desc->bold, sizeof(desc->bold), hval);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
182 hval = fnv_32a_buf(&desc->italic, sizeof(desc->italic), hval);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
183 return hval;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
184 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
185
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
186 static int font_compare(void* key1, void* key2, size_t key_size) {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
187 ass_font_desc_t* a = key1;
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
188 ass_font_desc_t* b = key2;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
189 if (strcmp(a->family, b->family) != 0)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
190 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
191 if (a->bold != b->bold)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
192 return 0;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
193 if (a->italic != b->italic)
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
194 return 0;
28860
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 28789
diff changeset
195 if (a->treat_family_as_pattern != b->treat_family_as_pattern)
7fcc0bf5b27a Treat -font/-subfont as Fontconfig pattern in libass.
eugeni
parents: 28789
diff changeset
196 return 0;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
197 return 1;
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
198 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
199
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
200 static void font_hash_dtor(void* key, size_t key_size, void* value, size_t value_size)
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
201 {
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
202 ass_font_free(value);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
203 free(key);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
204 }
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
205
21317
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
206 ass_font_t* ass_font_cache_find(ass_font_desc_t* desc)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
207 {
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
208 return hashmap_find(font_cache, desc);
21317
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
209 }
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
210
21317
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
211 /**
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
212 * \brief Add a face struct to cache.
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
213 * \param font font struct
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
214 */
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
215 void* ass_font_cache_add(ass_font_t* font)
21317
dcfd069efd8f Move ass_font_t allocation to ass_font.h.
eugeni
parents: 21279
diff changeset
216 {
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
217 return hashmap_insert(font_cache, &(font->desc), font);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
218 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
219
21265
4e7a7dea3e1f Rename:
eugeni
parents: 21066
diff changeset
220 void ass_font_cache_init(void)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
221 {
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
222 font_cache = hashmap_init(sizeof(ass_font_desc_t),
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
223 sizeof(ass_font_t),
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
224 1000,
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
225 font_hash_dtor, font_compare, font_desc_hash);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
226 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
227
21265
4e7a7dea3e1f Rename:
eugeni
parents: 21066
diff changeset
228 void ass_font_cache_done(void)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
229 {
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
230 hashmap_done(font_cache);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
231 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
232
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
233 //---------------------------------
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
234 // bitmap cache
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
235
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
236 hashmap_t* bitmap_cache;
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
237
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
238 static void bitmap_hash_dtor(void* key, size_t key_size, void* value, size_t value_size)
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
239 {
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
240 bitmap_hash_val_t* v = value;
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
241 if (v->bm) ass_free_bitmap(v->bm);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
242 if (v->bm_o) ass_free_bitmap(v->bm_o);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
243 if (v->bm_s) ass_free_bitmap(v->bm_s);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
244 free(key);
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
245 free(value);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
246 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
247
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
248 void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
249 {
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
250 return hashmap_insert(bitmap_cache, key, val);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
251 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
252
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
253 /**
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
254 * \brief Get a bitmap from bitmap cache.
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
255 * \param key hash key
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
256 * \return requested hash val or 0 if not found
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28860
diff changeset
257 */
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
258 bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
259 {
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
260 return hashmap_find(bitmap_cache, key);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
261 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
262
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
263 void ass_bitmap_cache_init(void)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
264 {
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
265 bitmap_cache = hashmap_init(sizeof(bitmap_hash_key_t),
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
266 sizeof(bitmap_hash_val_t),
23016
a1ced37f2ee5 Add generic hash map implementation.
eugeni
parents: 22292
diff changeset
267 0xFFFF + 13,
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
268 bitmap_hash_dtor, NULL, NULL);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
269 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
270
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
271 void ass_bitmap_cache_done(void)
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
272 {
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
273 hashmap_done(bitmap_cache);
18937
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
274 }
9e95ac641e77 Initial libass release (without mencoder support).
eugeni
parents:
diff changeset
275
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
276 void ass_bitmap_cache_reset(void)
19539
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
277 {
23017
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
278 ass_bitmap_cache_done();
f3b04984b0da Rename glyph cache to bitmap cache.
eugeni
parents: 23016
diff changeset
279 ass_bitmap_cache_init();
19539
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
280 }
64009ae411fb Reset glyph cache on reconfigure.
eugeni
parents: 18937
diff changeset
281
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
282 //---------------------------------
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
283 // glyph cache
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
284
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
285 hashmap_t* glyph_cache;
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
286
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
287 static void glyph_hash_dtor(void* key, size_t key_size, void* value, size_t value_size)
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
288 {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
289 glyph_hash_val_t* v = value;
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
290 if (v->glyph) FT_Done_Glyph(v->glyph);
23025
ab0943242d1a Store outline_glyph (glyph border) in glyph cache.
eugeni
parents: 23020
diff changeset
291 if (v->outline_glyph) FT_Done_Glyph(v->outline_glyph);
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
292 free(key);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
293 free(value);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
294 }
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
295
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
296 void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val)
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
297 {
23211
d9b4bfea1093 Make cache_*_add functions return the pointer to new (copied) value.
eugeni
parents: 23025
diff changeset
298 return hashmap_insert(glyph_cache, key, val);
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
299 }
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
300
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
301 /**
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
302 * \brief Get a glyph from glyph cache.
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
303 * \param key hash key
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
304 * \return requested hash val or 0 if not found
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28860
diff changeset
305 */
23018
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
306 glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key)
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
307 {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
308 return hashmap_find(glyph_cache, key);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
309 }
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
310
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
311 void ass_glyph_cache_init(void)
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
312 {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
313 glyph_cache = hashmap_init(sizeof(glyph_hash_key_t),
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
314 sizeof(glyph_hash_val_t),
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
315 0xFFFF + 13,
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
316 glyph_hash_dtor, NULL, NULL);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
317 }
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
318
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
319 void ass_glyph_cache_done(void)
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
320 {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
321 hashmap_done(glyph_cache);
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
322 }
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
323
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
324 void ass_glyph_cache_reset(void)
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
325 {
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
326 ass_glyph_cache_done();
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
327 ass_glyph_cache_init();
a4517aa83565 Add outline glyph cache (unused yet).
eugeni
parents: 23017
diff changeset
328 }
28789
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
329
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
330
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
331 //---------------------------------
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
332 // composite cache
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
333
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
334 hashmap_t* composite_cache;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
335
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
336 static void composite_hash_dtor(void* key, size_t key_size, void* value, size_t value_size)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
337 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
338 composite_hash_val_t* v = value;
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
339 free(v->a);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
340 free(v->b);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
341 free(key);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
342 free(value);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
343 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
344
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
345 void* cache_add_composite(composite_hash_key_t* key, composite_hash_val_t* val)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
346 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
347 return hashmap_insert(composite_cache, key, val);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
348 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
349
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
350 /**
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
351 * \brief Get a composite bitmap from composite cache.
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
352 * \param key hash key
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
353 * \return requested hash val or 0 if not found
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
354 */
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
355 composite_hash_val_t* cache_find_composite(composite_hash_key_t* key)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
356 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
357 return hashmap_find(composite_cache, key);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
358 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
359
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
360 void ass_composite_cache_init(void)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
361 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
362 composite_cache = hashmap_init(sizeof(composite_hash_key_t),
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
363 sizeof(composite_hash_val_t),
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
364 0xFFFF + 13,
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
365 composite_hash_dtor, NULL, NULL);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
366 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
367
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
368 void ass_composite_cache_done(void)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
369 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
370 hashmap_done(composite_cache);
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
371 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
372
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
373 void ass_composite_cache_reset(void)
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
374 {
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
375 ass_composite_cache_done();
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
376 ass_composite_cache_init();
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
377 }
a0ce88ba2557 Combine adjacent overlapping, translucent glyph borders and shadows to
greg
parents: 26759
diff changeset
378