Remove unused hash key item
[libass.git] / libass / ass_cache_template.h
blob2339e2bcaba018906a643366b84dd06aaab8d25f
1 #ifdef CREATE_STRUCT_DEFINITIONS
2 #undef CREATE_STRUCT_DEFINITIONS
3 #define START(funcname, structname) \
4 typedef struct structname {
5 #define GENERIC(type, member) \
6 type member;
7 #define STRING(member) \
8 char *member;
9 #define FTVECTOR(member) \
10 FT_Vector member;
11 #define BITMAPHASHKEY(member) \
12 BitmapHashKey member;
13 #define END(typedefnamename) \
14 } typedefnamename;
16 #elif defined(CREATE_COMPARISON_FUNCTIONS)
17 #undef CREATE_COMPARISON_FUNCTIONS
18 #define START(funcname, structname) \
19 static unsigned funcname##_compare(void *key1, void *key2, size_t key_size) \
20 { \
21 struct structname *a = key1; \
22 struct structname *b = key2; \
23 return // conditions follow
24 #define GENERIC(type, member) \
25 a->member == b->member &&
26 #define STRING(member) \
27 strcmp(a->member, b->member) == 0 &&
28 #define FTVECTOR(member) \
29 a->member.x == b->member.x && a->member.y == b->member.y &&
30 #define BITMAPHASHKEY(member) \
31 bitmap_compare(&a->member, &b->member, sizeof(a->member)) &&
32 #define END(typedefname) \
33 1; \
36 #elif defined(CREATE_HASH_FUNCTIONS)
37 #undef CREATE_HASH_FUNCTIONS
38 #define START(funcname, structname) \
39 static unsigned funcname##_hash(void *buf, size_t len) \
40 { \
41 struct structname *p = buf; \
42 unsigned hval = FNV1_32A_INIT;
43 #define GENERIC(type, member) \
44 hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
45 #define STRING(member) \
46 hval = fnv_32a_str(p->member, hval);
47 #define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
48 #define BITMAPHASHKEY(member) { \
49 unsigned temp = bitmap_hash(&p->member, sizeof(p->member)); \
50 hval = fnv_32a_buf(&temp, sizeof(temp), hval); \
52 #define END(typedefname) \
53 return hval; \
56 #else
57 #error missing defines
58 #endif
62 // describes an outline bitmap
63 START(outline_bitmap, outline_bitmap_hash_key)
64 GENERIC(OutlineHashValue *, outline)
65 GENERIC(char, be) // blur edges
66 GENERIC(double, blur) // gaussian blur
67 GENERIC(int, frx) // signed 16.16
68 GENERIC(int, fry) // signed 16.16
69 GENERIC(int, frz) // signed 16.16
70 GENERIC(int, fax) // signed 16.16
71 GENERIC(int, fay) // signed 16.16
72 // shift vector that was added to glyph before applying rotation
73 // = 0, if frx = fry = frx = 0
74 // = (glyph base point) - (rotation origin), otherwise
75 GENERIC(int, shift_x)
76 GENERIC(int, shift_y)
77 FTVECTOR(advance) // subpixel shift vector
78 FTVECTOR(shadow_offset) // shadow subpixel shift
79 END(OutlineBitmapHashKey)
81 // describe a clip mask bitmap
82 START(clip_bitmap, clip_bitmap_hash_key)
83 STRING(text)
84 END(ClipMaskHashKey)
86 // describes an outline glyph
87 START(glyph, glyph_hash_key)
88 GENERIC(ASS_Font *, font)
89 GENERIC(double, size) // font size
90 GENERIC(uint32_t, ch) // character code
91 GENERIC(int, bold)
92 GENERIC(int, italic)
93 GENERIC(unsigned, scale_x) // 16.16
94 GENERIC(unsigned, scale_y) // 16.16
95 FTVECTOR(outline) // border width, 16.16
96 GENERIC(unsigned, flags) // glyph decoration flags
97 GENERIC(unsigned, border_style)
98 END(GlyphHashKey)
100 // describes an outline drawing
101 START(drawing, drawing_hash_key)
102 GENERIC(unsigned, scale_x)
103 GENERIC(unsigned, scale_y)
104 GENERIC(int, pbo)
105 FTVECTOR(outline)
106 GENERIC(unsigned, border_style)
107 GENERIC(int, scale)
108 GENERIC(unsigned, hash)
109 STRING(text)
110 END(DrawingHashKey)
112 // Cache for composited bitmaps
113 START(composite, composite_hash_key)
114 GENERIC(int, aw)
115 GENERIC(int, ah)
116 GENERIC(int, bw)
117 GENERIC(int, bh)
118 GENERIC(int, ax)
119 GENERIC(int, ay)
120 GENERIC(int, bx)
121 GENERIC(int, by)
122 GENERIC(int, as)
123 GENERIC(int, bs)
124 GENERIC(unsigned char *, a)
125 GENERIC(unsigned char *, b)
126 END(CompositeHashKey)
129 #undef START
130 #undef GENERIC
131 #undef STRING
132 #undef FTVECTOR
133 #undef BITMAPHASHKEY
134 #undef END