@ -112,18 +112,13 @@ impl Swap for BottomScreen {
}
}
pub trait Flush : private ::Sealed {
pub trait Flush : private ::Sealed {
/// Flushes the video buffer for this screen.
/// Flushes the video buffer(s) for this screen. Note that you must still call
fn flush_buffer ( & mut self ) ;
/// [`Swap::swap_buffers`] after this method for the buffer contents to be displayed.
fn flush_buffers ( & mut self ) ;
}
}
trait FlushableScreen : Screen { }
impl < S : Screen > Flush for S {
impl FlushableScreen for TopScreen { }
fn flush_buffers ( & mut self ) {
impl FlushableScreen for BottomScreen { }
impl FlushableScreen for TopScreenLeft { }
impl FlushableScreen for TopScreenRight { }
impl < S : FlushableScreen > Flush for S {
fn flush_buffer ( & mut self ) {
let framebuffer = self . raw_framebuffer ( ) ;
let framebuffer = self . raw_framebuffer ( ) ;
// Flush the data array. `self.raw_framebuffer` should get the correct parameters for all kinds of screens
// Flush the data array. `self.raw_framebuffer` should get the correct parameters for all kinds of screens
@ -136,6 +131,16 @@ impl<S: FlushableScreen> Flush for S {
}
}
}
}
impl Flush for TopScreen3D < ' _ > {
/// Unlike most other implementations of [`Flush`], this flushes the buffers for both
/// the left and right sides of the top screen.
fn flush_buffers ( & mut self ) {
let ( mut left , mut right ) = self . split_mut ( ) ;
left . flush_buffers ( ) ;
right . flush_buffers ( ) ;
}
}
/// The left side of the top screen, when using 3D mode.
/// The left side of the top screen, when using 3D mode.
#[ derive(Debug) ]
#[ derive(Debug) ]
#[ non_exhaustive ]
#[ non_exhaustive ]
@ -248,13 +253,6 @@ impl TopScreen3D<'_> {
( & mut screen . left as _ , & mut screen . right as _ )
( & mut screen . left as _ , & mut screen . right as _ )
} )
} )
}
}
/// Convenient helper to flush the buffers for both the left and right sides of the screen.
pub fn flush_buffers ( & mut self ) {
let ( mut left , mut right ) = self . split_mut ( ) ;
left . flush_buffer ( ) ;
right . flush_buffer ( ) ;
}
}
}
impl < ' top_screen > From < & ' top_screen RefCell < TopScreen > > for TopScreen3D < ' top_screen > {
impl < ' top_screen > From < & ' top_screen RefCell < TopScreen > > for TopScreen3D < ' top_screen > {