2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
4 * This file is part of libass.
6 * libass is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * libass is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with libass; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef LIBASS_CACHE_H
22 #define LIBASS_CACHE_H
26 #include "ass_bitmap.h"
28 typedef void (*HashmapItemDtor
) (void *key
, size_t key_size
,
29 void *value
, size_t value_size
);
30 typedef int (*HashmapKeyCompare
) (void *key1
, void *key2
,
32 typedef unsigned (*HashmapHash
) (void *key
, size_t key_size
);
34 typedef struct hashmap_item
{
37 struct hashmap_item
*next
;
39 typedef HashmapItem
*hashmap_item_p
;
43 size_t key_size
, value_size
;
45 HashmapItemDtor item_dtor
; // a destructor for hashmap key/value pairs
46 HashmapKeyCompare key_compare
;
56 Hashmap
*hashmap_init(ASS_Library
*library
, size_t key_size
,
57 size_t value_size
, int nbuckets
,
58 HashmapItemDtor item_dtor
,
59 HashmapKeyCompare key_compare
,
61 void hashmap_done(Hashmap
*map
);
62 void *hashmap_insert(Hashmap
*map
, void *key
, void *value
);
63 void *hashmap_find(Hashmap
*map
, void *key
);
65 Hashmap
*ass_font_cache_init(ASS_Library
*library
);
66 ASS_Font
*ass_font_cache_find(Hashmap
*, ASS_FontDesc
*desc
);
67 void *ass_font_cache_add(Hashmap
*, ASS_Font
*font
);
68 void ass_font_cache_done(Hashmap
*);
70 // Create definitions for bitmap_hash_key and glyph_hash_key
71 #define CREATE_STRUCT_DEFINITIONS
72 #include "ass_cache_template.h"
75 Bitmap
*bm
; // the actual bitmaps
80 Hashmap
*ass_bitmap_cache_init(ASS_Library
*library
);
81 void *cache_add_bitmap(Hashmap
*, BitmapHashKey
*key
,
82 BitmapHashValue
*val
);
83 BitmapHashValue
*cache_find_bitmap(Hashmap
*bitmap_cache
,
85 Hashmap
*ass_bitmap_cache_reset(Hashmap
*bitmap_cache
);
86 void ass_bitmap_cache_done(Hashmap
*bitmap_cache
);
94 Hashmap
*ass_composite_cache_init(ASS_Library
*library
);
95 void *cache_add_composite(Hashmap
*, CompositeHashKey
*key
,
96 CompositeHashValue
*val
);
97 CompositeHashValue
*cache_find_composite(Hashmap
*composite_cache
,
98 CompositeHashKey
*key
);
99 Hashmap
*ass_composite_cache_reset(Hashmap
*composite_cache
);
100 void ass_composite_cache_done(Hashmap
*composite_cache
);
105 FT_Glyph outline_glyph
;
106 FT_BBox bbox_scaled
; // bbox after scaling, but before rotation
107 FT_Vector advance
; // 26.6, advance distance to the next bitmap in line
108 int asc
, desc
; // ascender/descender of a drawing
111 Hashmap
*ass_glyph_cache_init(ASS_Library
*library
);
112 void *cache_add_glyph(Hashmap
*, GlyphHashKey
*key
,
113 GlyphHashValue
*val
);
114 GlyphHashValue
*cache_find_glyph(Hashmap
*glyph_cache
,
116 Hashmap
*ass_glyph_cache_reset(Hashmap
*glyph_cache
);
117 void ass_glyph_cache_done(Hashmap
*glyph_cache
);
119 #endif /* LIBASS_CACHE_H */