Delete OrthoSize, and run the seeds in parallel
A span is as long across itself as its longest child, unless a rule beside it already says how long it is -- and then reading the children answers nothing and only makes its size depend on theirs. `OrthoSize::Full` was that second case written twice, once as an enum on the span and once as the rule that actually decides; `Painter::ruled` lets the span ask which it is in. The widget under a rule still does not learn what the rule says, only that its answer for that axis is not wanted. The fuzzers grow, lay out and drop a tree within one seed, so the seeds share nothing and take a thread each, one short of every core. Measured here: the generated oracle's hundred seeds went from 68 s to 10 s, and a shrinker case at 300 seeds from 18 s to 3.5 s. A seed that fails still shrinks and panics on its own thread, and `std::thread::scope` carries that out. The shrinker now allows the two steps the oracle already did -- the deeper trees these grow reach a second composition, and a step is a thousandth of a pixel. Checked: fmt, clippy, 102 tests, all five shrinker cases at 300 seeds, 100 generated seeds, and five examples byte-identical at 1920x1200. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cb955f1023
commit
9d8415d65f
8 files changed
+94
-74
No files matched your search
@@ -1,21 +1,10 @@
|
||||
use crate::prelude::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum OrthoSize {
|
||||
/// Reports one full relative length across the span's orthogonal axis,
|
||||
/// whether or not its siblings also take space.
|
||||
Full,
|
||||
/// Reports its longest fixed child, or leftover space if any child scales.
|
||||
#[default]
|
||||
Children,
|
||||
}
|
||||
|
||||
pub struct Span {
|
||||
pub children: Vec<StrongWidget>,
|
||||
pub dir: Dir,
|
||||
pub gap: Px,
|
||||
pub ortho: OrthoSize,
|
||||
}
|
||||
|
||||
impl Widget for Span {
|
||||
@@ -90,6 +79,10 @@ impl Widget for Span {
|
||||
painter.holds(axis, holds);
|
||||
}
|
||||
|
||||
// Across itself a span is as long as its longest child -- unless a
|
||||
// rule beside it already says how long it is, and then reading them
|
||||
// answers nothing and makes its size depend on theirs for it.
|
||||
let shrinks = !painter.ruled(!axis);
|
||||
let mut start = UiScalar::rel_min();
|
||||
let mut ortho = Len::ZERO;
|
||||
for (child, len) in self.children.iter().zip(&lens) {
|
||||
@@ -119,7 +112,7 @@ impl Widget for Span {
|
||||
region.flip(axis);
|
||||
}
|
||||
let placed = painter.widget_within(child, region);
|
||||
if self.ortho == OrthoSize::Children {
|
||||
if shrinks {
|
||||
let used = placed.len(!axis);
|
||||
// Choosing between a fixed and a relative length from the
|
||||
// span's own eventual width admits multiple fixed points.
|
||||
@@ -142,9 +135,9 @@ impl Widget for Span {
|
||||
// not give. Resolution happens at the nearest ancestor with a length,
|
||||
// and the root always has one.
|
||||
let along = total;
|
||||
let ortho = match self.ortho {
|
||||
OrthoSize::Full => Len::rel(1.0),
|
||||
OrthoSize::Children => ortho,
|
||||
let ortho = match shrinks {
|
||||
true => ortho,
|
||||
false => Len::rel(1.0),
|
||||
};
|
||||
Size::from_axis(axis, along, ortho)
|
||||
}
|
||||
@@ -156,7 +149,6 @@ impl Span {
|
||||
children: Vec::new(),
|
||||
dir,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,11 +157,6 @@ impl Span {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ortho(mut self, ortho: OrthoSize) -> Self {
|
||||
self.ortho = ortho;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn push(&mut self, w: StrongWidget) {
|
||||
self.children.push(w);
|
||||
}
|
||||
@@ -183,7 +170,6 @@ pub struct SpanBuilder<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Ta
|
||||
pub children: Wa,
|
||||
pub dir: Dir,
|
||||
pub gap: Px,
|
||||
pub ortho: OrthoSize,
|
||||
_pd: PhantomData<(State, Tag)>,
|
||||
}
|
||||
|
||||
@@ -198,7 +184,6 @@ impl<Rsc, const LEN: usize, Wa: WidgetArrLike<Rsc, LEN, Tag>, Tag> WidgetFnTrait
|
||||
children: self.children.add(rsc).arr.into_iter().collect(),
|
||||
dir: self.dir,
|
||||
gap: self.gap,
|
||||
ortho: self.ortho,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,7 +196,6 @@ impl<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag>
|
||||
children,
|
||||
dir,
|
||||
gap: Px::ZERO,
|
||||
ortho: OrthoSize::Children,
|
||||
_pd: PhantomData,
|
||||
}
|
||||
}
|
||||
@@ -220,11 +204,6 @@ impl<State, const LEN: usize, Wa: WidgetArrLike<State, LEN, Tag>, Tag>
|
||||
self.gap = Px::from_num(gap);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn ortho(mut self, ortho: OrthoSize) -> Self {
|
||||
self.ortho = ortho;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for Span {
|
||||
|
||||
Reference in new issue
Block a user