Fix Svg and Image primitives in iced_tiny_skia
This commit is contained in:
parent
4cae262d22
commit
1bba9a080f
1 changed files with 22 additions and 15 deletions
|
|
@ -205,7 +205,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
.then(|| clip_mask as &_);
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
let transform = tiny_skia::Transform::from_translate(
|
let transform = tiny_skia::Transform::from_translate(
|
||||||
translation.x,
|
translation.x,
|
||||||
|
|
@ -269,7 +269,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
.then(|| clip_mask as &_);
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
self.text_pipeline.draw(
|
self.text_pipeline.draw(
|
||||||
content,
|
content,
|
||||||
|
|
@ -285,25 +285,23 @@ impl Backend {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "image")]
|
#[cfg(feature = "image")]
|
||||||
Primitive::Image { handle, bounds } => {
|
Primitive::Image { handle, bounds } => {
|
||||||
if !clip_bounds
|
let physical_bounds = (*bounds + translation) * scale_factor;
|
||||||
.intersects(&((*bounds + translation) * scale_factor))
|
|
||||||
{
|
if !clip_bounds.intersects(&physical_bounds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
let transform = tiny_skia::Transform::from_translate(
|
let transform = tiny_skia::Transform::from_translate(
|
||||||
translation.x,
|
translation.x,
|
||||||
translation.y,
|
translation.y,
|
||||||
)
|
)
|
||||||
.post_scale(scale_factor, scale_factor);
|
.post_scale(scale_factor, scale_factor);
|
||||||
|
|
||||||
self.raster_pipeline.draw(
|
self.raster_pipeline
|
||||||
handle,
|
.draw(handle, *bounds, pixels, transform, clip_mask);
|
||||||
*bounds,
|
|
||||||
pixels,
|
|
||||||
transform,
|
|
||||||
Some(clip_mask),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
#[cfg(feature = "svg")]
|
#[cfg(feature = "svg")]
|
||||||
Primitive::Svg {
|
Primitive::Svg {
|
||||||
|
|
@ -311,12 +309,21 @@ impl Backend {
|
||||||
bounds,
|
bounds,
|
||||||
color,
|
color,
|
||||||
} => {
|
} => {
|
||||||
|
let physical_bounds = (*bounds + translation) * scale_factor;
|
||||||
|
|
||||||
|
if !clip_bounds.intersects(&physical_bounds) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
self.vector_pipeline.draw(
|
self.vector_pipeline.draw(
|
||||||
handle,
|
handle,
|
||||||
*color,
|
*color,
|
||||||
(*bounds + translation) * scale_factor,
|
(*bounds + translation) * scale_factor,
|
||||||
pixels,
|
pixels,
|
||||||
clip_bounds.map(|_| clip_mask as &_),
|
clip_mask,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Primitive::Fill {
|
Primitive::Fill {
|
||||||
|
|
@ -340,7 +347,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
.then(|| clip_mask as &_);
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
pixels.fill_path(
|
pixels.fill_path(
|
||||||
path,
|
path,
|
||||||
|
|
@ -373,7 +380,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
let clip_mask = (!physical_bounds.is_within(&clip_bounds))
|
||||||
.then(|| clip_mask as &_);
|
.then_some(clip_mask as &_);
|
||||||
|
|
||||||
pixels.stroke_path(
|
pixels.stroke_path(
|
||||||
path,
|
path,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue