mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
swrenderer: Fix drawing of tiled svg
This fixes drawing the background of the live preview with the software renderer. The problem was that when a svg image is tiled (and the svg is not pre-rendered), we would render the svg in a duffer the size of the target. But that's not the size at which it should be rendered as it is going to be tiled over this surface. Too big images are not supported by the software renderer, it would panic in overflows in diverse places. So this also fixes panics
This commit is contained in:
parent
eab8952729
commit
ff8aff6ab4
1 changed files with 8 additions and 2 deletions
|
@ -1368,9 +1368,15 @@ impl<'a, T: ProcessScene> SceneBuilder<'a, T> {
|
|||
let Some(clipped_target) = physical_clip.intersection(&target_rect) else {
|
||||
return;
|
||||
};
|
||||
if let Some(buffer) = image_inner.render_to_buffer(Some(target_rect.size.cast())) {
|
||||
let orig = image_inner.size().cast::<f32>();
|
||||
let svg_target_size = if tiled.is_some() {
|
||||
euclid::size2(orig.width * source_to_target_x, orig.height * source_to_target_y)
|
||||
.cast()
|
||||
} else {
|
||||
target_rect.size.cast()
|
||||
};
|
||||
if let Some(buffer) = image_inner.render_to_buffer(Some(svg_target_size)) {
|
||||
let buf_size = buffer.size().cast::<f32>();
|
||||
let orig = image_inner.size().cast::<f32>();
|
||||
let dx =
|
||||
Fixed::from_f32(buf_size.width / orig.width / source_to_target_x).unwrap();
|
||||
let dy = Fixed::from_f32(buf_size.height / orig.height / source_to_target_y)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue