Skip to content

Commit 18ce3ee

Browse files
committed
avif image lifetime [skip skia]
1 parent 7ea1791 commit 18ce3ee

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: src/image.rs

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub struct Image {
124124
pub(crate) is_svg: bool,
125125
pub(crate) color_space: ColorSpace,
126126
pub(crate) src: Option<Either<Uint8Array, String>>,
127+
// take ownership of avif image, let it be dropped when image is dropped
128+
_avif_image_ref: Option<AvifImage>,
127129
}
128130

129131
impl ObjectFinalize for Image {
@@ -154,6 +156,7 @@ impl Image {
154156
is_svg: false,
155157
color_space,
156158
src: None,
159+
_avif_image_ref: None,
157160
})
158161
}
159162

@@ -501,6 +504,7 @@ impl Task for BitmapDecoder {
501504
self_mut.src = self.data.take();
502505
self_mut.is_svg = bitmap.is_svg;
503506
self_mut.bitmap = Some(bitmap.data);
507+
self_mut._avif_image_ref = bitmap.decoded_image;
504508
env.adjust_external_memory((output.width as i64) * (output.height as i64) * 4)?;
505509
}
506510
DecodeStatus::Empty => {}

0 commit comments

Comments
 (0)