use device;
use device::target::{Level, Layer, Mask};
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Plane {
Surface(device::SurfaceHandle),
Texture(device::TextureHandle, Level, Option<Layer>),
}
impl Plane {
pub fn get_surface_info(&self) -> device::tex::SurfaceInfo {
match *self {
Plane::Surface(ref suf) => *suf.get_info(),
Plane::Texture(ref tex, _, _) => tex.get_info().to_surface_info(),
}
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct Frame {
pub width: u16,
pub height: u16,
pub colors: Vec<Plane>,
pub depth: Option<Plane>,
pub stencil: Option<Plane>,
}
impl Frame {
pub fn new(width: u16, height: u16) -> Frame {
Frame {
width: width,
height: height,
colors: Vec::new(),
depth: None,
stencil: None,
}
}
pub fn is_default(&self) -> bool {
self.colors.is_empty() &&
self.depth.is_none() &&
self.stencil.is_none()
}
pub fn get_mask(&self) -> Mask {
use device::target as t;
let mut mask = [t::COLOR0, t::COLOR1, t::COLOR2, t::COLOR3]
.iter().zip(self.colors.iter())
.fold(Mask::empty(), |u, (&m, _)| (u | m));
if self.depth.is_some() {
mask.insert(t::DEPTH);
}
if self.stencil.is_some() {
mask.insert(t::STENCIL);
}
if mask.is_empty() {
t::COLOR | t::DEPTH | t::STENCIL
}else {
mask
}
}
}