1 #ifdef CREATE_STRUCT_DEFINITIONS
2 #undef CREATE_STRUCT_DEFINITIONS
3 #define START(funcname, structname) \
4 typedef struct structname {
5 #define GENERIC(type, member) \
7 #define FTVECTOR(member) \
9 #define BITMAPHASHKEY(member) \
11 #define END(typedefnamename) \
14 #elif defined(CREATE_COMPARISON_FUNCTIONS)
15 #undef CREATE_COMPARISON_FUNCTIONS
16 #define START(funcname, structname) \
17 static int funcname##_compare(void *key1, void *key2, size_t key_size) \
19 struct structname *a = key1; \
20 struct structname *b = key2; \
21 return // conditions follow
22 #define GENERIC(type, member) \
23 a->member == b->member &&
24 #define FTVECTOR(member) \
25 a->member.x == b->member.x && a->member.y == b->member.y &&
26 #define BITMAPHASHKEY(member) \
27 bitmap_compare(&a->member, &b->member, sizeof(a->member)) &&
28 #define END(typedefname) \
32 #elif defined(CREATE_HASH_FUNCTIONS)
33 #undef CREATE_HASH_FUNCTIONS
34 #define START(funcname, structname) \
35 static unsigned funcname##_hash(void *buf, size_t len) \
37 struct structname *p = buf; \
38 unsigned hval = FNV1_32A_INIT;
39 #define GENERIC(type, member) \
40 hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
41 #define FTVECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
42 #define BITMAPHASHKEY(member) { \
43 unsigned temp = bitmap_hash(&p->member, sizeof(p->member)); \
44 hval = fnv_32a_buf(&temp, sizeof(temp), hval); \
46 #define END(typedefname) \
51 #error missing defines
56 // describes a bitmap; bitmaps with equivalents structs are considered identical
57 START(bitmap
, bitmap_hash_key
)
58 GENERIC(char, bitmap
) // bool : true = bitmap, false = outline
59 GENERIC(ASS_Font
*, font
)
60 GENERIC(double, size
) // font size
61 GENERIC(uint32_t, ch
) // character code
62 FTVECTOR(outline
) // border width, 16.16 fixed point value
65 GENERIC(char, be
) // blur edges
66 GENERIC(double, blur
) // gaussian blur
67 GENERIC(unsigned, scale_x
) // 16.16
68 GENERIC(unsigned, scale_y
) // 16.16
69 GENERIC(int, frx
) // signed 16.16
70 GENERIC(int, fry
) // signed 16.16
71 GENERIC(int, frz
) // signed 16.16
72 GENERIC(int, fax
) // signed 16.16
73 GENERIC(int, fay
) // signed 16.16
74 // shift vector that was added to glyph before applying rotation
75 // = 0, if frx = fry = frx = 0
76 // = (glyph base point) - (rotation origin), otherwise
79 FTVECTOR(advance
) // subpixel shift vector
80 FTVECTOR(shadow_offset
) // shadow subpixel shift
81 GENERIC(unsigned, drawing_hash
) // hashcode of a drawing
82 GENERIC(unsigned, flags
) // glyph decoration
83 GENERIC(unsigned, border_style
)
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
93 GENERIC(unsigned, scale_x
) // 16.16
94 GENERIC(unsigned, scale_y
) // 16.16
95 FTVECTOR(outline
) // border width, 16.16
96 GENERIC(unsigned, drawing_hash
) // hashcode of a drawing
97 GENERIC(unsigned, flags
) // glyph decoration flags
98 GENERIC(unsigned, border_style
)
101 // Cache for composited bitmaps
102 START(composite
, composite_hash_key
)
113 GENERIC(unsigned char *, a
)
114 GENERIC(unsigned char *, b
)
115 END(CompositeHashKey
)