-
I am using tiny skia to fill a Image component in slint using the example code proposed here : https://releases.slint.dev/1.7.2/docs/rust/slint/struct.image# This call :
takes around 2 secondes for a 6500 x 6500 SharedPixelBuffer. Is there a way to speed up this operation or use another and faster implementation ? Due to lifetime/move issues, I need to call this each time a path is added in my implementation. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Hm, do you need to call this on an existing buffer? I think allocating a new buffer might be faster, especially if you intend to fill the entire buffer anyway. |
Beta Was this translation helpful? Give feedback.
-
I tried to cache the SaredPixelBuffer (with very low time improvement), but for lifetime reasons, I need to call Here what the code looks like : if self.discard_overlay {
self.overlay_pixel_buffer = SharedPixelBuffer::<Rgba8Pixel>::new(self.image_width, self.image_height);
}
let data = self.overlay_pixel_buffer.make_mut_bytes();
let mut pixmap = tiny_skia::PixmapMut::from_bytes(data,width,height).unwrap(); I would be happy to put the last to lines inside the |
Beta Was this translation helpful? Give feedback.
Ahh, now I can run it. Thanks.
Regarding the size: Oops, you're right :-)
Looking at your code now, I think what I'd do is this:
Keep your background map as it is, in a scrollview indeed. Put that into a
slint::Image
once, make it the background, then don't ever touch it again :-). For each drawable that you have, besides theDrawable
also have aslint::Image
that contains the rendering of it. You could squeeze yourVec<Drawable>
intoslint::VecModel
. Then create aslint::MapModel
that maps your RustDrawable
struct to a struct that you declare in.slint
:export struct OverlayDrawable { x: length, y: length, data: image}
, and expose thatMapModel
to slint. Then in Slint you can write som…