1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:38:11 +00:00

LibWeb: cache in-process decoded images in ImageResource

Otherwise cloned Bitmaps returned by the decoder will be prematurely
freed
This commit is contained in:
Peter Nelson 2020-09-12 12:36:36 +01:00 committed by Andreas Kling
parent 16ebbde26f
commit 9494b03a02
2 changed files with 5 additions and 5 deletions

View file

@ -62,10 +62,10 @@ const Gfx::Bitmap* ImageResource::bitmap(size_t frame_index) const
if (!m_decoder)
return nullptr;
if (m_decoder->is_animated())
return m_decoder->frame(frame_index).image;
return m_decoder->bitmap();
}
if (!m_decoded_image && !m_has_attempted_decode) {
m_decoded_image = m_decoder->frame(frame_index).image;
else
m_decoded_image = m_decoder->bitmap();
} else if (!m_decoded_image && !m_has_attempted_decode) {
auto image_decoder_client = ImageDecoderClient::Client::construct();
m_decoded_image = image_decoder_client->decode_image(encoded_data());
m_has_attempted_decode = true;