From 73c3ced3d7116b905ccec6b14d8e4531e4234a43 Mon Sep 17 00:00:00 2001 From: Victoria Fischer Date: Fri, 22 Nov 2024 15:54:06 +0100 Subject: [PATCH] render: add api for setting the rectangle on a surface --- src/buffers.rs | 9 +++++++-- src/render.rs | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/buffers.rs b/src/buffers.rs index 0de96d6..eee4c37 100644 --- a/src/buffers.rs +++ b/src/buffers.rs @@ -59,6 +59,10 @@ impl Surface for BoundSurface>> { fn clear_shader(&mut self) { self.binding.borrow_mut().shader = None; } + + fn set_rect(&mut self, rect: &Rectangle) { + self.binding.borrow_mut().rect = rect.clone(); + } } #[cfg(feature="threads")] @@ -132,8 +136,9 @@ impl SurfacePool { } impl Surfaces for SurfacePool { - fn new_surface(&mut self, _area: &Rectangle) -> Result { - let surface = S::default(); + fn new_surface(&mut self, area: &Rectangle) -> Result { + let mut surface = S::default(); + surface.set_rect(area); self.surfaces.push(surface.clone()); return Ok(surface); } diff --git a/src/render.rs b/src/render.rs index 8117c98..c78c763 100644 --- a/src/render.rs +++ b/src/render.rs @@ -22,6 +22,7 @@ pub trait Surface: Default + Clone + Debug { fn clear_shader(&mut self); fn rect(&self) -> Rectangle; + fn set_rect(&mut self, rect: &Rectangle); } pub trait Framed {