Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BufferInterface::pixels for KMS backend #203

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/backends/kms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ struct Buffers {

/// Whether to use the first buffer or the second buffer as the front buffer.
first_is_front: bool,

/// A buffer full of zeroes.
zeroes: Box<[u32]>,
}

/// The buffer implementation.
Expand All @@ -106,9 +103,6 @@ pub(crate) struct BufferImpl<'a, D: ?Sized, W: ?Sized> {
/// This is used to change the front buffer.
first_is_front: &'a mut bool,

/// Buffer full of zeroes.
zeroes: &'a [u32],

/// The current size.
size: (NonZeroU32, NonZeroU32),

Expand Down Expand Up @@ -232,7 +226,6 @@ impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> fo
self.buffer = Some(Buffers {
first_is_front: true,
buffers: [front_buffer, back_buffer],
zeroes: vec![0; width.get() as usize * height.get() as usize].into_boxed_slice(),
});

Ok(())
Expand Down Expand Up @@ -276,7 +269,6 @@ impl<D: HasDisplayHandle + ?Sized, W: HasWindowHandle> SurfaceInterface<D, W> fo
front_fb,
crtc_handle: self.crtc.handle(),
display: &self.display,
zeroes: &set.zeroes,
front_age,
back_age,
_window: PhantomData,
Expand All @@ -302,9 +294,7 @@ impl<D: ?Sized, W: ?Sized> Drop for KmsImpl<D, W> {
impl<D: ?Sized, W: ?Sized> BufferInterface for BufferImpl<'_, D, W> {
#[inline]
fn pixels(&self) -> &[u32] {
// drm-rs doesn't let us have the immutable reference... so just use a bunch of zeroes.
// TODO: There has to be a better way of doing this!
self.zeroes
bytemuck::cast_slice(self.mapping.as_ref())
}

#[inline]
Expand Down