Give a child a part of the container's extent rather than its raw box
`Pad` and `Stack` read `Painter::placement` to put their children inside their own drawing, and reading it is what says the drawing holds for that placement alone. So a pad or a stack anywhere in a row was drawn again -- with its whole subtree -- the moment an earlier sibling changed length, however little else had moved. `widget_within` now takes a `DrawRegion`, and `DrawRegion::Extent(part)` gives the child a part of the extent without reading it. What is retained is the part rather than the box it resolved to, so moving the extent re-places the child through the same rule instead of redrawing the parent: `inherited_children` becomes `extent_children`, carrying `Inherit` for the wrapper case `Painter::widget` already had and `Within(part)` for the new one. The dependency that goes up is a range on the container's extent rather than on its frame, since only the part's *length* reaches the child and where the part sits is re-placed. A declared length is unchanged: it is a length of the frame wherever the box it sits in came from. What still pins the placement is a report with a fraction in it -- the same fraction of a different extent is a different length -- and that pin is on the answer, which `extent_frames_keep_fractional_reports_and_numeric_dependencies_valid` fails without. Three tests from the first attempt at this come with it, and the diagnostics rig now says which of the three contracts refused a reuse, which is what found the above. Measured, seed 1 at depth 8, median frame: `many` 0.667 -> 0.613 ms and `resize` 48 -> 32 us; seed 13's `many` 6.35 -> 5.15 ms. Green: fmt, clippy, 109 suite and 20 core tests, the oracle at 100 seeds, the shrinker at 400 trees of depth 5, 1000 seeds at depth 6, and 2000 seeds at depth 4 over all fifteen cases. The five reference renders are byte-identical to `0e107f0` on Venus, as are `tabs` resized to 900x1200 and `random` to 1280x800 against cold renders there. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e107f0e89
commit
e6ba570d07
7 files changed
+358
-57
No files matched your search
+24
-1
@@ -41,7 +41,11 @@ pub struct ActiveData {
|
||||
pub textures: Vec<TextureHandle>,
|
||||
pub primitives: Vec<RetainedPrimitive>,
|
||||
pub mask_region: Option<DrawRegion>,
|
||||
pub inherited_children: Vec<WidgetId>,
|
||||
/// The children whose box is a part of this widget's extent rather than
|
||||
/// of its frame, and which part each was given. Moving the extent
|
||||
/// re-places them, so this widget's drawing does not have to depend on
|
||||
/// where its own drawing sits.
|
||||
pub(crate) extent_children: Vec<(WidgetId, ExtentPlacement)>,
|
||||
pub children: Vec<WidgetId>,
|
||||
/// The children whose size this widget read while drawing.
|
||||
pub size_deps: Vec<WidgetId>,
|
||||
@@ -87,3 +91,22 @@ impl ActiveData {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// What of a container's extent a child was given: the whole of it, for a
|
||||
/// wrapper whose box is its child's, or a part of it.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub(crate) enum ExtentPlacement {
|
||||
Inherit,
|
||||
Within(UiRegion),
|
||||
}
|
||||
|
||||
impl ExtentPlacement {
|
||||
/// The child's frame in the container's frame coordinates, and the slot
|
||||
/// the container chose within it.
|
||||
pub fn resolve(self, extent: UiRegion) -> (UiRegion, [Option<crate::UiSpan>; 2]) {
|
||||
match self {
|
||||
Self::Inherit => (UiRegion::FULL, [Some(extent.x), Some(extent.y)]),
|
||||
Self::Within(part) => (part.within(&extent), [None; 2]),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user