gbm: expose buffer age
This commit is contained in:
parent
6c57e27e5e
commit
a4f2729608
|
@ -26,6 +26,7 @@
|
|||
- Remove `InputBackend::dispatch_new_events`, turning `InputBackend` into a definition of backend event types. Future input backends should be a `calloop::EventSource`.
|
||||
- Remove `InputBackend::EventError` associated type as it is unneeded since `dispatch_new_events` was removed.
|
||||
- `Swapchain` does not have a generic Userdata-parameter anymore, but utilizes `UserDataMap` instead
|
||||
- `GbmBufferedSurface::next_buffer` now additionally returns the age of the buffer
|
||||
|
||||
### Additions
|
||||
|
||||
|
|
|
@ -738,7 +738,7 @@ fn render_surface(
|
|||
return Ok(());
|
||||
};
|
||||
|
||||
let dmabuf = surface.surface.next_buffer()?;
|
||||
let (dmabuf, _age) = surface.surface.next_buffer()?;
|
||||
renderer.bind(dmabuf)?;
|
||||
|
||||
// and draw to our buffer
|
||||
|
@ -867,7 +867,7 @@ fn schedule_initial_render<Data: 'static>(
|
|||
}
|
||||
|
||||
fn initial_render(surface: &mut RenderSurface, renderer: &mut Gles2Renderer) -> Result<(), SwapBuffersError> {
|
||||
let dmabuf = surface.next_buffer()?;
|
||||
let (dmabuf, _age) = surface.next_buffer()?;
|
||||
renderer.bind(dmabuf)?;
|
||||
// Does not matter if we render an empty frame
|
||||
renderer
|
||||
|
|
|
@ -167,11 +167,11 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Retrieves the next buffer to be rendered into.
|
||||
/// Retrieves the next buffer to be rendered into and it's age.
|
||||
///
|
||||
/// *Note*: This function can be called multiple times and
|
||||
/// will return the same buffer until it is queued (see [`GbmBufferedSurface::queue_buffer`]).
|
||||
pub fn next_buffer(&mut self) -> Result<Dmabuf, Error> {
|
||||
pub fn next_buffer(&mut self) -> Result<(Dmabuf, u8), Error> {
|
||||
if self.next_fb.is_none() {
|
||||
let slot = self.swapchain.acquire()?.ok_or(Error::NoFreeSlotsError)?;
|
||||
|
||||
|
@ -189,7 +189,7 @@ where
|
|||
}
|
||||
|
||||
let slot = self.next_fb.as_ref().unwrap();
|
||||
Ok(slot.userdata().get::<Dmabuf>().unwrap().clone())
|
||||
Ok((slot.userdata().get::<Dmabuf>().unwrap().clone(), slot.age()))
|
||||
}
|
||||
|
||||
/// Queues the current buffer for rendering.
|
||||
|
@ -213,6 +213,7 @@ where
|
|||
pub fn frame_submitted(&mut self) -> Result<(), Error> {
|
||||
if let Some(mut pending) = self.pending_fb.take() {
|
||||
std::mem::swap(&mut pending, &mut self.current_fb);
|
||||
self.swapchain.submitted(pending);
|
||||
if self.queued_fb.is_some() {
|
||||
self.submit()?;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue