Repository navigation
Expand file tree
/
Copy pathFrameArtifacts.swift
More file actions
130 lines (127 loc) · 5.6 KB
/
Copy pathFrameArtifacts.swift
File metadata and controls
130 lines (127 loc) · 5.6 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/// Aggregate frame product for inspection, retained reuse, and runtime handoff.
///
/// The individual phase products keep their own ownership contracts. This
/// bundle preserves the current-frame products together with diagnostics,
/// presentation hints, and the commit plan. Retained-layout indexes must use a
/// canonical baseline placed tree rather than an animation-decorated placed tree
/// when storing these artifacts for a later frame.
///
/// Field authority:
///
/// - Canonical phase products: ``resolvedTree``, ``measuredTree``,
/// ``semanticSnapshot``, ``drawTree``, and ``rasterSurface``.
/// - Decorated/baseline-sensitive projection: ``placedTree``. A current frame
/// may commit an animation-decorated placed tree, but retained-layout
/// baselines must store the canonical placement product.
/// - Renderer artifact raster damage: ``presentationDamage``.
/// - Advisory visibility signals: ``drawnIdentities``.
/// - Side-effect plan: ``commitPlan``.
/// - Diagnostics: ``diagnostics``.
package struct FrameArtifacts: Equatable, Sendable {
package var resolvedTree: ResolvedNode
package var measuredTree: MeasuredNode
package var placedTree: PlacedNode
package var semanticSnapshot: SemanticSnapshot
package var drawTree: DrawNode
package var rasterSurface: RasterSurface
/// Optional artifact-level raster damage for this renderer commit.
///
/// A non-`nil` value must describe the actual changed raster rows/ranges
/// between the previous renderer-committed `RasterSurface` and this frame's
/// `rasterSurface`. A `nil` value means the previous renderer surface is
/// incompatible or unavailable. Runtime presentation code re-derives
/// host-facing damage from the previous actually presented surface so skipped
/// async artifacts cannot leak retained renderer history to frontends.
/// Private retained-layout reuse hints must not be exposed through this field
/// unless they have been proven to cover the actual renderer-surface diff.
package var presentationDamage: PresentationDamage?
/// Identities whose ``DrawNode`` had a non-empty visible rect after
/// all ancestor clip bounds were applied during rasterization.
///
/// The runtime retains this set as a geometric visibility signal for
/// diagnostics and scheduling policy. Animation deadlines are no longer
/// suppressed solely because an identity is absent from this set; the
/// scheduler may still use it to understand whether an animating subtree
/// painted any cells in the current frame.
///
/// Note: this is a geometric predicate (would the identity paint any
/// cells given the current clip), not an observation of incremental
/// repaint behavior. An identity that is visible but happens to
/// fall outside ``presentationDamage`` for this particular frame is
/// still recorded here.
package var drawnIdentities: Set<Identity>
package var commitPlan: CommitPlan
package var diagnostics: FrameDiagnostics
/// Committed scroll-route table extracted from ``placedTree`` in the frame
/// tail (scroll-latency R3.2a). Retained as the next frame's baseline for
/// tail-time translation candidates. Derived product: excluded from `==`
/// like ``diagnostics``.
package var committedScrollRoutes: CommittedScrollRouteTable?
/// The frame's committed-products translation candidate, when the committed
/// route tables of this frame and the previous committed frame describe a
/// pure single-route vertical translation. Derived product: excluded from
/// `==` like ``diagnostics``.
package var committedScrollTranslation: CommittedScrollTranslation?
/// Creates a full frame artifact bundle.
package init(
resolvedTree: ResolvedNode,
measuredTree: MeasuredNode,
placedTree: PlacedNode,
semanticSnapshot: SemanticSnapshot,
drawTree: DrawNode,
rasterSurface: RasterSurface,
commitPlan: CommitPlan,
diagnostics: FrameDiagnostics = .init()
) {
self.resolvedTree = resolvedTree
self.measuredTree = measuredTree
self.placedTree = placedTree
self.semanticSnapshot = semanticSnapshot
self.drawTree = drawTree
self.rasterSurface = rasterSurface
presentationDamage = nil
drawnIdentities = []
self.commitPlan = commitPlan
self.diagnostics = diagnostics
committedScrollRoutes = nil
committedScrollTranslation = nil
}
package init(
resolvedTree: ResolvedNode,
measuredTree: MeasuredNode,
placedTree: PlacedNode,
semanticSnapshot: SemanticSnapshot,
drawTree: DrawNode,
rasterSurface: RasterSurface,
presentationDamage: PresentationDamage?,
drawnIdentities: Set<Identity> = [],
commitPlan: CommitPlan,
diagnostics: FrameDiagnostics = .init()
) {
self.resolvedTree = resolvedTree
self.measuredTree = measuredTree
self.placedTree = placedTree
self.semanticSnapshot = semanticSnapshot
self.drawTree = drawTree
self.rasterSurface = rasterSurface
self.presentationDamage = presentationDamage
self.drawnIdentities = drawnIdentities
self.commitPlan = commitPlan
self.diagnostics = diagnostics
committedScrollRoutes = nil
committedScrollTranslation = nil
}
}
extension FrameArtifacts {
package static func == (lhs: Self, rhs: Self) -> Bool {
lhs.resolvedTree == rhs.resolvedTree
&& lhs.measuredTree == rhs.measuredTree
&& lhs.placedTree == rhs.placedTree
&& lhs.semanticSnapshot == rhs.semanticSnapshot
&& lhs.drawTree == rhs.drawTree
&& lhs.rasterSurface == rhs.rasterSurface
&& lhs.presentationDamage == rhs.presentationDamage
&& lhs.drawnIdentities == rhs.drawnIdentities
&& lhs.commitPlan == rhs.commitPlan
}
}