Coalesce resize layout diagnostics
This commit is contained in:
1 parent
480f0bc99f
commit
82fa6c1123
7 files changed
+316
-28
No files matched your search
+31
-1
@@ -18,6 +18,33 @@ use iris::random::{Edits, Lens, Rng, SpanEdit, Tree, grow};
|
||||
|
||||
const DEPTH: usize = 4;
|
||||
const SEEDS: [u64; 6] = [1, 2, 3, 5, 8, 13];
|
||||
const REGION_ULPS: u32 = 4;
|
||||
|
||||
fn ordered_bits(value: f32) -> u32 {
|
||||
const SIGN: u32 = 1 << 31;
|
||||
let bits = value.to_bits();
|
||||
match bits & SIGN {
|
||||
0 => bits | SIGN,
|
||||
_ => !bits,
|
||||
}
|
||||
}
|
||||
|
||||
fn same_coordinate(got: f32, want: f32) -> bool {
|
||||
got == want || ordered_bits(got).abs_diff(ordered_bits(want)) <= REGION_ULPS
|
||||
}
|
||||
|
||||
fn same_region(got: Option<PixelRegion>, want: Option<PixelRegion>) -> bool {
|
||||
match (got, want) {
|
||||
(Some(got), Some(want)) => {
|
||||
same_coordinate(got.top_left.x, want.top_left.x)
|
||||
&& same_coordinate(got.top_left.y, want.top_left.y)
|
||||
&& same_coordinate(got.bot_right.x, want.bot_right.x)
|
||||
&& same_coordinate(got.bot_right.y, want.bot_right.y)
|
||||
}
|
||||
(None, None) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn plant(h: &mut Harness, seed: u64, edits: &Edits) -> Tree {
|
||||
let (root, tree) = grow(&mut h.rsc, seed, DEPTH, edits);
|
||||
@@ -138,7 +165,10 @@ fn assert_same(seed: u64, what: &str, warm: (&Harness, &Tree), cold: (&Harness,
|
||||
for (i, (&w, &c)) in wt.ids.iter().zip(&ct.ids).enumerate() {
|
||||
let (got, want) = (wh.region(&w), ch.region(&c));
|
||||
drawn += usize::from(got.is_some());
|
||||
if got == want {
|
||||
// Equivalent composition orders can differ by a few f32 ULPs. Bound
|
||||
// that representation drift directly, while whether a widget drew
|
||||
// remains exact.
|
||||
if same_region(got, want) {
|
||||
continue;
|
||||
}
|
||||
wrong += 1;
|
||||
|
||||
Reference in new issue
Block a user