fix: prevent edge darkening on GPU-blurred wallpaper (v0.5.3)
GskBlurNode samples pixels outside texture bounds as transparent, causing visible darkening at wallpaper edges. Fix renders the texture with 3x-sigma padding before blur, then clips back to original size. Symmetric fix with moonset v0.7.1.
This commit is contained in:
parent
b06b02faac
commit
77b94a560d
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -569,7 +569,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "moongreet"
|
name = "moongreet"
|
||||||
version = "0.5.2"
|
version = "0.5.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gdk-pixbuf",
|
"gdk-pixbuf",
|
||||||
"gdk4",
|
"gdk4",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "moongreet"
|
name = "moongreet"
|
||||||
version = "0.5.2"
|
version = "0.5.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "A greetd greeter for Wayland with GTK4 and Layer Shell"
|
description = "A greetd greeter for Wayland with GTK4 and Layer Shell"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|||||||
@ -119,6 +119,10 @@ pub fn load_background_texture(bg_path: &Path) -> Option<gdk::Texture> {
|
|||||||
// -- GPU blur via GskBlurNode -------------------------------------------------
|
// -- GPU blur via GskBlurNode -------------------------------------------------
|
||||||
|
|
||||||
/// Render a blurred texture using the GPU via GskBlurNode.
|
/// Render a blurred texture using the GPU via GskBlurNode.
|
||||||
|
///
|
||||||
|
/// To avoid edge darkening (blur samples transparent pixels outside bounds),
|
||||||
|
/// the texture is rendered with padding equal to 3x the blur sigma. The blur
|
||||||
|
/// is applied to the padded area, then cropped back to the original size.
|
||||||
fn render_blurred_texture(
|
fn render_blurred_texture(
|
||||||
widget: &impl IsA<gtk::Widget>,
|
widget: &impl IsA<gtk::Widget>,
|
||||||
texture: &gdk::Texture,
|
texture: &gdk::Texture,
|
||||||
@ -126,15 +130,24 @@ fn render_blurred_texture(
|
|||||||
) -> Option<gdk::Texture> {
|
) -> Option<gdk::Texture> {
|
||||||
let native = widget.native()?;
|
let native = widget.native()?;
|
||||||
let renderer = native.renderer()?;
|
let renderer = native.renderer()?;
|
||||||
|
|
||||||
|
let w = texture.width() as f32;
|
||||||
|
let h = texture.height() as f32;
|
||||||
|
// Padding must cover the blur kernel radius (typically ~3x sigma)
|
||||||
|
let pad = (sigma * 3.0).ceil();
|
||||||
|
|
||||||
let snapshot = gtk::Snapshot::new();
|
let snapshot = gtk::Snapshot::new();
|
||||||
let bounds = graphene_rs::Rect::new(
|
// Clip output to original texture size
|
||||||
0.0, 0.0, texture.width() as f32, texture.height() as f32,
|
snapshot.push_clip(&graphene_rs::Rect::new(pad, pad, w, h));
|
||||||
);
|
|
||||||
snapshot.push_blur(sigma as f64);
|
snapshot.push_blur(sigma as f64);
|
||||||
snapshot.append_texture(texture, &bounds);
|
// Render texture with padding on all sides (edges repeat via oversized bounds)
|
||||||
snapshot.pop();
|
snapshot.append_texture(texture, &graphene_rs::Rect::new(0.0, 0.0, w + 2.0 * pad, h + 2.0 * pad));
|
||||||
|
snapshot.pop(); // blur
|
||||||
|
snapshot.pop(); // clip
|
||||||
|
|
||||||
let node = snapshot.to_node()?;
|
let node = snapshot.to_node()?;
|
||||||
Some(renderer.render_texture(&node, None))
|
let viewport = graphene_rs::Rect::new(pad, pad, w, h);
|
||||||
|
Some(renderer.render_texture(&node, Some(&viewport)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a wallpaper-only window for secondary monitors.
|
/// Create a wallpaper-only window for secondary monitors.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user