mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-12 01:46:46 +02:00
LibWeb: Account text and image storage as external memory
Report DOM character data, decoded image frames, ImageBitmap pixel buffers, and 2D canvas surfaces through the GC external memory hook. This lets image and text-heavy pages participate in GC threshold calculations through their retained backing storage.
This commit is contained in:
committed by
Andreas Kling
parent
68fa684f76
commit
a414136d7c
Notes:
github-actions[bot]
2026-05-07 08:04:42 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/a414136d7ce Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9286
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibJS/Runtime/ExternalMemory.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/HTML/BitmapDecodedImageData.h>
|
||||
#include <LibWeb/Painting/DisplayListRecorder.h>
|
||||
@@ -28,6 +30,16 @@ BitmapDecodedImageData::BitmapDecodedImageData(Vector<Frame>&& frames, size_t lo
|
||||
|
||||
BitmapDecodedImageData::~BitmapDecodedImageData() = default;
|
||||
|
||||
size_t BitmapDecodedImageData::external_memory_size() const
|
||||
{
|
||||
size_t size = JS::vector_external_memory_size(m_frames);
|
||||
for (auto const& frame : m_frames) {
|
||||
if (frame.frame)
|
||||
size = JS::saturating_add_external_memory_size(size, frame.frame->bitmap().data_size());
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::DecodedImageFrame> BitmapDecodedImageData::frame(size_t frame_index, Gfx::IntSize) const
|
||||
{
|
||||
if (frame_index >= m_frames.size())
|
||||
|
||||
Reference in New Issue
Block a user