mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 13:17:36 +00:00
LibGfx: Implement is_animated() and frame_count() for webp plugin
This commit is contained in:
parent
0393a37843
commit
3c5450b8be
2 changed files with 22 additions and 7 deletions
|
@ -284,9 +284,10 @@ TEST_CASE(test_webp_extended_lossless_animated)
|
||||||
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
|
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
|
||||||
EXPECT(plugin_decoder->initialize());
|
EXPECT(plugin_decoder->initialize());
|
||||||
|
|
||||||
// FIXME: These three lines are wrong.
|
EXPECT_EQ(plugin_decoder->frame_count(), 8u);
|
||||||
EXPECT_EQ(plugin_decoder->frame_count(), 1u);
|
EXPECT(plugin_decoder->is_animated());
|
||||||
EXPECT(!plugin_decoder->is_animated());
|
|
||||||
|
// FIXME: This is wrong.
|
||||||
EXPECT(!plugin_decoder->loop_count());
|
EXPECT(!plugin_decoder->loop_count());
|
||||||
|
|
||||||
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(990, 1050));
|
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(990, 1050));
|
||||||
|
|
|
@ -519,8 +519,15 @@ ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> WebPImageDecoderPlugin::create(Readon
|
||||||
|
|
||||||
bool WebPImageDecoderPlugin::is_animated()
|
bool WebPImageDecoderPlugin::is_animated()
|
||||||
{
|
{
|
||||||
// FIXME
|
if (m_context->state == WebPLoadingContext::State::Error)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (m_context->state < WebPLoadingContext::State::FirstChunkDecoded) {
|
||||||
|
if (decode_webp_first_chunk(*m_context).is_error())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_context->first_chunk->type == FourCC("VP8X") && m_context->vp8x_header.has_animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t WebPImageDecoderPlugin::loop_count()
|
size_t WebPImageDecoderPlugin::loop_count()
|
||||||
|
@ -531,8 +538,15 @@ size_t WebPImageDecoderPlugin::loop_count()
|
||||||
|
|
||||||
size_t WebPImageDecoderPlugin::frame_count()
|
size_t WebPImageDecoderPlugin::frame_count()
|
||||||
{
|
{
|
||||||
// FIXME
|
if (!is_animated())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
if (m_context->state < WebPLoadingContext::State::ChunksDecoded) {
|
||||||
|
if (decode_webp_chunks(*m_context).is_error())
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_context->animation_frame_chunks.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<ImageFrameDescriptor> WebPImageDecoderPlugin::frame(size_t index)
|
ErrorOr<ImageFrameDescriptor> WebPImageDecoderPlugin::frame(size_t index)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue