mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-25 10:46:34 +11:00
076e6d600d
Write the right_edge to the binning output. More work on encoding the fill/stroke distinction and plumbing that through the pipeline. This is a bit unsatisfying because of the code duplication; having an extra fill/stroke bool might be better, but I want to avoid making the structs bigger (this could be solved by better packing in the struct encoding). Fills are plumbed through to the last stage. Backdrop is WIP.
105 lines
2.8 KiB
Rust
105 lines
2.8 KiB
Rust
use piet_gpu_derive::piet_gpu;
|
|
|
|
pub use self::scene::{
|
|
Bbox, PietCircle, PietFill, PietItem, PietStrokeLine, PietStrokePolyLine, Point, SimpleGroup,
|
|
};
|
|
|
|
pub use self::scene::{CubicSeg, Element, Fill, LineSeg, QuadSeg, SetLineWidth, Stroke, Transform};
|
|
|
|
piet_gpu! {
|
|
#[rust_encode]
|
|
mod scene {
|
|
struct Bbox {
|
|
bbox: [i16; 4],
|
|
}
|
|
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>,
|
|
offset: Point,
|
|
}
|
|
struct PietCircle {
|
|
rgba_color: u32,
|
|
center: Point,
|
|
radius: f32,
|
|
}
|
|
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 {
|
|
Group(SimpleGroup),
|
|
Circle(PietCircle),
|
|
Line(PietStrokeLine),
|
|
Fill(PietFill),
|
|
Poly(PietStrokePolyLine),
|
|
}
|
|
|
|
// 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,
|
|
// 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.
|
|
Quad(QuadSeg),
|
|
Cubic(CubicSeg),
|
|
Stroke(Stroke),
|
|
Fill(Fill),
|
|
SetLineWidth(SetLineWidth),
|
|
Transform(Transform),
|
|
}
|
|
}
|
|
}
|