winit: Fix returned buffer age

This commit is contained in:
Victoria Brekenfeld 2022-01-22 22:11:57 +01:00
parent e019b4fa9e
commit 6ae0a3510a
2 changed files with 7 additions and 4 deletions

View File

@ -874,6 +874,7 @@ impl Bind<Rc<EGLSurface>> for Gles2Renderer {
fn bind(&mut self, surface: Rc<EGLSurface>) -> Result<(), Gles2Error> { fn bind(&mut self, surface: Rc<EGLSurface>) -> Result<(), Gles2Error> {
self.unbind()?; self.unbind()?;
self.target_surface = Some(surface); self.target_surface = Some(surface);
self.make_current()?;
Ok(()) Ok(())
} }
} }
@ -881,9 +882,7 @@ impl Bind<Rc<EGLSurface>> for Gles2Renderer {
impl Bind<Dmabuf> for Gles2Renderer { impl Bind<Dmabuf> for Gles2Renderer {
fn bind(&mut self, dmabuf: Dmabuf) -> Result<(), Gles2Error> { fn bind(&mut self, dmabuf: Dmabuf) -> Result<(), Gles2Error> {
self.unbind()?; self.unbind()?;
unsafe { self.make_current()?;
self.egl.make_current()?;
}
// Free outdated buffer resources // Free outdated buffer resources
// TODO: Replace with `drain_filter` once it lands // TODO: Replace with `drain_filter` once it lands

View File

@ -302,7 +302,11 @@ impl WinitGraphicsBackend {
Ok(()) Ok(())
} }
/// Retrieve the buffer age of the current backbuffer of the window /// Retrieve the buffer age of the current backbuffer of the window.
///
/// This will only return a meaningful value, if this `WinitGraphicsBackend`
/// is currently bound (by previously calling [`WinitGraphicsBackend::bind`]).
/// Otherwise the contents of the return value are undefined.
pub fn buffer_age(&self) -> usize { pub fn buffer_age(&self) -> usize {
if self.damage_tracking { if self.damage_tracking {
self.egl.buffer_age() as usize self.egl.buffer_age() as usize