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/core/src/manager.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'crates/core/src') diff --git a/crates/core/src/manager.rs b/crates/core/src/manager.rs index 08284c5..0cca0d3 100644 --- a/crates/core/src/manager.rs +++ b/crates/core/src/manager.rs @@ -72,10 +72,15 @@ pub struct WindowManager { pub resize_margin: i32, /// Whether a decorated window's content rounds its bottom two corners /// to match the titlebar's own curve (an undecorated/CSD window rounds - /// all four). Read from `general.rounded_corners`. GLES-backend-only - /// in practice - see `crates/wayland/src/rounded_corners.rs` - so - /// this is a no-op on the udev/Pixman backend regardless of its value. - pub rounded_corners_enabled: bool, + /// all four). Read from `general.rounded_corners` - `None` when the + /// user's config never touched that key at all (deliberately *not* + /// defaulted in `crates/config`, unlike every other `general.*` key), + /// so each backend can fall back to its own default rather than one + /// baked in here: GLES/winit defaults on, udev/Pixman defaults off + /// (an untested-on-real-hardware per-frame CPU cost for content that + /// redraws constantly - see `crates/wayland/src/rounded_corners.rs`). + /// `Some(_)` only when the user explicitly set it, and wins either way. + pub rounded_corners_enabled: Option, /// Default decoration colours and border width, read from `theme.colors.*`/ /// `theme.decorations.*`. See `ThemeConfig`'s own doc comment. pub theme: ThemeConfig, @@ -120,7 +125,7 @@ impl WindowManager { animation_duration_ms: 200, shadows_enabled: true, resize_margin: RESIZE_MARGIN, - rounded_corners_enabled: true, + rounded_corners_enabled: None, theme: ThemeConfig::default(), drag: None, resize: None, -- cgit v1.2.3