diff options
Diffstat (limited to 'stockton-skeleton/src/draw_passes')
-rw-r--r-- | stockton-skeleton/src/draw_passes/cons.rs | 22 | ||||
-rw-r--r-- | stockton-skeleton/src/draw_passes/mod.rs | 8 |
2 files changed, 24 insertions, 6 deletions
diff --git a/stockton-skeleton/src/draw_passes/cons.rs b/stockton-skeleton/src/draw_passes/cons.rs index 51c06a6..dea42af 100644 --- a/stockton-skeleton/src/draw_passes/cons.rs +++ b/stockton-skeleton/src/draw_passes/cons.rs @@ -32,12 +32,26 @@ macro_rules! cons_shared_impl { } fn handle_surface_change( - &mut self, + mut self, session: &Session, context: &mut RenderingContext, - ) -> Result<()> { - self.a.handle_surface_change(session, context)?; - self.b.handle_surface_change(session, context) + ) -> Result<Self> { + match self.a.handle_surface_change(session, context) { + Ok(a) => self.a = a, + Err(e) => { + self.b.deactivate(context)?; + return Err(e); + } + } + match self.b.handle_surface_change(session, context) { + Ok(b) => self.b = b, + Err(e) => { + self.a.deactivate(context)?; + return Err(e); + } + } + + Ok(self) } }; } diff --git a/stockton-skeleton/src/draw_passes/mod.rs b/stockton-skeleton/src/draw_passes/mod.rs index cdc983f..5b138c2 100644 --- a/stockton-skeleton/src/draw_passes/mod.rs +++ b/stockton-skeleton/src/draw_passes/mod.rs @@ -27,11 +27,15 @@ pub trait DrawPass<P: PassPosition> { ) -> Result<()>; /// Called just after the surface changes (probably a resize). + /// This takes ownership and returns itself to ensure that the `DrawPass` is not called again if it fails. + /// This means you should deactivate as much as possible in case of an error. fn handle_surface_change( - &mut self, + self, session: &Session, context: &mut RenderingContext, - ) -> Result<()>; + ) -> Result<Self> + where + Self: Sized; /// Deactivate any vulkan parts that need to be deactivated fn deactivate(self, context: &mut RenderingContext) -> Result<()>; |