Commit graph

7 commits

Author SHA1 Message Date
Aliaksandr Kalenik
411e74d51c LibGfx: Preserve single-frame BitmapSequence backing
BitmapSequence IPC decodes every frame from the collated transport
buffer into a new malloc-backed Bitmap. That keeps animated sequences
compact, but it also breaks the shared-memory chain for the common
single-frame image path. WebContent receives anonymous buffer data from
ImageDecoder, then has to allocate another anonymous buffer when the
image is sent to the Compositor.

Preserve the backing for single-frame sequences by wrapping the received
AnonymousBuffer directly in the decoded Bitmap after validating that it
exactly matches the frame metadata. That lets the decoded image keep its
shared-memory backing all the way through ImageDecoder -> WebContent ->
Compositor without another allocation and copy.
2026-05-25 19:46:46 +02:00
Andreas Kling
039fa00bfc LibGfx: Use checked arithmetic when encoding BitmapSequence
The total_buffer_size calculation could theoretically overflow if we
tried to encode a sequence of bitmaps with combined size > SIZE_MAX.

Use Checked<size_t> and VERIFY to catch this (unlikely) encoding bug.
2026-01-22 17:38:15 +01:00
Andreas Kling
4f684bb4c9 LibGfx: Don't create AnonymousBuffer for each bitmap in BitmapSequence
When decoding a BitmapSequence received over IPC, we were creating an
AnonymousBuffer for each bitmap and then making a Gfx::Bitmap wrapper
around it.

This was unnecessarily using up one file descriptor per bitmap, and also
wasting a lot of memory for small bitmaps since we always allocated at
least one VM page.

This patch changes the BitmapSequence decoder to use malloc memory
instead, saving file descriptors and using less memory overall.
2025-10-24 08:52:53 +02:00
Jelle Raaijmakers
e4a5be0206 LibGfx+ImageDecoder: Use RefPtr<Bitmap> instead of optional
Simplify the list of bitmaps a bit by changing
`Optional<NonnullRefPtr<Bitmap>>` into `RefPtr<Bitmap>`. No functional
changes.
2025-03-22 17:49:38 +01:00
Andreas Kling
f44166ebd0 LibGfx: Allow IPC encode/decode of empty BitmapSequence
This would fail with EINVAL earlier, due to an attempt to create a
zero-length Core::AnonymousBuffer.

We fix this by transferring the buffer length separately, and only
going down the AnonymousBuffer allocation path if the length is
non-zero.
2024-12-19 16:49:28 +01:00
Pavel Shliak
8a07131229 LibGfx: Clean up #include directives
We actually include what we use where we use it.
This change aims to improve the speed of incremental builds.
2024-11-20 21:13:23 +01:00
Timothy Flynn
93712b24bf Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Renamed from Userland/Libraries/LibGfx/BitmapSequence.cpp (Browse further)