2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
3 * Copyright (C) 2011 Grigori Goronzy <greg@chown.ath.cx>
5 * This file is part of libass.
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 #ifndef LIBASS_CACHE_H
21 #define LIBASS_CACHE_H
25 #include "ass_outline.h"
26 #include "ass_bitmap.h"
28 typedef struct cache Cache;
33 Bitmap *bm; // the actual bitmap
44 ASS_Outline outline[2];
45 ASS_Rect cbox; // bounding box of all control points
46 int advance; // 26.6, advance distance to the next outline in line
47 int asc, desc; // ascender/descender
51 FT_Glyph_Metrics metrics;
52 } GlyphMetricsHashValue;
54 // Create definitions for bitmap, outline and composite hash keys
55 #define CREATE_STRUCT_DEFINITIONS
56 #include "ass_cache_template.h"
58 // Type-specific function pointers
59 typedef uint32_t (*HashFunction)(void *key, uint32_t hval);
60 typedef bool (*HashCompare)(void *a, void *b);
61 typedef bool (*CacheKeyMove)(void *dst, void *src);
62 typedef size_t (*CacheValueConstructor)(void *key, void *value, void *priv);
63 typedef void (*CacheItemDestructor)(void *key, void *value);
67 typedef struct outline_hash_key {
76 DrawingHashKey drawing;
82 BitmapHashValue *image, *image_o;
87 FILTER_BORDER_STYLE_3 = 1,
88 FILTER_NONZERO_BORDER = 2,
89 FILTER_NONZERO_SHADOW = 4,
90 FILTER_DRAW_SHADOW = 8, // VSFilter compatibility
101 HashFunction hash_func;
102 HashCompare compare_func;
103 CacheKeyMove key_move_func;
104 CacheValueConstructor construct_func;
105 CacheItemDestructor destruct_func;
110 Cache *ass_cache_create(const CacheDesc *desc);
111 void *ass_cache_get(Cache *cache, void *key, void *priv);
112 void *ass_cache_key(void *value);
113 void ass_cache_inc_ref(void *value);
114 void ass_cache_dec_ref(void *value);
115 void ass_cache_cut(Cache *cache, size_t max_size);
116 void ass_cache_stats(Cache *cache, size_t *size, unsigned *hits,
117 unsigned *misses, unsigned *count);
118 void ass_cache_empty(Cache *cache);
119 void ass_cache_done(Cache *cache);
120 Cache *ass_font_cache_create(void);
121 Cache *ass_outline_cache_create(void);
122 Cache *ass_glyph_metrics_cache_create(void);
123 Cache *ass_bitmap_cache_create(void);
124 Cache *ass_composite_cache_create(void);
126 #endif /* LIBASS_CACHE_H */