cursor: don't overwrite busy hardware buffers
This commit is contained in:
parent
b9ce5f22d8
commit
375d7da2f2
3 changed files with 13 additions and 4 deletions
|
|
@ -178,6 +178,7 @@ pub struct MetalConnector {
|
|||
pub cursor_enabled: Cell<bool>,
|
||||
pub cursor_buffers: CloneCell<Option<Rc<[RenderBuffer; 2]>>>,
|
||||
pub cursor_front_buffer: NumCell<usize>,
|
||||
pub cursor_swap_buffer: Cell<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -228,7 +229,7 @@ impl HardwareCursor for MetalHardwareCursor {
|
|||
self.connector.cursor_x.set(self.cursor_x_pending.get());
|
||||
self.connector.cursor_y.set(self.cursor_y_pending.get());
|
||||
if self.cursor_swap_buffer.take() {
|
||||
self.connector.cursor_front_buffer.fetch_add(1);
|
||||
self.connector.cursor_swap_buffer.set(true);
|
||||
}
|
||||
self.connector.cursor_changed.set(true);
|
||||
if self.connector.can_present.get() {
|
||||
|
|
@ -363,6 +364,9 @@ impl MetalConnector {
|
|||
if self.cursor_changed.get() && cursor.is_some() {
|
||||
let plane = cursor.unwrap();
|
||||
if self.cursor_enabled.get() {
|
||||
if self.cursor_swap_buffer.take() {
|
||||
self.cursor_front_buffer.fetch_add(1);
|
||||
}
|
||||
let buffers = self.cursor_buffers.get().unwrap();
|
||||
let buffer = &buffers[self.cursor_front_buffer.get() % buffers.len()];
|
||||
changes.change_object(plane.id, |c| {
|
||||
|
|
@ -545,6 +549,7 @@ fn create_connector(
|
|||
connect_sent: Cell::new(false),
|
||||
cursor_changed: Cell::new(false),
|
||||
cursor_front_buffer: Default::default(),
|
||||
cursor_swap_buffer: Cell::new(false),
|
||||
});
|
||||
let futures = ConnectorFutures {
|
||||
present: backend
|
||||
|
|
|
|||
|
|
@ -832,6 +832,7 @@ impl WlSurface {
|
|||
if buffer_changed || transform_changed {
|
||||
for (_, cursor) in &self.cursors {
|
||||
cursor.handle_buffer_change();
|
||||
cursor.update_hardware_cursor();
|
||||
}
|
||||
}
|
||||
ext.post_commit();
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ impl CursorSurface {
|
|||
let (hot_x, hot_y) = self.hotspot.get();
|
||||
self.extents
|
||||
.set(self.surface.extents.get().move_(-hot_x, -hot_y));
|
||||
if self.seat.hardware_cursor() {
|
||||
self.seat.update_hardware_cursor();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn handle_surface_destroy(&self) {
|
||||
|
|
@ -57,6 +54,12 @@ impl CursorSurface {
|
|||
self.hotspot.set((hot_x - hotspot_dx, hot_y - hotspot_dy));
|
||||
self.update_extents();
|
||||
}
|
||||
|
||||
pub fn update_hardware_cursor(&self) {
|
||||
if self.seat.hardware_cursor() {
|
||||
self.seat.update_hardware_cursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Cursor for CursorSurface {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue