Module scene_parts
Expand description
Keyed parts of a shell scene section, so a small change inside a section damages that change’s bounds instead of the whole display.
The retained-damage producer proves a frame sparse by comparing each scene section with the previous frame’s; without parts, any difference inside the workspace (a caret, a peer’s cursor, a hover) made the whole section opaque to that proof. A part marks a stretch of a section’s draw commands with a key and the bounds those commands can paint, and every part boundary splits the section’s encoded streams into pieces, each belonging to the innermost part open across it. Comparing piece by piece then gives: every piece equal, the section is unchanged; only pieces of parts differ, damage is each changed part’s old and new bounds; a piece of the section itself differs, or the proof cannot be made, and the frame is dense.
Correctness rests on two facts: pixels outside every changed part’s bounds come from byte-identical commands in both frames (the sparse renderer re-renders the whole scene inside the damage, so blend layers above a part compose correctly), and a part’s commands are independent of what precedes them — the encoder dedups a transform or style against the last one encoded, so each boundary forces the next transform and style to be encoded again.
Only sections the producer registered (track) are split.
Structs§
- Begun
- Whether a key was begun, for
end_widget. - Damage
Hint - What changed in a part’s content between two generations of it, as the one who painted it knows: an embedded app’s own widget damage.
- Draw
Bounds - Device-space bounds of everything a scene paints, for a caller that must know what lies over a region without rasterising the scene. Keep one: it retains glyph outlines across calls.
- Drawn
Scroll - A scroll region a keyed widget drew this frame (
Widget::primary_vertical_scroll). - Keyer
- The code that writes widget keys, handed to
key_widgets. - PartKey
- Identifies one part among the parts of a section. Two frames’ parts are matched by key and position, so a key must name the same thing in both.
- Presented
- How a host presents a frame over the pixels of the one before:
present_copies. - Recorded
- Every tracked section’s parts from one finished
Recording. - Recording
- Records parts for the sections registered with
trackuntil finished. - Section
Copy - A copy a hinted part’s content made (
DamageHint::copies), as a host presenting the section over its last frame must check it: what it moves, what the section draws over that content, and how it composites. - Section
Damage damage_with_copies— where a section changed, and the copies that explain the rest.- Section
Parts - The parts recorded for one section in one frame.
Enums§
- Unproven
- Why two frames of a section cannot be compared piece by piece.
Functions§
- append
- Append
other, whose parts were recorded asparts(record), so that a trackedscenekeeps them: each becomes a part ofsceneat the same place, its bounds carried throughtransform. Withoutpartseverythingotherdraws belongs to whatever part this append is in. - append_
with appendfor a caller that appends the recorded scene itself (withcrate::backdrop::append_nested, say):appendmust append exactly that scene attransform.- begin
- Begin a part keyed
keyaround draws too long to pass topartas one closure;endcloses it, under the same contract. A part left open gives the section no parts. - begin_
frame - Start keying a frame: root widgets count from the first again. A host that keys widgets calls it before every frame it draws.
- begin_
item - Begin one item of a widget under
key(item_key), standing atorigin, for draws that cannot be one closure;end_widgetends it. - begin_
widget - Begin
widget’s draws:indexis its place among its parent’s children, when the caller knows it (a container that skips children it does not draw must say it, or the children after them would take their keys).transformis the one it draws with. Writes nothing unless widgets are keyed. - culled
scene, drawn withparts, without every bounded part whose boundswantedrefuses, orNonewhen no part is left out. Where the parts left out paint nothing, the result paints whatscenedoes: a part’s commands depend on nothing before them ([boundary]), and only a part whose layers it pops itself is left out, so every layer around the rest is the same. A renderer’s work grows with every path a scene holds, wherever it lands, so a frame repainting a small damage renders only what can reach it.- damage
- Damage, in section coordinates, between two frames of a section drawn
with parts: the old and new bounds of every part whose commands changed
(or what a
hintedpart’s hint says changed).Okwith no rects means the section is unchanged. - damage_
with_ copies damagefor a host that presents the section over the pixels of the frame it compares with and can move them: a hinted part whose hint follows on and carries copies (DamageHint::copies) damages its rects only, and each copy comes with what the section draws over it and how its content composites, which the host must check before making it (and otherwise repaint where it lands,SectionDamage::without_copies).boundsbounds the draws of the section outside every bounded part.- drawn_
bounds - Where
scene, drawn withparts(if it was), paints anything: inside a bounded part by that part’s bounds, anywhere else by its draw bounds.Nonewhen some of it cannot be bounded. - drawn_
scrolls - The scroll regions of the widgets the last frame showed (
retain_shown). - end
- Close the part
beginopened, with the bounds of what it painted. - end_
hinted - Close the part
beginopened as ahintedpart: for a draw that knows what changed only once it has drawn (a widget notes its damage while drawing). - end_
widget - End the draws
begin_widgetbegan. - hinted
- Draw one part of a section with no bounds of its own:
drawpaints content whose change since an earlier framehintdescribes. A change inside the part damages the hint’s rects when the hint follows on from the compared frame’s (same source and placement, the next generation). Otherwise, or with no hint, the change belongs to the enclosing part, and outside every bounded part it is not proven. - is_
tracked - Whether
sceneis split into parts for the active recording. - item_
key - The key a draw of something under the innermost open key gets:
kindnames the draw site andidtells its draws apart. For a widget that draws many items itself (an editor’s blocks, a list’s rows), so each item keeps an element of its own. - key_
widgets - Have every widget this thread draws through the toolkit’s draw paths
mark its draws with its key (
begin_widget), withkeyer’s code;Nonestops it. Off by default. - keyed
- Draw one item of a widget under
key(item_key), standing atorigin. Writes no marks unless widgets are keyed. - keyer
- The keying code: the one way to it.
- keys_
widgets - Whether widgets drawn on this thread mark their draws with their keys.
- painted_
key - The key
widget’s draws carried in the frame keyed last, as the page names it (16 hex digits);Nonewhen it was not drawn keyed. The widget is matched by address and type, and nothing kept is dereferenced. - part
- Draw one part of a section:
bounds, in the section’s coordinates (the draw transform already applied), must cover every pixeldrawcan paint, shadows and antialiasing included. An emptyboundsclaimsdrawpaints nothing; a part that then draws anything is treated as unbounded. - part_
drawn partfor a draw that knows what it painted only once it has:drawreturns the bounds, under the same contract.- present_
copies - Decide which of a frame’s section copies (
damage_with_copies) a host that keeps its target makes, and what it repaints around them.damageis every other change of the frame, in device pixels;aboveis where the scene draws over the section after it (later sections), in section coordinates;to_devicemaps section coordinates into thesizetarget. - record
- Record the parts of a scene drawn on its own (a retained scene a widget
re-records only when it changes): the parts
drawmarks inscene, orNonewhen they are not well nested. Any recording around this one is suspended whiledrawruns, sodrawmust paint only intoscene. - retain_
shown - Forget the scroll regions and widgets whose keys
scene(a whole frame) no longer shows: what a cached subtree replayed into it keeps. - scroll_
widget - Scroll the region
scrollnames tooffset, in the widget’s own pixels, when the widget that drew it is still inroot’s tree. Finds it by address and type, never through the address kept. Returns whether it was found. - skip_
widget - Count a child left undrawn, so the siblings drawn after it without an index keep their keys.
- track
- Split
sceneat its parts’ boundaries for the active recording. The section must stay at its address until the recording finishes.