1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Modified by Longbridge for gpui-fast.
//! A layer's recorded content: its content-space scene, painted region,
//! translation at paint, prepaint and paint ranges and dependencies (M3).
use crate::{
Bounds, EntityId, GlobalElementId, HitboxId, PaintIndex, Pixels, Point, PrepaintStateIndex,
Rgba, ScaledPixels, TileCoord,
fast::{
dependencies::RenderDependencies,
layers::{reuse::KeptLayout, scene::LayerContent},
},
scene::Primitive,
};
use collections::FxHashMap;
use std::{ops::Range, rc::Rc};
/// The content of a scroll container as it was last painted into its layer.
#[allow(
dead_code,
reason = "the invalidation and input streams read the ranges, hovers and dependencies"
)]
#[derive(Default)]
pub(crate) struct LayerRecord {
/// The painted content in content space (window space less
/// `translation`).
pub(crate) content: LayerContent,
/// Bumps each time `content` is replaced.
pub(crate) generation: u64,
/// The part of the content painted, in window space at paint: the
/// viewport and the overscan around it.
pub(crate) painted_region: Bounds<Pixels>,
/// The container's clip rect in window space at paint.
pub(crate) viewport: Bounds<Pixels>,
/// The scroll offset the content was painted at, snapped.
pub(crate) scroll_offset: Point<Pixels>,
/// The layer's translation at paint, in whole device pixels: window
/// position = content position + translation.
pub(crate) translation: Point<ScaledPixels>,
/// What prepainting the content added to the frame.
pub(crate) prepaint_range: Range<PrepaintStateIndex>,
/// What painting the content added to the frame; its scene indices are
/// the layer's own scene's.
pub(crate) paint_range: Range<PaintIndex>,
/// The hash of each tile of the painted region.
pub(crate) tile_hashes: FxHashMap<TileCoord, u64>,
/// The tiles `generation` changed.
pub(crate) dirty_tiles: Vec<TileCoord>,
/// The opaque colour under the viewport, which every tile is cleared with.
pub(crate) background: Rgba,
/// The hovers the content was painted by.
pub(crate) hovers: Rc<[(HitboxId, bool)]>,
/// What prepainting and painting the content read.
pub(crate) dependencies: RenderDependencies,
/// The views drawn inside the content, which render before it is
/// recorded.
pub(crate) views: Rc<[EntityId]>,
/// Whether the content's overlay cannot be drawn over its tiles: a
/// list row drew over the overlay of a row before it. Such content is
/// drawn into the frame instead.
pub(crate) has_paths: bool,
/// The paths the content painted, and what it drew over them, in
/// content space, in drawing order: left out of `content`, and drawn
/// into the frame over the layer's tiles wherever it is composited
/// (`fast::layers::overlay`).
pub(crate) overlay: Rc<[Primitive]>,
/// How the views drawn inside the content were laid out when it was
/// painted, by the views' ids: a frame that composites the layer lays
/// them out again from these instead of rendering them (spec ยง6.3).
pub(crate) view_layouts: Rc<FxHashMap<GlobalElementId, KeptLayout>>,
/// What prepainting the content added to the accessibility tree, when
/// accessibility was active, as painted: a frame compositing the layer
/// adds it again, moved by the scroll since.
pub(crate) a11y: Option<Rc<crate::fast::a11y::A11yStretch>>,
}