Another project
1pub mod arc;
2pub mod chrome;
3pub mod chrome_text;
4pub mod edge_3d;
5pub mod glyph;
6pub mod grid;
7pub mod icon;
8pub mod lines;
9pub mod solid;
10pub mod text;
11mod text_common;
12pub mod vector;
13
14pub use arc::ArcPipeline;
15pub use chrome::{ChromeInstance, ChromePipeline};
16pub use chrome_text::{ChromeTextPipeline, SdfGlyphInstance};
17pub(crate) use edge_3d::{Edge3dPipeline, EdgeProjection, EdgeView, HiddenEdges};
18pub use glyph::GlyphPipeline;
19pub use grid::GridPipeline;
20pub use icon::{IconInstance, IconPipeline};
21pub use lines::LinesPipeline;
22pub(crate) use solid::{FaceFill, SolidPipeline, SolidView};
23pub use text::TextPipeline;
24pub use vector::{
25 ConvexInstance, ConvexPolyPipeline, MAX_PLANES, MAX_STROKE_POINTS, StrokeInstance,
26 StrokePipeline,
27};
28
29use crate::camera::Camera2;
30use crate::snapshot::Style;
31
32#[repr(C, align(16))]
33#[derive(Copy, Clone, bytemuck::Pod, bytemuck::Zeroable)]
34pub(crate) struct FrameUniform {
35 pub clip_from_world: [f32; 16],
36 pub stroke_color: [f32; 4],
37 pub construction_color: [f32; 4],
38 pub pixels_per_mm: f32,
39 pub dash_period_px: f32,
40 pub dash_on_ratio: f32,
41 pub _pad: f32,
42}
43
44pub(crate) const FRAME_UNIFORM_SIZE: u64 = core::mem::size_of::<FrameUniform>() as u64;
45
46pub(crate) const CONSTRUCTION_BIT: u32 = 1;
47
48#[allow(
49 clippy::cast_possible_truncation,
50 clippy::cast_precision_loss,
51 reason = "zoom factor and stroke widths fit f32 mantissa at CAD scales"
52)]
53pub(crate) fn build_frame_uniform(camera: Camera2, style: &Style) -> FrameUniform {
54 let strokes = style.strokes();
55 FrameUniform {
56 clip_from_world: camera.clip_from_world_mm(),
57 stroke_color: strokes.stroke().to_rgba_array(),
58 construction_color: strokes.construction().to_rgba_array(),
59 pixels_per_mm: camera.zoom().value() as f32,
60 dash_period_px: strokes.construction_dash_period_px(),
61 dash_on_ratio: strokes.construction_dash_on_ratio(),
62 _pad: 0.0,
63 }
64}