1mod atlases;
11mod common;
12mod custom;
13mod draw_pipe;
14mod flat_round;
15mod images;
16mod round_2col;
17mod shaded_round;
18mod shaded_square;
19mod shaders;
20
21use kas::draw::WindowCommon;
22use kas::geom::{Offset, Rect};
23use shaders::ShaderManager;
24use wgpu::TextureFormat;
25
26pub use custom::{CustomPipe, CustomPipeBuilder, CustomWindow, DrawCustom};
27
28pub(crate) const RENDER_TEX_FORMAT: TextureFormat = TextureFormat::Bgra8UnormSrgb;
33
34type Scale = [f32; 4];
35
36#[derive(Debug)]
37struct ClipRegion {
38 rect: Rect,
39 offset: Offset,
40 order: u64,
41}
42
43impl Default for ClipRegion {
44 fn default() -> Self {
45 ClipRegion {
46 rect: Rect::ZERO,
47 offset: Offset::ZERO,
48 order: 1,
49 }
50 }
51}
52
53pub struct DrawPipe<C> {
55 pub(crate) adapter: wgpu::Adapter,
56 pub(crate) device: wgpu::Device,
57 queue: wgpu::Queue,
58 staging_belt: wgpu::util::StagingBelt,
59 bgl_common: wgpu::BindGroupLayout,
60 light_norm_buf: wgpu::Buffer,
61 bg_common: Vec<(wgpu::Buffer, wgpu::BindGroup)>,
62 images: images::Images,
63 text: kas::text::raster::State,
64 shaded_square: shaded_square::Pipeline,
65 shaded_round: shaded_round::Pipeline,
66 flat_round: flat_round::Pipeline,
67 round_2col: round_2col::Pipeline,
68 custom: C,
69}
70
71kas::impl_scope! {
72 #[impl_default(where CW: Default)]
74 pub struct DrawWindow<CW: CustomWindow> {
75 pub(crate) common: WindowCommon,
76 scale: Scale,
77 clip_regions: Vec<ClipRegion> = vec![Default::default()],
78 images: images::Window,
79 shaded_square: shaded_square::Window,
80 shaded_round: shaded_round::Window,
81 flat_round: flat_round::Window,
82 round_2col: round_2col::Window,
83 custom: CW,
84 }
85}