use super::DrawWindow;
use kas::draw::Pass;
use kas::geom::{Rect, Size};
pub trait DrawCustom<CW: CustomWindow> {
fn custom(&mut self, pass: Pass, rect: Rect, param: CW::Param);
}
pub trait CustomPipeBuilder {
type Pipe: CustomPipe;
fn build(
&mut self,
device: &wgpu::Device,
tex_format: wgpu::TextureFormat,
depth_format: wgpu::TextureFormat,
) -> Self::Pipe;
}
pub trait CustomPipe {
type Window: CustomWindow + 'static;
fn new_window(&self, device: &wgpu::Device, size: Size) -> Self::Window;
fn resize(
&self,
window: &mut Self::Window,
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
size: Size,
);
fn update(
&self,
_window: &mut Self::Window,
_device: &wgpu::Device,
_encoder: &mut wgpu::CommandEncoder,
) {
}
#[allow(unused)]
fn render_pass<'a>(
&'a self,
window: &'a mut Self::Window,
device: &wgpu::Device,
pass: usize,
rpass: &mut wgpu::RenderPass<'a>,
) {
}
#[allow(unused)]
fn render_final<'a>(
&'a self,
window: &'a mut Self::Window,
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
frame_view: &wgpu::TextureView,
depth_stencil_attachment: wgpu::RenderPassDepthStencilAttachmentDescriptor,
size: Size,
) {
}
}
pub trait CustomWindow {
type Param;
fn invoke(&mut self, pass: Pass, rect: Rect, param: Self::Param);
}
impl CustomPipeBuilder for () {
type Pipe = ();
fn build(
&mut self,
_: &wgpu::Device,
_: wgpu::TextureFormat,
_: wgpu::TextureFormat,
) -> Self::Pipe {
()
}
}
pub enum Void {}
impl CustomPipe for () {
type Window = ();
fn new_window(&self, _: &wgpu::Device, _: Size) -> Self::Window {
()
}
fn resize(
&self,
_: &mut Self::Window,
_: &wgpu::Device,
_: &mut wgpu::CommandEncoder,
_: Size,
) {
}
}
impl CustomWindow for () {
type Param = Void;
fn invoke(&mut self, _: Pass, _: Rect, _: Self::Param) {}
}
impl<CW: CustomWindow> DrawCustom<CW> for DrawWindow<CW> {
fn custom(&mut self, pass: Pass, rect: Rect, param: CW::Param) {
self.custom.invoke(pass, rect, param);
}
}