use crate::descriptors::TextureFormat;
use crate::device::Device;
use thiserror::Error;
#[derive(Clone, Copy, PartialEq, Eq, Debug, Error)]
#[non_exhaustive]
pub enum SurfaceError {
#[error("surface lost")]
Lost,
#[error("surface outdated")]
Outdated,
#[error("surface acquire timed out")]
Timeout,
#[error("surface out of memory")]
OutOfMemory,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct SurfaceConfig {
pub width: u32,
pub height: u32,
pub format: TextureFormat,
}
pub trait SurfaceFrame<D: Device> {
fn view(&self) -> &D::TextureView;
fn present(self);
}
pub trait Surface<D: Device>: Sized {
type Frame: SurfaceFrame<D>;
fn configure(&mut self, device: &D, config: &SurfaceConfig);
fn config(&self) -> &SurfaceConfig;
fn acquire(&mut self) -> Result<Self::Frame, SurfaceError>;
}