mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03: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:
parent
16ebbde26f
commit
9494b03a02
Notes:
sideshowbarker
2024-07-19 02:43:07 +09:00
Author: https://github.com/peterdn Commit: https://github.com/SerenityOS/serenity/commit/9494b03a020 Pull-request: https://github.com/SerenityOS/serenity/pull/3465 Reviewed-by: https://github.com/awesomekling
@ -115,7 +115,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase)
|
||||
if (alt.is_empty())
|
||||
alt = image_element.src();
|
||||
context.painter().draw_text(enclosing_int_rect(absolute_rect()), alt, Gfx::TextAlignment::Center, specified_style().color_or_fallback(CSS::PropertyID::Color, document(), Color::Black), Gfx::TextElision::Right);
|
||||
} else if (auto* bitmap = m_image_loader.bitmap()) {
|
||||
} else if (auto bitmap = m_image_loader.bitmap()) {
|
||||
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *bitmap, bitmap->rect());
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user