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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
//! Animation-renderer-visible types.
//!
//! Part of the transparent-overlay animation architecture. These types
//! describe the per-icon rendering plan the engine hands to the backend
//! at the start of every animation, plus the outcome of the final Shell
//! commit.
//!
//! Everything in this module is plain data (no callbacks, no COM types)
//! so it is safe to build on any thread. Backends turn it into
//! platform-specific overlay resources on the worker thread.
//!
//! # Field responsibilities
//!
//! The `IconRenderPlan` is a **shared build target** — the engine fills
//! in the fields it knows about, and the backend enriches the ones it
//! knows how to source from the platform. Specifically:
//!
//! | Field | Written by |
//! | --- | --- |
//! | `id` | Engine (from `IconAnimationSpec`) |
//! | `source_position` | Engine (from `list_icons` snapshot) |
//! | `final_position` | Engine (from `IconAnimationSpec::target`) |
//! | `size_px` | Engine sets a fallback; backend refines |
//! | `image` | **Backend** — `None` if not resolvable |
//! | `label` | **Backend** — `None` if not resolvable |
//! | `selected` | **Backend** |
//! | `focused` | **Backend** |
use crate::;
/// Per-icon rendering plan the engine hands to
/// [`DesktopBackend::begin_overlay_session`](crate::DesktopBackend::begin_overlay_session).
///
/// See the module-level documentation for who fills which field. The
/// engine builds the plan from an `IconAnimationSpec` + the current
/// icon snapshot; the backend enriches it with platform data (icon
/// bitmap, label text, selection state, refined size).
/// Premultiplied BGRA icon bitmap the renderer can upload directly to a
/// GPU texture / Direct2D bitmap.
///
/// Bytes are `pixels[y * stride + x * 4] = [B, G, R, A]` with premultiplied
/// alpha. `stride` is in bytes and must equal `width * 4` (no padding).
/// Label metadata for an icon.
/// Global feature toggles for the overlay renderer, so callers can
/// request a minimal / stylised look without patching the backend.
/// All fields default to `true` — draw everything Explorer does.
///
/// The engine passes this struct to
/// [`DesktopBackend::begin_overlay_session`](crate::DesktopBackend::begin_overlay_session)
/// exactly once per animation; the backend uses it while enriching
/// [`IconRenderPlan`]s and building overlay resources. When a
/// decoration is disabled, the backend also skips the associated
/// Shell COM query (cheaper session start, no wasted work).
///
/// Consumers on the Rust side normally build this via
/// `OverlayRenderOptions::default()` and flip individual fields;
/// Python callers pass the same three booleans as keyword arguments
/// on `AnimationOptions`.
/// Outcome of the final Shell commit issued by
/// [`DesktopBackend::finalize_overlay_session`](crate::DesktopBackend::finalize_overlay_session).
///
/// Surfaced to callers through
/// [`AnimationHandle::final_commit`](crate::AnimationHandle::final_commit).
///
/// * `moved_ids` — icons the Shell confirmed at their new position via
/// `IFolderView2::GetItemPosition` polling. **This is a confirmation
/// signal, not a census**: the Windows backend stops polling at the
/// first icon that lands, so a successful commit of 200 icons yields
/// a single id here. Treat non-empty as "the commit reached the
/// Shell" and nothing more.
/// * `missing_ids` — icons that were not resolvable by the backend
/// (same semantics as
/// [`DesktopBackend::set_positions`](crate::DesktopBackend::set_positions)).
/// Unlike `moved_ids` this **is** complete: every id listed here was
/// left wherever the Shell last had it.
/// Off-screen render output from
/// [`DesktopBackend::render_overlay_snapshot`](crate::DesktopBackend::render_overlay_snapshot).
///
/// Pixel buffer is tightly-packed premultiplied BGRA — `stride =
/// width * 4` (no row padding). Callers can hand it directly to any
/// image library that accepts BGRA with a known stride (e.g. PIL's
/// `Image.frombuffer("RGBA", (w, h), buf, "raw", "BGRA", 0, 1)`).
///
/// `geometry` is the authoritative per-icon paint answer, populated
/// from D2D's per-icon `DrawBitmap` rect and DirectWrite's
/// `IDWriteTextLayout::GetMetrics`. Callers doing pixel-level
/// diagnostics should prefer these rects to any CV-based
/// segmentation of `pixels`.
/// Backends that can't compute geometry (e.g. the platform stub)
/// return an empty `geometry` vector.
/// Per-icon paint geometry captured during
/// [`SnapshotFrame`] rendering.
///
/// Rects are expressed as `(x, y, width, height)` in overlay-canvas
/// physical pixels (same coordinate space as the pixel buffer,
/// origin at the top-left, y grows downward).
///
/// `icon_rect_px` is the rect passed to D2D `DrawBitmap` — the
/// exact bounds the icon (or placeholder tile) was drawn into.
/// Aspect-fit padding sits *outside* this rect, not inside it.
///
/// `label_rect_px` is derived from `IDWriteTextLayout::GetMetrics`
/// after the layout was populated with the icon's display name,
/// then translated by the label draw origin. It reflects post-wrap,
/// post-trim glyph extents — the pixel-truthful answer to "where
/// does the label actually land". `None` when the icon has no
/// label (headless plans, empty display name).
///
/// `arrow_rect_px` is the D2D `DrawBitmap` rect used for the
/// shortcut-arrow overlay. The arrow is anchored to the actual
/// thumbnail's bottom-left, mirrored by `shadow_reserve_dip`. For
/// slot-filling icons that coincides with the slot bottom-left.
/// `None` when the icon has no shortcut arrow.