ImageDecoder+LibGfx: Collate decoded bitmaps before sending over IPC

There is an issue where gifs with many frames cannot be loaded, as each
bitmap is sent over IPC using a separate file descriptor, and there is
limit on the maximum number of descriptors per IPC message. Thus, trying
to load gifs with more than 64 frames (the current limit) causes the
image decoder process to die.

This commit introduces the BitmapSequence class, which is a thin wrapper
around the type Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>> and
provides an IPC encode/decode routine that collates all bitmap data into
a single buffer so that only a single file descriptor is required per
IPC transfer, even if multiple frames are being sent.
This commit is contained in:
Zachary Huang 2024-09-18 17:37:44 -04:00 committed by Andrew Kaster
commit e0bd42be95
Notes: github-actions[bot] 2024-10-02 21:58:35 +00:00
9 changed files with 193 additions and 7 deletions

View file

@ -57,8 +57,9 @@ NonnullRefPtr<Core::Promise<DecodedImage>> Client::decode_image(ReadonlyBytes en
return promise;
}
void Client::did_decode_image(i64 image_id, bool is_animated, u32 loop_count, Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>> const& bitmaps, Vector<u32> const& durations, Gfx::FloatPoint scale)
void Client::did_decode_image(i64 image_id, bool is_animated, u32 loop_count, Gfx::BitmapSequence const& bitmap_sequence, Vector<u32> const& durations, Gfx::FloatPoint scale)
{
auto const& bitmaps = bitmap_sequence.bitmaps;
VERIFY(!bitmaps.is_empty());
auto maybe_promise = m_pending_decoded_images.take(image_id);