Skip to main content

euv_core/style/effect/
struct.rs

1use super::*;
2
3/// Rare paint effect payload stored out-of-line in `EffectTable` so standard nodes stay cache-compact.
4#[derive(Clone, Copy, Data, Debug, PartialEq)]
5pub struct PaintEffectEntry {
6    /// Optional drop shadow specification.
7    #[get(skip)]
8    pub(crate) shadow: Option<Shadow>,
9    /// Optional two-stop linear gradient background fill.
10    #[get(skip)]
11    pub(crate) gradient: Option<LinearGradient>,
12    /// 2D visual transform applied during painting without triggering layout.
13    #[get(type(copy))]
14    pub(crate) transform: Transform2D,
15    /// Optional outer focus ring stroke.
16    #[get(skip)]
17    pub(crate) focus_ring: Option<Border>,
18    /// Backdrop blur radius in logical pixels (`0.0` when disabled).
19    #[get(type(copy))]
20    pub(crate) backdrop_blur: f32,
21}
22
23/// Sparse slot-recycled table storing rare `PaintEffectEntry` payloads indexed by 1-based `effect_id` (`0` = none).
24#[derive(Clone, Data, Debug, Default, PartialEq)]
25pub struct EffectTable {
26    /// Contiguous slot storage (`index = effect_id - 1`).
27    #[get(pub(crate))]
28    #[get_mut(pub(crate))]
29    #[set(skip)]
30    pub(crate) entries: Vec<Option<PaintEffectEntry>>,
31    /// Recycled 0-based slot indices for O(1) effect insertion.
32    #[get(pub(crate))]
33    #[get_mut(pub(crate))]
34    #[set(skip)]
35    pub(crate) free_slots: Vec<u32>,
36    /// Incrementally maintained count of active effect entries.
37    #[get(pub(crate), type(copy))]
38    #[get_mut(skip)]
39    #[set(pub(crate))]
40    pub(crate) live_count: usize,
41}
42
43/// Dense 32-byte cache-compact paint style storing hot fields inline and referencing rare effects via `effect_id`.
44#[derive(Clone, Copy, Data, Debug, PartialEq)]
45pub struct CompactPaintStyle {
46    /// Solid background color (valid when `COMPACT_PAINT_HAS_BACKGROUND` is set in `flags`).
47    #[get(type(copy))]
48    pub(crate) background: Color,
49    /// Border stroke color.
50    #[get(type(copy))]
51    pub(crate) border_color: Color,
52    /// Border stroke width in logical pixels.
53    #[get(type(copy))]
54    pub(crate) border_width: f32,
55    /// Quarter-pixel quantized corner radii `[top_left, top_right, bottom_right, bottom_left]`.
56    #[get(pub(crate), type(copy))]
57    #[get_mut(skip)]
58    #[set(pub(crate))]
59    pub(crate) radii_q4: [u16; 4],
60    /// Node opacity in `[0.0, 1.0]`.
61    #[get(type(copy))]
62    pub(crate) opacity: f32,
63    /// 1-based index into `EffectTable` (`EFFECT_ID_NONE == 0` when no rare effects are present).
64    #[get(type(copy))]
65    pub(crate) effect_id: u32,
66    /// Packed bitflags encoding background presence, scroll/event propagation guards, cursor icon, and pointer policy.
67    #[get(type(copy))]
68    pub(crate) flags: u32,
69}