Creating or freeing a frame or region re-derives only what it touches (#915)
Any write that changed the layout graph's roster (a frame or region created, freed, re-owned or re-pointed) made the next resolve derive the whole graph: about 1.35 ms for one `CreateTexture` or `CreateFrame` on the stock UI, against 0.05 ms for a no-op. A write now names the nodes it touched, and the resolve re-derives just those in the cached graph: a joining node is added with its edges, a leaving one is removed and its dependents seeded, a staying one has its edges and inputs re-synced. The full derivation stays the fallback. A region's owner and an art change are now layout inputs that name their region. Verify now also compares the graph itself. A randomized test checks rects and graph against a scratch solve after every batch of creates, frees, re-owns and re-anchors. `CreateTexture` now costs 0.14 ms, `CreateFrame` 0.15 ms, a backdrop rebuild 0.22 ms. Fixes #903 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
55729baff9
commit
fa5568dcdc
@@ -284,7 +284,7 @@ fn ensure_slot(lua: &Lua, this: &Table, slot: Slot) -> mlua::Result<u32> {
|
||||
.create_region(h, kind, layer, 0)
|
||||
.ok_or_else(|| mlua::Error::runtime("stale frame handle"))?;
|
||||
model.region_data.insert(rh, RegionData::default());
|
||||
model.touch_layout(); // a region entered the layout gate's read set
|
||||
model.touch_layout_region(rh);
|
||||
if let Some(frame) = model.arena.frame_mut(h) {
|
||||
if let KindState::Button(bs) = &mut frame.kind_state {
|
||||
slot.set(bs, Some(rh));
|
||||
@@ -418,6 +418,7 @@ fn set_slot_texture(
|
||||
if let Some(blend) = blend {
|
||||
data.blend = blend;
|
||||
}
|
||||
model.touch_layout_art(rh);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -571,8 +572,8 @@ pub(super) fn install(lua: &Lua) -> mlua::Result<()> {
|
||||
}
|
||||
super::region::link_region(&mut model, rh, owner, DrawLayer::Artwork);
|
||||
adopt_label(&mut model, owner, rh);
|
||||
// The layout's read set moved, and `GetTextWidth` reads the new label's extents.
|
||||
model.touch_layout();
|
||||
// A new owner, so a new scale for its node, and `GetTextWidth` reads its extents.
|
||||
model.touch_layout_region(rh);
|
||||
model.touch_measure(rh);
|
||||
Ok(())
|
||||
})?,
|
||||
|
||||
Reference in New Issue
Block a user