LibGfx/GIF: Move the code to read the header to its own function

By header, I include the logical screen descriptor here, so all the
information that is not specific to each frame.
This commit is contained in:
Lucas CHOLLET 2023-07-14 17:50:01 -04:00 committed by Andreas Kling
parent b8bc84a3e8
commit 294217586b
Notes: sideshowbarker 2024-07-17 09:37:30 +09:00

View file

@ -381,7 +381,7 @@ static ErrorOr<void> decode_frame(GIFLoadingContext& context, size_t frame_index
return {};
}
static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
static ErrorOr<void> load_header_and_logical_screen(GIFLoadingContext& context)
{
if (TRY(context.stream.size()) < 32)
return Error::from_string_literal("Size too short for GIF frame descriptors");
@ -412,6 +412,13 @@ static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
context.logical_screen.color_map[i] = { r, g, b };
}
return {};
}
static ErrorOr<void> load_gif_frame_descriptors(GIFLoadingContext& context)
{
TRY(load_header_and_logical_screen(context));
NonnullOwnPtr<GIFImageDescriptor> current_image = make<GIFImageDescriptor>();
for (;;) {
u8 sentinel = TRY(context.stream.read_value<u8>());