30200
|
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;
|
34295
|
7 #define STRING(member) \
|
|
8 char *member;
|
30200
|
9 #define FTVECTOR(member) \
|
|
10 FT_Vector member;
|
|
11 #define BITMAPHASHKEY(member) \
|
|
12 BitmapHashKey member;
|
|
13 #define END(typedefnamename) \
|
|
14 } typedefnamename;
|
|
15
|
|
16 #elif defined(CREATE_COMPARISON_FUNCTIONS)
|
|
17 #undef CREATE_COMPARISON_FUNCTIONS
|
|
18 #define START(funcname, structname) \
|
34295
|
19 static unsigned funcname##_compare(void *key1, void *key2, size_t key_size) \
|
30200
|
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 &&
|
34295
|
26 #define STRING(member) \
|
|
27 strcmp(a->member, b->member) == 0 &&
|
30200
|
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; \
|
|
34 }
|
|
35
|
|
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);
|
34295
|
45 #define STRING(member) \
|
|
46 hval = fnv_32a_str(p->member, hval);
|
30200
|
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); \
|
|
51 }
|
|
52 #define END(typedefname) \
|
|
53 return hval; \
|
|
54 }
|
|
55
|
|
56 #else
|
|
57 #error missing defines
|
|
58 #endif
|
|
59
|
|
60
|
|
61
|
34295
|
62 // describes an outline bitmap
|
|
63 START(outline_bitmap, outline_bitmap_hash_key)
|
|
64 GENERIC(OutlineHashValue *, outline)
|
30200
|
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
|
34295
|
79 END(OutlineBitmapHashKey)
|
|
80
|
|
81 // describe a clip mask bitmap
|
|
82 START(clip_bitmap, clip_bitmap_hash_key)
|
|
83 STRING(text)
|
|
84 END(ClipMaskHashKey)
|
30200
|
85
|
|
86 // describes an outline glyph
|
|
87 START(glyph, glyph_hash_key)
|
|
88 GENERIC(ASS_Font *, font)
|
|
89 GENERIC(double, size) // font size
|
34295
|
90 GENERIC(int, face_index)
|
|
91 GENERIC(int, glyph_index)
|
30200
|
92 GENERIC(int, bold)
|
|
93 GENERIC(int, italic)
|
|
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)
|
|
99 END(GlyphHashKey)
|
|
100
|
34295
|
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)
|
|
109
|
|
110 // describes an outline drawing
|
|
111 START(drawing, drawing_hash_key)
|
|
112 GENERIC(unsigned, scale_x)
|
|
113 GENERIC(unsigned, scale_y)
|
|
114 GENERIC(int, pbo)
|
|
115 FTVECTOR(outline)
|
|
116 GENERIC(unsigned, border_style)
|
|
117 GENERIC(int, scale)
|
|
118 GENERIC(unsigned, hash)
|
|
119 STRING(text)
|
|
120 END(DrawingHashKey)
|
|
121
|
30200
|
122 // Cache for composited bitmaps
|
|
123 START(composite, composite_hash_key)
|
|
124 GENERIC(int, aw)
|
|
125 GENERIC(int, ah)
|
|
126 GENERIC(int, bw)
|
|
127 GENERIC(int, bh)
|
|
128 GENERIC(int, ax)
|
|
129 GENERIC(int, ay)
|
|
130 GENERIC(int, bx)
|
|
131 GENERIC(int, by)
|
|
132 GENERIC(int, as)
|
|
133 GENERIC(int, bs)
|
|
134 GENERIC(unsigned char *, a)
|
|
135 GENERIC(unsigned char *, b)
|
|
136 END(CompositeHashKey)
|
|
137
|
|
138
|
|
139 #undef START
|
|
140 #undef GENERIC
|
34295
|
141 #undef STRING
|
30200
|
142 #undef FTVECTOR
|
|
143 #undef BITMAPHASHKEY
|
|
144 #undef END
|