render: add api for setting the rectangle on a surface
This commit is contained in:
parent
7b6cf42e4f
commit
73c3ced3d7
@ -59,6 +59,10 @@ impl Surface for BoundSurface<Rc<RefCell<ShaderBinding>>> {
|
||||
fn clear_shader(&mut self) {
|
||||
self.binding.borrow_mut().shader = None;
|
||||
}
|
||||
|
||||
fn set_rect(&mut self, rect: &Rectangle<u8, Virtual>) {
|
||||
self.binding.borrow_mut().rect = rect.clone();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature="threads")]
|
||||
@ -132,8 +136,9 @@ impl<S: Surface + Default> SurfacePool<S> {
|
||||
}
|
||||
|
||||
impl<S: Surface + Default> Surfaces<S> for SurfacePool<S> {
|
||||
fn new_surface(&mut self, _area: &Rectangle<u8, Virtual>) -> Result<S, io::Error> {
|
||||
let surface = S::default();
|
||||
fn new_surface(&mut self, area: &Rectangle<u8, Virtual>) -> Result<S, io::Error> {
|
||||
let mut surface = S::default();
|
||||
surface.set_rect(area);
|
||||
self.surfaces.push(surface.clone());
|
||||
return Ok(surface);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ pub trait Surface: Default + Clone + Debug {
|
||||
fn clear_shader(&mut self);
|
||||
|
||||
fn rect(&self) -> Rectangle<u8, Virtual>;
|
||||
fn set_rect(&mut self, rect: &Rectangle<u8, Virtual>);
|
||||
}
|
||||
|
||||
pub trait Framed {
|
||||
|
Loading…
x
Reference in New Issue
Block a user