summaryrefslogtreecommitdiffstats
path: root/libass/ass_cache.c
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-06-27 21:04:12 +0200
committerGrigori Goronzy <greg@blackbox>2011-06-27 21:04:12 +0200
commit2a97a6cfc2c99a8998d4464d765530e08f9751ae (patch)
treeced694d216fb36787cce62f3e72cb2e9a0a7dbfd /libass/ass_cache.c
parentfd1acd2373662a14f3131d1a20b587ba5e4aa393 (diff)
downloadlibass-2a97a6cfc2c99a8998d4464d765530e08f9751ae.tar.bz2
libass-2a97a6cfc2c99a8998d4464d765530e08f9751ae.tar.xz
cache: unified bitmap cache
Similarly to the glyph cache, subclass the bitmap cache to allow both outline bitmaps and clipping mask bitmaps to coexist in the same cache in a much cleaner way.
Diffstat (limited to 'libass/ass_cache.c')
-rw-r--r--libass/ass_cache.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libass/ass_cache.c b/libass/ass_cache.c
index 6c34539..8a18e0a 100644
--- a/libass/ass_cache.c
+++ b/libass/ass_cache.c
@@ -76,12 +76,15 @@ static void font_destruct(void *key, void *value)
static void bitmap_destruct(void *key, void *value)
{
BitmapHashValue *v = value;
+ BitmapHashKey *k = key;
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);
+ if (k->type == BITMAP_CLIP)
+ free(k->u.clip.text);
free(key);
free(value);
}
@@ -96,6 +99,28 @@ static size_t bitmap_size(void *value, size_t value_size)
return 0;
}
+static unsigned bitmap_hash(void *key, size_t key_size)
+{
+ BitmapHashKey *k = key;
+ switch (k->type) {
+ case BITMAP_OUTLINE: return outline_bitmap_hash(&k->u, key_size);
+ case BITMAP_CLIP: return clip_bitmap_hash(&k->u, key_size);
+ default: return 0;
+ }
+}
+
+static unsigned bitmap_compare (void *a, void *b, size_t key_size)
+{
+ BitmapHashKey *ak = a;
+ BitmapHashKey *bk = b;
+ if (ak->type != bk->type) return 0;
+ switch (ak->type) {
+ case BITMAP_OUTLINE: return outline_bitmap_compare(&ak->u, &bk->u, key_size);
+ case BITMAP_CLIP: return clip_bitmap_compare(&ak->u, &bk->u, key_size);
+ default: return 0;
+ }
+}
+
// composite cache
static void composite_destruct(void *key, void *value)
{