summaryrefslogtreecommitdiffstats
path: root/libass/ass_cache.h
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2011-06-27 02:17:10 +0200
committerGrigori Goronzy <greg@blackbox>2011-06-27 02:17:10 +0200
commitd14f08365d9ecd16e8c762d852b6a22d7cc2307d (patch)
treef1957f459b64213d3dd380007b5b8864599db9d7 /libass/ass_cache.h
parent308f4193c6b8d9f3ab8c70f7a9e083e7e2ad867d (diff)
downloadlibass-d14f08365d9ecd16e8c762d852b6a22d7cc2307d.tar.bz2
libass-d14f08365d9ecd16e8c762d852b6a22d7cc2307d.tar.xz
cache: unified outline cache for glyphs/drawings
Glyphs and drawings have wildly different hash keys. Subclass the hash keys of glyphs and drawings in a new, unified outline cache. This also fixes some issues with drawings in the glyph cache. Now, the textual description of the drawing is included in the key (the hash value isn't really good enough, especially not fnv32) and the baseline offset is saved as well.
Diffstat (limited to 'libass/ass_cache.h')
-rw-r--r--libass/ass_cache.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/libass/ass_cache.h b/libass/ass_cache.h
index cf2c400..0ad7cae 100644
--- a/libass/ass_cache.h
+++ b/libass/ass_cache.h
@@ -26,10 +26,31 @@
typedef struct cache Cache;
-// Create definitions for bitmap, glyph and composite hash keys
+// Create definitions for bitmap, outline and composite hash keys
#define CREATE_STRUCT_DEFINITIONS
#include "ass_cache_template.h"
+// Type-specific function pointers
+typedef unsigned(*HashFunction)(void *key, size_t key_size);
+typedef size_t(*ItemSize)(void *value, size_t value_size);
+typedef unsigned(*HashCompare)(void *a, void *b, size_t key_size);
+typedef void(*CacheItemDestructor)(void *key, void *value);
+
+// cache hash keys
+
+typedef struct outline_hash_key {
+ enum {
+ OUTLINE_GLYPH,
+ OUTLINE_DRAWING,
+ } type;
+ union {
+ GlyphHashKey glyph;
+ DrawingHashKey drawing;
+ } u;
+} OutlineHashKey;
+
+// cache values
+
typedef struct {
Bitmap *bm; // the actual bitmaps
Bitmap *bm_o;
@@ -46,15 +67,9 @@ typedef struct {
FT_Outline *outline;
FT_Outline *border;
FT_BBox bbox_scaled; // bbox after scaling, but before rotation
- FT_Vector advance; // 26.6, advance distance to the next bitmap in line
- int asc, desc; // ascender/descender of a drawing
-} GlyphHashValue;
-
-// Type-specific function pointers
-typedef unsigned(*HashFunction)(void *key, size_t key_size);
-typedef size_t(*ItemSize)(void *value, size_t value_size);
-typedef unsigned(*HashCompare)(void *a, void *b, size_t key_size);
-typedef void(*CacheItemDestructor)(void *key, void *value);
+ FT_Vector advance; // 26.6, advance distance to the next outline in line
+ int asc, desc; // ascender/descender
+} OutlineHashValue;
Cache *ass_cache_create(HashFunction hash_func, HashCompare compare_func,
CacheItemDestructor destruct_func, ItemSize size_func,
@@ -66,7 +81,7 @@ void ass_cache_stats(Cache *cache, size_t *size, unsigned *hits,
unsigned *misses, unsigned *count);
void ass_cache_done(Cache *cache);
Cache *ass_font_cache_create(void);
-Cache *ass_glyph_cache_create(void);
+Cache *ass_outline_cache_create(void);
Cache *ass_bitmap_cache_create(void);
Cache *ass_composite_cache_create(void);