pub mod command;
pub mod pipeline;
use crate::{
PxPosition,
px::{PxRect, PxSize},
};
pub use command::DrawCommand;
pub use pipeline::{DrawablePipeline, PipelineRegistry};
pub struct Drawer {
pub pipeline_registry: PipelineRegistry,
}
impl Default for Drawer {
fn default() -> Self {
Self::new()
}
}
impl Drawer {
pub fn new() -> Self {
Self {
pipeline_registry: PipelineRegistry::new(),
}
}
pub fn begin_pass(
&mut self,
gpu: &wgpu::Device,
queue: &wgpu::Queue,
config: &wgpu::SurfaceConfiguration,
render_pass: &mut wgpu::RenderPass<'_>,
scene_texture_view: &wgpu::TextureView,
) {
self.pipeline_registry.begin_all_passes(
gpu,
queue,
config,
render_pass,
scene_texture_view,
);
}
pub fn end_pass(
&mut self,
gpu: &wgpu::Device,
queue: &wgpu::Queue,
config: &wgpu::SurfaceConfiguration,
render_pass: &mut wgpu::RenderPass<'_>,
scene_texture_view: &wgpu::TextureView,
) {
self.pipeline_registry
.end_all_passes(gpu, queue, config, render_pass, scene_texture_view);
}
pub fn submit(
&mut self,
gpu: &wgpu::Device,
queue: &wgpu::Queue,
config: &wgpu::SurfaceConfiguration,
render_pass: &mut wgpu::RenderPass<'_>,
commands: &[(&dyn DrawCommand, PxSize, PxPosition)],
scene_texture_view: &wgpu::TextureView,
clip_rect: Option<PxRect>,
) {
self.pipeline_registry.dispatch(
gpu,
queue,
config,
render_pass,
commands,
scene_texture_view,
clip_rect,
);
}
}