✅ Guard the scale a 150% screen's guest is told
Three guards that passed with their fixes taken out now see them. A Windows screen at 150% told the guest 1x (a user's report, fixed by4420e9cc4). Its tests read pixels_per_point and Layout::on_screen_of alone, and passed with the fix out. The new test fakes the OS's screen_scale with SDL's display scale of the window, lays the window out through window_layout, sets the layout on the render thread's surface and has the render thread's draw tell a recording presenter. A window whose sizes are pixels (Windows, X11) on a screen at 150% tells 1.5. A window whose sizes are points (Wayland, 3841 pixels over 1829 points at 2.1) still tells its density, not SDL's display scale. Taking out either half of the fix (the shell's on_screen_of, or the draw's screen scale) turns it red. The OS call itself is seen only on a real 150% Windows screen and stays a manual check. The person's release test in game.rs (eed36c1d8) ended capture between each of its moves into the released hide. After an end, the next move is always the hide's first, which the tablet takes whether or not the release is remembered, so the test passed with the fix out. Each capture now moves twice with no end between, as the SDL thread's test of the release chord does. A session's first picture that does not decode is said at warn (148699829): its test now reads the level through the testkit's log capture, so a line back at info fails it.
This commit is contained in:
1 parent
ca11296635
commit
09598dc7ed
3 files changed
+63
-4
No files matched your search
@@ -526,9 +526,12 @@ pub(crate) mod tests {
|
||||
assert_eq!(begun(&mut game, &mouse, (3.0, 4.0)), Some(Hold::Raw));
|
||||
mouse.hide_for(2 * SETTLE_NS);
|
||||
assert_eq!(game.released(Some(&mouse)), Some(Hold::Unlock((3.0, 4.0))));
|
||||
for (n, at) in [(3, (5.0, 5.0)), (20, (6.0, 5.0)), (200, (7.0, 5.0))] {
|
||||
mouse.hide_for(n * SETTLE_NS);
|
||||
assert_eq!(game.begin(&mouse, at), None, "{n} settles into the hide");
|
||||
// Captured again, each capture's moves past the settle stay the tablet's.
|
||||
for first in [3, 300] {
|
||||
for (n, at) in [(first, (5.0, 5.0)), (first + 20, (6.0, 5.0))] {
|
||||
mouse.hide_for(n * SETTLE_NS);
|
||||
assert_eq!(game.begin(&mouse, at), None, "{n} settles into the hide");
|
||||
}
|
||||
assert_eq!(game.end(), None, "capture changes");
|
||||
}
|
||||
mouse.show();
|
||||
|
||||
@@ -328,6 +328,8 @@ fn draw(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::geometry::{self, Insets};
|
||||
use crate::handle::PixelRect;
|
||||
use crate::present::{Drawn, Presenter};
|
||||
|
||||
/// The process's device is made and let go on a thread of the render thread's own stack, as
|
||||
/// the render thread's presenter can ask for it first: the process's first device, so the
|
||||
@@ -422,6 +424,51 @@ mod tests {
|
||||
assert!(surface.next(None).is_none());
|
||||
}
|
||||
|
||||
/// A presenter keeping the scale each draw is told.
|
||||
struct Told(Arc<Mutex<Vec<f64>>>);
|
||||
|
||||
impl Presenter for Told {
|
||||
fn draw(
|
||||
&mut self,
|
||||
_drawable: (u64, u64),
|
||||
scale: f64,
|
||||
_region: PixelRect,
|
||||
_cursor: Option<&DrawnCursor>,
|
||||
_overlay: Option<&DrawnOverlay>,
|
||||
) -> Drawn {
|
||||
self.0.lock().push(scale);
|
||||
Drawn::Presented
|
||||
}
|
||||
}
|
||||
|
||||
/// The guest is told the scale of its window's screen, from SDL's display scale of the
|
||||
/// window (`os::screen_scale`, faked here) through the layout to the draw: a window whose
|
||||
/// sizes are pixels (Windows, X11) on a screen at 150% tells 1.5, not its density of 1 (a
|
||||
/// user's report), and one whose sizes are points (Wayland) still tells its density
|
||||
#[test]
|
||||
fn the_guest_is_told_its_screen_s_scale() {
|
||||
let wayland = 3841.0 / 1829.0;
|
||||
for (density, display_scale, told) in [(1.0, 1.5_f32, 1.5), (wayland, 2.1, wayland)] {
|
||||
let layout = crate::sdl::shell::window_layout(
|
||||
(1829.0, 1000.0),
|
||||
density,
|
||||
Insets::default(),
|
||||
Some((2560, 1600)),
|
||||
|d| crate::sdl::units::pixels_per_point(d, display_scale),
|
||||
);
|
||||
let surface = Surface::new();
|
||||
surface.set_target(a_target());
|
||||
surface.set_visible(true);
|
||||
surface.set_layout(layout);
|
||||
let work = surface.next(None).unwrap();
|
||||
let scales = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut presenting = Presenting::default();
|
||||
presenting.make(|| Some(Box::new(Told(Arc::clone(&scales)))));
|
||||
draw(&mut presenting, &work.layout, None, None);
|
||||
assert_eq!(*scales.lock(), [told], "{density} pixels a unit");
|
||||
}
|
||||
}
|
||||
|
||||
/// An overlay set or taken away asks for a draw; the UI thread is told once an overlay that
|
||||
/// it does not show, and not where there is none
|
||||
#[cfg(target_os = "linux")]
|
||||
|
||||
@@ -925,7 +925,7 @@ fn a_picture_of_the_stream_that_does_not_decode_lands_nothing_and_completes() {
|
||||
assert_eq!((counts.skipped, counts.not_decoded), (3, 2));
|
||||
}
|
||||
|
||||
/// Of a session's pictures of the stream that do not decode, only its first is said
|
||||
/// Of a session's pictures of the stream that do not decode, only its first is said, at `warn`
|
||||
/// ([`HostVideoSession::not_decoded`] answers whether it said it), each session's own.
|
||||
#[test]
|
||||
fn a_session_says_its_first_picture_that_does_not_decode_alone() {
|
||||
@@ -935,11 +935,20 @@ fn a_session_says_its_first_picture_that_does_not_decode_alone() {
|
||||
session(&p, Vec::new(), &Log::default()),
|
||||
session(&p, Vec::new(), &Log::default()),
|
||||
);
|
||||
let logs = reims_vgpu_vulkan::core::testkit::logs::capture();
|
||||
assert_eq!(
|
||||
[one.not_decoded(¬), one.not_decoded(¬)],
|
||||
[true, false]
|
||||
);
|
||||
assert!(two.not_decoded(¬));
|
||||
// Each session's first is said at warn, the level a report carries by default.
|
||||
let said: Vec<_> = logs
|
||||
.take()
|
||||
.into_iter()
|
||||
.filter(|(_, _, line)| line.contains("does not decode"))
|
||||
.map(|(level, ..)| level)
|
||||
.collect();
|
||||
assert_eq!(said, [log::Level::Warn; 2]);
|
||||
assert_eq!(one.counts.lock().not_decoded, 2);
|
||||
assert_eq!(two.counts.lock().not_decoded, 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user