Skip to content
Open
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
18 changes: 18 additions & 0 deletions src/backend/renderer/pixman/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,24 @@ impl PixmanFrame<'_, '_> {

Ok(())
}

/// Run custom drawing code on the framebuffer used by this frame.
///
/// You are given mutable access to the underlying [`pixman::Image`].
/// The state of the image is considered an implementation detail, some modifications may have undesired side effects.
///
/// # Safety
///
/// - The image must still referr to the same memory region after `func` was executed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - The image must still referr to the same memory region after `func` was executed.
/// - The image must still refer to the same memory region after `func` was executed.

pub unsafe fn with_framebuffer<R, F>(&mut self, func: F) -> Result<R, PixmanError>
where
F: for<'a> FnOnce(&'a mut Image<'static, 'static>) -> R,
{
match &mut self.target.0 {
PixmanTargetInternal::Dmabuf { ref mut image, .. } => image.accessor()?.with_image(func),
PixmanTargetInternal::Image(ref mut image) => Ok(func(image)),
}
}
}

impl Frame for PixmanFrame<'_, '_> {
Expand Down
Loading