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 STRING(member) \
9 #define FTVECTOR(member) \
11 #define BITMAPHASHKEY(member) \
13 #define END(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) \
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) \
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) \
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) \
57 #error missing defines
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
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
)
86 // describes an outline glyph
87 START(glyph
, glyph_hash_key
)
88 GENERIC(ASS_Font
*, font
)
89 GENERIC(double, size
) // font size
90 GENERIC(int, face_index
)
91 GENERIC(int, glyph_index
)
94 GENERIC(unsigned, scale_x
) // 16.16
95 GENERIC(unsigned, scale_y
) // 16.16
96 FTVECTOR(outline
) // border width, 16.16
97 GENERIC(unsigned, flags
) // glyph decoration flags
98 GENERIC(unsigned, border_style
)
101 START(glyph_metrics
, glyph_metrics_hash_key
)
102 GENERIC(ASS_Font
*, font
)
103 GENERIC(double, size
)
104 GENERIC(int, face_index
)
105 GENERIC(int, glyph_index
)
106 GENERIC(unsigned, scale_x
)
107 GENERIC(unsigned, scale_y
)
108 END(GlyphMetricsHashKey
)
110 // describes an outline drawing
111 START(drawing
, drawing_hash_key
)
112 GENERIC(unsigned, scale_x
)
113 GENERIC(unsigned, scale_y
)
116 GENERIC(unsigned, border_style
)
118 GENERIC(unsigned, hash
)
122 // Cache for composited bitmaps
123 START(composite
, composite_hash_key
)
134 GENERIC(unsigned char *, a
)
135 GENERIC(unsigned char *, b
)
136 END(CompositeHashKey
)