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

Pixman (and gles) renderer fixes #1602

Merged
merged 3 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/backend/renderer/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,6 @@ impl GlesRenderer {

#[profiling::function]
fn cleanup(&mut self) {
#[cfg(feature = "wayland_frontend")]
self.dmabuf_cache.retain(|entry, _tex| !entry.is_gone());
// Free outdated buffer resources
// TODO: Replace with `drain_filter` once it lands
Expand Down
18 changes: 7 additions & 11 deletions src/backend/renderer/pixman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
wayland::{compositor::SurfaceData, shm},
};
#[cfg(feature = "wayland_frontend")]
use wayland_server::{protocol::wl_buffer, Resource, Weak};
use wayland_server::protocol::wl_buffer;

#[cfg(all(
feature = "wayland_frontend",
Expand Down Expand Up @@ -89,7 +89,7 @@ struct PixmanDmabufMapping {
#[derive(Debug)]
struct PixmanImageInner {
#[cfg(feature = "wayland_frontend")]
buffer: Option<Weak<wl_buffer::WlBuffer>>,
buffer: Option<wl_buffer::WlBuffer>,
dmabuf: Option<PixmanDmabufMapping>,
image: RefCell<Image<'static, 'static>>,
_flipped: bool, /* TODO: What about flipped textures? */
Expand All @@ -101,13 +101,6 @@ struct PixmanImage(Rc<PixmanImageInner>);
impl PixmanImage {
#[profiling::function]
fn accessor<'l>(&'l self) -> Result<TextureAccessor<'l>, PixmanError> {
#[cfg(feature = "wayland_frontend")]
let buffer = if let Some(buffer) = self.0.buffer.as_ref() {
Some(buffer.upgrade().map_err(|_| PixmanError::BufferDestroyed)?)
} else {
None
};

let guard = if let Some(mapping) = self.0.dmabuf.as_ref() {
let dmabuf = mapping.dmabuf.upgrade().ok_or(PixmanError::BufferDestroyed)?;
Some(DmabufReadGuard::new(dmabuf)?)
Expand All @@ -117,7 +110,7 @@ impl PixmanImage {

Ok(TextureAccessor {
#[cfg(feature = "wayland_frontend")]
buffer,
buffer: self.0.buffer.clone(),
image: &self.0.image,
_guard: guard,
})
Expand Down Expand Up @@ -746,6 +739,9 @@ impl PixmanRenderer {
});
}

dmabuf.sync_plane(0, DmabufSyncFlags::START | DmabufSyncFlags::READ)?;
dmabuf.sync_plane(0, DmabufSyncFlags::END | DmabufSyncFlags::READ)?;

let image: Image<'_, '_> = unsafe {
pixman::Image::from_raw_mut(
format,
Expand Down Expand Up @@ -1127,7 +1123,7 @@ impl ImportMemWl for PixmanRenderer {
std::result::Result::<_, PixmanError>::Ok(image)
})??;
Ok(PixmanTexture(PixmanImage(Rc::new(PixmanImageInner {
buffer: Some(buffer.downgrade()),
buffer: Some(buffer.clone()),
dmabuf: None,
image: RefCell::new(image),
_flipped: false,
Expand Down
Loading