LibGfx: Enhance APNG format support

Improve handling of APNG chunks by avoiding premature termination when
encountering non-fcTL chunks. With this patch, the browser now passes
additional APNG-related tests in the "png/" Web Platform Tests (WPT)
suite.
This commit is contained in:
Khaled Lakehal 2024-08-19 15:49:11 +02:00 committed by Andreas Kling
parent 18fc23b3d6
commit 2d6069650a
Notes: github-actions[bot] 2024-08-19 18:05:20 +00:00

View file

@ -244,15 +244,16 @@ ErrorOr<size_t> PNGLoadingContext::read_frames(png_structp png_ptr, png_infop in
u32 y = 0;
u16 delay_num = 0;
u16 delay_den = 0;
u8 dispose_op = 0;
u8 blend_op = 0;
u8 dispose_op = PNG_DISPOSE_OP_NONE;
u8 blend_op = PNG_BLEND_OP_SOURCE;
if (!png_get_valid(png_ptr, info_ptr, PNG_INFO_fcTL)) {
return Error::from_string_literal("Missing fcTL chunk in APNG frame");
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_fcTL)) {
png_get_next_frame_fcTL(png_ptr, info_ptr, &width, &height, &x, &y, &delay_num, &delay_den, &dispose_op, &blend_op);
} else {
width = png_get_image_width(png_ptr, info_ptr);
height = png_get_image_height(png_ptr, info_ptr);
}
png_get_next_frame_fcTL(png_ptr, info_ptr, &width, &height, &x, &y, &delay_num, &delay_den, &dispose_op, &blend_op);
decoded_frame_bitmap = TRY(Bitmap::create(BitmapFormat::BGRA8888, AlphaType::Unpremultiplied, IntSize { static_cast<int>(width), static_cast<int>(height) }));
row_pointers.resize(height);