mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 06:10:06 -04:00
Update resvg dependency of egui_extras (#3719)
Update `resvg` from v0.28 to v0.37. Remove related, unnecessary entries from `deny.toml`. ⚠ In example `images` ferris is scaled differently, but I guess that now it scales in expected way (takes all available space; before this PR it takes up to space that, was available at first render- it does not upscale). This PR is minimal adaptation to new `resvg` api and small related simplification, however it should be considered to update loaders (currently if svg image initially was small and was scaled up it will be blurred, see https://github.com/emilk/egui/issues/3501). As svg image now scales over render size, problem will be more often seen now. (currently `SvgLoader` theoretically should rerender for different sizes (but I guess it will result in memory leak in that case), but refreshing is stopped earlier in `DefaultTextureLoader`). I have initial version of loaders update, that will fix issue with svg scaling (and also enable e.g. reloading image if file has been changed), I will submit these changes in separate PR once this one is merged. Closes <https://github.com/emilk/egui/issues/3652>.
This commit is contained in:
@@ -7,8 +7,6 @@ use egui::{
|
||||
ColorImage,
|
||||
};
|
||||
|
||||
use resvg::usvg;
|
||||
|
||||
type Entry = Result<Arc<ColorImage>, String>;
|
||||
|
||||
#[derive(Default)]
|
||||
@@ -51,14 +49,8 @@ impl ImageLoader for SvgLoader {
|
||||
match ctx.try_load_bytes(&uri) {
|
||||
Ok(BytesPoll::Ready { bytes, .. }) => {
|
||||
log::trace!("started loading {uri:?}");
|
||||
let fit_to = match size_hint {
|
||||
SizeHint::Scale(factor) => usvg::FitTo::Zoom(factor.into_inner()),
|
||||
SizeHint::Width(w) => usvg::FitTo::Width(w),
|
||||
SizeHint::Height(h) => usvg::FitTo::Height(h),
|
||||
SizeHint::Size(w, h) => usvg::FitTo::Size(w, h),
|
||||
};
|
||||
let result =
|
||||
crate::image::load_svg_bytes_with_size(&bytes, fit_to).map(Arc::new);
|
||||
let result = crate::image::load_svg_bytes_with_size(&bytes, Some(size_hint))
|
||||
.map(Arc::new);
|
||||
log::trace!("finished loading {uri:?}");
|
||||
cache.insert((uri, size_hint), result.clone());
|
||||
match result {
|
||||
|
||||
Reference in New Issue
Block a user