2020-04-16 18:14:09 -07:00
|
|
|
use piet_gpu_derive::piet_gpu;
|
|
|
|
|
|
|
|
pub use self::scene::{
|
2020-04-17 16:01:37 -07:00
|
|
|
Bbox, PietCircle, PietFill, PietItem, PietStrokeLine, PietStrokePolyLine, Point, SimpleGroup,
|
2020-04-16 18:14:09 -07:00
|
|
|
};
|
|
|
|
|
2020-05-11 20:01:06 -07:00
|
|
|
pub use self::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke, Transform};
|
|
|
|
|
2020-04-16 18:14:09 -07:00
|
|
|
piet_gpu! {
|
|
|
|
#[rust_encode]
|
|
|
|
mod scene {
|
|
|
|
struct Bbox {
|
2020-04-20 17:15:36 -07:00
|
|
|
bbox: [i16; 4],
|
2020-04-16 18:14:09 -07:00
|
|
|
}
|
|
|
|
struct Point {
|
|
|
|
xy: [f32; 2],
|
|
|
|
}
|
|
|
|
struct SimpleGroup {
|
|
|
|
n_items: u32,
|
|
|
|
// Note: both of the following items are actually arrays
|
|
|
|
items: Ref<PietItem>,
|
|
|
|
bboxes: Ref<Bbox>,
|
2020-04-20 17:15:36 -07:00
|
|
|
offset: Point,
|
2020-04-16 18:14:09 -07:00
|
|
|
}
|
2020-04-17 16:01:37 -07:00
|
|
|
struct PietCircle {
|
|
|
|
rgba_color: u32,
|
|
|
|
center: Point,
|
|
|
|
radius: f32,
|
|
|
|
}
|
2020-04-16 18:14:09 -07:00
|
|
|
struct PietStrokeLine {
|
|
|
|
flags: u32,
|
|
|
|
rgba_color: u32,
|
|
|
|
width: f32,
|
|
|
|
start: Point,
|
|
|
|
end: Point,
|
|
|
|
}
|
|
|
|
struct PietFill {
|
|
|
|
flags: u32,
|
|
|
|
rgba_color: u32,
|
|
|
|
n_points: u32,
|
|
|
|
points: Ref<Point>,
|
|
|
|
}
|
|
|
|
struct PietStrokePolyLine {
|
|
|
|
rgba_color: u32,
|
|
|
|
width: f32,
|
|
|
|
n_points: u32,
|
|
|
|
points: Ref<Point>,
|
|
|
|
}
|
|
|
|
enum PietItem {
|
2020-04-20 17:15:36 -07:00
|
|
|
Group(SimpleGroup),
|
2020-04-17 16:01:37 -07:00
|
|
|
Circle(PietCircle),
|
2020-04-16 18:14:09 -07:00
|
|
|
Line(PietStrokeLine),
|
|
|
|
Fill(PietFill),
|
|
|
|
Poly(PietStrokePolyLine),
|
|
|
|
}
|
2020-05-11 20:01:06 -07:00
|
|
|
|
|
|
|
// New approach follows (above to be deleted)
|
|
|
|
struct LineSeg {
|
|
|
|
p0: [f32; 2],
|
|
|
|
p1: [f32; 2],
|
|
|
|
}
|
|
|
|
struct QuadSeg {
|
|
|
|
p0: [f32; 2],
|
|
|
|
p1: [f32; 2],
|
|
|
|
p2: [f32; 2],
|
|
|
|
}
|
|
|
|
struct CubicSeg {
|
|
|
|
p0: [f32; 2],
|
|
|
|
p1: [f32; 2],
|
|
|
|
p2: [f32; 2],
|
|
|
|
p3: [f32; 2],
|
|
|
|
}
|
|
|
|
struct Fill {
|
|
|
|
rgba_color: u32,
|
|
|
|
}
|
|
|
|
struct Stroke {
|
|
|
|
rgba_color: u32,
|
|
|
|
}
|
|
|
|
struct SetLineWidth {
|
|
|
|
width: f32,
|
|
|
|
}
|
|
|
|
struct Transform {
|
|
|
|
mat: [f32; 4],
|
|
|
|
translate: [f32; 2],
|
|
|
|
}
|
|
|
|
enum Element {
|
|
|
|
Nop,
|
2020-05-20 07:38:52 -07:00
|
|
|
// Another approach to encoding would be to use a single
|
|
|
|
// variant but have a bool for fill/stroke. This could be
|
|
|
|
// packed into the tag, so the on-the-wire representation
|
|
|
|
// would be very similar to what's here.
|
|
|
|
StrokeLine(LineSeg),
|
|
|
|
FillLine(LineSeg),
|
|
|
|
|
|
|
|
// Note: we'll need to handle the stroke/fill distinction
|
|
|
|
// for these as well, when we do flattening on the GPU.
|
2020-05-11 20:01:06 -07:00
|
|
|
Quad(QuadSeg),
|
|
|
|
Cubic(CubicSeg),
|
|
|
|
Stroke(Stroke),
|
|
|
|
Fill(Fill),
|
|
|
|
SetLineWidth(SetLineWidth),
|
|
|
|
Transform(Transform),
|
|
|
|
}
|
2020-04-16 18:14:09 -07:00
|
|
|
}
|
|
|
|
}
|