Move some trait bounds to definition of AsGlowRenderer

Everything implementing `AsGlowRenderer` implements `Renderer` and various
other traits, and by making `AsGlowRenderer` depend on these trait,
things requiring `AsGlowRenderer` can avoid listing those traits as
well.

Looks like implied trait bounds still won't work for the
`Self::TexutureId` and `Self::Error` requirements? So those are not
included here.
This commit is contained in:
Ian Douglas Scott 2026-03-11 10:04:15 -07:00
parent d902f4b5c3
commit c860fcddad
9 changed files with 86 additions and 93 deletions

View file

@ -3,10 +3,10 @@
use calloop::LoopHandle;
use smithay::{
backend::{
allocator::{Buffer, Fourcc, dmabuf::Dmabuf, format::get_transparent},
allocator::{Buffer, Fourcc, format::get_transparent},
renderer::{
Bind, Blit, BufferType, Color32F, ExportMem, ImportAll, ImportMem, Offscreen, Renderer,
buffer_dimensions, buffer_type,
BufferType, Color32F, ExportMem, ImportAll, ImportMem, Offscreen, buffer_dimensions,
buffer_type,
damage::{Error as DTError, OutputDamageTracker, RenderOutputResult},
element::{
AsRenderElements, RenderElement,
@ -193,7 +193,7 @@ pub fn render_session<F, R, T>(
render_fn: F,
) -> Result<Option<PendingImageCopyData>, DTError<R::Error>>
where
R: ExportMem + Offscreen<T>,
R: Offscreen<T> + AsGlowRenderer,
R::Error: FromGlesError,
F: for<'d> FnOnce(
&WlBuffer,
@ -215,9 +215,7 @@ where
.expect("We should be able to convert all hardcoded shm screencopy formats")
})
.map_err(|_| DTError::OutputNoMode(OutputNoMode))?;
renderer
.create_buffer(format, size)
.map_err(DTError::Rendering)
Offscreen::<T>::create_buffer(renderer, format, size).map_err(DTError::Rendering)
})
.transpose()?;
@ -304,7 +302,7 @@ pub fn render_workspace_to_buffer(
handle: (WorkspaceHandle, usize),
) -> Result<RenderOutputResult<'d>, DTError<R::Error>>
where
R: Renderer + ImportAll + ImportMem + ExportMem + Bind<Dmabuf> + Blit + AsGlowRenderer,
R: AsGlowRenderer,
R::TextureId: Send + Clone + 'static,
R::Error: FromGlesError,
CosmicElement<R>: RenderElement<R>,
@ -537,7 +535,7 @@ pub fn render_window_to_buffer(
geometry: Rectangle<i32, Logical>,
) -> Result<RenderOutputResult<'d>, DTError<R::Error>>
where
R: Renderer + ImportAll + ImportMem + ExportMem + Bind<Dmabuf> + Blit + AsGlowRenderer,
R: AsGlowRenderer,
R::TextureId: Send + Clone + 'static,
R::Error: FromGlesError,
CosmicElement<R>: RenderElement<R>,
@ -776,7 +774,7 @@ pub fn render_cursor_to_buffer(
seat: &Seat<State>,
) -> Result<RenderOutputResult<'d>, DTError<R::Error>>
where
R: Renderer + ImportAll + ImportMem + ExportMem + Bind<Dmabuf> + Blit + AsGlowRenderer,
R: AsGlowRenderer,
R::TextureId: Send + Clone + 'static,
R::Error: FromGlesError,
CosmicElement<R>: RenderElement<R>,