pathseg.h raw
1 // SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense
2
3 // Code auto-generated by piet-gpu-derive
4
5 struct PathCubicRef {
6 uint offset;
7 };
8
9 struct PathSegRef {
10 uint offset;
11 };
12
13 struct PathCubic {
14 vec2 p0;
15 vec2 p1;
16 vec2 p2;
17 vec2 p3;
18 uint path_ix;
19 uint trans_ix;
20 vec2 stroke;
21 };
22
23 #define PathCubic_size 48
24
25 PathCubicRef PathCubic_index(PathCubicRef ref, uint index) {
26 return PathCubicRef(ref.offset + index * PathCubic_size);
27 }
28
29 #define PathSeg_Nop 0
30 #define PathSeg_Cubic 1
31 #define PathSeg_size 52
32
33 PathSegRef PathSeg_index(PathSegRef ref, uint index) {
34 return PathSegRef(ref.offset + index * PathSeg_size);
35 }
36
37 struct PathSegTag {
38 uint tag;
39 uint flags;
40 };
41
42 PathCubic PathCubic_read(Alloc a, PathCubicRef ref) {
43 uint ix = ref.offset >> 2;
44 uint raw0 = read_mem(a, ix + 0);
45 uint raw1 = read_mem(a, ix + 1);
46 uint raw2 = read_mem(a, ix + 2);
47 uint raw3 = read_mem(a, ix + 3);
48 uint raw4 = read_mem(a, ix + 4);
49 uint raw5 = read_mem(a, ix + 5);
50 uint raw6 = read_mem(a, ix + 6);
51 uint raw7 = read_mem(a, ix + 7);
52 uint raw8 = read_mem(a, ix + 8);
53 uint raw9 = read_mem(a, ix + 9);
54 uint raw10 = read_mem(a, ix + 10);
55 uint raw11 = read_mem(a, ix + 11);
56 PathCubic s;
57 s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
58 s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
59 s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
60 s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
61 s.path_ix = raw8;
62 s.trans_ix = raw9;
63 s.stroke = vec2(uintBitsToFloat(raw10), uintBitsToFloat(raw11));
64 return s;
65 }
66
67 void PathCubic_write(Alloc a, PathCubicRef ref, PathCubic s) {
68 uint ix = ref.offset >> 2;
69 write_mem(a, ix + 0, floatBitsToUint(s.p0.x));
70 write_mem(a, ix + 1, floatBitsToUint(s.p0.y));
71 write_mem(a, ix + 2, floatBitsToUint(s.p1.x));
72 write_mem(a, ix + 3, floatBitsToUint(s.p1.y));
73 write_mem(a, ix + 4, floatBitsToUint(s.p2.x));
74 write_mem(a, ix + 5, floatBitsToUint(s.p2.y));
75 write_mem(a, ix + 6, floatBitsToUint(s.p3.x));
76 write_mem(a, ix + 7, floatBitsToUint(s.p3.y));
77 write_mem(a, ix + 8, s.path_ix);
78 write_mem(a, ix + 9, s.trans_ix);
79 write_mem(a, ix + 10, floatBitsToUint(s.stroke.x));
80 write_mem(a, ix + 11, floatBitsToUint(s.stroke.y));
81 }
82
83 PathSegTag PathSeg_tag(Alloc a, PathSegRef ref) {
84 uint tag_and_flags = read_mem(a, ref.offset >> 2);
85 return PathSegTag(tag_and_flags & 0xffff, tag_and_flags >> 16);
86 }
87
88 PathCubic PathSeg_Cubic_read(Alloc a, PathSegRef ref) {
89 return PathCubic_read(a, PathCubicRef(ref.offset + 4));
90 }
91
92 void PathSeg_Nop_write(Alloc a, PathSegRef ref) {
93 write_mem(a, ref.offset >> 2, PathSeg_Nop);
94 }
95
96 void PathSeg_Cubic_write(Alloc a, PathSegRef ref, uint flags, PathCubic s) {
97 write_mem(a, ref.offset >> 2, (flags << 16) | PathSeg_Cubic);
98 PathCubic_write(a, PathCubicRef(ref.offset + 4), s);
99 }
100
101