aboutsummaryrefslogtreecommitdiff
path: root/vendor/gioui.org/shader/piet/scene.h
blob: 38c2549dd82db6536c24a0841bbbb7d406b74196 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense

// Code auto-generated by piet-gpu-derive

struct LineSegRef {
    uint offset;
};

struct QuadSegRef {
    uint offset;
};

struct CubicSegRef {
    uint offset;
};

struct FillColorRef {
    uint offset;
};

struct FillImageRef {
    uint offset;
};

struct SetLineWidthRef {
    uint offset;
};

struct TransformRef {
    uint offset;
};

struct ClipRef {
    uint offset;
};

struct SetFillModeRef {
    uint offset;
};

struct ElementRef {
    uint offset;
};

struct LineSeg {
    vec2 p0;
    vec2 p1;
};

#define LineSeg_size 16

LineSegRef LineSeg_index(LineSegRef ref, uint index) {
    return LineSegRef(ref.offset + index * LineSeg_size);
}

struct QuadSeg {
    vec2 p0;
    vec2 p1;
    vec2 p2;
};

#define QuadSeg_size 24

QuadSegRef QuadSeg_index(QuadSegRef ref, uint index) {
    return QuadSegRef(ref.offset + index * QuadSeg_size);
}

struct CubicSeg {
    vec2 p0;
    vec2 p1;
    vec2 p2;
    vec2 p3;
};

#define CubicSeg_size 32

CubicSegRef CubicSeg_index(CubicSegRef ref, uint index) {
    return CubicSegRef(ref.offset + index * CubicSeg_size);
}

struct FillColor {
    uint rgba_color;
};

#define FillColor_size 4

FillColorRef FillColor_index(FillColorRef ref, uint index) {
    return FillColorRef(ref.offset + index * FillColor_size);
}

struct FillImage {
    uint index;
    ivec2 offset;
};

#define FillImage_size 8

FillImageRef FillImage_index(FillImageRef ref, uint index) {
    return FillImageRef(ref.offset + index * FillImage_size);
}

struct SetLineWidth {
    float width;
};

#define SetLineWidth_size 4

SetLineWidthRef SetLineWidth_index(SetLineWidthRef ref, uint index) {
    return SetLineWidthRef(ref.offset + index * SetLineWidth_size);
}

struct Transform {
    vec4 mat;
    vec2 translate;
};

#define Transform_size 24

TransformRef Transform_index(TransformRef ref, uint index) {
    return TransformRef(ref.offset + index * Transform_size);
}

struct Clip {
    vec4 bbox;
};

#define Clip_size 16

ClipRef Clip_index(ClipRef ref, uint index) {
    return ClipRef(ref.offset + index * Clip_size);
}

struct SetFillMode {
    uint fill_mode;
};

#define SetFillMode_size 4

SetFillModeRef SetFillMode_index(SetFillModeRef ref, uint index) {
    return SetFillModeRef(ref.offset + index * SetFillMode_size);
}

#define Element_Nop 0
#define Element_Line 1
#define Element_Quad 2
#define Element_Cubic 3
#define Element_FillColor 4
#define Element_SetLineWidth 5
#define Element_Transform 6
#define Element_BeginClip 7
#define Element_EndClip 8
#define Element_FillImage 9
#define Element_SetFillMode 10
#define Element_size 36

ElementRef Element_index(ElementRef ref, uint index) {
    return ElementRef(ref.offset + index * Element_size);
}

struct ElementTag {
   uint tag;
   uint flags;
};

LineSeg LineSeg_read(LineSegRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    uint raw2 = scene[ix + 2];
    uint raw3 = scene[ix + 3];
    LineSeg s;
    s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
    s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
    return s;
}

QuadSeg QuadSeg_read(QuadSegRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    uint raw2 = scene[ix + 2];
    uint raw3 = scene[ix + 3];
    uint raw4 = scene[ix + 4];
    uint raw5 = scene[ix + 5];
    QuadSeg s;
    s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
    s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
    s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
    return s;
}

CubicSeg CubicSeg_read(CubicSegRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    uint raw2 = scene[ix + 2];
    uint raw3 = scene[ix + 3];
    uint raw4 = scene[ix + 4];
    uint raw5 = scene[ix + 5];
    uint raw6 = scene[ix + 6];
    uint raw7 = scene[ix + 7];
    CubicSeg s;
    s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
    s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
    s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
    s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
    return s;
}

FillColor FillColor_read(FillColorRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    FillColor s;
    s.rgba_color = raw0;
    return s;
}

FillImage FillImage_read(FillImageRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    FillImage s;
    s.index = raw0;
    s.offset = ivec2(int(raw1 << 16) >> 16, int(raw1) >> 16);
    return s;
}

SetLineWidth SetLineWidth_read(SetLineWidthRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    SetLineWidth s;
    s.width = uintBitsToFloat(raw0);
    return s;
}

Transform Transform_read(TransformRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    uint raw2 = scene[ix + 2];
    uint raw3 = scene[ix + 3];
    uint raw4 = scene[ix + 4];
    uint raw5 = scene[ix + 5];
    Transform s;
    s.mat = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));
    s.translate = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
    return s;
}

Clip Clip_read(ClipRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    uint raw1 = scene[ix + 1];
    uint raw2 = scene[ix + 2];
    uint raw3 = scene[ix + 3];
    Clip s;
    s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3));
    return s;
}

SetFillMode SetFillMode_read(SetFillModeRef ref) {
    uint ix = ref.offset >> 2;
    uint raw0 = scene[ix + 0];
    SetFillMode s;
    s.fill_mode = raw0;
    return s;
}

ElementTag Element_tag(ElementRef ref) {
    uint tag_and_flags = scene[ref.offset >> 2];
    return ElementTag(tag_and_flags & 0xffff, tag_and_flags >> 16);
}

LineSeg Element_Line_read(ElementRef ref) {
    return LineSeg_read(LineSegRef(ref.offset + 4));
}

QuadSeg Element_Quad_read(ElementRef ref) {
    return QuadSeg_read(QuadSegRef(ref.offset + 4));
}

CubicSeg Element_Cubic_read(ElementRef ref) {
    return CubicSeg_read(CubicSegRef(ref.offset + 4));
}

FillColor Element_FillColor_read(ElementRef ref) {
    return FillColor_read(FillColorRef(ref.offset + 4));
}

SetLineWidth Element_SetLineWidth_read(ElementRef ref) {
    return SetLineWidth_read(SetLineWidthRef(ref.offset + 4));
}

Transform Element_Transform_read(ElementRef ref) {
    return Transform_read(TransformRef(ref.offset + 4));
}

Clip Element_BeginClip_read(ElementRef ref) {
    return Clip_read(ClipRef(ref.offset + 4));
}

Clip Element_EndClip_read(ElementRef ref) {
    return Clip_read(ClipRef(ref.offset + 4));
}

FillImage Element_FillImage_read(ElementRef ref) {
    return FillImage_read(FillImageRef(ref.offset + 4));
}

SetFillMode Element_SetFillMode_read(ElementRef ref) {
    return SetFillMode_read(SetFillModeRef(ref.offset + 4));
}