From 36a89aeff85bd1e89557f585b8f6fe7e5a15f93e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 5 Mar 2025 23:14:30 +0100 Subject: [PATCH] Software renderer: fix drawing background of rotated screen We need to draw the background over the rotated rectangle otherwise we don't fill the whole background. Regression from https://github.com/slint-ui/slint/pull/7685 (also cleanup a useless blend that was leftover from the same change) Adapt the screenshot test to have at least one non-square "window" so that we catch the problem in the future --- internal/core/software_renderer.rs | 8 +++----- tests/screenshots/build.rs | 13 ++++++++++++- .../software/basic/translucent-background.slint | 4 +++- .../software/basic/translucent-background.png | Bin 652 -> 714 bytes tests/screenshots/testing.rs | 9 +++++++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/internal/core/software_renderer.rs b/internal/core/software_renderer.rs index 76ec6eae281..8f22921c880 100644 --- a/internal/core/software_renderer.rs +++ b/internal/core/software_renderer.rs @@ -588,13 +588,11 @@ impl SoftwareRenderer { }; drop(i); - let mut bg = PremultipliedRgbaColor::background(); - // TODO: gradient background - PremultipliedRgbaColor::blend(&mut bg, background.color().into()); renderer.actual_renderer.processor.dirty_region = dirty_region.clone(); renderer.actual_renderer.processor.process_rectangle_impl( - PhysicalRect::from_size(euclid::Size2D::new(size.width, size.height)), - bg, + screen_rect.transformed(rotation), + // TODO: gradient background + background.color().into(), CompositionMode::Source, ); diff --git a/tests/screenshots/build.rs b/tests/screenshots/build.rs index f91c352a012..f2aa2fac4a0 100644 --- a/tests/screenshots/build.rs +++ b/tests/screenshots/build.rs @@ -102,6 +102,17 @@ fn main() -> std::io::Result<()> { }); let skip_clipping = source.contains("SKIP_CLIPPING"); + let needle = "SIZE="; + let (size_w, size_h) = source.find(needle).map_or((64, 64), |p| { + source[p + needle.len()..] + .find(char::is_whitespace) + .and_then(|end| source[p + needle.len()..][..end].split_once('x')) + .and_then(|(w, h)| Some((w.parse().ok()?, h.parse().ok()?))) + .unwrap_or_else(|| { + panic!("Cannot parse {needle} for {}", testcase.relative_path.display()) + }) + }); + let mut output = BufWriter::new(std::fs::File::create( Path::new(&std::env::var_os("OUT_DIR").unwrap()).join(format!("{module_name}.rs")), )?); @@ -122,7 +133,7 @@ fn main() -> std::io::Result<()> { use crate::testing; let window = testing::init_swr(); - window.set_size(slint::PhysicalSize::new(64, 64)); + window.set_size(slint::PhysicalSize::new({size_w}, {size_h})); let screenshot = {reference_path}; let options = testing::TestCaseOptions {{ rotation_threshold: {rotation_threshold}f32, skip_clipping: {skip_clipping} }}; diff --git a/tests/screenshots/cases/software/basic/translucent-background.slint b/tests/screenshots/cases/software/basic/translucent-background.slint index e8f8ff6f2d0..c2a3bb04c42 100644 --- a/tests/screenshots/cases/software/basic/translucent-background.slint +++ b/tests/screenshots/cases/software/basic/translucent-background.slint @@ -1,8 +1,10 @@ // Copyright © SixtyFPS GmbH // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 +// SIZE=60x64 + export component TestCase inherits Window { - width: 64px; + width: 60px; height: 64px; background: #2360e62b; diff --git a/tests/screenshots/references/software/basic/translucent-background.png b/tests/screenshots/references/software/basic/translucent-background.png index 6b432caa2c9422907a95142f9f88a7f1d7084c64..d94e67d171197a15567d3bb64f993ec066c6272d 100644 GIT binary patch literal 714 zcmeAS@N?(olHy`uVBq!ia0vp^HbCsa!2~2v)-}&(U|^c)>Eakt!T9z7^8%H~X~#bP zFMrp2;>_|Q@8os4x3@u2X3xB7UhC%>87sZ}S++f^YFWE=_SN-e$K_A{S7HeHSI)TL z(|&G-ssCdcR{VL-&wtFtp!I(@L%`4b ztPQ9B>tWMdFHT=23*P-u{u$4L$2m>UKVE2`ezYn5rscBP`J4=Yy4J_+;=A2nxp7m( z2c@bPhfgOR-2CRvi)YbH4ErBxPhZDeai)9f(WZJyhJ&AXJUli-|H$8M+e+S+GB&*1 zclvRP=XM*7U2%Id@^%Hoq_J4HV0Gb#MI z{@N<;(bCS-GY=}v1rvEp#nd%D> dh};AAOdX9y4$Tb@Q-Nue!PC{xWt~$(69Ae4Uikn3 literal 652 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1SD0tpLH@YFa>+MIEGX(zCFOaKqYe8v5)`D z-}Rn2v%JVVd0p=9ZBUfiGjE#L`gumiO7DJ_ZO^J&)^44Bb$!`!`IG;XLjIL6{i@ed{=9d4YPt8#_r0wD9shl@t?T=Z%t=R9R&TELe|O-|`@N_B=b@QEHK|v9_LKe} z1-lB(OyvqW{@RL2or-C5lXv}`#&BT$k5fxuZ}>YyT)Ug~zZOhR_HKVW}R4;5kJ?r1%)MCwN@r@7S*T1gloc_*l9>+iDQd#|vm+p2>KDeI=6omDA z>yB-BW*=jp9PxR*o5ufKL0+}vP(Lxm(zdzh