Skip to main content

backdrop_blur_core/
lib.rs

1//! `backdrop-blur-core` — the backend-agnostic heart of [`backdrop-blur`].
2//!
3//! This crate owns the *vocabulary* of frosted glass and the *seam* every GPU backend
4//! implements, and nothing else. It has **no GPU dependency**, is fully headless-testable,
5//! and forbids `unsafe`. That makes it the one crate in the workspace that cannot break a
6//! backend: the material/geometry types, the [`BlurError`] model, the liveness policy, and
7//! the backdrop-blur seam trait all live here, while `wgpu`/`glow` resource types stay out.
8//!
9//! # The shape of a blur
10//!
11//! A caller describes a frosted surface with a [`BlurRequest`] — *where* the backdrop lives
12//! and the surface goes ([`Region`]s in physical pixels), and *what kind of glass* it is
13//! ([`BlurStrength`], [`Tint`], [`CornerRadius`]). Core resolves the algorithm-agnostic parts
14//! (a physical blur radius via [`BlurRequest::physical_blur_radius`]; a clamped
15//! [`ResolvedMask`]); the backend resolves the algorithm-specific parts (kernel offsets,
16//! pipelines) and does the GPU work.
17//!
18//! See `docs/DESIGN.md` (§4 is the load-bearing type design) and `docs/IMPL.md` for the
19//! rationale and build sequence.
20//!
21//! [`backdrop-blur`]: https://github.com/abdu-benayad/backdrop-blur
22#![forbid(unsafe_code)]
23
24mod algorithm;
25mod error;
26mod eviction;
27mod geometry;
28mod gl_region;
29mod liveness;
30mod material;
31mod seam;
32
33pub use algorithm::{
34    GaussianKernel, KAWASE_THRESHOLD_PX, MAX_GAUSSIAN_RADIUS, MAX_KAWASE_LEVELS, PingPongKey,
35    TargetEncoding, backdrop_uv_remap, kawase_halfpixel, kawase_level_size, resolve_gaussian,
36    resolve_kawase_levels, use_dual_kawase,
37};
38pub use error::{BackendError, BlurError, BlurStage};
39pub use eviction::{RETENTION_FRAMES, evict_decision};
40pub use geometry::{BlurRequest, Region, ResolvedMask, Scale};
41pub use gl_region::GlRegion;
42pub use liveness::RepaintPolicy;
43pub use material::{BlurStrength, CornerRadius, LinearRgba, Opacity, Tint};
44pub use seam::{BackdropBlur, GrabPass};