pub struct ExtractContextCache { /* private fields */ }Expand description
Per-extract-phase memo of the parent-derived maps that every extract fn recomputes identically within a single frame.
The default extract pass runs six extract fns back-to-back
(extract_shadows, extract_rects, extract_borders,
extract_text, extract_clips, extract_scrollbars) - plus the
image/SVG extractors registered by lumen-assets - and each one
independently rebuilds the same hierarchy-derived structures via
build_parent_map, hidden_entities, parent_scroll_offsets,
parent_opacities, and parent_scroll_clip_rects. Those depend
only on the main-world hierarchy / ScrollOffset / Opacity /
Visible / clip components, none of which mutate between extractors of
the same phase (extract fns only read the main world and write the
render world). Recomputing them six times is pure redundant traversal +
allocation on every dirty frame - the steady-state cost of any
animation, scroll, or state change.
crate::app::App::tick wraps the extract-fn loop with
Self::begin_phase / Self::end_phase. The first extractor of a
phase computes each map and stores a copy here; the rest clone it back
(an O(n) memcpy instead of the query + DFS + sort rebuild). Reuse is
gated on Self::active, so Systems-stage callers that share these
helpers - hit-testing hover, which runs before the <if> / <for>
reconcilers have finalised the tree - never observe a cached, stale
hierarchy: with active == false they always recompute. begin_phase
clears every slot, so no data survives across phases either.
Mirrors the “compute the frame’s scene-graph context once” pattern in
retained-scene toolkits (Qt Quick’s QSGRenderContext, GTK4’s snapshot
pass): shared per-frame derivations are built once and threaded through
the emitters, not rederived per draw-list.
Implementations§
Source§impl ExtractContextCache
impl ExtractContextCache
Sourcepub fn begin_phase(&mut self)
pub fn begin_phase(&mut self)
Open the extract phase: enable reuse and drop any slots left from a prior phase so the first extractor recomputes against the current (post-reconcile, post-layout) hierarchy.
Trait Implementations§
Source§impl Component for ExtractContextCache
impl Component for ExtractContextCache
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
Source§type Mutability = Mutable
type Mutability = Mutable
Component<Mutability = Mutable>,
while immutable components will instead have Component<Mutability = Immutable>. Read moreSource§fn register_required_components(
_requiree: ComponentId,
required_components: &mut RequiredComponentsRegistrator<'_, '_>,
)
fn register_required_components( _requiree: ComponentId, required_components: &mut RequiredComponentsRegistrator<'_, '_>, )
Source§fn clone_behavior() -> ComponentCloneBehavior
fn clone_behavior() -> ComponentCloneBehavior
Source§fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
fn relationship_accessor() -> Option<ComponentRelationshipAccessor<Self>>
ComponentRelationshipAccessor] required for working with relationships in dynamic contexts. Read more§fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_discard() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
fn on_despawn() -> Option<for<'w> fn(DeferredWorld<'w>, HookContext)>
§fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
fn map_entities<E>(_this: &mut Self, _mapper: &mut E)where
E: EntityMapper,
EntityMapper. This is used to remap entities in contexts like scenes and entity cloning.
When deriving Component, this is populated by annotating fields containing entities with #[entities] Read moreSource§impl Default for ExtractContextCache
impl Default for ExtractContextCache
Source§fn default() -> ExtractContextCache
fn default() -> ExtractContextCache
impl Resource for ExtractContextCache
Auto Trait Implementations§
impl Freeze for ExtractContextCache
impl RefUnwindSafe for ExtractContextCache
impl Send for ExtractContextCache
impl Sync for ExtractContextCache
impl Unpin for ExtractContextCache
impl UnsafeUnpin for ExtractContextCache
impl UnwindSafe for ExtractContextCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut ComponentsRegistrator<'_>, ) -> impl Iterator<Item = ComponentId> + use<C>
§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
§unsafe fn get_components(
ptr: MovingPtr<'_, C>,
func: &mut impl FnMut(StorageType, OwningPtr<'_>),
) -> <C as DynamicBundle>::Effect
unsafe fn get_components( ptr: MovingPtr<'_, C>, func: &mut impl FnMut(StorageType, OwningPtr<'_>), ) -> <C as DynamicBundle>::Effect
§unsafe fn apply_effect(
_ptr: MovingPtr<'_, MaybeUninit<C>>,
_entity: &mut EntityWorldMut<'_>,
)
unsafe fn apply_effect( _ptr: MovingPtr<'_, MaybeUninit<C>>, _entity: &mut EntityWorldMut<'_>, )
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().