Skip to content

Commit 7cc5d7e

Browse files
authored
anyrender_skia: size render_to_vec buffers before wrapping pixels (#49)
SkiaImageRenderer::render_to_vec currently assumes the caller has already resized the Vec to the exact pixel buffer size. When callers pass an empty Vec with only capacity reserved, wrap_pixels receives an empty slice and the renderer panics. Resize the Vec to image_info.compute_min_byte_size() before wrapping it so offscreen rendering works with a plain empty Vec.
1 parent 0691c2d commit 7cc5d7e

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

crates/anyrender_skia/src/image_renderer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ impl ImageRenderer for SkiaImageRenderer {
5151
) {
5252
debug_timer!(timer, feature = "log_frame_times");
5353

54+
buffer.resize(self.image_info.compute_min_byte_size(), 0);
55+
5456
let mut surface = surfaces::wrap_pixels(
5557
&self.image_info,
5658
&mut buffer[..],

0 commit comments

Comments
 (0)