2020-04-17 11:14:09 +10:00
|
|
|
use piet_gpu_derive::piet_gpu;
|
|
|
|
|
|
|
|
piet_gpu! {
|
|
|
|
#[gpu_write]
|
|
|
|
mod ptcl {
|
|
|
|
struct CmdCircle {
|
2020-04-22 10:55:17 +10:00
|
|
|
center: [f32; 2],
|
|
|
|
radius: f32,
|
|
|
|
rgba_color: u32,
|
2020-04-17 11:14:09 +10:00
|
|
|
}
|
|
|
|
struct CmdLine {
|
|
|
|
start: [f32; 2],
|
|
|
|
end: [f32; 2],
|
|
|
|
}
|
|
|
|
struct CmdStroke {
|
2020-05-26 02:08:21 +10:00
|
|
|
// Consider a specialization to one segment.
|
|
|
|
seg_ref: Ref<SegChunk>,
|
2020-04-29 04:02:19 +10:00
|
|
|
half_width: f32,
|
2020-04-17 11:14:09 +10:00
|
|
|
rgba_color: u32,
|
|
|
|
}
|
|
|
|
struct CmdFill {
|
2020-05-16 08:20:25 +10:00
|
|
|
// Should be Ref<FillSegChunk>
|
2020-05-01 10:06:01 +10:00
|
|
|
seg_ref: u32,
|
|
|
|
backdrop: i32,
|
|
|
|
rgba_color: u32,
|
2020-04-17 11:14:09 +10:00
|
|
|
}
|
|
|
|
struct CmdFillEdge {
|
|
|
|
// The sign is only one bit.
|
|
|
|
sign: i32,
|
|
|
|
y: f32,
|
|
|
|
}
|
|
|
|
struct CmdDrawFill {
|
|
|
|
backdrop: i32,
|
|
|
|
rgba_color: u32,
|
|
|
|
}
|
|
|
|
struct CmdSolid {
|
|
|
|
rgba_color: u32,
|
|
|
|
}
|
2020-04-26 03:15:22 +10:00
|
|
|
struct CmdJump {
|
|
|
|
new_ref: u32,
|
|
|
|
}
|
2020-04-17 11:14:09 +10:00
|
|
|
enum Cmd {
|
|
|
|
End,
|
|
|
|
Circle(CmdCircle),
|
|
|
|
Line(CmdLine),
|
|
|
|
Fill(CmdFill),
|
|
|
|
Stroke(CmdStroke),
|
|
|
|
FillEdge(CmdFillEdge),
|
|
|
|
DrawFill(CmdDrawFill),
|
|
|
|
Solid(CmdSolid),
|
2020-04-26 03:15:22 +10:00
|
|
|
Jump(CmdJump),
|
2020-04-17 11:14:09 +10:00
|
|
|
Bail,
|
|
|
|
}
|
2020-05-16 08:20:25 +10:00
|
|
|
|
|
|
|
// TODO: strongly consider using f16. If so, these would be
|
|
|
|
// relative to the tile. We're doing f32 for now to minimize
|
|
|
|
// divergence from piet-metal originals.
|
|
|
|
struct Segment {
|
|
|
|
start: [f32; 2],
|
|
|
|
end: [f32; 2],
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SegChunk {
|
|
|
|
n: u32,
|
|
|
|
next: Ref<SegChunk>,
|
2020-05-26 02:08:21 +10:00
|
|
|
// Actually a reference to a variable-sized slice.
|
|
|
|
segs: Ref<Segment>,
|
2020-05-16 08:20:25 +10:00
|
|
|
}
|
2020-04-17 11:14:09 +10:00
|
|
|
}
|
|
|
|
}
|