summaryrefslogtreecommitdiffstats
path: root/libass/ass_cache_template.h
blob: 2bb0228b875322c7a21a4070d01feb7964e12d9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifdef CREATE_STRUCT_DEFINITIONS
#undef CREATE_STRUCT_DEFINITIONS
#define START(funcname, structname) \
    typedef struct structname {
#define GENERIC(type, member) \
        type member;
#define STRING(member) \
        char *member;
#define VECTOR(member) \
        ASS_Vector member;
#define END(typedefnamename) \
    } typedefnamename;

#elif defined(CREATE_COMPARISON_FUNCTIONS)
#undef CREATE_COMPARISON_FUNCTIONS
#define START(funcname, structname) \
    static bool funcname##_compare(void *key1, void *key2) \
    { \
        struct structname *a = key1; \
        struct structname *b = key2; \
        return // conditions follow
#define GENERIC(type, member) \
            a->member == b->member &&
#define STRING(member) \
            strcmp(a->member, b->member) == 0 &&
#define VECTOR(member) \
            a->member.x == b->member.x && a->member.y == b->member.y &&
#define END(typedefname) \
            true; \
    }

#elif defined(CREATE_HASH_FUNCTIONS)
#undef CREATE_HASH_FUNCTIONS
#define START(funcname, structname) \
    static uint32_t funcname##_hash(void *buf, uint32_t hval) \
    { \
        struct structname *p = buf;
#define GENERIC(type, member) \
        hval = fnv_32a_buf(&p->member, sizeof(p->member), hval);
#define STRING(member) \
        hval = fnv_32a_str(p->member, hval);
#define VECTOR(member) GENERIC(, member.x); GENERIC(, member.y);
#define END(typedefname) \
        return hval; \
    }

#else
#error missing defines
#endif



// describes an outline bitmap
START(outline_bitmap, outline_bitmap_hash_key)
    GENERIC(OutlineHashValue *, outline)
    GENERIC(int, frx) // signed 10.22
    GENERIC(int, fry) // signed 10.22
    GENERIC(int, frz) // signed 10.22
    GENERIC(int, fax) // signed 16.16
    GENERIC(int, fay) // signed 16.16
    // shift vector that was added to glyph before applying rotation
    // = 0, if frx = fry = frx = 0
    // = (glyph base point) - (rotation origin), otherwise
    GENERIC(int, shift_x)
    GENERIC(int, shift_y)
    VECTOR(advance) // subpixel shift vector
END(OutlineBitmapHashKey)

// describe a clip mask bitmap
START(clip_bitmap, clip_bitmap_hash_key)
    GENERIC(int, scale)
    STRING(text)
END(ClipMaskHashKey)

START(glyph_metrics, glyph_metrics_hash_key)
    GENERIC(ASS_Font *, font)
    GENERIC(double, size)
    GENERIC(int, face_index)
    GENERIC(int, glyph_index)
END(GlyphMetricsHashKey)

// common outline data
START(outline_common, outline_common_hash_key)
    GENERIC(unsigned, scale_x) // 16.16
    GENERIC(unsigned, scale_y) // 16.16
    VECTOR(outline) // border width, 26.6
    GENERIC(unsigned, border_style)
    GENERIC(int, scale_fix)    // 16.16
    GENERIC(int, advance)      // 26.6
END(OutlineCommonKey)

// describes an outline glyph
START(glyph, glyph_hash_key)
    GENERIC(unsigned, scale_x) // 16.16
    GENERIC(unsigned, scale_y) // 16.16
    VECTOR(outline) // border width, 26.6
    GENERIC(unsigned, border_style)
    GENERIC(int, scale_fix)    // 16.16
    GENERIC(int, advance)      // 26.6

    GENERIC(ASS_Font *, font)
    GENERIC(double, size) // font size
    GENERIC(int, face_index)
    GENERIC(int, glyph_index)
    GENERIC(int, bold)
    GENERIC(int, italic)
    GENERIC(unsigned, flags) // glyph decoration flags
END(GlyphHashKey)

// describes an outline drawing
START(drawing, drawing_hash_key)
    GENERIC(unsigned, scale_x) // 16.16
    GENERIC(unsigned, scale_y) // 16.16
    VECTOR(outline) // border width, 26.6
    GENERIC(unsigned, border_style)
    GENERIC(int, scale_fix)    // 16.16
    GENERIC(int, advance)      // 26.6

    GENERIC(int, pbo)
    GENERIC(int, scale)
    STRING(text)
END(DrawingHashKey)

// describes post-combining effects
START(filter, filter_desc)
    GENERIC(int, flags)
    GENERIC(int, be)
    GENERIC(double, blur)
    VECTOR(shadow)
END(FilterDesc)

#undef START
#undef GENERIC
#undef STRING
#undef VECTOR
#undef END