use super::DrawWindow;
use kas::draw::PassId;
use kas::geom::{Rect, Size};
pub trait DrawCustom<CW: CustomWindow> {
fn custom(&mut self, pass: PassId, rect: Rect, param: CW::Param);
}
pub trait CustomPipeBuilder {
type Pipe: CustomPipe;
fn device_descriptor(adapter: &wgpu::Adapter) -> wgpu::DeviceDescriptor<'static> {
let _ = adapter;
Default::default()
}
fn build(
&mut self,
device: &wgpu::Device,
bgl_common: &wgpu::BindGroupLayout,
tex_format: wgpu::TextureFormat,
) -> Self::Pipe;
}
pub trait CustomPipe: 'static {
type Window: CustomWindow + Default;
fn resize(
&self,
window: &mut Self::Window,
device: &wgpu::Device,
queue: &wgpu::Queue,
size: Size,
) {
let _ = (window, device, queue, size);
}
fn prepare(
&self,
window: &mut Self::Window,
device: &wgpu::Device,
staging_belt: &mut wgpu::util::StagingBelt,
encoder: &mut wgpu::CommandEncoder,
) {
let _ = (window, device, staging_belt, encoder);
}
#[allow(unused)]
fn render_pass<'a>(
&'a self,
window: &'a mut Self::Window,
device: &wgpu::Device,
pass: usize,
rpass: &mut wgpu::RenderPass<'a>,
bg_common: &'a wgpu::BindGroup,
) {
}
#[allow(unused)]
fn render_final<'a>(
&'a self,
window: &'a mut Self::Window,
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
frame_view: &wgpu::TextureView,
size: Size,
) {
}
}
pub trait CustomWindow: 'static {
type Param;
fn invoke(&mut self, pass: PassId, rect: Rect, param: Self::Param);
}
impl CustomPipeBuilder for () {
type Pipe = ();
fn build(
&mut self,
_: &wgpu::Device,
_: &wgpu::BindGroupLayout,
_: wgpu::TextureFormat,
) -> Self::Pipe {
}
}
pub enum Void {}
impl CustomPipe for () {
type Window = ();
fn resize(&self, _: &mut Self::Window, _: &wgpu::Device, _: &wgpu::Queue, _: Size) {}
}
impl CustomWindow for () {
type Param = Void;
fn invoke(&mut self, _: PassId, _: Rect, _: Self::Param) {}
}
impl<CW: CustomWindow> DrawCustom<CW> for DrawWindow<CW> {
fn custom(&mut self, pass: PassId, rect: Rect, param: CW::Param) {
self.custom.invoke(pass, rect, param);
}
}