summaryrefslogtreecommitdiffstats
path: root/libass/ass_cache.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2010-08-01 03:30:59 +0200
committerGrigori Goronzy <greg@blackbox>2010-08-01 03:35:19 +0200
commitec0d975158e5f3b1c6a60c44fb10171f1b3c1b32 (patch)
tree88bbd0ee922abcd25bab3bca4ead1aa6dbdb1596 /libass/ass_cache.c
parent7bdeea8453b2643b1925223acab41f5c7b56b6e2 (diff)
downloadlibass-ec0d975158e5f3b1c6a60c44fb10171f1b3c1b32.tar.bz2
libass-ec0d975158e5f3b1c6a60c44fb10171f1b3c1b32.tar.xz
Limit (bitmap) glyph cache size
Now that bitmap glyphs (for vector clip masks) are stored in the glyph cache, make sure it cannot grow indefinitely easily. Similar to the bitmap cache, track approximate size of the cached elements and reset if the cache exceeds a certain limit. Also, reduce default bitmap cache size to 30 MB as we have essentially two bitmap caches now. That's still plenty in all use cases where caching matters.
Diffstat (limited to 'libass/ass_cache.c')
-rw-r--r--libass/ass_cache.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index 0252735..3ebf0cc 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -288,6 +288,11 @@ static void glyph_hash_dtor(void *key, size_t key_size, void *value,
void *cache_add_glyph(Hashmap *glyph_cache, GlyphHashKey *key,
GlyphHashValue *val)
{
+ if (val->glyph && val->glyph->format == FT_GLYPH_FORMAT_BITMAP) {
+ FT_Bitmap *bitmap = &((FT_BitmapGlyph) val->glyph)->bitmap;
+ glyph_cache->cache_size += bitmap->rows * bitmap->pitch;
+ }
+
return hashmap_insert(glyph_cache, key, val);
}