2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
4 * This file is part of libass.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef LIBASS_CACHE_H
20 #define LIBASS_CACHE_H
24 #include "ass_bitmap.h"
26 typedef void (*HashmapItemDtor
) (void *key
, size_t key_size
,
27 void *value
, size_t value_size
);
28 typedef int (*HashmapKeyCompare
) (void *key1
, void *key2
,
30 typedef unsigned (*HashmapHash
) (void *key
, size_t key_size
);
32 typedef struct hashmap_item
{
35 struct hashmap_item
*next
;
37 typedef HashmapItem
*hashmap_item_p
;
41 size_t key_size
, value_size
;
43 HashmapItemDtor item_dtor
; // a destructor for hashmap key/value pairs
44 HashmapKeyCompare key_compare
;
54 Hashmap
*hashmap_init(ASS_Library
*library
, size_t key_size
,
55 size_t value_size
, int nbuckets
,
56 HashmapItemDtor item_dtor
,
57 HashmapKeyCompare key_compare
,
59 void hashmap_done(Hashmap
*map
);
60 void *hashmap_insert(Hashmap
*map
, void *key
, void *value
);
61 void *hashmap_find(Hashmap
*map
, void *key
);
63 Hashmap
*ass_font_cache_init(ASS_Library
*library
);
64 ASS_Font
*ass_font_cache_find(Hashmap
*, ASS_FontDesc
*desc
);
65 void *ass_font_cache_add(Hashmap
*, ASS_Font
*font
);
66 void ass_font_cache_done(Hashmap
*);
68 // Create definitions for bitmap_hash_key and glyph_hash_key
69 #define CREATE_STRUCT_DEFINITIONS
70 #include "ass_cache_template.h"
73 Bitmap
*bm
; // the actual bitmaps
78 Hashmap
*ass_bitmap_cache_init(ASS_Library
*library
);
79 void *cache_add_bitmap(Hashmap
*, BitmapHashKey
*key
,
80 BitmapHashValue
*val
);
81 BitmapHashValue
*cache_find_bitmap(Hashmap
*bitmap_cache
,
83 Hashmap
*ass_bitmap_cache_reset(Hashmap
*bitmap_cache
);
84 void ass_bitmap_cache_done(Hashmap
*bitmap_cache
);
92 Hashmap
*ass_composite_cache_init(ASS_Library
*library
);
93 void *cache_add_composite(Hashmap
*, CompositeHashKey
*key
,
94 CompositeHashValue
*val
);
95 CompositeHashValue
*cache_find_composite(Hashmap
*composite_cache
,
96 CompositeHashKey
*key
);
97 Hashmap
*ass_composite_cache_reset(Hashmap
*composite_cache
);
98 void ass_composite_cache_done(Hashmap
*composite_cache
);
103 FT_Glyph outline_glyph
;
104 FT_BBox bbox_scaled
; // bbox after scaling, but before rotation
105 FT_Vector advance
; // 26.6, advance distance to the next bitmap in line
106 int asc
, desc
; // ascender/descender of a drawing
109 Hashmap
*ass_glyph_cache_init(ASS_Library
*library
);
110 void *cache_add_glyph(Hashmap
*, GlyphHashKey
*key
,
111 GlyphHashValue
*val
);
112 GlyphHashValue
*cache_find_glyph(Hashmap
*glyph_cache
,
114 Hashmap
*ass_glyph_cache_reset(Hashmap
*glyph_cache
);
115 void ass_glyph_cache_done(Hashmap
*glyph_cache
);
117 #endif /* LIBASS_CACHE_H */