mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
736f883f66
Apply transform to paths and annotate with computed linewidth and bounding box information, storing the result.
291 lines
8.3 KiB
C
291 lines
8.3 KiB
C
// Code auto-generated by piet-gpu-derive
|
|
|
|
struct AnnoLineSegRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnoQuadSegRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnoCubicSegRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnoFillRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnoStrokeRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnotatedRef {
|
|
uint offset;
|
|
};
|
|
|
|
struct AnnoLineSeg {
|
|
vec2 p0;
|
|
vec2 p1;
|
|
vec2 stroke;
|
|
};
|
|
|
|
#define AnnoLineSeg_size 24
|
|
|
|
AnnoLineSegRef AnnoLineSeg_index(AnnoLineSegRef ref, uint index) {
|
|
return AnnoLineSegRef(ref.offset + index * AnnoLineSeg_size);
|
|
}
|
|
|
|
struct AnnoQuadSeg {
|
|
vec2 p0;
|
|
vec2 p1;
|
|
vec2 p2;
|
|
vec2 stroke;
|
|
};
|
|
|
|
#define AnnoQuadSeg_size 32
|
|
|
|
AnnoQuadSegRef AnnoQuadSeg_index(AnnoQuadSegRef ref, uint index) {
|
|
return AnnoQuadSegRef(ref.offset + index * AnnoQuadSeg_size);
|
|
}
|
|
|
|
struct AnnoCubicSeg {
|
|
vec2 p0;
|
|
vec2 p1;
|
|
vec2 p2;
|
|
vec2 p3;
|
|
vec2 stroke;
|
|
};
|
|
|
|
#define AnnoCubicSeg_size 40
|
|
|
|
AnnoCubicSegRef AnnoCubicSeg_index(AnnoCubicSegRef ref, uint index) {
|
|
return AnnoCubicSegRef(ref.offset + index * AnnoCubicSeg_size);
|
|
}
|
|
|
|
struct AnnoFill {
|
|
uint rgba_color;
|
|
vec4 bbox;
|
|
};
|
|
|
|
#define AnnoFill_size 20
|
|
|
|
AnnoFillRef AnnoFill_index(AnnoFillRef ref, uint index) {
|
|
return AnnoFillRef(ref.offset + index * AnnoFill_size);
|
|
}
|
|
|
|
struct AnnoStroke {
|
|
uint rgba_color;
|
|
vec4 bbox;
|
|
float linewidth;
|
|
};
|
|
|
|
#define AnnoStroke_size 24
|
|
|
|
AnnoStrokeRef AnnoStroke_index(AnnoStrokeRef ref, uint index) {
|
|
return AnnoStrokeRef(ref.offset + index * AnnoStroke_size);
|
|
}
|
|
|
|
#define Annotated_Nop 0
|
|
#define Annotated_Line 1
|
|
#define Annotated_Quad 2
|
|
#define Annotated_Cubic 3
|
|
#define Annotated_Stroke 4
|
|
#define Annotated_Fill 5
|
|
#define Annotated_size 44
|
|
|
|
AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) {
|
|
return AnnotatedRef(ref.offset + index * Annotated_size);
|
|
}
|
|
|
|
AnnoLineSeg AnnoLineSeg_read(AnnoLineSegRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = annotated[ix + 0];
|
|
uint raw1 = annotated[ix + 1];
|
|
uint raw2 = annotated[ix + 2];
|
|
uint raw3 = annotated[ix + 3];
|
|
uint raw4 = annotated[ix + 4];
|
|
uint raw5 = annotated[ix + 5];
|
|
AnnoLineSeg s;
|
|
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
s.stroke = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
|
return s;
|
|
}
|
|
|
|
void AnnoLineSeg_write(AnnoLineSegRef ref, AnnoLineSeg s) {
|
|
uint ix = ref.offset >> 2;
|
|
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
|
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
|
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
|
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
|
annotated[ix + 4] = floatBitsToUint(s.stroke.x);
|
|
annotated[ix + 5] = floatBitsToUint(s.stroke.y);
|
|
}
|
|
|
|
AnnoQuadSeg AnnoQuadSeg_read(AnnoQuadSegRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = annotated[ix + 0];
|
|
uint raw1 = annotated[ix + 1];
|
|
uint raw2 = annotated[ix + 2];
|
|
uint raw3 = annotated[ix + 3];
|
|
uint raw4 = annotated[ix + 4];
|
|
uint raw5 = annotated[ix + 5];
|
|
uint raw6 = annotated[ix + 6];
|
|
uint raw7 = annotated[ix + 7];
|
|
AnnoQuadSeg s;
|
|
s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1));
|
|
s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3));
|
|
s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5));
|
|
s.stroke = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7));
|
|
return s;
|
|
}
|
|
|
|
void AnnoQuadSeg_write(AnnoQuadSegRef ref, AnnoQuadSeg s) {
|
|
uint ix = ref.offset >> 2;
|
|
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
|
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
|
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
|
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
|
annotated[ix + 4] = floatBitsToUint(s.p2.x);
|
|
annotated[ix + 5] = floatBitsToUint(s.p2.y);
|
|
annotated[ix + 6] = floatBitsToUint(s.stroke.x);
|
|
annotated[ix + 7] = floatBitsToUint(s.stroke.y);
|
|
}
|
|
|
|
AnnoCubicSeg AnnoCubicSeg_read(AnnoCubicSegRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = annotated[ix + 0];
|
|
uint raw1 = annotated[ix + 1];
|
|
uint raw2 = annotated[ix + 2];
|
|
uint raw3 = annotated[ix + 3];
|
|
uint raw4 = annotated[ix + 4];
|
|
uint raw5 = annotated[ix + 5];
|
|
uint raw6 = annotated[ix + 6];
|
|
uint raw7 = annotated[ix + 7];
|
|
uint raw8 = annotated[ix + 8];
|
|
uint raw9 = annotated[ix + 9];
|
|
AnnoCubicSeg 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));
|
|
s.stroke = vec2(uintBitsToFloat(raw8), uintBitsToFloat(raw9));
|
|
return s;
|
|
}
|
|
|
|
void AnnoCubicSeg_write(AnnoCubicSegRef ref, AnnoCubicSeg s) {
|
|
uint ix = ref.offset >> 2;
|
|
annotated[ix + 0] = floatBitsToUint(s.p0.x);
|
|
annotated[ix + 1] = floatBitsToUint(s.p0.y);
|
|
annotated[ix + 2] = floatBitsToUint(s.p1.x);
|
|
annotated[ix + 3] = floatBitsToUint(s.p1.y);
|
|
annotated[ix + 4] = floatBitsToUint(s.p2.x);
|
|
annotated[ix + 5] = floatBitsToUint(s.p2.y);
|
|
annotated[ix + 6] = floatBitsToUint(s.p3.x);
|
|
annotated[ix + 7] = floatBitsToUint(s.p3.y);
|
|
annotated[ix + 8] = floatBitsToUint(s.stroke.x);
|
|
annotated[ix + 9] = floatBitsToUint(s.stroke.y);
|
|
}
|
|
|
|
AnnoFill AnnoFill_read(AnnoFillRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = annotated[ix + 0];
|
|
uint raw1 = annotated[ix + 1];
|
|
uint raw2 = annotated[ix + 2];
|
|
uint raw3 = annotated[ix + 3];
|
|
uint raw4 = annotated[ix + 4];
|
|
AnnoFill s;
|
|
s.rgba_color = raw0;
|
|
s.bbox = vec4(uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3), uintBitsToFloat(raw4));
|
|
return s;
|
|
}
|
|
|
|
void AnnoFill_write(AnnoFillRef ref, AnnoFill s) {
|
|
uint ix = ref.offset >> 2;
|
|
annotated[ix + 0] = s.rgba_color;
|
|
annotated[ix + 1] = floatBitsToUint(s.bbox.x);
|
|
annotated[ix + 2] = floatBitsToUint(s.bbox.y);
|
|
annotated[ix + 3] = floatBitsToUint(s.bbox.z);
|
|
annotated[ix + 4] = floatBitsToUint(s.bbox.w);
|
|
}
|
|
|
|
AnnoStroke AnnoStroke_read(AnnoStrokeRef ref) {
|
|
uint ix = ref.offset >> 2;
|
|
uint raw0 = annotated[ix + 0];
|
|
uint raw1 = annotated[ix + 1];
|
|
uint raw2 = annotated[ix + 2];
|
|
uint raw3 = annotated[ix + 3];
|
|
uint raw4 = annotated[ix + 4];
|
|
uint raw5 = annotated[ix + 5];
|
|
AnnoStroke s;
|
|
s.rgba_color = raw0;
|
|
s.bbox = vec4(uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3), uintBitsToFloat(raw4));
|
|
s.linewidth = uintBitsToFloat(raw5);
|
|
return s;
|
|
}
|
|
|
|
void AnnoStroke_write(AnnoStrokeRef ref, AnnoStroke s) {
|
|
uint ix = ref.offset >> 2;
|
|
annotated[ix + 0] = s.rgba_color;
|
|
annotated[ix + 1] = floatBitsToUint(s.bbox.x);
|
|
annotated[ix + 2] = floatBitsToUint(s.bbox.y);
|
|
annotated[ix + 3] = floatBitsToUint(s.bbox.z);
|
|
annotated[ix + 4] = floatBitsToUint(s.bbox.w);
|
|
annotated[ix + 5] = floatBitsToUint(s.linewidth);
|
|
}
|
|
|
|
uint Annotated_tag(AnnotatedRef ref) {
|
|
return annotated[ref.offset >> 2];
|
|
}
|
|
|
|
AnnoLineSeg Annotated_Line_read(AnnotatedRef ref) {
|
|
return AnnoLineSeg_read(AnnoLineSegRef(ref.offset + 4));
|
|
}
|
|
|
|
AnnoQuadSeg Annotated_Quad_read(AnnotatedRef ref) {
|
|
return AnnoQuadSeg_read(AnnoQuadSegRef(ref.offset + 4));
|
|
}
|
|
|
|
AnnoCubicSeg Annotated_Cubic_read(AnnotatedRef ref) {
|
|
return AnnoCubicSeg_read(AnnoCubicSegRef(ref.offset + 4));
|
|
}
|
|
|
|
AnnoStroke Annotated_Stroke_read(AnnotatedRef ref) {
|
|
return AnnoStroke_read(AnnoStrokeRef(ref.offset + 4));
|
|
}
|
|
|
|
AnnoFill Annotated_Fill_read(AnnotatedRef ref) {
|
|
return AnnoFill_read(AnnoFillRef(ref.offset + 4));
|
|
}
|
|
|
|
void Annotated_Nop_write(AnnotatedRef ref) {
|
|
annotated[ref.offset >> 2] = Annotated_Nop;
|
|
}
|
|
|
|
void Annotated_Line_write(AnnotatedRef ref, AnnoLineSeg s) {
|
|
annotated[ref.offset >> 2] = Annotated_Line;
|
|
AnnoLineSeg_write(AnnoLineSegRef(ref.offset + 4), s);
|
|
}
|
|
|
|
void Annotated_Quad_write(AnnotatedRef ref, AnnoQuadSeg s) {
|
|
annotated[ref.offset >> 2] = Annotated_Quad;
|
|
AnnoQuadSeg_write(AnnoQuadSegRef(ref.offset + 4), s);
|
|
}
|
|
|
|
void Annotated_Cubic_write(AnnotatedRef ref, AnnoCubicSeg s) {
|
|
annotated[ref.offset >> 2] = Annotated_Cubic;
|
|
AnnoCubicSeg_write(AnnoCubicSegRef(ref.offset + 4), s);
|
|
}
|
|
|
|
void Annotated_Stroke_write(AnnotatedRef ref, AnnoStroke s) {
|
|
annotated[ref.offset >> 2] = Annotated_Stroke;
|
|
AnnoStroke_write(AnnoStrokeRef(ref.offset + 4), s);
|
|
}
|
|
|
|
void Annotated_Fill_write(AnnotatedRef ref, AnnoFill s) {
|
|
annotated[ref.offset >> 2] = Annotated_Fill;
|
|
AnnoFill_write(AnnoFillRef(ref.offset + 4), s);
|
|
}
|
|
|