WEFT_OS/crates/weft-compositor/src/backend/drm_device.rs
Marco Allegretti 61bef1a0a7 feat(compositor): implement surface compositing and layer shell rendering
Replace the clear-colour-only stub in render_output with full
surface compositing via Space::render_elements_for_output.

Changes:
- drm_device.rs: add start_time: Instant to WeftDrmData for elapsed-
 time frame callbacks
- drm.rs: rewrite render_output rendering block
 - collect SpaceRenderElements from Space via render_elements_for_output
 which includes both mapped windows and wlr-layer-shell surfaces from
 layer_map_for_output (sorted by z-index, clipped to output geometry)
 - pass collected elements to DrmOutput::render_frame
 - fix send_frame timing from Duration::ZERO to start_time.elapsed()
 with 16ms throttle hint
 - add space.refresh() and popups.cleanup() after each frame
 Use explicit inner block to scope space+drm borrows so post-render
 bookkeeping can access state mutably

Cursor rendering deferred requires cursor theme loading or MemoryRenderBuffer
setup; tracked separately.
2026-03-11 00:03:33 +01:00

59 lines
1.8 KiB
Rust

use std::{collections::HashMap, time::Instant};
use smithay::{
backend::{
allocator::gbm::GbmAllocator,
drm::{
DrmDeviceFd, DrmNode,
exporter::gbm::GbmFramebufferExporter,
output::{DrmOutput, DrmOutputManager},
},
renderer::{
gles::GlesRenderer,
multigpu::{GpuManager, gbm::GbmGlesBackend},
},
session::libseat::LibSeatSession,
},
desktop::utils::OutputPresentationFeedback,
output::Output,
reexports::{
calloop::RegistrationToken,
drm::control::crtc,
wayland_server::{DisplayHandle, backend::GlobalId},
},
};
use smithay_drm_extras::drm_scanner::DrmScanner;
pub type WeftAllocator = GbmAllocator<DrmDeviceFd>;
pub type WeftExporter = GbmFramebufferExporter<DrmDeviceFd>;
pub type WeftDrmOutput =
DrmOutput<WeftAllocator, WeftExporter, Option<OutputPresentationFeedback>, DrmDeviceFd>;
pub type WeftDrmOutputManager =
DrmOutputManager<WeftAllocator, WeftExporter, Option<OutputPresentationFeedback>, DrmDeviceFd>;
pub type WeftGpuManager = GpuManager<GbmGlesBackend<GlesRenderer, DrmDeviceFd>>;
#[allow(dead_code)]
pub struct WeftOutputSurface {
pub output: Output,
pub drm_output: WeftDrmOutput,
pub device_id: DrmNode,
pub global: GlobalId,
}
pub struct WeftDrmDevice {
pub drm_output_manager: WeftDrmOutputManager,
pub drm_scanner: DrmScanner,
pub surfaces: HashMap<crtc::Handle, WeftOutputSurface>,
pub render_node: Option<DrmNode>,
pub registration_token: RegistrationToken,
}
pub struct WeftDrmData {
pub session: LibSeatSession,
pub primary_gpu: DrmNode,
pub gpu_manager: WeftGpuManager,
pub devices: HashMap<DrmNode, WeftDrmDevice>,
pub keyboards: Vec<smithay::reexports::input::Device>,
pub display_handle: DisplayHandle,
pub start_time: Instant,
}