diff options
| author | srdusr <[email protected]> | 2024-07-09 14:43:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2024-07-09 14:43:00 +0200 |
| commit | d2952af18b907a5b18fccd26468a74aabe49bb2f (patch) | |
| tree | 9bc553b83eed57ff62e2cbe308e496f641d32d5b /crates/wayland/src/state.rs | |
| parent | 2cc10b0704d7352198374597075ef184253026be (diff) | |
| download | srdwm-d2952af18b907a5b18fccd26468a74aabe49bb2f.tar.gz srdwm-d2952af18b907a5b18fccd26468a74aabe49bb2f.zip | |
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<bool> so the backend can tell "unset" from "explicitly off".
Diffstat (limited to 'crates/wayland/src/state.rs')
| -rw-r--r-- | crates/wayland/src/state.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/wayland/src/state.rs b/crates/wayland/src/state.rs index 4416869..5b5b4e0 100644 --- a/crates/wayland/src/state.rs +++ b/crates/wayland/src/state.rs @@ -259,6 +259,22 @@ pub(crate) struct CompState { /// declare on the shared `CompState` even though only one backend ever /// populates it. pub(crate) rounded_corners_program: Option<smithay::backend::renderer::gles::GlesTexProgram>, + /// Bumped once per real `commit()` of a mapped window's surface -- + /// see that handler in `protocols.rs`. The only signal `rounded_content_buffers` + /// needs to know its cached masked copy is stale, since content changes + /// (unlike geometry, which `redraw_decoration_buffer`'s trigger points + /// already cover) can arrive on every single frame for a video or + /// terminal, with nothing else in this struct tracking that. + pub(crate) content_epoch: HashMap<WindowId, u64>, + /// The udev/Pixman-backend rounded-corner masked copy of a window's own + /// content (`rounded_corners_pixman::masked_content_buffer`), paired + /// with the `content_epoch` value it was built from - see + /// `elements::rounded_content_buffer`, which owns rebuilding this. + /// Always empty on the winit backend (GLES rounds via a shader instead, + /// `rounded_corners_program`), but costs nothing to declare here + /// unconditionally, the same call `rounded_corners_program` itself + /// already makes. + pub(crate) rounded_content_buffers: HashMap<WindowId, (u64, MemoryRenderBuffer)>, /// Persistent solid-colour buffers backing a window's other three /// border strips (bottom, left, right - `decoration::border_strips`' /// order past index 0), reused by position every frame rather than @@ -662,6 +678,8 @@ impl CompState { self.shadow_buffers.remove(&id); self.border_side_buffers.remove(&id); self.last_synced_size.remove(&id); + self.content_epoch.remove(&id); + self.rounded_content_buffers.remove(&id); // A window closing (crash, kill, or its own menu's "Close" action // racing ahead of this) while its context menu is still open would // otherwise leave the menu pointing at a dead id - selecting any |