atomic: do not cache cursor fb info

This commit is contained in:
Victor Brekenfeld 2020-05-03 00:22:35 +02:00
parent 7518f8c0f7
commit 7bca463934
1 changed files with 66 additions and 61 deletions

View File

@ -22,7 +22,7 @@ use crate::backend::graphics::CursorBackend;
pub struct CursorState {
position: Cell<Option<(u32, u32)>>,
hotspot: Cell<(u32, u32)>,
framebuffer: Cell<Option<framebuffer::Info>>,
framebuffer: Cell<Option<framebuffer::Handle>>,
}
#[derive(Debug, PartialEq, Eq, Clone)]
@ -610,23 +610,17 @@ impl<A: AsRawFd + 'static> CursorBackend for AtomicDrmSurfaceInternal<A> {
trace!(self.logger, "Setting the new imported cursor");
if let Some(fb) = self.cursor.framebuffer.get().take() {
let _ = self.destroy_framebuffer(fb.handle());
let _ = self.destroy_framebuffer(fb);
}
self.cursor.framebuffer.set(Some(
self.get_framebuffer(self.add_planar_framebuffer(buffer, &[0; 4], 0).compat().map_err(
self.add_planar_framebuffer(buffer, &[0; 4], 0).compat().map_err(
|source| Error::Access {
errmsg: "Failed to import cursor",
dev: self.dev_path(),
source,
},
)?)
.compat()
.map_err(|source| Error::Access {
errmsg: "Failed to get framebuffer info",
dev: self.dev_path(),
source,
})?,
)?,
));
self.cursor.hotspot.set(hotspot);
@ -803,6 +797,12 @@ impl<A: AsRawFd + 'static> AtomicDrmSurfaceInternal<A> {
let cursor_fb = self.cursor.framebuffer.get();
if let (Some(pos), Some(fb)) = (cursor_pos, cursor_fb) {
match self.get_framebuffer(fb).compat().map_err(|source| Error::Access {
errmsg: "Error getting cursor fb",
dev: self.dev_path(),
source,
}) {
Ok(cursor_info) => {
let hotspot = self.cursor.hotspot.get();
req.add_property(
@ -823,12 +823,12 @@ impl<A: AsRawFd + 'static> AtomicDrmSurfaceInternal<A> {
req.add_property(
planes.cursor,
self.plane_prop_handle(planes.cursor, "SRC_W")?,
property::Value::UnsignedRange((fb.size().0 as u64) << 16),
property::Value::UnsignedRange((cursor_info.size().0 as u64) << 16),
);
req.add_property(
planes.cursor,
self.plane_prop_handle(planes.cursor, "SRC_H")?,
property::Value::UnsignedRange((fb.size().1 as u64) << 16),
property::Value::UnsignedRange((cursor_info.size().1 as u64) << 16),
);
req.add_property(
planes.cursor,
@ -843,18 +843,23 @@ impl<A: AsRawFd + 'static> AtomicDrmSurfaceInternal<A> {
req.add_property(
planes.cursor,
self.plane_prop_handle(planes.cursor, "CRTC_W")?,
property::Value::UnsignedRange(fb.size().0 as u64),
property::Value::UnsignedRange(cursor_info.size().0 as u64),
);
req.add_property(
planes.cursor,
self.plane_prop_handle(planes.cursor, "CRTC_H")?,
property::Value::UnsignedRange(fb.size().1 as u64),
property::Value::UnsignedRange(cursor_info.size().1 as u64),
);
req.add_property(
planes.cursor,
self.plane_prop_handle(planes.cursor, "FB_ID")?,
property::Value::Framebuffer(Some(fb.handle())),
property::Value::Framebuffer(Some(fb)),
);
},
Err(err) => {
warn!(self.logger, "Cursor FB invalid: {}. Skipping.", err);
}
}
}
Ok(req)