Expand description
Render world definitions and the extract pipeline.
§Worlds
- Main world (
App::world): UI state, layout, scripts. Tick stages:Input -> CommandDrain -> Systems -> LayoutSync -> A11ySync. - Render world (
App::render_world): per-frame extracted draw data, GPU resource caches, renderer state. Tick stages:Prepare -> Render.
§Extract step
After the main schedule and before the render schedule, the registered chain of ExtractFn entries runs.
Each function takes (&mut World, &mut World) and copies or upserts draw data from the main world into the render world.
§Drawable model
Each render-world entity represents one drawable. Adding a primitive consists of: one Extracted* component, one extract fn, and one render system.
Structs§
- Animations
Active - Per-tick flag raised by animation drivers (hover / press tweens, opacity transitions, scroll inertia) while a value is still in motion.
- Background
Clip - The box a background image is clipped to: the element’s border box with its corner radii, the same shape its background colour fills.
- Dock
Insets - Main-world resource shrinking the layout viewport of every normal root
while a panel is docked to a window edge (browser-devtools semantics: the
page reflows into the remaining space instead of being covered). Roots in
the top paint band (
OverlayLayer) keep the full viewport - the docked panel itself is one, so it can lay out along the edge it occupies. - Extract
Context Cache - Per-extract-phase memo of the parent-derived maps that every extract fn recomputes identically within a single frame.
- Extract
Pipeline - Marks a render world whose extract pipeline is installed, so a second backend asking for it finds it already there.
- Extract
Schedule - Schedule label for the dedicated extract schedule on the render world.
- Extracted
Border - CSS border for one entity: per-side widths, one solid color, painted
between the outer border-box edge and the padding box (inside the
rect, unlike
ExtractedOutlinewhich strokes centered on the box edge). Emitted byextract_bordersat the entity’s ownPaintOrder; the IR builder pushes borders after rects, so at the shared order key the border paints above the background fill and below all descendants - CSS’s background -> border -> content order. - Extracted
Clip Box - One rectangular clip region constraining descendant paints.
- Extracted
Image - One decoded image to render this frame in RGBA8 row-major pixels.
The renderer wraps
rgbain apeniko::Blobwhose stable identity keys the vello/wgpu upload cache across frames. - Extracted
Opacity Group - One element whose paints composite as a single layer that fades as a whole: CSS group opacity.
- Extracted
Outline - Stroked outline ring rendered around an entity (typically when
crate::input::Focused). - Extracted
Rect - One filled rectangle to render this frame.
- Extracted
Scrollbar - Overlay-scrollbar draw list for one scroll container (spec section 16.2 /
section 16.6). Emitted by
extract_scrollbars; theorderis the container’smax descendant order + 1, so the bars paint above all of the container’s content, indrawsorder, and outside its clip bracket - overlay bars are never clipped by their own viewport. That slot is also where the next element’s drop shadows go; the IR builder keys the bars under them, so a later sibling paints over an earlier one’s bars and an opacity group the sibling opens there leaves the bars out. - Extracted
Shadow - Shadow extracted for one entity. The renderer draws it at
order = rect.order - 1so it appears underneath the source rect without bleeding onto unrelated siblings. - Extracted
Text - One text run to render this frame.
- Frame
Dirty - Per-frame flag indicating that the upcoming frame requires a fresh GPU encode.
- Hidden
Extracts - Render-world snapshot of the set of MAIN-world entities that are hidden by
a [
Visible(false)] on themselves or any ancestor (CSSvisibility: hiddensemantics - the box keeps its layout space but paints nothing). - Opacity
Model - How
Opacityreaches the paints of one frame: the alpha each entity’s own paints carry, and the elements whose subtree composites as one layer (ExtractedOpacityGroup). - Overlay
Layer - Marker component lifting an entity and its whole subtree into the top-layer paint band (browser top-layer / Qt popup-window semantics): the subtree paints after ALL normal tree content regardless of its document position, keeps its internal document order, and escapes ancestor clip / scroll-cull rects (its own internal clips still apply).
- Overlay
Open Order - Main-world resource tracking the order in which
OverlayLayerroots became visible, so concurrently open popups stack later-opened-on-top (like OS popup windows). - Rect
- Axis-aligned rectangle in logical pixel coordinates.
- Render
- Schedule label for the render schedule.
- Render
Entity Map - Persistent map from a main-world entity to its render-world entity for each
Extracted*type. Upserting extracts read the prior map, update render entities in place, and write the new map back; legacy despawn-and-respawn extracts leave their slot untouched. - Scrollbar
Draw Rect - One rounded solid rect of an overlay scrollbar (track or thumb).
- Surface
Capture - Coordination handle for on-screen surface screenshots, inserted as a
Resourceinto both worlds. - Surface
Frame - One CPU-side snapshot of the on-screen window surface produced by a GPU->CPU readback.
- Viewport
- Window viewport, inserted as a
Resourceinto both the main and render worlds. The window plugin writes both copies on every resize.
Enums§
- Brush
- Fill brush for an
ExtractedRect. Gradient variants store their stops in anArc<[...]>so cloning the brush bumps the Arc instead of deep-copying. - Extract
Set SystemSetlabel for render-world extract systems registered viacrate::app::App::add_extract_systems.- Render
Stage - Ordered stages inside the
Renderschedule.
Constants§
- DEFAULT_
SELECTION_ BG - Single built-in fallback for the selection highlight when no
selection-colortoken is set - the platform “highlight” blue at ~40 % alpha (mirrors macOS / web selection tints and Qt’sHighlightrole). Translucent on purpose so the text underneath keeps its contrast, so noselection-text-coloris required for legibility. Skins override the whole look via the--lumen-selectiontoken; this is the one Rust fallback. - OVERLAY_
ORDER_ BASE - First
PaintOrderof the top-layer band. Every rank in anOverlayLayersubtree is>= OVERLAY_ORDER_BASE; every normal-tree rank is below it (real UI trees are nowhere near0x2000_0000entities), so overlay content always paints after all normal content.
Functions§
- build_
parent_ map - Returns
(parent_map, document_order_map)used by every extract fn to computePaintOrderconsistently. - clear_
extracted - Despawns transient render-world entities carrying
Extracted*components, called once per frame before anyExtractFnruns. - cull_
hidden - Prepare-stage guard that despawns every extracted render entity whose
owning main entity is hidden (per
HiddenExtracts), then drops those entries fromRenderEntityMapso the next frame’s keyed upserts start clean. Runs beforecrate::node_ir::transform_extracted_to_nodesso no hidden leaf reaches the retained tree. - cull_
offscreen - Despawns extracted entities whose AABB lies fully outside the
Viewport. - draw_
opacity - The alpha an entity’s own paints carry, from
OpacityModel::draw. - extract_
borders - Extract fn that emits one
ExtractedBorderper main-world entity carrying aTransformand aVisuals::border. A border paints even when the entity has no background fill (CSS:background: none; border: 1px solid ...still draws the border). Logical border edges (border-inline-*) are resolved against the entity’scrate::components::ResolvedDirection. - extract_
clips - Extracts one
ExtractedClipBoxper clipping entity (carryingcrate::input::ScrollorStyle.overflow_x/overflow_y == Hidden). Each emission carries the containing rect plus the(start_order, end_order)range bracketing descendant paints so the renderer can push/pop a vello layer. - extract_
opacity_ groups - Extracts one
ExtractedOpacityGroupper element that fades as a group (seeopacity_model). Each carries the element’s opacity and the(start_order, end_order)bracket of the paints it fades, whichcrate::node_ir::transform_extracted_to_nodesfolds into acrate::node_ir::Node::Opacity. - extract_
rects - Default extract fn that emits one
ExtractedRectper main-world entity carrying aTransformand aVisuals::fill. - extract_
scrollbars - Extract fn emitting one
ExtractedScrollbarpercrate::input::Scrollcontainer whose content overflows on an allowed axis and whose fade alpha is above zero. Geometry comes from the sharedcrate::input::vertical_scrollbar/crate::input::horizontal_scrollbarmath so painted pixels and hit regions always agree. All visuals (colors, thickness, minimums) resolve throughcrate::input::ScrollbarStyle- CSSscrollbar-color/scrollbar-widthper container, with the component’sDefaultas the no-stylesheet fallback. - extract_
shadows - Extract fn that emits one
ExtractedShadowper entry inVisuals::shadows. A drop shadow is placed atrect.order - 1 + idxso it paints under the source rect and stacked shadows keep source order. An inset shadow takes the rect’s own order: it paints over the background and under the border, as CSS draws it. - extract_
text - Default extract fn that emits one
ExtractedTextper entity withTransformandTextContent. - hidden_
entities - Returns the set of entities hidden by a [
Visible(false)] or adisplay: noneon themselves or any ancestor. - install_
extract_ pipeline - Install the pipeline that turns the main world into a paintable scene: the
built-in extractors, the dirty roll-up that decides whether a tick extracts
at all, and the
Preparesystems that cull what was extracted and fold the rest into the retained node tree. - opacity_
model - Resolves CSS
opacityfor the frame. - paint_
order_ of - Returns the
PaintOrderfore- the document-order rank precomputed bybuild_parent_map(whose second return value is the map passed here ascache). - parent_
scroll_ clip_ rects - Returns the nearest clipping-ancestor rect (origin and size in window coordinates) for every entity.
- parent_
scroll_ offsets - Returns each entity’s cumulative ancestor-chain
ScrollOffset. - reset_
animations_ active - Clears
AnimationsActiveat the top of every tick (registered incrate::tick::TickStage::Input, which is chained before theSystemsstage where animation drivers run). Recomputing the flag from scratch each tick is what guarantees idle-quiescence: a tick with no live animation leaves itfalse. - roll_
up_ frame_ dirty - Rolls up render-relevant change signals into
FrameDirty. Runs each tick incrate::tick::TickStage::A11ySync; the window backend reads the flag right before encoding and clears it after submission. - snap_
to_ device_ pixels - Snap a box’s edges to the device pixel grid, as browsers do before painting backgrounds. Each edge rounds on its own, so two boxes that share an edge still share it after snapping: a scroll offset or a layout position with a fraction no longer leaves the antialiased seam between adjacent backgrounds through which whatever is behind them shows. A box with any width or height keeps at least one device pixel of it.
- stash_
hidden_ entities - Extract fn: recompute the hidden-subtree set from the main-world hierarchy
and mirror it into the render world for
cull_hidden.
Type Aliases§
- Extract
Fn - Function pointer for an extract step. Stateless; closures are disallowed, so per-extract state lives in render-world resources.
- Paint
Order - Painter-algorithm sort key for
Extracted*entries. Higher values paint later (closer to the viewer).