mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
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.
45 lines
833 B
C++
45 lines
833 B
C++
/*
|
|
* Copyright (c) 2024, Zachary Huang <zack466@gmail.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/RefPtr.h>
|
|
#include <LibGfx/Bitmap.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibIPC/Forward.h>
|
|
|
|
namespace Gfx {
|
|
|
|
struct BitmapSequence {
|
|
Vector<Optional<NonnullRefPtr<Gfx::Bitmap>>> bitmaps;
|
|
};
|
|
|
|
// a struct to temporarily store bitmap fields before the buffer data is decoded
|
|
struct BitmapMetadata {
|
|
Gfx::BitmapFormat format;
|
|
Gfx::AlphaType alpha_type;
|
|
Gfx::IntSize size;
|
|
size_t size_in_bytes;
|
|
};
|
|
|
|
}
|
|
|
|
namespace IPC {
|
|
|
|
template<>
|
|
ErrorOr<void> encode(Encoder&, Gfx::BitmapMetadata const&);
|
|
|
|
template<>
|
|
ErrorOr<Gfx::BitmapMetadata> decode(Decoder&);
|
|
|
|
template<>
|
|
ErrorOr<void> encode(Encoder&, Gfx::BitmapSequence const&);
|
|
|
|
template<>
|
|
ErrorOr<Gfx::BitmapSequence> decode(Decoder&);
|
|
|
|
}
|