use crate::graphics::Graphics;
use crate::painter::Painter;
pub struct Frame {
pub(crate) encoder: Option<wgpu::CommandEncoder>,
pub(crate) view: wgpu::TextureView,
pub(crate) surface_texture: Option<wgpu::SurfaceTexture>,
pub clear_color: [f32; 4],
pub(crate) flushed: bool,
}
impl Frame {
pub fn painter<'a>(&'a mut self, gfx: &'a mut Graphics) -> Painter<'a> {
Painter::new(self, gfx)
}
pub fn encoder_mut(&mut self) -> Option<&mut wgpu::CommandEncoder> {
self.encoder.as_mut()
}
pub fn view(&self) -> &wgpu::TextureView {
&self.view
}
pub fn view_and_encoder(&mut self) -> (&wgpu::TextureView, &mut wgpu::CommandEncoder) {
(
&self.view,
self.encoder
.as_mut()
.expect("frame encoder taken/dropped before view_and_encoder"),
)
}
}