gbm: split out clear_framebuffers
This commit is contained in:
parent
eaa3a0ca87
commit
0a716438e3
|
@ -106,6 +106,17 @@ impl<D: RawDevice + 'static> GbmSurfaceInternal<D> {
|
|||
.map_err(Error::SurfaceCreationFailed)?;
|
||||
|
||||
// Clean up buffers
|
||||
self.clear_framebuffers();
|
||||
|
||||
// Drop the old surface after cleanup
|
||||
*self.surface.borrow_mut() = surface;
|
||||
|
||||
self.recreated.set(true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear_framebuffers(&self) {
|
||||
if let Some(Ok(Some(fb))) = self.next_buffer.take().map(|mut bo| bo.take_userdata()) {
|
||||
if let Err(err) = self.crtc.destroy_framebuffer(fb) {
|
||||
warn!(
|
||||
|
@ -123,13 +134,6 @@ impl<D: RawDevice + 'static> GbmSurfaceInternal<D> {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Drop the old surface after cleanup
|
||||
*self.surface.borrow_mut() = surface;
|
||||
|
||||
self.recreated.set(true);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,27 +232,7 @@ impl<D: RawDevice + 'static> Drop for GbmSurfaceInternal<D> {
|
|||
fn drop(&mut self) {
|
||||
// Drop framebuffers attached to the userdata of the gbm surface buffers.
|
||||
// (They don't implement drop, as they need the device)
|
||||
if let Ok(Some(fb)) = {
|
||||
if let Some(mut next) = self.next_buffer.take() {
|
||||
next.take_userdata()
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
} {
|
||||
// ignore failure at this point
|
||||
let _ = self.crtc.destroy_framebuffer(fb);
|
||||
}
|
||||
|
||||
if let Ok(Some(fb)) = {
|
||||
if let Some(mut next) = self.front_buffer.take() {
|
||||
next.take_userdata()
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
} {
|
||||
// ignore failure at this point
|
||||
let _ = self.crtc.destroy_framebuffer(fb);
|
||||
}
|
||||
self.clear_framebuffers();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue