From d2952af18b907a5b18fccd26468a74aabe49bb2f Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 9 Jul 2024 14:43:00 +0200 Subject: Rounded corners on udev/Pixman backend, opt-in and off by default CPU-side rounded corners for the software-only udev/Pixman renderer, which has no shader stage to hook the existing GLES version into. Reads a window's own committed wl_shm buffer, punches premultiplied- alpha holes into the four corner regions, and hands the masked copy to MemoryRenderBuffer - the same path already used for titlebar/ border/shadow bitmaps, so it composites through the ordinary unmasked path and the corners genuinely disappear rather than being painted over. Cached per window, invalidated by a per-commit content_epoch counter rather than rebuilt every frame, so an idle window costs nothing once masked. general.rounded_corners now defaults per backend instead of one global true: on for GLES/winit (a real GPU shader, no measurable cost), off for udev/Pixman (an untested-on-real-hardware CPU cost for constantly-repainting clients) - WindowManager.rounded_corners_enabled is Option so the backend can tell "unset" from "explicitly off". --- crates/wayland/src/winit.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crates/wayland/src/winit.rs') diff --git a/crates/wayland/src/winit.rs b/crates/wayland/src/winit.rs index 5f072b6..f50d095 100644 --- a/crates/wayland/src/winit.rs +++ b/crates/wayland/src/winit.rs @@ -242,6 +242,8 @@ impl WaylandPlatform { border_top_decorations: HashMap::new(), shadow_buffers: HashMap::new(), rounded_corners_program, + content_epoch: HashMap::new(), + rounded_content_buffers: HashMap::new(), border_side_buffers: HashMap::new(), last_synced_size: HashMap::new(), pending: pending.clone(), @@ -406,7 +408,12 @@ impl WaylandPlatform { // The bar/dock/launcher, skipped entirely for a fullscreen window -- // see `udev.rs`'s matching push for the full reasoning. let hide_top_layers = self.wm.borrow().visible_windows_front_to_back().any(|w| w.fullscreen); - let rounded_corners_enabled = self.wm.borrow().rounded_corners_enabled; + // `None` (the user's config never touched `general.rounded_corners`) + // defaults to *on* here - this backend has an actual GPU shader + // behind the feature (see `rounded_corners.rs`), no untested + // per-frame CPU cost to weigh the way the udev backend's own + // default has to. + let rounded_corners_enabled = self.wm.borrow().rounded_corners_enabled.unwrap_or(true); if !hide_top_layers { custom_elements.extend( crate::elements::output_layer_elements(renderer, &self.output, (0, 0), |layer| matches!(layer, Layer::Top | Layer::Overlay)) -- cgit v1.2.3