diff --git a/iris/src/android/view.rs b/iris/src/android/view.rs index 6a8ca54..77a81da 100644 --- a/iris/src/android/view.rs +++ b/iris/src/android/view.rs @@ -573,7 +573,26 @@ impl ViewPeer for IrisViewPeer { // nothing but the clear colour: the widget tree laid out against // whatever size `UiRenderState::new` starts at instead of the // surface's real one. - self.render.resize((width as u32, height as u32)); + // + // **Logical, not physical** -- `content_scale`'s field comment on + // `AndroidUiState`. This call sets `UiRenderState::output_size`, + // which is what every widget's absolute `PixelRegion` (a fixed + // `.height(56)`, in particular) is computed against; `AndroidRenderer`'s + // own `size()`/`resize()`/`new()` already report logical dimensions + // to the *shader*'s window uniform, so leaving this call on raw + // physical `width`/`height` split the two into different units -- + // layout placed a "56"-unit-tall row in an ~2219-tall physical + // canvas (an absolute, correctly-56-unit box), the shader then + // divided that same 56 by a ~845-unit *logical* window dimension, + // and the row rendered far too short rather than too tall or + // right, because a fixed-size item's absolute unit value never + // adapts to the mismatch the way a `rest(n)`-proportional one + // does. Found by measuring a fresh install's top button row at + // ~40 physical px instead of the ~147px `56 * content_scale` + // predicts, immediately after the density fix below was added. + let content_scale = self.state.android_state().content_scale; + self.render + .resize((width as f32 / content_scale, height as f32 / content_scale)); // Drop the old renderer (and the surface it owns) before building // one from the new window -- see `AndroidRenderer`'s doc comment. let ui_state = self.state.android_state_mut(); @@ -740,6 +759,7 @@ pub fn new_peer<'local, State: AndroidAppState>( .resources(&mut env) .display_metrics(&mut env) .density(&mut env); + log::info!("iris: new_peer content_scale={content_scale}"); let vm = env.get_java_vm().unwrap(); let global_view = env.new_global_ref(&view.0).unwrap(); let redraw: Arc = Arc::new(AndroidRedrawHandle::new(vm, global_view));