Add const where appropriate, also gets rid of a compiler warning.
[mplayer/glamo.git] / libass / ass_cache.h
blob59ac8cee2a230e929e84d7e220955910e0e9565d
1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
2 // vim:ts=8:sw=8:noet:ai:
3 /*
4 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
6 * This file is part of libass.
8 * libass is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * libass is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with libass; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef LIBASS_CACHE_H
24 #define LIBASS_CACHE_H
26 #include "ass.h"
27 #include "ass_font.h"
28 #include "ass_bitmap.h"
30 void ass_font_cache_init(void);
31 ass_font_t* ass_font_cache_find(ass_font_desc_t* desc);
32 void* ass_font_cache_add(ass_font_t* font);
33 void ass_font_cache_done(void);
36 // describes a bitmap; bitmaps with equivalents structs are considered identical
37 typedef struct bitmap_hash_key_s {
38 char bitmap; // bool : true = bitmap, false = outline
39 ass_font_t* font;
40 double size; // font size
41 uint32_t ch; // character code
42 unsigned outline; // border width, 16.16 fixed point value
43 int bold, italic;
44 char be; // blur edges
45 double blur; // gaussian blur
47 unsigned scale_x, scale_y; // 16.16
48 int frx, fry, frz; // signed 16.16
49 int shift_x, shift_y; // shift vector that was added to glyph before applying rotation
50 // = 0, if frx = fry = frx = 0
51 // = (glyph base point) - (rotation origin), otherwise
53 FT_Vector advance; // subpixel shift vector
54 } bitmap_hash_key_t;
56 typedef struct bitmap_hash_val_s {
57 bitmap_t* bm; // the actual bitmaps
58 bitmap_t* bm_o;
59 bitmap_t* bm_s;
60 } bitmap_hash_val_t;
62 void ass_bitmap_cache_init(void);
63 void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val);
64 bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key);
65 void ass_bitmap_cache_reset(void);
66 void ass_bitmap_cache_done(void);
69 // Cache for composited bitmaps
70 typedef struct composite_hash_key_s {
71 int aw, ah, bw, bh;
72 int ax, ay, bx, by;
73 bitmap_hash_key_t a;
74 bitmap_hash_key_t b;
75 } composite_hash_key_t;
77 typedef struct composite_hash_val_s {
78 unsigned char* a;
79 unsigned char* b;
80 } composite_hash_val_t;
82 void ass_composite_cache_init(void);
83 void* cache_add_composite(composite_hash_key_t* key, composite_hash_val_t* val);
84 composite_hash_val_t* cache_find_composite(composite_hash_key_t* key);
85 void ass_composite_cache_reset(void);
86 void ass_composite_cache_done(void);
89 // describes an outline glyph
90 typedef struct glyph_hash_key_s {
91 ass_font_t* font;
92 double size; // font size
93 uint32_t ch; // character code
94 int bold, italic;
95 unsigned scale_x, scale_y; // 16.16
96 FT_Vector advance; // subpixel shift vector
97 unsigned outline; // border width, 16.16
98 } glyph_hash_key_t;
100 typedef struct glyph_hash_val_s {
101 FT_Glyph glyph;
102 FT_Glyph outline_glyph;
103 FT_BBox bbox_scaled; // bbox after scaling, but before rotation
104 FT_Vector advance; // 26.6, advance distance to the next bitmap in line
105 } glyph_hash_val_t;
107 void ass_glyph_cache_init(void);
108 void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val);
109 glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key);
110 void ass_glyph_cache_reset(void);
111 void ass_glyph_cache_done(void);
113 typedef struct hashmap_s hashmap_t;
114 typedef void (*hashmap_item_dtor_t)(void* key, size_t key_size, void* value, size_t value_size);
115 typedef int (*hashmap_key_compare_t)(void* key1, void* key2, size_t key_size);
116 typedef unsigned (*hashmap_hash_t)(void* key, size_t key_size);
118 hashmap_t* hashmap_init(size_t key_size, size_t value_size, int nbuckets,
119 hashmap_item_dtor_t item_dtor, hashmap_key_compare_t key_compare,
120 hashmap_hash_t hash);
121 void hashmap_done(hashmap_t* map);
122 void* hashmap_insert(hashmap_t* map, void* key, void* value);
123 void* hashmap_find(hashmap_t* map, void* key);
125 #endif /* LIBASS_CACHE_H */