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:
Andreas Kling 2019-12-18 20:57:18 +01:00
parent 7e068565bc
commit 54bd322881
Notes: sideshowbarker 2024-07-19 10:48:59 +09:00
5 changed files with 38 additions and 2 deletions

View file

@ -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());
}