mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-02 22:55:23 +00:00
LibHTML: Mark image bitmaps outside the visible viewport as volatile
When the visible viewport rect changes, we walk the layout tree and check where each LayoutImage is in relation to the viewport rect. Images outside have their bitmaps marked as volatile. Note that the bitmaps are managed by ImageDecoder objects. If a bitmap is purged by the kernel while volatile, we construct a new ImageDecoder next time we need pixels for the image.
This commit is contained in:
@@ -80,3 +80,17 @@ const GraphicsBitmap* HTMLImageElement::bitmap() const
|
||||
return nullptr;
|
||||
return m_image_decoder->bitmap();
|
||||
}
|
||||
|
||||
void HTMLImageElement::set_volatile(Badge<LayoutDocument>, bool v)
|
||||
{
|
||||
if (!m_image_decoder)
|
||||
return;
|
||||
if (v) {
|
||||
m_image_decoder->set_volatile();
|
||||
return;
|
||||
}
|
||||
bool has_image = m_image_decoder->set_nonvolatile();
|
||||
if (has_image)
|
||||
return;
|
||||
m_image_decoder = ImageDecoder::create(m_encoded_data.data(), m_encoded_data.size());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user