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/testing.rs b/tests/screenshots/testing.rs index 0ad8c47d02a..02315814ce7 100644 --- a/tests/screenshots/testing.rs +++ b/tests/screenshots/testing.rs @@ -75,7 +75,8 @@ pub fn screenshot( LogicalRect::from_size(euclid::size2(width as f32, height as f32)).into(), ); renderer.set_rendering_rotation(rotated); - renderer.render(buffer.make_mut_slice(), width as usize); + let stride = buffer.width() as usize; + renderer.render(buffer.make_mut_slice(), stride); renderer.set_rendering_rotation(RenderingRotation::NoRotation); }); @@ -133,7 +134,11 @@ fn compare_images( let reference = image_buffer(reference_path) .map_err(|image_err| format!("error loading reference image: {image_err:#}"))?; - if reference.size() != screenshot.size() { + let mut ref_size = reference.size(); + if matches!(rotated, RenderingRotation::Rotate90 | RenderingRotation::Rotate270) { + std::mem::swap(&mut ref_size.width, &mut ref_size.height); + } + if ref_size != screenshot.size() { return Err(format!( "image sizes don't match. reference size {:#?} rendered size {:#?}", reference.size(),